44 ASSERT (Option !=
NULL);
48 if ((OptionLen <= 0) || (OptionLen > IP6_MAX_EXT_DATA_LENGTH)) {
49 ASSERT (OptionLen > 0 && OptionLen <= IP6_MAX_EXT_DATA_LENGTH);
54 ASSERT (Packet !=
NULL);
59 ASSERT (IpSb !=
NULL);
65 while (Offset < OptionLen) {
66 OptionType = *(Option + Offset);
80 Offset = IP6_NEXT_OPTION_OFFSET (Offset, OptDataLen);
82 case Ip6OptionRouterAlert:
93 switch (OptionType & Ip6OptionMask) {
96 Offset = IP6_NEXT_OPTION_OFFSET (Offset, OptDataLen);
98 case Ip6OptionDiscard:
100 case Ip6OptionParameterProblem:
106 &Packet->Ip.Ip6->SourceAddress,
107 ICMP_V6_PARAMETER_PROBLEM,
113 if (!IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) {
119 &Packet->Ip.Ip6->SourceAddress,
120 ICMP_V6_PARAMETER_PROBLEM,
159 if (Option ==
NULL) {
160 ASSERT (Option !=
NULL);
181 Length = (UINT16)OptionHeader->
Length * 8;
183 switch (OptionHeader->
Type) {
184 case Ip6OptionPrefixInfo:
210 switch (OptionHeader->
Type) {
211 case Ip6OptionEtherSource:
212 case Ip6OptionEtherTarget:
213 case Ip6OptionPrefixInfo:
214 case Ip6OptionRedirected:
216 if (Offset + Length > (UINT32)OptionLen) {
260 if ((NextHeader == EFI_IP_PROTO_TCP) ||
261 (NextHeader == EFI_IP_PROTO_UDP) ||
262 (NextHeader == IP6_ICMP) ||
263 (NextHeader == IP6_ESP)
273 if (IpSb->Signature != IP6_SERVICE_SIGNATURE) {
277 NET_LIST_FOR_EACH (Entry, &IpSb->Children) {
278 IpInstance = NET_LIST_USER_STRUCT_S (Entry,
IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
279 if (IpInstance->State == IP6_STATE_CONFIGED) {
321 IN UINT8 *NextHeader,
323 IN UINT32 ExtHdrsLen,
325 OUT UINT32 *FormerHeader OPTIONAL,
326 OUT UINT8 **LastHeader,
327 OUT UINT32 *RealExtsLen OPTIONAL,
328 OUT UINT32 *UnFragmentLen OPTIONAL,
329 OUT BOOLEAN *Fragmented OPTIONAL
340 UINT16 FragmentOffset;
343 if (RealExtsLen !=
NULL) {
347 if (UnFragmentLen !=
NULL) {
351 if (Fragmented !=
NULL) {
355 *LastHeader = NextHeader;
357 if ((ExtHdrs ==
NULL) && (ExtHdrsLen == 0)) {
361 if (((ExtHdrs ==
NULL) && (ExtHdrsLen != 0)) || ((ExtHdrs !=
NULL) && (ExtHdrsLen == 0))) {
371 while (Offset <= ExtHdrsLen) {
372 switch (*NextHeader) {
389 if ((IpSb !=
NULL) && (Packet !=
NULL) &&
390 !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress))
396 &Packet->Ip.Ip6->SourceAddress,
397 ICMP_V6_PARAMETER_PROBLEM,
411 case IP6_DESTINATION:
442 if (*NextHeader == IP6_DESTINATION) {
450 NextHeader = ExtHdrs + Offset;
454 Option = ExtHdrs + Offset;
455 OptionLen = IP6_HDR_EXT_LEN (*Option) -
sizeof (
IP6_EXT_HDR);
463 Offset = Offset + OptionLen;
466 if (UnFragmentLen !=
NULL) {
467 *UnFragmentLen = Offset;
476 NextHeader = ExtHdrs + Offset;
483 if (RoutingHead->SegmentsLeft == 0) {
487 Offset = Offset + IP6_HDR_EXT_LEN (RoutingHead->HeaderLen);
489 if (UnFragmentLen !=
NULL) {
490 *UnFragmentLen = Offset;
499 if ((IpSb !=
NULL) && (Packet !=
NULL) &&
500 !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress))
506 &Packet->Ip.Ip6->SourceAddress,
507 ICMP_V6_PARAMETER_PROBLEM,
533 if ((IpSb !=
NULL) && (Packet !=
NULL) && ((ExtHdrsLen % 8) != 0)) {
538 if (FragmentHead ==
NULL) {
542 FragmentOffset = NTOHS (FragmentHead->FragmentOffset);
544 if (((FragmentOffset & 0x1) == 0x1) &&
545 !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress))
547 Pointer =
sizeof (UINT32);
552 &Packet->Ip.Ip6->SourceAddress,
553 ICMP_V6_PARAMETER_PROBLEM,
561 if (Fragmented !=
NULL) {
565 if (Rcvd && (FormerHeader !=
NULL)) {
566 *FormerHeader = (UINT32)(NextHeader - ExtHdrs);
569 NextHeader = ExtHdrs + Offset;
578 Option = ExtHdrs + Offset;
584 OptionLen = ((UINT16)(*Option + 2) * 4);
585 Offset = Offset + OptionLen;
588 case IP6_NO_NEXT_HEADER:
589 *LastHeader = NextHeader;
595 *LastHeader = NextHeader;
597 if (RealExtsLen !=
NULL) {
598 *RealExtsLen = Offset;
621 if ((IpSb !=
NULL) && (Packet !=
NULL) &&
622 !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress))
628 &Packet->Ip.Ip6->SourceAddress,
629 ICMP_V6_PARAMETER_PROBLEM,
639 *LastHeader = NextHeader;
641 if (RealExtsLen !=
NULL) {
642 *RealExtsLen = Offset;
669 UINT8 BufferArray[8];
671 if (*BufferLen < 8) {
673 return EFI_BUFFER_TOO_SMALL;
681 ZeroMem (BufferArray,
sizeof (BufferArray));
682 BufferArray[0] = NextHeader;
683 BufferArray[2] = 0x5;
684 BufferArray[3] = 0x2;
687 CopyMem (Buffer, BufferArray,
sizeof (BufferArray));
716 IN UINT32 ExtHdrsLen,
717 IN UINT16 FragmentOffset,
718 OUT UINT8 **UpdatedExtHdrs
730 if (UpdatedExtHdrs ==
NULL) {
731 return EFI_INVALID_PARAMETER;
736 if (Buffer ==
NULL) {
737 return EFI_OUT_OF_RESOURCES;
743 Current = NextHeader;
745 while ((ExtHdrs !=
NULL) && (Offset <= ExtHdrsLen)) {
746 switch (NextHeader) {
749 case IP6_DESTINATION:
750 Current = NextHeader;
751 NextHeader = *(ExtHdrs + Offset);
753 if ((Current == IP6_DESTINATION) && (NextHeader != IP6_ROUTING)) {
760 CopyMem (Buffer, ExtHdrs, Part1Len);
761 *(Buffer + FormerHeader) = IP6_FRAGMENT;
765 Offset = ExtHdrsLen + 1;
769 FormerHeader = Offset;
770 HeaderLen = (*(ExtHdrs + Offset + 1) + 1) * 8;
771 Part1Len = Part1Len + HeaderLen;
772 Offset = Offset + HeaderLen;
776 Current = NextHeader;
779 CopyMem (Buffer, ExtHdrs, Part1Len);
782 *(Buffer + FormerHeader) = IP6_FRAGMENT;
787 Offset = ExtHdrsLen + 1;
791 Current = NextHeader;
792 NextHeader = *(ExtHdrs + Offset);
796 HeaderLen = (*(ExtHdrs + Offset + 1) + 2) * 4;
797 Part1Len = Part1Len + HeaderLen;
798 Offset = Offset + HeaderLen;
803 Current = NextHeader;
804 CopyMem (Buffer, ExtHdrs, Part1Len);
805 *(Buffer + FormerHeader) = IP6_FRAGMENT;
809 Offset = ExtHdrsLen + 1;
814 return EFI_UNSUPPORTED;
822 if ((FragmentOffset & IP6_FRAGMENT_OFFSET_MASK) == 0) {
823 FragmentHead.NextHeader = Current;
825 FragmentHead.NextHeader = LastHeader;
828 FragmentHead.Reserved = 0;
829 FragmentHead.FragmentOffset = HTONS (FragmentOffset);
830 FragmentHead.Identification = mIp6Id;
834 if ((ExtHdrs !=
NULL) && (Part1Len < ExtHdrsLen)) {
841 ExtHdrsLen - Part1Len
845 *UpdatedExtHdrs = Buffer;
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
struct _EFI_IP6_HEADER EFI_IP6_HEADER
EFI_STATUS Ip6SendIcmpError(IN IP6_SERVICE *IpSb, IN NET_BUF *Packet, IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL, IN EFI_IPv6_ADDRESS *DestinationAddress, IN UINT8 Type, IN UINT8 Code, IN UINT32 *Pointer OPTIONAL)
BOOLEAN Ip6IsOptionValid(IN IP6_SERVICE *IpSb, IN NET_BUF *Packet, IN UINT8 *Option, IN UINT16 OptionLen, IN UINT32 Pointer)
EFI_STATUS Ip6FillHopByHop(OUT UINT8 *Buffer, IN OUT UINTN *BufferLen, IN UINT8 NextHeader)
BOOLEAN Ip6IsExtsValid(IN IP6_SERVICE *IpSb OPTIONAL, IN NET_BUF *Packet OPTIONAL, IN UINT8 *NextHeader, IN UINT8 *ExtHdrs, IN UINT32 ExtHdrsLen, IN BOOLEAN Rcvd, OUT UINT32 *FormerHeader OPTIONAL, OUT UINT8 **LastHeader, OUT UINT32 *RealExtsLen OPTIONAL, OUT UINT32 *UnFragmentLen OPTIONAL, OUT BOOLEAN *Fragmented OPTIONAL)
BOOLEAN Ip6IsNDOptionValid(IN UINT8 *Option, IN UINT16 OptionLen)
BOOLEAN Ip6IsValidProtocol(IN IP6_SERVICE *IpSb, IN UINT8 NextHeader)
EFI_STATUS Ip6FillFragmentHeader(IN IP6_SERVICE *IpSb, IN UINT8 NextHeader, IN UINT8 LastHeader, IN UINT8 *ExtHdrs, IN UINT32 ExtHdrsLen, IN UINT16 FragmentOffset, OUT UINT8 **UpdatedExtHdrs)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)