TianoCore EDK2 master
Loading...
Searching...
No Matches
Ip4Input.c File Reference
#include "Ip4Impl.h"

Go to the source code of this file.

Functions

IP4_ASSEMBLE_ENTRYIp4CreateAssembleEntry (IN IP4_ADDR Dst, IN IP4_ADDR Src, IN UINT16 Id, IN UINT8 Protocol)
 
VOID Ip4FreeAssembleEntry (IN IP4_ASSEMBLE_ENTRY *Assemble)
 
VOID Ip4InitAssembleTable (IN OUT IP4_ASSEMBLE_TABLE *Table)
 
VOID Ip4CleanAssembleTable (IN IP4_ASSEMBLE_TABLE *Table)
 
VOID Ip4TrimPacket (IN OUT NET_BUF *Packet, IN INTN Start, IN INTN End)
 
VOID EFIAPI Ip4OnFreeFragments (IN VOID *Arg)
 
NET_BUFIp4Reassemble (IN OUT IP4_ASSEMBLE_TABLE *Table, IN OUT NET_BUF *Packet)
 
VOID EFIAPI Ip4IpSecFree (IN VOID *Arg)
 
EFI_STATUS Ip4IpSecProcessPacket (IN IP4_SERVICE *IpSb, IN OUT IP4_HEAD **Head, IN OUT NET_BUF **Netbuf, IN OUT UINT8 **Options, IN OUT UINT32 *OptionsLen, IN EFI_IPSEC_TRAFFIC_DIR Direction, IN VOID *Context)
 
EFI_STATUS Ip4PreProcessPacket (IN IP4_SERVICE *IpSb, IN OUT NET_BUF **Packet, IN IP4_HEAD *Head, IN UINT8 *Option, IN UINT32 OptionLen, IN UINT32 Flag)
 
BOOLEAN Ip4IsValidPacketLength (IN NET_BUF *Packet)
 
VOID Ip4AccpetFrame (IN IP4_PROTOCOL *Ip4Instance, IN NET_BUF *Packet, IN EFI_STATUS IoStatus, IN UINT32 Flag, IN VOID *Context)
 
BOOLEAN Ip4InstanceFrameAcceptable (IN IP4_PROTOCOL *IpInstance, IN IP4_HEAD *Head, IN NET_BUF *Packet)
 
EFI_STATUS Ip4InstanceEnquePacket (IN IP4_PROTOCOL *IpInstance, IN IP4_HEAD *Head, IN NET_BUF *Packet)
 
VOID EFIAPI Ip4OnRecyclePacket (IN EFI_EVENT Event, IN VOID *Context)
 
IP4_RXDATA_WRAPIp4WrapRxData (IN IP4_PROTOCOL *IpInstance, IN NET_BUF *Packet)
 
EFI_STATUS Ip4InstanceDeliverPacket (IN IP4_PROTOCOL *IpInstance)
 
INTN Ip4InterfaceEnquePacket (IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet, IN UINT8 *Option, IN UINT32 OptionLen, IN IP4_INTERFACE *IpIf)
 
EFI_STATUS Ip4InterfaceDeliverPacket (IN IP4_SERVICE *IpSb, IN IP4_INTERFACE *IpIf)
 
EFI_STATUS Ip4Demultiplex (IN IP4_SERVICE *IpSb, IN IP4_HEAD *Head, IN NET_BUF *Packet, IN UINT8 *Option, IN UINT32 OptionLen)
 
VOID Ip4PacketTimerTicking (IN IP4_SERVICE *IpSb)
 

Detailed Description

IP4 input process.

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

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

Definition in file Ip4Input.c.

Function Documentation

◆ Ip4AccpetFrame()

VOID Ip4AccpetFrame ( IN IP4_PROTOCOL Ip4Instance,
IN NET_BUF Packet,
IN EFI_STATUS  IoStatus,
IN UINT32  Flag,
IN VOID *  Context 
)

The IP4 input routine. It is called by the IP4_INTERFACE when a IP4 fragment is received from MNP.

Parameters
[in]Ip4InstanceThe IP4 child that request the receive, most like it is NULL.
[in]PacketThe IP4 packet received.
[in]IoStatusThe return status of receive request.
[in]FlagThe link layer flag for the packet received, such as multicast.
[in]ContextThe IP4 service instance that own the MNP.

