TianoCore EDK2 master
|
#include "Ip4Impl.h"
Go to the source code of this file.
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.
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.
[in] | Ip4Instance | The IP4 child that request the receive, most like it is NULL. |
[in] | Packet | The IP4 packet received. |
[in] | IoStatus | The return status of receive request. |
[in] | Flag | The link layer flag for the packet received, such as multicast. |
[in] | Context | The IP4 service instance that own the MNP. |
Definition at line 838 of file Ip4Input.c.
VOID Ip4CleanAssembleTable | ( | IN IP4_ASSEMBLE_TABLE * | Table | ) |
Clean up the assemble table: remove all the fragments and assemble entries.
[in] | Table | The assemble table to clean up |
Definition at line 111 of file Ip4Input.c.
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.
[in] | Dst | The destination address |
[in] | Src | The source address |
[in] | Id | The ID field in IP header |
[in] | Protocol | The protocol field in IP header |
Definition at line 28 of file Ip4Input.c.
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.
[in] | IpSb | The IP4 service instance that received the packet. |
[in] | Head | The header of the received packet. |
[in] | Packet | The data of the received packet. |
[in] | Option | Point to the IP4 packet header options. |
[in] | OptionLen | Length of the IP4 packet header options. |
EFI_NOT_FOUND | No IP child accepts the packet. |
EFI_SUCCESS | The packet is enqueued or delivered to some IP children. |
Definition at line 1495 of file Ip4Input.c.
VOID Ip4FreeAssembleEntry | ( | IN IP4_ASSEMBLE_ENTRY * | Assemble | ) |
Release all the fragments of a packet, then free the assemble entry.
[in] | Assemble | The assemble entry to free |
Definition at line 66 of file Ip4Input.c.
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.
[in,out] | Table | The assemble table to initialize. |
Definition at line 92 of file Ip4Input.c.
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.
[in] | IpInstance | The IP child to deliver the packet up. |
EFI_OUT_OF_RESOURCES | Failed to allocate resources to deliver the packets. |
EFI_SUCCESS | All the enqueued packets that can be delivered are delivered up. |
Definition at line 1256 of file Ip4Input.c.
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.
[in] | IpInstance | The IP4 child to enqueue the packet to |
[in] | Head | The IP header of the received packet |
[in] | Packet | The data of the received packet |
EFI_NOT_STARTED | The IP child hasn't been configured. |
EFI_INVALID_PARAMETER | The child doesn't want to receive the packet |
EFI_OUT_OF_RESOURCES | Failed to allocate some resource |
EFI_SUCCESS | A shared copy the packet is enqueued to the child. |
Definition at line 1087 of file Ip4Input.c.
BOOLEAN Ip4InstanceFrameAcceptable | ( | IN IP4_PROTOCOL * | IpInstance, |
IN IP4_HEAD * | Head, | ||
IN NET_BUF * | Packet | ||
) |
Check whether this IP child accepts the packet.
[in] | IpInstance | The IP child to check |
[in] | Head | The IP header of the packet |
[in] | Packet | The data of the packet |
TRUE | If the child wants to receive the packet. |
FALSE | Otherwise. |
Definition at line 981 of file Ip4Input.c.
EFI_STATUS Ip4InterfaceDeliverPacket | ( | IN IP4_SERVICE * | IpSb, |
IN IP4_INTERFACE * | IpIf | ||
) |
Deliver the packet for each IP4 child on the interface.
[in] | IpSb | The IP4 service instance that received the packet |
[in] | IpIf | The IP4 interface to deliver the packet. |
EFI_SUCCESS | It always returns EFI_SUCCESS now |
Definition at line 1458 of file Ip4Input.c.
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.
[in] | IpSb | The IP4 service instance that receive the packet. |
[in] | Head | The header of the received packet. |
[in] | Packet | The data of the received packet. |
[in] | Option | Point to the IP4 packet header options. |
[in] | OptionLen | Length of the IP4 packet header options. |
[in] | IpIf | The interface to enqueue the packet to. |
Definition at line 1363 of file Ip4Input.c.
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.
[in] | Arg | The wrap context |
Definition at line 439 of file Ip4Input.c.
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.
[in] | IpSb | The IP4 service instance. |
[in,out] | Head | The caller supplied IP4 header. |
[in,out] | Netbuf | The IP4 packet to be processed by IPsec. |
[in,out] | Options | The caller supplied options. |
[in,out] | OptionsLen | The length of the option. |
[in] | Direction | The directionality in an SPD entry, EfiIPsecInBound or EfiIPsecOutBound. |
[in] | Context | The token's wrap. |
EFI_SUCCESS | The IPsec protocol is not available or disabled. |
EFI_SUCCESS | The packet was bypassed and all buffers remain the same. |
EFI_SUCCESS | The packet was protected. |
EFI_ACCESS_DENIED | The packet was discarded. |
EFI_OUT_OF_RESOURCES | There is no sufficient resource to complete the operation. |
EFI_BUFFER_TOO_SMALL | The 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.
This function checks the IPv4 packet length.
[in] | Packet | Pointer to the IPv4 Packet to be checked. |
TRUE | The input IPv4 packet length is valid. |
FALSE | The input IPv4 packet length is invalid. |
Definition at line 810 of file Ip4Input.c.
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.
[in] | Arg | The assemble entry to free |
Definition at line 181 of file Ip4Input.c.
The signal handle of IP4's recycle event. It is called back when the upper layer release the packet.
Event | The IP4's recycle event. |
Context | The context of the handle, which is a IP4_RXDATA_WRAP |
Definition at line 1138 of file Ip4Input.c.
VOID Ip4PacketTimerTicking | ( | IN IP4_SERVICE * | IpSb | ) |
Timeout the fragment and enqueued packets.
[in] | IpSb | The IP4 service instance to timeout |
Definition at line 1557 of file Ip4Input.c.
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.
[in] | IpSb | Pointer to IP4_SERVICE. |
[in,out] | Packet | Pointer to the Packet to be processed. |
[in] | Head | Pointer to the IP4_HEAD. |
[in] | Option | Pointer to a buffer which contains the IPv4 option. |
[in] | OptionLen | The length of Option in bytes. |
[in] | Flag | The link layer flag for the packet received, such as multicast. |
EFI_SUCCESS | The received packet is in well form. |
EFI_INVALID_PARAMETER | The received packet is malformed. |
Definition at line 689 of file Ip4Input.c.
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.
Table | The assemble table used. New assemble entry will be created if the Packet is from a new chain of fragments. |
Packet | The fragment to assemble. It might be freed if the fragment can't be re-assembled. |
Definition at line 204 of file Ip4Input.c.
Trim the packet to fit in [Start, End), and update the per packet information.
Packet | Packet to trim |
Start | The sequence of the first byte to fit in |
End | One beyond the sequence of last byte to fit in. |
Definition at line 140 of file Ip4Input.c.
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.
[in] | IpInstance | The IP4 child to receive the packet. |
[in] | Packet | The packet to deliver up. |
Wrap | if warp the packet succeed. |
NULL | failed to wrap the packet . |
Definition at line 1174 of file Ip4Input.c.