TianoCore EDK2 master
Loading...
Searching...
No Matches
Ip6Input.c File Reference
#include "Ip6Impl.h"

Go to the source code of this file.

Functions

IP6_ASSEMBLE_ENTRYIp6CreateAssembleEntry (IN EFI_IPv6_ADDRESS *Dst, IN EFI_IPv6_ADDRESS *Src, IN UINT32 Id)
 
VOID Ip6FreeAssembleEntry (IN IP6_ASSEMBLE_ENTRY *Assemble)
 
VOID EFIAPI Ip6OnFreeFragments (IN VOID *Arg)
 
VOID Ip6TrimPacket (IN OUT NET_BUF *Packet, IN INTN Start, IN INTN End)
 
NET_BUFIp6Reassemble (IN OUT IP6_ASSEMBLE_TABLE *Table, IN NET_BUF *Packet)
 
VOID EFIAPI Ip6IpSecFree (IN VOID *Arg)
 
EFI_STATUS Ip6IpSecProcessPacket (IN IP6_SERVICE *IpSb, IN OUT EFI_IP6_HEADER **Head, IN OUT UINT8 *LastHead, IN OUT NET_BUF **Netbuf, IN OUT UINT8 **ExtHdrs, IN OUT UINT32 *ExtHdrsLen, IN EFI_IPSEC_TRAFFIC_DIR Direction, IN VOID *Context)
 
EFI_STATUS Ip6PreProcessPacket (IN IP6_SERVICE *IpSb, IN OUT NET_BUF **Packet, IN UINT32 Flag, OUT UINT8 **Payload, OUT UINT8 **LastHead, OUT UINT32 *ExtHdrsLen, OUT UINT32 *UnFragmentLen, OUT BOOLEAN *Fragmented, OUT EFI_IP6_HEADER **Head)
 
VOID Ip6AcceptFrame (IN NET_BUF *Packet, IN EFI_STATUS IoStatus, IN UINT32 Flag, IN VOID *Context)
 
VOID Ip6CreateAssembleTable (IN OUT IP6_ASSEMBLE_TABLE *Table)
 
VOID Ip6CleanAssembleTable (IN OUT IP6_ASSEMBLE_TABLE *Table)
 
VOID EFIAPI Ip6OnRecyclePacket (IN EFI_EVENT Event, IN VOID *Context)
 
IP6_RXDATA_WRAPIp6WrapRxData (IN IP6_PROTOCOL *IpInstance, IN NET_BUF *Packet)
 
BOOLEAN Ip6InstanceFrameAcceptable (IN IP6_PROTOCOL *IpInstance, IN EFI_IP6_HEADER *Head, IN NET_BUF *Packet)
 
EFI_STATUS Ip6InstanceEnquePacket (IN IP6_PROTOCOL *IpInstance, IN EFI_IP6_HEADER *Head, IN NET_BUF *Packet)
 
EFI_STATUS Ip6InstanceDeliverPacket (IN IP6_PROTOCOL *IpInstance)
 
INTN Ip6InterfaceEnquePacket (IN IP6_SERVICE *IpSb, IN EFI_IP6_HEADER *Head, IN NET_BUF *Packet, IN IP6_INTERFACE *IpIf)
 
VOID Ip6InterfaceDeliverPacket (IN IP6_SERVICE *IpSb, IN IP6_INTERFACE *IpIf)
 
EFI_STATUS Ip6Demultiplex (IN IP6_SERVICE *IpSb, IN EFI_IP6_HEADER *Head, IN NET_BUF *Packet)
 