Definition at line 838 of file Ip4Input.c.

◆ Ip4CleanAssembleTable()

VOID Ip4CleanAssembleTable ( IN IP4_ASSEMBLE_TABLE Table)

Clean up the assemble table: remove all the fragments and assemble entries.

Parameters
[in]TableThe assemble table to clean up

Definition at line 111 of file Ip4Input.c.

◆ Ip4CreateAssembleEntry()

IP4_ASSEMBLE_ENTRY * Ip4CreateAssembleEntry ( IN IP4_ADDR  Dst,
IN IP4_ADDR  Src,
IN UINT16  Id,
IN UINT8  Protocol 
)

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

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

Definition at line 28 of file Ip4Input.c.

◆ Ip4Demultiplex()

EFI_STATUS Ip4Demultiplex ( IN IP4_SERVICE IpSb,
IN IP4_HEAD Head,
IN NET_BUF Packet,
IN UINT8 *  Option,
IN UINT32  OptionLen 
)

Demultiple the packet. the packet delivery is processed in two passes. The first pass will enqueue a shared copy of the packet to each IP4 child that accepts the packet. The second pass will deliver a non-shared copy of the packet to each IP4 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 IP4 service instance that received the packet.
[in]HeadThe header of the received packet.
[in]PacketThe data of the received packet.
[in]OptionPoint to the IP4 packet header options.
[in]OptionLenLength of the IP4 packet header options.
Return values
EFI_NOT_FOUNDNo IP child accepts the packet.
EFI_SUCCESSThe packet is enqueued or delivered to some IP children.

Definition at line 1495 of file Ip4Input.c.

◆ Ip4FreeAssembleEntry()

