+/**\r
+ Append the appointed IA Address option to Buf, and move Buf to the end.\r
+\r
+ @param[in, out] Buf The pointer to the position to append.\r
+ @param[in] IaAddr The pointer to the IA Address.\r
+ @param[in] MessageType Message type of DHCP6 package.\r
+\r
+ @return Buf The position to append the next option.\r
+\r
+**/\r
+UINT8 *\r
+Dhcp6AppendIaAddrOption (\r
+ IN OUT UINT8 *Buf,\r
+ IN EFI_DHCP6_IA_ADDRESS *IaAddr,\r
+ IN UINT32 MessageType\r
+)\r
+{\r
+\r
+ // The format of the IA Address option is:\r
+ //\r
+ // 0 1 2 3\r
+ // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\r
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+ // | OPTION_IAADDR | option-len |\r
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+ // | |\r
+ // | IPv6 address |\r
+ // | |\r
+ // | |\r
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+ // | preferred-lifetime |\r
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+ // | valid-lifetime |\r
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+ // . .\r
+ // . IAaddr-options .\r
+ // . .\r
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r
+ \r
+ //\r
+ // Fill the value of Ia Address option type\r
+ //\r
+ WriteUnaligned16 ((UINT16 *) Buf, HTONS (Dhcp6OptIaAddr));\r
+ Buf += 2;\r
+\r
+ WriteUnaligned16 ((UINT16 *) Buf, HTONS (sizeof (EFI_DHCP6_IA_ADDRESS)));\r
+ Buf += 2;\r
+\r
+ CopyMem (Buf, &IaAddr->IpAddress, sizeof(EFI_IPv6_ADDRESS));\r
+ Buf += sizeof(EFI_IPv6_ADDRESS);\r
+\r
+ //\r
+ // Fill the value of preferred-lifetime and valid-lifetime.\r
+ // According to RFC3315 Chapter 18.1.2, the preferred-lifetime and valid-lifetime fields\r
+ // should set to 0 when initiate a Confirm message.\r
+ //\r
+ if (MessageType != Dhcp6MsgConfirm) {\r
+ WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->PreferredLifetime));\r
+ }\r
+ Buf += 4;\r
+\r
+ if (MessageType != Dhcp6MsgConfirm) {\r
+ WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->ValidLifetime));\r
+ }\r
+ Buf += 4;\r
+\r
+ return Buf;\r
+}\r
+\r