EFI_STATUS EFIAPI Ip6SentPacketTicking (IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
 
VOID Ip6PacketTimerTicking (IN IP6_SERVICE *IpSb)
 

Detailed Description

IP6 internal functions to process the incoming packets.

Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Ip6Input.c.

Function Documentation

◆ Ip6AcceptFrame()

VOID Ip6AcceptFrame ( IN NET_BUF Packet,
IN EFI_STATUS  IoStatus,
IN UINT32  Flag,
IN VOID *  Context 
)

The IP6 input routine. It is called by the IP6_INTERFACE when an IP6 fragment is received from MNP.

Parameters
[in]PacketThe IP6 packet received.
[in]IoStatusThe return status of receive request.
[in]FlagThe link layer flag for the packet received, such as multicast.
[in]ContextThe IP6 service instance that owns the MNP.

Definition at line 976 of file Ip6Input.c.

◆ Ip6CleanAssembleTable()

VOID Ip6CleanAssembleTable ( IN OUT IP6_ASSEMBLE_TABLE Table)

Clean up the assemble table by removing all of the fragments and assemble entries.

Parameters
[in,out]TableThe assemble table to clean up.

Definition at line 1136 of file Ip6Input.c.

◆ Ip6CreateAssembleEntry()

IP6_ASSEMBLE_ENTRY * Ip6CreateAssembleEntry ( IN EFI_IPv6_ADDRESS Dst,
IN EFI_IPv6_ADDRESS Src,
IN UINT32  Id 
)

Create an empty assemble entry for the packet identified by (Dst, Src, Id). The default life for the packet is 60 seconds.

Parameters
[in]DstThe destination address.
[in]SrcThe source address.
[in]IdThe ID field in the IP header.
Returns
NULL if failed to allocate memory for the entry. Otherwise, the pointer to the just created reassemble entry.

Definition at line 26 of file Ip6Input.c.

◆ Ip6CreateAssembleTable()

VOID Ip6CreateAssembleTable ( IN OUT IP6_ASSEMBLE_TABLE Table)

Initialize an already allocated assemble table. This is generally the assemble table embedded in the IP6 service instance.

Parameters
[in,out]TableThe assemble table to initialize.

Definition at line 1117 of file Ip6Input.c.

◆ Ip6Demultiplex()

EFI_STATUS Ip6Demultiplex ( IN IP6_SERVICE IpSb,
IN EFI_IP6_HEADER Head,
IN NET_BUF Packet 
)

De-multiplex the packet. the packet delivery is processed in two passes. The first pass will enqueue a shared copy of the packet to each IP6 child that accepts the packet. The second pass will deliver a non-shared copy of the packet to each IP6 child that has pending receive requests. Data is copied if more than one child wants to consume the packet, because each IP child needs its own copy of the packet to make changes.

Parameters
[in]IpSbThe IP6 service instance that received the packet.
[in]HeadThe header of the received packet.
[in]PacketThe data of the received packet.
Return values
EFI_NOT_FOUNDNo IP child accepts the packet.
EFI_SUCCESSThe packet is enqueued or delivered to some IP children.

Definition at line 1651 of file Ip6Input.c.

◆ Ip6FreeAssembleEntry()

VOID Ip6FreeAssembleEntry ( IN IP6_ASSEMBLE_ENTRY Assemble)

Release all the fragments of a packet, then free the assemble entry.

Parameters
[in]AssembleThe assemble entry to free.

Definition at line 62 of file Ip6Input.c.

◆ Ip6InstanceDeliverPacket()

EFI_STATUS Ip6InstanceDeliverPacket ( IN IP6_PROTOCOL IpInstance)

Deliver the received packets to the upper layer if there are both received requests and enqueued packets. If the enqueued packet is shared, it will duplicate it to a non-shared packet, release the shared packet, then deliver the non-shared packet up.

Parameters
[in]IpInstanceThe IP child to deliver the packet up.
Return values
EFI_OUT_OF_RESOURCESFailed to allocate resources to deliver the packets.
EFI_SUCCESSAll the enqueued packets that can be delivered are delivered up.

Definition at line 1466 of file Ip6Input.c.

◆ Ip6InstanceEnquePacket()

EFI_STATUS Ip6InstanceEnquePacket ( IN IP6_PROTOCOL IpInstance,
IN EFI_IP6_HEADER Head,
IN NET_BUF Packet 
)

Enqueue a shared copy of the packet to the IP6 child if the packet is acceptable to it. Here the data of the packet is shared, but the net buffer isn't.

Parameters
IpInstanceThe IP6 child to enqueue the packet to.
HeadThe IP header of the received packet.
PacketThe data of the received packet.
Return values
EFI_NOT_STARTEDThe IP child hasn't been configured.
EFI_INVALID_PARAMETERThe child doesn't want to receive the packet.
EFI_OUT_OF_RESOURCESFailed to allocate some resources
EFI_SUCCESSA shared copy the packet is enqueued to the child.

Definition at line 1411 of file Ip6Input.c.

◆ Ip6InstanceFrameAcceptable()

BOOLEAN Ip6InstanceFrameAcceptable ( IN IP6_PROTOCOL IpInstance,
IN EFI_IP6_HEADER Head,
IN NET_BUF Packet 
)

Check whether this IP child accepts the packet.

Parameters
[in]IpInstanceThe IP child to check.
[in]HeadThe IP header of the packet.
[in]PacketThe data of the packet.
Return values
TRUEThe child wants to receive the packet.
FALSEThe child does not want to receive the packet.

Definition at line 1266 of file Ip6Input.c.

◆ Ip6InterfaceDeliverPacket()

VOID Ip6InterfaceDeliverPacket ( IN IP6_SERVICE IpSb,
IN IP6_INTERFACE IpIf 
)

Deliver the packet for each IP6 child on the interface.

Parameters
[in]IpSbThe IP6 service instance that received the packet.
[in]IpIfThe IP6 interface to deliver the packet.

Definition at line 1618 of file Ip6Input.c.

◆ Ip6InterfaceEnquePacket()

INTN Ip6InterfaceEnquePacket ( IN IP6_SERVICE IpSb,
IN EFI_IP6_HEADER Head,
IN NET_BUF Packet,
IN IP6_INTERFACE IpIf 
)

Enqueue a received packet to all the IP children that share the same interface.

Parameters
[in]IpSbThe IP6 service instance that receive the packet.
[in]HeadThe header of the received packet.
[in]PacketThe data of the received packet.
[in]IpIfThe interface to enqueue the packet to.
Returns
The number of the IP6 children that accepts the packet.

Definition at line 1559 of file Ip6Input.c.

◆ Ip6IpSecFree()

VOID EFIAPI Ip6IpSecFree ( IN VOID *  Arg)

The callback function for the net buffer that wraps the packet processed by IPsec. It releases the wrap packet and also signals IPsec to free the resources.

Parameters
[in]ArgThe wrap context.

Definition at line 453 of file Ip6Input.c.

◆ Ip6IpSecProcessPacket()

EFI_STATUS Ip6IpSecProcessPacket ( IN IP6_SERVICE IpSb,
IN OUT EFI_IP6_HEADER **  Head,
IN OUT UINT8 *  LastHead,
IN OUT NET_BUF **  Netbuf,
IN OUT UINT8 **  ExtHdrs,
IN OUT UINT32 *  ExtHdrsLen,
IN EFI_IPSEC_TRAFFIC_DIR  Direction,
IN VOID *  Context 
)

The work function to locate the IPsec protocol to process the inbound or outbound IP packets. The process routine handles the packet with the following actions: bypass the packet, discard the packet, or protect the packet.

Parameters
[in]IpSbThe IP6 service instance.
[in,out]HeadThe caller-supplied IP6 header.
[in,out]LastHeadThe next header field of last IP header.
[in,out]NetbufThe IP6 packet to be processed by IPsec.
[in,out]ExtHdrsThe caller-supplied options.
[in,out]ExtHdrsLenThe length of the option.
[in]DirectionThe directionality in an SPD entry, EfiIPsecInBound, or EfiIPsecOutBound.
[in]ContextThe token's wrap.
Return values
EFI_SUCCESSThe IPsec protocol is not available or disabled.
EFI_SUCCESSThe packet was bypassed, and all buffers remain the same.
EFI_SUCCESSThe packet was protected.
EFI_ACCESS_DENIEDThe packet was discarded.
EFI_OUT_OF_RESOURCESThere are not sufficient resources to complete the operation.
EFI_BUFFER_TOO_SMALLThe number of non-empty blocks is bigger than the number of input data blocks when building a fragment table.

Definition at line 497 of file Ip6Input.c.

◆ Ip6OnFreeFragments()

VOID EFIAPI Ip6OnFreeFragments ( IN VOID *  Arg)

Release all the fragments of the packet. This is the callback for the assembled packet's OnFree. It will free the assemble entry, which in turn frees all the fragments of the packet.

Parameters
[in]ArgThe assemble entry to free.

Definition at line 94 of file Ip6Input.c.

◆ Ip6OnRecyclePacket()

VOID EFIAPI Ip6OnRecyclePacket ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

The signal handle of IP6's recycle event. It is called back when the upper layer releases the packet.

Parameters
[in]EventThe IP6's recycle event.
[in]ContextThe context of the handle, which is a IP6_RXDATA_WRAP.

Definition at line 1165 of file Ip6Input.c.

◆ Ip6PacketTimerTicking()

VOID Ip6PacketTimerTicking ( IN IP6_SERVICE IpSb)

Timeout the fragments, and the enqueued, and transmitted packets.

Parameters
[in]IpSbThe IP6 service instance to timeout.

Definition at line 1739 of file Ip6Input.c.

◆ Ip6PreProcessPacket()

EFI_STATUS Ip6PreProcessPacket ( IN IP6_SERVICE IpSb,
IN OUT NET_BUF **  Packet,
IN UINT32  Flag,
OUT UINT8 **  Payload,
OUT UINT8 **  LastHead,
OUT UINT32 *  ExtHdrsLen,
OUT UINT32 *  UnFragmentLen,
OUT BOOLEAN *  Fragmented,
OUT EFI_IP6_HEADER **  Head 
)

Pre-process the IPv6 packet. First validates the IPv6 packet, and then reassembles packet if it is necessary.

Parameters
[in]IpSbThe IP6 service instance.
[in,out]PacketThe received IP6 packet to be processed.
[in]FlagThe link layer flag for the packet received, such as multicast.
[out]PayloadThe pointer to the payload of the received packet. it starts from the first byte of the extension header.
[out]LastHeadThe pointer of NextHeader of the last extension header processed by IP6.
[out]ExtHdrsLenThe length of the whole option.
[out]UnFragmentLenThe length of unfragmented length of extension headers.
[out]FragmentedIndicate whether the packet is fragmented.
[out]HeadThe pointer to the EFI_IP6_Header.
Return values
EFI_SUCCESSThe received packet is well format.
EFI_INVALID_PARAMETERThe received packet is malformed.

Definition at line 732 of file Ip6Input.c.

◆ Ip6Reassemble()

NET_BUF * Ip6Reassemble ( IN OUT IP6_ASSEMBLE_TABLE Table,
IN NET_BUF Packet 
)

Reassemble the IP fragments. If all the fragments of the packet have been received, it will wrap the packet in a net buffer then return it to caller. If the packet can't be assembled, NULL is returned.

Parameters
[in,out]TableThe assemble table used. A new assemble entry will be created if the Packet is from a new chain of fragments.
[in]PacketThe fragment to assemble. It might be freed if the fragment can't be re-assembled.
Returns
NULL if the packet can't be reassembled. The pointer to the just assembled packet if all the fragments of the packet have arrived.

Definition at line 158 of file Ip6Input.c.

◆ Ip6SentPacketTicking()

EFI_STATUS EFIAPI Ip6SentPacketTicking ( IN NET_MAP Map,
IN NET_MAP_ITEM Item,
IN VOID *  Context 
)

Decrease the life of the transmitted packets. If it is decreased to zero, cancel the packet. This function is called by Ip6packetTimerTicking that provides timeout for both the received-but-not-delivered and transmitted-but-not-recycle packets.

Parameters
[in]MapThe IP6 child's transmit map.
[in]ItemCurrent transmitted packet.
[in]ContextNot used.
Return values
EFI_SUCCESSAlways returns EFI_SUCCESS.

Definition at line 1714 of file Ip6Input.c.

◆ Ip6TrimPacket()

VOID Ip6TrimPacket ( IN OUT NET_BUF Packet,
IN INTN  Start,
IN INTN  End 
)

Trim the packet to fit in [Start, End), and update per the packet information.

Parameters
[in,out]PacketPacket to trim.
[in]StartThe sequence of the first byte to fit in.
[in]EndOne beyond the sequence of last byte to fit in.

Definition at line 111 of file Ip6Input.c.

◆ Ip6WrapRxData()

IP6_RXDATA_WRAP * Ip6WrapRxData ( IN IP6_PROTOCOL IpInstance,
IN NET_BUF Packet 
)

Wrap the received packet to a IP6_RXDATA_WRAP, which will be delivered to the upper layer. Each IP6 child that accepts the packet will get a not-shared copy of the packet which is wrapped in the IP6_RXDATA_WRAP. The IP6_RXDATA_WRAP->RxData is passed to the upper layer. The upper layer will signal the recycle event in it when it is done with the packet.

Parameters
[in]IpInstanceThe IP6 child to receive the packet.
[in]PacketThe packet to deliver up.
Returns
NULL if it failed to wrap the packet; otherwise, the wrapper.

Definition at line 1200 of file Ip6Input.c.