VOID Ip4FreeAssembleEntry ( IN IP4_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 66 of file Ip4Input.c.

◆ Ip4InitAssembleTable()

VOID Ip4InitAssembleTable ( IN OUT IP4_ASSEMBLE_TABLE Table)

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

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

Definition at line 92 of file Ip4Input.c.

◆ Ip4InstanceDeliverPacket()

EFI_STATUS Ip4InstanceDeliverPacket ( IN IP4_PROTOCOL IpInstance)

Deliver the received packets to 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 1256 of file Ip4Input.c.

◆ Ip4InstanceEnquePacket()

EFI_STATUS Ip4InstanceEnquePacket ( IN IP4_PROTOCOL IpInstance,
IN IP4_HEAD Head,
IN NET_BUF Packet 
)

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

Parameters
[in]IpInstanceThe IP4 child to enqueue the packet to
[in]HeadThe IP header of the received packet
[in]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 resource
EFI_SUCCESSA shared copy the packet is enqueued to the child.

Definition at line 1087 of file Ip4Input.c.

◆ Ip4InstanceFrameAcceptable()

BOOLEAN Ip4InstanceFrameAcceptable ( IN IP4_PROTOCOL IpInstance,
IN IP4_HEAD 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
TRUEIf the child wants to receive the packet.
FALSEOtherwise.

Definition at line 981 of file Ip4Input.c.

◆ Ip4InterfaceDeliverPacket()

EFI_STATUS Ip4InterfaceDeliverPacket ( IN IP4_SERVICE IpSb,
IN IP4_INTERFACE IpIf 
)

Deliver the packet for each IP4 child on the interface.

Parameters
[in]IpSbThe IP4 service instance that received the packet
[in]IpIfThe IP4 interface to deliver the packet.
Return values
EFI_SUCCESSIt always returns EFI_SUCCESS now

Definition at line 1458 of file Ip4Input.c.

◆ Ip4InterfaceEnquePacket()

INTN Ip4InterfaceEnquePacket ( IN IP4_SERVICE IpSb,
IN IP4_HEAD Head,
IN NET_BUF Packet,
IN UINT8 *  Option,
IN UINT32  OptionLen,
IN IP4_INTERFACE IpIf 
)

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

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

Definition at line 1363 of file Ip4Input.c.

◆ Ip4IpSecFree()

VOID EFIAPI Ip4IpSecFree ( IN VOID *  Arg)

The callback function for the net buffer which 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 439 of file Ip4Input.c.

◆ Ip4IpSecProcessPacket()

EFI_STATUS Ip4IpSecProcessPacket ( IN IP4_SERVICE IpSb,
IN OUT IP4_HEAD **  Head,
IN OUT NET_BUF **  Netbuf,
IN OUT UINT8 **  Options,
IN OUT UINT32 *  OptionsLen,
IN EFI_IPSEC_TRAFFIC_DIR  Direction,
IN VOID *  Context 
)

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

Parameters
[in]IpSbThe IP4 service instance.
[in,out]HeadThe caller supplied IP4 header.
[in,out]NetbufThe IP4 packet to be processed by IPsec.
[in,out]OptionsThe caller supplied options.
[in,out]OptionsLenThe 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 is no sufficient resource to complete the operation.
EFI_BUFFER_TOO_SMALLThe number of non-empty block is bigger than the number of input data blocks when build a fragment table.

Definition at line 482 of file Ip4Input.c.

◆ Ip4IsValidPacketLength()

BOOLEAN Ip4IsValidPacketLength ( IN NET_BUF Packet)

This function checks the IPv4 packet length.

Parameters
[in]PacketPointer to the IPv4 Packet to be checked.
Return values
TRUEThe input IPv4 packet length is valid.
FALSEThe input IPv4 packet length is invalid.

Definition at line 810 of file Ip4Input.c.

◆ Ip4OnFreeFragments()

VOID EFIAPI Ip4OnFreeFragments ( 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 will free all the fragments of the packet.

Parameters
[in]ArgThe assemble entry to free

Definition at line 181 of file Ip4Input.c.

◆ Ip4OnRecyclePacket()

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

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

Parameters
EventThe IP4's recycle event.
ContextThe context of the handle, which is a IP4_RXDATA_WRAP

Definition at line 1138 of file Ip4Input.c.

◆ Ip4PacketTimerTicking()

VOID Ip4PacketTimerTicking ( IN IP4_SERVICE IpSb)

Timeout the fragment and enqueued packets.

Parameters
[in]IpSbThe IP4 service instance to timeout

Definition at line 1557 of file Ip4Input.c.

◆ Ip4PreProcessPacket()

EFI_STATUS Ip4PreProcessPacket ( IN IP4_SERVICE IpSb,
IN OUT NET_BUF **  Packet,
IN IP4_HEAD Head,
IN UINT8 *  Option,
IN UINT32  OptionLen,
IN UINT32  Flag 
)

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

Parameters
[in]IpSbPointer to IP4_SERVICE.
[in,out]PacketPointer to the Packet to be processed.
[in]HeadPointer to the IP4_HEAD.
[in]OptionPointer to a buffer which contains the IPv4 option.
[in]OptionLenThe length of Option in bytes.
[in]FlagThe link layer flag for the packet received, such as multicast.
Return values
EFI_SUCCESSThe received packet is in well form.
EFI_INVALID_PARAMETERThe received packet is malformed.

Definition at line 689 of file Ip4Input.c.

◆ Ip4Reassemble()

NET_BUF * Ip4Reassemble ( IN OUT IP4_ASSEMBLE_TABLE Table,
IN OUT 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 return.

Parameters
TableThe assemble table used. New assemble entry will be created if the Packet is from a new chain of fragments.
PacketThe fragment to assemble. It might be freed if the fragment can't be re-assembled.
Returns
NULL if the packet can't be reassemble. The point to just assembled packet if all the fragments of the packet have arrived.

Definition at line 204 of file Ip4Input.c.

◆ Ip4TrimPacket()

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

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

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

Definition at line 140 of file Ip4Input.c.

◆ Ip4WrapRxData()

IP4_RXDATA_WRAP * Ip4WrapRxData ( IN IP4_PROTOCOL IpInstance,
IN NET_BUF Packet 
)

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

Parameters
[in]IpInstanceThe IP4 child to receive the packet.
[in]PacketThe packet to deliver up.
Return values
Wrapif warp the packet succeed.
NULLfailed to wrap the packet .

Definition at line 1174 of file Ip4Input.c.