39 ASSERT (Packet !=
NULL);
41 IaCb = &Instance->IaCb;
45 return EFI_OUT_OF_RESOURCES;
51 TxCb->TxPacket = Packet;
52 TxCb->Xid = Packet->Dhcp6.Header.TransactionId;
57 TxCb->Elapsed = Elapsed;
62 switch (Packet->Dhcp6.Header.MessageType) {
68 if (RetryCtl ==
NULL) {
69 TxCb->RetryCtl.
Irt = DHCP6_SOL_IRT;
70 TxCb->RetryCtl.
Mrc = DHCP6_SOL_MRC;
71 TxCb->RetryCtl.
Mrt = DHCP6_SOL_MRT;
72 TxCb->RetryCtl.
Mrd = DHCP6_SOL_MRD;
74 TxCb->RetryCtl.
Irt = (RetryCtl->Irt != 0) ? RetryCtl->Irt : DHCP6_SOL_IRT;
75 TxCb->RetryCtl.
Mrc = (RetryCtl->Mrc != 0) ? RetryCtl->Mrc : DHCP6_SOL_MRC;
76 TxCb->RetryCtl.
Mrt = (RetryCtl->Mrt != 0) ? RetryCtl->Mrt : DHCP6_SOL_MRT;
77 TxCb->RetryCtl.
Mrd = (RetryCtl->Mrd != 0) ? RetryCtl->Mrd : DHCP6_SOL_MRD;
92 TxCb->RetryCtl.
Mrc = DHCP6_REQ_MRC;
93 TxCb->RetryCtl.
Mrt = DHCP6_REQ_MRT;
94 TxCb->RetryCtl.
Mrd = DHCP6_REQ_MRD;
102 case Dhcp6MsgConfirm:
106 TxCb->RetryCtl.
Irt = DHCP6_CNF_IRT;
107 TxCb->RetryCtl.
Mrc = DHCP6_CNF_MRC;
108 TxCb->RetryCtl.
Mrt = DHCP6_CNF_MRT;
109 TxCb->RetryCtl.
Mrd = DHCP6_CNF_MRD;
122 TxCb->RetryCtl.
Mrc = DHCP6_REB_MRC;
123 TxCb->RetryCtl.
Mrt = DHCP6_REB_MRT;
124 TxCb->RetryCtl.
Mrd = IaCb->T2 - IaCb->T1;
137 TxCb->RetryCtl.
Mrc = DHCP6_REN_MRC;
138 TxCb->RetryCtl.
Mrt = DHCP6_REN_MRT;
139 TxCb->RetryCtl.
Mrd = IaCb->AllExpireTime - IaCb->T2;
147 case Dhcp6MsgDecline:
152 TxCb->RetryCtl.
Mrc = DHCP6_DEC_MRC;
153 TxCb->RetryCtl.
Mrt = DHCP6_DEC_MRT;
154 TxCb->RetryCtl.
Mrd = DHCP6_DEC_MRD;
162 case Dhcp6MsgRelease:
167 TxCb->RetryCtl.
Mrc = DHCP6_REL_MRC;
168 TxCb->RetryCtl.
Mrt = DHCP6_REL_MRT;
169 TxCb->RetryCtl.
Mrd = DHCP6_REL_MRD;
177 case Dhcp6MsgInfoRequest:
182 if (RetryCtl ==
NULL) {
183 TxCb->RetryCtl.
Irt = DHCP6_INF_IRT;
184 TxCb->RetryCtl.
Mrc = DHCP6_INF_MRC;
185 TxCb->RetryCtl.
Mrt = DHCP6_INF_MRT;
186 TxCb->RetryCtl.
Mrd = DHCP6_INF_MRD;
188 TxCb->RetryCtl.
Irt = (RetryCtl->Irt != 0) ? RetryCtl->Irt : DHCP6_INF_IRT;
189 TxCb->RetryCtl.
Mrc = (RetryCtl->Mrc != 0) ? RetryCtl->Mrc : DHCP6_INF_MRC;
190 TxCb->RetryCtl.
Mrt = (RetryCtl->Mrt != 0) ? RetryCtl->Mrt : DHCP6_INF_MRT;
191 TxCb->RetryCtl.
Mrd = (RetryCtl->Mrd != 0) ? RetryCtl->Mrd : DHCP6_INF_MRD;
206 return EFI_DEVICE_ERROR;
233 IN BOOLEAN NeedSignal
244 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
245 TxCb = NET_LIST_USER_STRUCT (Entry,
DHCP6_TX_CB, Link);
246 ASSERT (TxCb->TxPacket);
248 if (TxCb->Xid == PacketXid) {
253 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) {
254 InfCb = NET_LIST_USER_STRUCT (Entry,
DHCP6_INF_CB, Link);
256 if (InfCb->Xid == PacketXid) {
260 if ((InfCb->TimeoutEvent !=
NULL) && NeedSignal) {
261 gBS->SignalEvent (InfCb->TimeoutEvent);
274 ASSERT (TxCb->TxPacket);
281 return EFI_NOT_FOUND;
305 if ((Scope == DHCP6_PACKET_STATEFUL) || (Scope == DHCP6_PACKET_ALL)) {
306 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
307 TxCb = NET_LIST_USER_STRUCT (Entry,
DHCP6_TX_CB, Link);
308 ASSERT (TxCb->TxPacket);
321 if ((Scope == DHCP6_PACKET_STATELESS) || (Scope == DHCP6_PACKET_ALL)) {
325 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
326 TxCb = NET_LIST_USER_STRUCT (Entry,
DHCP6_TX_CB, Link);
327 ASSERT (TxCb->TxPacket);
339 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) {
340 InfCb = NET_LIST_USER_STRUCT (Entry,
DHCP6_INF_CB, Link);
342 if (InfCb->TimeoutEvent !=
NULL) {
343 gBS->SignalEvent (InfCb->TimeoutEvent);
370 NET_LIST_FOR_EACH (Entry, &Instance->TxList) {
371 if (TxCb == NET_LIST_USER_STRUCT (Entry,
DHCP6_TX_CB, Link)) {
395 ASSERT (Instance->Config);
396 ASSERT (Instance->IaCb.Ia);
403 if (Instance->Unicast !=
NULL) {
407 if (Instance->AdSelect !=
NULL) {
411 if (Instance->IaCb.Ia->ReplyPacket !=
NULL) {
412 FreePool (Instance->IaCb.Ia->ReplyPacket);
418 Instance->UdpSts = Status;
419 Instance->AdSelect =
NULL;
420 Instance->AdPref = 0;
421 Instance->Unicast =
NULL;
422 Instance->IaCb.T1 = 0;
423 Instance->IaCb.T2 = 0;
424 Instance->IaCb.AllExpireTime = 0;
425 Instance->IaCb.LeaseTime = 0;
430 Instance->StartTime = 0;
432 Ia = Instance->IaCb.Ia;
449 if (Instance->Config->IaInfoEvent !=
NULL) {
450 gBS->SignalEvent (Instance->Config->IaInfoEvent);
479 ASSERT (Packet !=
NULL);
480 ASSERT (Instance->Config !=
NULL);
481 ASSERT (Instance->IaCb.Ia !=
NULL);
485 Callback = Instance->Config->Dhcp6Callback;
486 Context = Instance->Config->CallbackContext;
491 if (Callback !=
NULL) {
495 Instance->IaCb.Ia->State,
503 if (NewPacket !=
NULL) {
504 ASSERT (*Packet !=
NULL);
541 ASSERT (Instance->Config !=
NULL);
546 OptionLen = Packet->Length -
sizeof (Packet->Dhcp6.Header);
561 Packet->Dhcp6.Option,
563 &Instance->Config->IaDescriptor
565 if (Option ==
NULL) {
566 return EFI_DEVICE_ERROR;
583 OptionLen = OptionLen - (UINT32)(Option - Packet->Dhcp6.Option);
624 Instance->Config->IaDescriptor.Type,
632 return EFI_DEVICE_ERROR;
635 if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) {
636 T1 = NTOHL (
ReadUnaligned32 ((UINT32 *)(DHCP6_OFFSET_OF_IA_NA_T1 (Option))));
637 T2 = NTOHL (
ReadUnaligned32 ((UINT32 *)(DHCP6_OFFSET_OF_IA_NA_T2 (Option))));
643 if ((T1 > T2) && (T2 > 0)) {
644 return EFI_DEVICE_ERROR;
667 StsCode = Dhcp6StsSuccess;
670 if (Option !=
NULL) {
671 StsCode = NTOHS (
ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_STATUS_CODE (Option))));
672 if (StsCode != Dhcp6StsSuccess) {
673 return EFI_DEVICE_ERROR;
709 OUT UINT8 **IaInnerOpt,
710 OUT UINT16 *IaInnerLen
713 UINT16 IaInnerLenTmp;
714 UINT8 *IaInnerOptTmp;
716 if (Option ==
NULL) {
717 ASSERT (Option !=
NULL);
718 return EFI_DEVICE_ERROR;
721 if (IaInnerOpt ==
NULL) {
722 ASSERT (IaInnerOpt !=
NULL);
723 return EFI_DEVICE_ERROR;
726 if (IaInnerLen ==
NULL) {
727 ASSERT (IaInnerLen !=
NULL);
728 return EFI_DEVICE_ERROR;
731 if (IaType == Dhcp6OptIana) {
735 if (OptionLen < DHCP6_MIN_SIZE_OF_IA_NA) {
736 return EFI_DEVICE_ERROR;
742 IaInnerOptTmp = DHCP6_OFFSET_OF_IA_NA_INNER_OPT (Option);
747 IaInnerLenTmp = (UINT16)NTOHS (
ReadUnaligned16 ((UINT16 *)DHCP6_OFFSET_OF_OPT_LEN (Option)));
748 if (IaInnerLenTmp < DHCP6_SIZE_OF_COMBINED_IAID_T1_T2) {
749 return EFI_DEVICE_ERROR;
752 IaInnerLenTmp -= DHCP6_SIZE_OF_COMBINED_IAID_T1_T2;
753 }
else if (IaType == Dhcp6OptIata) {
757 if (OptionLen < DHCP6_MIN_SIZE_OF_IA_TA) {
758 return EFI_DEVICE_ERROR;
761 IaInnerOptTmp = DHCP6_OFFSET_OF_IA_TA_INNER_OPT (Option);
766 IaInnerLenTmp = (UINT16)NTOHS (
ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option))));
767 if (IaInnerLenTmp < DHCP6_SIZE_OF_IAID) {
768 return EFI_DEVICE_ERROR;
771 IaInnerLenTmp -= DHCP6_SIZE_OF_IAID;
773 return EFI_DEVICE_ERROR;
776 *IaInnerOpt = IaInnerOptTmp;
777 *IaInnerLen = IaInnerLenTmp;
810 OptionLen = Packet->Length -
sizeof (Packet->Dhcp6.Header);
817 Packet->Dhcp6.Option,
822 if (*Option !=
NULL) {
823 StsCode = NTOHS (
ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_STATUS_CODE (*Option))));
824 if (StsCode != Dhcp6StsSuccess) {
825 return EFI_DEVICE_ERROR;
833 Packet->Dhcp6.Option,
835 &Instance->Config->IaDescriptor
837 if (*Option ==
NULL) {
855 OptionLen = OptionLen - (UINT32)(*Option - Packet->Dhcp6.Option);
862 Instance->Config->IaDescriptor.Type,
870 return EFI_DEVICE_ERROR;
892 *Option =
Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode);
893 if (*Option !=
NULL) {
894 StsCode = NTOHS (
ReadUnaligned16 ((UINT16 *)((DHCP6_OFFSET_OF_STATUS_CODE (*Option)))));
895 if (StsCode != Dhcp6StsSuccess) {
896 return EFI_DEVICE_ERROR;
928 Service = Instance->Service;
933 Frag.Bulk = (UINT8 *)&Packet->Dhcp6.Header;
934 Frag.Len = Packet->Length;
942 return EFI_OUT_OF_RESOURCES;
950 if (Instance->Unicast !=
NULL) {
959 &mAllDhcpRelayAndServersAddress,
964 EndPt.RemotePort = DHCP6_PORT_SERVER;
965 EndPt.LocalPort = DHCP6_PORT_CLIENT;
970 if (Elapsed !=
NULL) {
986 if (EFI_ERROR (Status)) {
1020 Service = Instance->Service;
1021 ClientId = Service->ClientId;
1024 ASSERT (Service->ClientId !=
NULL);
1025 ASSERT (Instance->Config !=
NULL);
1026 ASSERT (Instance->IaCb.Ia !=
NULL);
1031 for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
1032 UserLen += (NTOHS (Instance->Config->OptionList[Index]->OpLen) + 4);
1039 if (Packet ==
NULL) {
1040 Status = EFI_OUT_OF_RESOURCES;
1044 Packet->
Size = DHCP6_BASE_PACKET_SIZE + UserLen;
1052 Cursor = Packet->Dhcp6.
Option;
1054 Length = HTONS (ClientId->
Length);
1058 HTONS (Dhcp6OptClientId),
1062 if (EFI_ERROR (Status)) {
1072 if (EFI_ERROR (Status)) {
1084 if (EFI_ERROR (Status)) {
1091 for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
1092 UserOpt = Instance->Config->OptionList[Index];
1100 if (EFI_ERROR (Status)) {
1111 if (EFI_ERROR (Status)) {
1123 Instance->StartTime = 0;
1126 if (EFI_ERROR (Status)) {
1137 Instance->Config->SolicitRetransmission
1164 Instance->IaCb.T1 = 0;
1165 Instance->IaCb.T2 = 0;
1166 Instance->IaCb.Ia->IaAddressCount = 0;
1200 ASSERT (Instance->AdSelect !=
NULL);
1201 ASSERT (Instance->Config !=
NULL);
1202 ASSERT (Instance->IaCb.Ia !=
NULL);
1203 ASSERT (Instance->Service !=
NULL);
1205 Service = Instance->Service;
1206 ClientId = Service->ClientId;
1208 ASSERT (ClientId !=
NULL);
1214 Instance->AdSelect->Dhcp6.Option,
1218 if (Option ==
NULL) {
1219 return EFI_DEVICE_ERROR;
1228 for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
1229 UserLen += (NTOHS (Instance->Config->OptionList[Index]->OpLen) + 4);
1236 if (Packet ==
NULL) {
1237 Status = EFI_OUT_OF_RESOURCES;
1241 Packet->
Size = DHCP6_BASE_PACKET_SIZE + UserLen;
1249 Cursor = Packet->Dhcp6.
Option;
1251 Length = HTONS (ClientId->
Length);
1255 HTONS (Dhcp6OptClientId),
1259 if (EFI_ERROR (Status)) {
1269 if (EFI_ERROR (Status)) {
1276 HTONS (Dhcp6OptServerId),
1280 if (EFI_ERROR (Status)) {
1292 if (EFI_ERROR (Status)) {
1299 for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
1300 UserOpt = Instance->Config->OptionList[Index];
1308 if (EFI_ERROR (Status)) {
1320 if (EFI_ERROR (Status)) {
1332 Instance->StartTime = 0;
1336 if (EFI_ERROR (Status)) {
1383 ASSERT (Instance->Config !=
NULL);
1384 ASSERT (Instance->IaCb.Ia !=
NULL);
1385 ASSERT (Instance->Service !=
NULL);
1387 Service = Instance->Service;
1388 ClientId = Service->ClientId;
1389 LastReply = Instance->IaCb.Ia->ReplyPacket;
1391 ASSERT (ClientId !=
NULL);
1392 ASSERT (LastReply !=
NULL);
1402 if (Option ==
NULL) {
1403 return EFI_DEVICE_ERROR;
1415 if (Packet ==
NULL) {
1416 Status = EFI_OUT_OF_RESOURCES;
1420 Packet->
Size = DHCP6_BASE_PACKET_SIZE;
1428 Cursor = Packet->Dhcp6.
Option;
1430 Length = HTONS (ClientId->
Length);
1434 HTONS (Dhcp6OptClientId),
1438 if (EFI_ERROR (Status)) {
1448 if (EFI_ERROR (Status)) {
1455 HTONS (Dhcp6OptServerId),
1459 if (EFI_ERROR (Status)) {
1471 if (EFI_ERROR (Status)) {
1481 if (EFI_ERROR (Status)) {
1493 Instance->StartTime = 0;
1496 if (EFI_ERROR (Status)) {
1543 ASSERT (Instance->Config);
1544 ASSERT (Instance->IaCb.Ia);
1546 Service = Instance->Service;
1547 ClientId = Service->ClientId;
1548 LastReply = Instance->IaCb.Ia->ReplyPacket;
1561 if (Option ==
NULL) {
1562 return EFI_DEVICE_ERROR;
1571 if (Packet ==
NULL) {
1572 Status = EFI_OUT_OF_RESOURCES;
1576 Packet->
Size = DHCP6_BASE_PACKET_SIZE;
1584 Cursor = Packet->Dhcp6.
Option;
1586 Length = HTONS (ClientId->
Length);
1590 HTONS (Dhcp6OptClientId),
1594 if (EFI_ERROR (Status)) {
1604 HTONS (Dhcp6OptServerId),
1608 if (EFI_ERROR (Status)) {
1618 if (EFI_ERROR (Status)) {
1630 if (EFI_ERROR (Status)) {
1640 if (EFI_ERROR (Status)) {
1651 if (EFI_ERROR (Status)) {
1685 IN BOOLEAN RebindRequest
1704 ASSERT (Instance->Config);
1705 ASSERT (Instance->IaCb.Ia);
1707 Service = Instance->Service;
1708 ClientId = Service->ClientId;
1716 for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
1717 UserLen += (NTOHS (Instance->Config->OptionList[Index]->OpLen) + 4);
1724 if (Packet ==
NULL) {
1725 Status = EFI_OUT_OF_RESOURCES;
1729 Packet->
Size = DHCP6_BASE_PACKET_SIZE + UserLen;
1731 Packet->Dhcp6.
Header.
MessageType = RebindRequest ? Dhcp6MsgRebind : Dhcp6MsgRenew;
1737 Cursor = Packet->Dhcp6.
Option;
1739 Length = HTONS (ClientId->
Length);
1743 HTONS (Dhcp6OptClientId),
1747 if (EFI_ERROR (Status)) {
1757 if (EFI_ERROR (Status)) {
1769 if (EFI_ERROR (Status)) {
1773 if (!RebindRequest) {
1778 LastReply = Instance->IaCb.Ia->ReplyPacket;
1786 if (Option ==
NULL) {
1787 Status = EFI_DEVICE_ERROR;
1796 HTONS (Dhcp6OptServerId),
1800 if (EFI_ERROR (Status)) {
1808 for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
1809 UserOpt = Instance->Config->OptionList[Index];
1817 if (EFI_ERROR (Status)) {
1831 if (EFI_ERROR (Status)) {
1841 Instance->IaCb.Ia->State = State;
1842 Instance->IaCb.LeaseTime = (RebindRequest) ? Instance->IaCb.T2 : Instance->IaCb.T1;
1846 Instance->StartTime = 0;
1849 if (EFI_ERROR (Status)) {
1891 IN BOOLEAN SendClientId,
1893 IN UINT32 OptionCount,
1898 IN VOID *CallbackContext OPTIONAL
1906 Service = Instance->Service;
1908 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1909 Instance->UdpSts = EFI_ALREADY_STARTED;
1915 if (InfCb ==
NULL) {
1916 gBS->RestoreTPL (OldTpl);
1917 return EFI_OUT_OF_RESOURCES;
1920 InfCb->ReplyCallback = ReplyCallback;
1921 InfCb->CallbackContext = CallbackContext;
1922 InfCb->TimeoutEvent = TimeoutEvent;
1939 if (EFI_ERROR (Status)) {
1953 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
1957 gBS->RestoreTPL (OldTpl);
1961 gBS->RestoreTPL (OldTpl);
1990 IN BOOLEAN SendClientId,
1992 IN UINT32 OptionCount,
2008 ASSERT (OptionRequest);
2010 Service = Instance->Service;
2011 ClientId = Service->ClientId;
2012 UserLen = NTOHS (OptionRequest->OpLen) + 4;
2019 for (Index = 0; Index < OptionCount; Index++) {
2020 UserLen += (NTOHS (OptionList[Index]->OpLen) + 4);
2027 if (Packet ==
NULL) {
2028 Status = EFI_OUT_OF_RESOURCES;
2032 Packet->
Size = DHCP6_BASE_PACKET_SIZE + UserLen;
2042 Cursor = Packet->Dhcp6.
Option;
2045 Length = HTONS (ClientId->
Length);
2049 HTONS (Dhcp6OptClientId),
2053 if (EFI_ERROR (Status)) {
2064 if (EFI_ERROR (Status)) {
2071 OptionRequest->OpCode,
2072 OptionRequest->OpLen,
2075 if (EFI_ERROR (Status)) {
2082 for (Index = 0; Index < OptionCount; Index++) {
2083 UserOpt = OptionList[Index];
2091 if (EFI_ERROR (Status)) {
2101 Instance->StartTime = 0;
2107 if (EFI_ERROR (Status)) {
2152 ASSERT (Instance->Config !=
NULL);
2153 ASSERT (Instance->IaCb.Ia !=
NULL);
2154 ASSERT (Instance->Service !=
NULL);
2156 Service = Instance->Service;
2157 ClientId = Service->ClientId;
2158 ASSERT (ClientId !=
NULL);
2164 for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
2165 UserLen += (NTOHS (Instance->Config->OptionList[Index]->OpLen) + 4);
2172 if (Packet ==
NULL) {
2173 Status = EFI_OUT_OF_RESOURCES;
2177 Packet->
Size = DHCP6_BASE_PACKET_SIZE + UserLen;
2185 Cursor = Packet->Dhcp6.
Option;
2187 Length = HTONS (ClientId->
Length);
2191 HTONS (Dhcp6OptClientId),
2195 if (EFI_ERROR (Status)) {
2205 if (EFI_ERROR (Status)) {
2217 if (EFI_ERROR (Status)) {
2224 for (Index = 0; Index < Instance->Config->OptionCount; Index++) {
2225 UserOpt = Instance->Config->OptionList[Index];
2233 if (EFI_ERROR (Status)) {
2244 if (EFI_ERROR (Status)) {
2256 Instance->StartTime = 0;
2259 if (EFI_ERROR (Status)) {
2299 ASSERT (Instance->Config !=
NULL);
2300 ASSERT (Instance->IaCb.Ia !=
NULL);
2301 ASSERT (Packet !=
NULL);
2305 if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) {
2306 return EFI_DEVICE_ERROR;
2317 Packet->Dhcp6.Option,
2322 if (((Option !=
NULL) && !Instance->Config->RapidCommit) || ((Option ==
NULL) && Instance->Config->RapidCommit)) {
2323 return EFI_DEVICE_ERROR;
2336 Packet->Dhcp6.Option,
2338 &Instance->Config->IaDescriptor
2340 if (Option ==
NULL) {
2350 if (EFI_ERROR (Status)) {
2360 if (Instance->IaCb.Ia->IaAddressCount != 0) {
2363 ASSERT (Instance->IaCb.Ia->ReplyPacket);
2364 FreePool (Instance->IaCb.Ia->ReplyPacket);
2365 Instance->IaCb.Ia->ReplyPacket =
NULL;
2377 if (Instance->Config->IaInfoEvent !=
NULL) {
2378 gBS->SignalEvent (Instance->Config->IaInfoEvent);
2384 Instance->StartTime = 0;
2402 if (!EFI_ERROR (Status)) {
2407 if (!EFI_ERROR (Status)) {
2411 Instance->StartTime = 0;
2416 if (Instance->IaCb.Ia->ReplyPacket !=
NULL) {
2417 FreePool (Instance->IaCb.Ia->ReplyPacket);
2422 if (Instance->IaCb.Ia->ReplyPacket ==
NULL) {
2423 Status = EFI_OUT_OF_RESOURCES;
2427 CopyMem (Instance->IaCb.Ia->ReplyPacket, Packet, Packet->Size);
2447 if (Instance->Config->IaInfoEvent !=
NULL) {
2448 gBS->SignalEvent (Instance->Config->IaInfoEvent);
2450 }
else if (Status == EFI_NOT_FOUND) {
2460 }
else if (Option !=
NULL) {
2464 StsCode = NTOHS (
ReadUnaligned16 ((UINT16 *)((DHCP6_OFFSET_OF_STATUS_CODE (Option)))));
2466 case Dhcp6StsUnspecFail:
2473 case Dhcp6StsUseMulticast:
2479 if (Instance->Unicast !=
NULL) {
2481 Instance->Unicast =
NULL;
2486 case Dhcp6StsNotOnLink:
2492 if (EFI_ERROR (Status)) {
2500 if (EFI_ERROR (Status)) {
2507 case Dhcp6StsNoBinding:
2514 if (EFI_ERROR (Status)) {
2533 if (!EFI_ERROR (Status)) {
2536 Packet->Dhcp6.Header.TransactionId,
2564 ASSERT (AdSelect !=
NULL);
2572 if (EFI_ERROR (Status)) {
2576 Instance->AdSelect = AdSelect;
2583 AdSelect->Dhcp6.Header.TransactionId,
2587 if (EFI_ERROR (Status)) {
2596 AdSelect->Dhcp6.Option,
2598 Dhcp6OptServerUnicast
2601 if (Option !=
NULL) {
2604 if (Instance->Unicast ==
NULL) {
2605 return EFI_OUT_OF_RESOURCES;
2616 if (EFI_ERROR (Status)) {
2648 ASSERT (Instance->Config);
2649 ASSERT (Instance->IaCb.Ia);
2660 Packet->Dhcp6.Option,
2665 if ((Option !=
NULL) && Instance->Config->RapidCommit && (Packet->Dhcp6.Header.MessageType == Dhcp6MsgReply)) {
2669 if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgAdvertise) {
2670 return EFI_DEVICE_ERROR;
2684 if (EFI_ERROR (Status)) {
2685 return EFI_DEVICE_ERROR;
2693 if (!EFI_ERROR (Status)) {
2697 if (Instance->AdSelect !=
NULL) {
2706 if (Instance->AdSelect ==
NULL) {
2707 return EFI_OUT_OF_RESOURCES;
2710 CopyMem (Instance->AdSelect, Packet, Packet->Size);
2712 Instance->AdPref = 0xff;
2713 }
else if (Status == EFI_NOT_READY) {
2717 if ((Instance->AdPref == 0xff) && (Instance->AdSelect ==
NULL)) {
2731 Packet->Dhcp6.Option,
2736 if ((Instance->AdSelect ==
NULL) || ((Option !=
NULL) && (*(Option + 4) > Instance->AdPref))) {
2742 if (Instance->AdSelect !=
NULL) {
2748 if (Instance->AdSelect ==
NULL) {
2749 return EFI_OUT_OF_RESOURCES;
2752 CopyMem (Instance->AdSelect, Packet, Packet->Size);
2754 if (Option !=
NULL) {
2755 Instance->AdPref = *(DHCP6_OFFSET_OF_OPT_DATA (Option));
2775 if ((Instance->AdPref == 0xff) || Timeout) {
2800 Service = Instance->Service;
2801 ClientId = Service->ClientId;
2804 if (Instance->Config ==
NULL) {
2809 ASSERT (Instance->Config);
2810 ASSERT (Instance->IaCb.Ia);
2815 if ((Packet->Dhcp6.Header.MessageType != Dhcp6MsgAdvertise) && (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply)) {
2823 Packet->Dhcp6.Option,
2824 Packet->Length - DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN,
2836 Packet->Dhcp6.Option,
2837 Packet->Length - DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN,
2841 if (Option ==
NULL) {
2845 switch (Instance->IaCb.Ia->State) {
2866 if (EFI_ERROR (Status)) {
2889 if (EFI_ERROR (Status)) {
2913 Service = Instance->Service;
2918 if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) {
2926 InfCb = NET_LIST_HEAD (&Instance->InfList,
DHCP6_INF_CB, Link);
2927 if (InfCb->Xid == Packet->Dhcp6.Header.TransactionId) {
2941 Packet->Dhcp6.Option,
2946 if (Option ==
NULL) {
2953 Status = InfCb->ReplyCallback (
2955 InfCb->CallbackContext,
2959 if (Status == EFI_NOT_READY) {
2973 Packet->Dhcp6.Header.TransactionId,
2980 Instance->UdpSts = Status;
2991 if (EFI_ERROR (Status)) {
3020 BOOLEAN IsDispatched;
3021 BOOLEAN IsStateless;
3028 ASSERT (Udp6Wrap !=
NULL);
3029 ASSERT (Context !=
NULL);
3034 IsDispatched =
FALSE;
3035 IsStateless =
FALSE;
3037 if (EFI_ERROR (IoStatus)) {
3051 if (Packet ==
NULL) {
3055 Packet->
Size = Size;
3056 Head = &Packet->Dhcp6.
Header;
3057 Packet->
Length =
NetbufCopy (Udp6Wrap, 0, Udp6Wrap->TotalSize, (UINT8 *)Head);
3059 if (Packet->
Length == 0) {
3066 NET_LIST_FOR_EACH_SAFE (Entry1, Next1, &Service->Child) {
3069 NET_LIST_FOR_EACH_SAFE (Entry2, Next2, &Instance->TxList) {
3070 TxCb = NET_LIST_USER_STRUCT (Entry2,
DHCP6_TX_CB, Link);
3081 IsDispatched =
TRUE;
3094 if (!IsDispatched) {
3109 if (!IsDispatched) {
3116 if (EFI_ERROR (Status)) {
3117 NET_LIST_FOR_EACH_SAFE (Entry1, Next1, &Service->Child) {
3126 if (Packet !=
NULL) {
3150 UINT32 InterruptStatus;
3151 BOOLEAN MediaPresent;
3155 ASSERT (Instance !=
NULL);
3156 Snp = Instance->Service->Snp;
3157 MediaPresent = Instance->MediaPresent;
3169 Status = Snp->GetStatus (Snp, &InterruptStatus,
NULL);
3170 if (EFI_ERROR (Status)) {
3178 if (!MediaPresent && Instance->MediaPresent) {
3207 ASSERT (Context !=
NULL);
3215 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) {
3216 TxCb = NET_LIST_USER_STRUCT (Entry,
DHCP6_TX_CB, Link);
3220 if (TxCb->TickTime > TxCb->RetryExp) {
3224 if (((TxCb->RetryCnt == 0) || TxCb->SolicitRetry) && (TxCb->TxPacket->Dhcp6.
Header.
MessageType == Dhcp6MsgSolicit)) {
3225 if (Instance->AdSelect ==
NULL) {
3230 Instance->AdPref = 0xff;
3236 if (Status == EFI_ABORTED) {
3238 }
else if (EFI_ERROR (Status)) {
3250 TxCb->RetryLos += TxCb->RetryExp;
3255 if ((TxCb->RetryCtl.
Mrc != 0) && (TxCb->RetryCtl.
Mrc < TxCb->RetryCnt)) {
3256 Status = EFI_NO_RESPONSE;
3263 if ((TxCb->RetryCtl.
Mrd != 0) && (TxCb->RetryCtl.
Mrd <= TxCb->RetryLos)) {
3264 Status = EFI_NO_RESPONSE;
3280 if ((TxCb->RetryCtl.
Mrt != 0) && (TxCb->RetryCtl.
Mrt < TxCb->RetryExp)) {
3292 LossTime = TxCb->RetryLos + TxCb->RetryExp;
3293 if ((TxCb->RetryCtl.
Mrd != 0) && (TxCb->RetryCtl.
Mrd < LossTime)) {
3294 TxCb->RetryExp = TxCb->RetryCtl.
Mrd - TxCb->RetryLos;
3306 TxCb->SolicitRetry =
FALSE;
3308 TxCb->SolicitRetry =
TRUE;
3317 IaCb = &Instance->IaCb;
3319 if ((Instance->Config ==
NULL) || (IaCb->Ia ==
NULL)) {
3326 if ((IaCb->LeaseTime > IaCb->T2) && (IaCb->Ia->
State ==
Dhcp6Bound)) {
3331 }
else if ((IaCb->LeaseTime > IaCb->T1) && (IaCb->Ia->
State ==
Dhcp6Bound)) {
3352 (TxCb->TxPacket !=
NULL) &&
3364 ASSERT (Instance->IaCb.Ia);
3372 Instance->UdpSts = EFI_NO_RESPONSE;
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
UINT16 EFIAPI ReadUnaligned16(IN CONST UINT16 *Buffer)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID SetElapsedTime(IN UINT16 *Elapsed, IN DHCP_PROTOCOL *Instance)
EFI_STATUS(EFIAPI * EFI_DHCP6_CALLBACK)(IN EFI_DHCP6_PROTOCOL *This, IN VOID *Context, IN EFI_DHCP6_STATE CurrentState, IN EFI_DHCP6_EVENT Dhcp6Event, IN EFI_DHCP6_PACKET *Packet, OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL)
EFI_STATUS(EFIAPI * EFI_DHCP6_INFO_CALLBACK)(IN EFI_DHCP6_PROTOCOL *This, IN VOID *Context, IN EFI_DHCP6_PACKET *Packet)
BOOLEAN Dhcp6LinkMovDetect(IN DHCP6_INSTANCE *Instance)
EFI_STATUS Dhcp6SendConfirmMsg(IN DHCP6_INSTANCE *Instance)
EFI_STATUS Dhcp6SendReleaseMsg(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_IA *RelIa)
EFI_STATUS Dhcp6SeekStsOption(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *Packet, OUT UINT8 **Option)
EFI_STATUS Dhcp6UpdateIaInfo(IN OUT DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *Packet)
VOID EFIAPI Dhcp6ReceivePacket(IN NET_BUF *Udp6Wrap, IN UDP_END_POINT *EndPoint, IN EFI_STATUS IoStatus, IN VOID *Context)
VOID Dhcp6CleanupSession(IN OUT DHCP6_INSTANCE *Instance, IN EFI_STATUS Status)
VOID Dhcp6HandleStateless(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *Packet)
VOID Dhcp6CleanupRetry(IN DHCP6_INSTANCE *Instance, IN UINT32 Scope)
EFI_STATUS Dhcp6SelectAdvertiseMsg(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *AdSelect)
EFI_STATUS Dhcp6HandleReplyMsg(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *Packet)
EFI_STATUS Dhcp6TransmitPacket(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *Packet, IN UINT16 *Elapsed)
VOID EFIAPI Dhcp6OnTimerTick(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS Dhcp6DequeueRetry(IN DHCP6_INSTANCE *Instance, IN UINT32 PacketXid, IN BOOLEAN NeedSignal)
EFI_STATUS Dhcp6StartInfoRequest(IN DHCP6_INSTANCE *Instance, IN BOOLEAN SendClientId, IN EFI_DHCP6_PACKET_OPTION *OptionRequest, IN UINT32 OptionCount, IN EFI_DHCP6_PACKET_OPTION *OptionList[] OPTIONAL, IN EFI_DHCP6_RETRANSMISSION *Retransmission, IN EFI_EVENT TimeoutEvent OPTIONAL, IN EFI_DHCP6_INFO_CALLBACK ReplyCallback, IN VOID *CallbackContext OPTIONAL)
EFI_STATUS EFIAPI Dhcp6CallbackUser(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_EVENT Event, IN OUT EFI_DHCP6_PACKET **Packet)
EFI_STATUS Dhcp6HandleAdvertiseMsg(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *Packet)
EFI_STATUS Dhcp6SendDeclineMsg(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_IA *DecIa)
VOID Dhcp6HandleStateful(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *Packet)
EFI_STATUS Dhcp6EnqueueRetry(IN DHCP6_INSTANCE *Instance, IN EFI_DHCP6_PACKET *Packet, IN UINT16 *Elapsed, IN EFI_DHCP6_RETRANSMISSION *RetryCtl OPTIONAL)
EFI_STATUS Dhcp6InitSolicitMsg(IN DHCP6_INSTANCE *Instance)
EFI_STATUS Dhcp6SendRequestMsg(IN DHCP6_INSTANCE *Instance)
EFI_STATUS Dhcp6SendSolicitMsg(IN DHCP6_INSTANCE *Instance)
EFI_STATUS Dhcp6SendRenewRebindMsg(IN DHCP6_INSTANCE *Instance, IN BOOLEAN RebindRequest)
EFI_STATUS Dhcp6SeekInnerOptionSafe(IN UINT16 IaType, IN UINT8 *Option, IN UINT32 OptionLen, OUT UINT8 **IaInnerOpt, OUT UINT16 *IaInnerLen)
EFI_STATUS Dhcp6SendInfoRequestMsg(IN DHCP6_INSTANCE *Instance, IN DHCP6_INF_CB *InfCb, IN BOOLEAN SendClientId, IN EFI_DHCP6_PACKET_OPTION *OptionRequest, IN UINT32 OptionCount, IN EFI_DHCP6_PACKET_OPTION *OptionList[], IN EFI_DHCP6_RETRANSMISSION *Retransmission)
BOOLEAN Dhcp6IsValidTxCb(IN DHCP6_INSTANCE *Instance, IN DHCP6_TX_CB *TxCb)
EFI_STATUS Dhcp6AppendIaOption(IN OUT EFI_DHCP6_PACKET *Packet, IN OUT UINT8 **PacketCursor, IN EFI_DHCP6_IA *Ia, IN UINT32 T1, IN UINT32 T2, IN UINT32 MessageType)
EFI_STATUS Dhcp6CacheIa(IN DHCP6_INSTANCE *Instance)
EFI_STATUS Dhcp6GenerateIaCb(IN DHCP6_INSTANCE *Instance, IN UINT8 *IaInnerOpt, IN UINT16 IaInnerLen, IN UINT32 T1, IN UINT32 T2)
VOID Dhcp6AppendCacheIa(IN DHCP6_INSTANCE *Instance)
VOID EFIAPI Dhcp6OnTransmitted(IN NET_BUF *Wrap, IN UDP_END_POINT *EndPoint, IN EFI_STATUS IoStatus, IN VOID *Context)
EFI_STATUS Dhcp6AppendOption(IN OUT EFI_DHCP6_PACKET *Packet, IN OUT UINT8 **PacketCursor, IN UINT16 OptType, IN UINT16 OptLen, IN UINT8 *Data)
EFI_STATUS Dhcp6AppendETOption(IN OUT EFI_DHCP6_PACKET *Packet, IN OUT UINT8 **PacketCursor, IN DHCP6_INSTANCE *Instance, OUT UINT16 **Elapsed)
UINT8 * Dhcp6SeekOption(IN UINT8 *Buf, IN UINT32 SeekLen, IN UINT16 OptType)
VOID EFIAPI Dhcp6DummyExtFree(IN VOID *Arg)
UINT32 Dhcp6CalculateExpireTime(IN UINT32 Base, IN BOOLEAN IsFirstRt, IN BOOLEAN NeedSigned)
UINT8 * Dhcp6SeekIaOption(IN UINT8 *Buf, IN UINT32 SeekLen, IN EFI_DHCP6_IA_DESCRIPTOR *IaDesc)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
NET_BUF *EFIAPI NetbufFromExt(IN NET_FRAGMENT *ExtFragment, IN UINT32 ExtNum, IN UINT32 HeadSpace, IN UINT32 HeadLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
EFI_STATUS EFIAPI UdpIoRecvDatagram(IN UDP_IO *UdpIo, IN UDP_IO_CALLBACK CallBack, IN VOID *Context, IN UINT32 HeadLen)
EFI_STATUS EFIAPI UdpIoSendDatagram(IN UDP_IO *UdpIo, IN NET_BUF *Packet, IN UDP_END_POINT *EndPoint OPTIONAL, IN EFI_IP_ADDRESS *Gateway OPTIONAL, IN UDP_IO_CALLBACK CallBack, IN VOID *Context)
EFI_SIMPLE_NETWORK_MODE * Mode
EFI_DHCP6_PACKET * ReplyPacket
EFI_DHCP6_IA_ADDRESS IaAddress[1]
BOOLEAN MediaPresentSupported