Path: blob/main/sys/contrib/edk2/Include/Protocol/Ip4.h
96339 views
/** @file1This file defines the EFI IPv4 (Internet Protocol version 4)2Protocol interface. It is split into the following three main3sections:4- EFI IPv4 Service Binding Protocol5- EFI IPv4 Variable (deprecated in UEFI 2.4B)6- EFI IPv4 Protocol.7The EFI IPv4 Protocol provides basic network IPv4 packet I/O services,8which includes support foR a subset of the Internet Control Message9Protocol (ICMP) and may include support for the Internet Group Management10Protocol (IGMP).1112Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>13SPDX-License-Identifier: BSD-2-Clause-Patent1415@par Revision Reference:16This Protocol is introduced in UEFI Specification 2.0.1718**/1920#ifndef __EFI_IP4_PROTOCOL_H__21#define __EFI_IP4_PROTOCOL_H__2223#include <Protocol/ManagedNetwork.h>2425#define EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID \26{ \270xc51711e7, 0xb4bf, 0x404a, {0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } \28}2930#define EFI_IP4_PROTOCOL_GUID \31{ \320x41d94cd2, 0x35b6, 0x455a, {0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } \33}3435typedef struct _EFI_IP4_PROTOCOL EFI_IP4_PROTOCOL;3637///38/// EFI_IP4_ADDRESS_PAIR is deprecated in the UEFI 2.4B and should not be used any more.39/// The definition in here is only present to provide backwards compatability.40///41typedef struct {42EFI_HANDLE InstanceHandle;43EFI_IPv4_ADDRESS Ip4Address;44EFI_IPv4_ADDRESS SubnetMask;45} EFI_IP4_ADDRESS_PAIR;4647///48/// EFI_IP4_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.49/// The definition in here is only present to provide backwards compatability.50///51typedef struct {52EFI_HANDLE DriverHandle;53UINT32 AddressCount;54EFI_IP4_ADDRESS_PAIR AddressPairs[1];55} EFI_IP4_VARIABLE_DATA;5657typedef struct {58///59/// The default IPv4 protocol packets to send and receive. Ignored60/// when AcceptPromiscuous is TRUE.61///62UINT8 DefaultProtocol;63///64/// Set to TRUE to receive all IPv4 packets that get through the receive filters.65/// Set to FALSE to receive only the DefaultProtocol IPv466/// packets that get through the receive filters.67///68BOOLEAN AcceptAnyProtocol;69///70/// Set to TRUE to receive ICMP error report packets. Ignored when71/// AcceptPromiscuous or AcceptAnyProtocol is TRUE.72///73BOOLEAN AcceptIcmpErrors;74///75/// Set to TRUE to receive broadcast IPv4 packets. Ignored when76/// AcceptPromiscuous is TRUE.77/// Set to FALSE to stop receiving broadcast IPv4 packets.78///79BOOLEAN AcceptBroadcast;80///81/// Set to TRUE to receive all IPv4 packets that are sent to any82/// hardware address or any protocol address.83/// Set to FALSE to stop receiving all promiscuous IPv4 packets84///85BOOLEAN AcceptPromiscuous;86///87/// Set to TRUE to use the default IPv4 address and default routing table.88///89BOOLEAN UseDefaultAddress;90///91/// The station IPv4 address that will be assigned to this EFI IPv4Protocol instance.92///93EFI_IPv4_ADDRESS StationAddress;94///95/// The subnet address mask that is associated with the station address.96///97EFI_IPv4_ADDRESS SubnetMask;98///99/// TypeOfService field in transmitted IPv4 packets.100///101UINT8 TypeOfService;102///103/// TimeToLive field in transmitted IPv4 packets.104///105UINT8 TimeToLive;106///107/// State of the DoNotFragment bit in transmitted IPv4 packets.108///109BOOLEAN DoNotFragment;110///111/// Set to TRUE to send and receive unformatted packets. The other112/// IPv4 receive filters are still applied. Fragmentation is disabled for RawData mode.113///114BOOLEAN RawData;115///116/// The timer timeout value (number of microseconds) for the117/// receive timeout event to be associated with each assembled118/// packet. Zero means do not drop assembled packets.119///120UINT32 ReceiveTimeout;121///122/// The timer timeout value (number of microseconds) for the123/// transmit timeout event to be associated with each outgoing124/// packet. Zero means do not drop outgoing packets.125///126UINT32 TransmitTimeout;127} EFI_IP4_CONFIG_DATA;128129typedef struct {130EFI_IPv4_ADDRESS SubnetAddress;131EFI_IPv4_ADDRESS SubnetMask;132EFI_IPv4_ADDRESS GatewayAddress;133} EFI_IP4_ROUTE_TABLE;134135typedef struct {136UINT8 Type;137UINT8 Code;138} EFI_IP4_ICMP_TYPE;139140typedef struct {141///142/// Set to TRUE after this EFI IPv4 Protocol instance has been successfully configured.143///144BOOLEAN IsStarted;145///146/// The maximum packet size, in bytes, of the packet which the upper layer driver could feed.147///148UINT32 MaxPacketSize;149///150/// Current configuration settings.151///152EFI_IP4_CONFIG_DATA ConfigData;153///154/// Set to TRUE when the EFI IPv4 Protocol instance has a station address and subnet mask.155///156BOOLEAN IsConfigured;157///158/// Number of joined multicast groups.159///160UINT32 GroupCount;161///162/// List of joined multicast group addresses.163///164EFI_IPv4_ADDRESS *GroupTable;165///166/// Number of entries in the routing table.167///168UINT32 RouteCount;169///170/// Routing table entries.171///172EFI_IP4_ROUTE_TABLE *RouteTable;173///174/// Number of entries in the supported ICMP types list.175///176UINT32 IcmpTypeCount;177///178/// Array of ICMP types and codes that are supported by this EFI IPv4 Protocol driver179///180EFI_IP4_ICMP_TYPE *IcmpTypeList;181} EFI_IP4_MODE_DATA;182183#pragma pack(1)184185typedef struct {186UINT8 HeaderLength : 4;187UINT8 Version : 4;188UINT8 TypeOfService;189UINT16 TotalLength;190UINT16 Identification;191UINT16 Fragmentation;192UINT8 TimeToLive;193UINT8 Protocol;194UINT16 Checksum;195EFI_IPv4_ADDRESS SourceAddress;196EFI_IPv4_ADDRESS DestinationAddress;197} EFI_IP4_HEADER;198#pragma pack()199200typedef struct {201UINT32 FragmentLength;202VOID *FragmentBuffer;203} EFI_IP4_FRAGMENT_DATA;204205typedef struct {206EFI_TIME TimeStamp;207EFI_EVENT RecycleSignal;208UINT32 HeaderLength;209EFI_IP4_HEADER *Header;210UINT32 OptionsLength;211VOID *Options;212UINT32 DataLength;213UINT32 FragmentCount;214EFI_IP4_FRAGMENT_DATA FragmentTable[1];215} EFI_IP4_RECEIVE_DATA;216217typedef struct {218EFI_IPv4_ADDRESS SourceAddress;219EFI_IPv4_ADDRESS GatewayAddress;220UINT8 Protocol;221UINT8 TypeOfService;222UINT8 TimeToLive;223BOOLEAN DoNotFragment;224} EFI_IP4_OVERRIDE_DATA;225226typedef struct {227EFI_IPv4_ADDRESS DestinationAddress;228EFI_IP4_OVERRIDE_DATA *OverrideData; // OPTIONAL229UINT32 OptionsLength; // OPTIONAL230VOID *OptionsBuffer; // OPTIONAL231UINT32 TotalDataLength;232UINT32 FragmentCount;233EFI_IP4_FRAGMENT_DATA FragmentTable[1];234} EFI_IP4_TRANSMIT_DATA;235236typedef struct {237///238/// This Event will be signaled after the Status field is updated239/// by the EFI IPv4 Protocol driver. The type of Event must be240/// EFI_NOTIFY_SIGNAL. The Task Priority Level (TPL) of241/// Event must be lower than or equal to TPL_CALLBACK.242///243EFI_EVENT Event;244///245/// The status that is returned to the caller at the end of the operation246/// to indicate whether this operation completed successfully.247///248EFI_STATUS Status;249union {250///251/// When this token is used for receiving, RxData is a pointer to the EFI_IP4_RECEIVE_DATA.252///253EFI_IP4_RECEIVE_DATA *RxData;254///255/// When this token is used for transmitting, TxData is a pointer to the EFI_IP4_TRANSMIT_DATA.256///257EFI_IP4_TRANSMIT_DATA *TxData;258} Packet;259} EFI_IP4_COMPLETION_TOKEN;260261/**262Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.263264The GetModeData() function returns the current operational mode data for this265driver instance. The data fields in EFI_IP4_MODE_DATA are read only. This266function is used optionally to retrieve the operational mode data of underlying267networks or drivers.268269@param This The pointer to the EFI_IP4_PROTOCOL instance.270@param Ip4ModeData The pointer to the EFI IPv4 Protocol mode data structure.271@param MnpConfigData The pointer to the managed network configuration data structure.272@param SnpModeData The pointer to the simple network mode data structure.273274@retval EFI_SUCCESS The operation completed successfully.275@retval EFI_INVALID_PARAMETER This is NULL.276@retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.277278**/279typedef280EFI_STATUS281(EFIAPI *EFI_IP4_GET_MODE_DATA)(282IN CONST EFI_IP4_PROTOCOL *This,283OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,284OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,285OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL286);287288/**289Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.290291The Configure() function is used to set, change, or reset the operational292parameters and filter settings for this EFI IPv4 Protocol instance. Until these293parameters have been set, no network traffic can be sent or received by this294instance. Once the parameters have been reset (by calling this function with295IpConfigData set to NULL), no more traffic can be sent or received until these296parameters have been set again. Each EFI IPv4 Protocol instance can be started297and stopped independently of each other by enabling or disabling their receive298filter settings with the Configure() function.299300When IpConfigData.UseDefaultAddress is set to FALSE, the new station address will301be appended as an alias address into the addresses list in the EFI IPv4 Protocol302driver. While set to TRUE, Configure() will trigger the EFI_IP4_CONFIG_PROTOCOL303to retrieve the default IPv4 address if it is not available yet. Clients could304frequently call GetModeData() to check the status to ensure that the default IPv4305address is ready.306307If operational parameters are reset or changed, any pending transmit and receive308requests will be cancelled. Their completion token status will be set to EFI_ABORTED309and their events will be signaled.310311@param This The pointer to the EFI_IP4_PROTOCOL instance.312@param IpConfigData The pointer to the EFI IPv4 Protocol configuration data structure.313314@retval EFI_SUCCESS The driver instance was successfully opened.315@retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,316RARP, etc.) is not finished yet.317@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:318This is NULL.319IpConfigData.StationAddress is not a unicast IPv4 address.320IpConfigData.SubnetMask is not a valid IPv4 subnet321@retval EFI_UNSUPPORTED One or more of the following conditions is TRUE:322A configuration protocol (DHCP, BOOTP, RARP, etc.) could323not be located when clients choose to use the default IPv4324address. This EFI IPv4 Protocol implementation does not325support this requested filter or timeout setting.326@retval EFI_OUT_OF_RESOURCES The EFI IPv4 Protocol driver instance data could not be allocated.327@retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the328IPv4 address or subnet mask can be changed. The interface must329also be stopped when switching to/from raw packet mode.330@retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv4331Protocol driver instance is not opened.332333**/334typedef335EFI_STATUS336(EFIAPI *EFI_IP4_CONFIGURE)(337IN EFI_IP4_PROTOCOL *This,338IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL339);340341/**342Joins and leaves multicast groups.343344The Groups() function is used to join and leave multicast group sessions. Joining345a group will enable reception of matching multicast packets. Leaving a group will346disable the multicast packet reception.347348If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.349350@param This The pointer to the EFI_IP4_PROTOCOL instance.351@param JoinFlag Set to TRUE to join the multicast group session and FALSE to leave.352@param GroupAddress The pointer to the IPv4 multicast address.353354@retval EFI_SUCCESS The operation completed successfully.355@retval EFI_INVALID_PARAMETER One or more of the following is TRUE:356- This is NULL.357- JoinFlag is TRUE and GroupAddress is NULL.358- GroupAddress is not NULL and *GroupAddress is359not a multicast IPv4 address.360@retval EFI_NOT_STARTED This instance has not been started.361@retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,362RARP, etc.) is not finished yet.363@retval EFI_OUT_OF_RESOURCES System resources could not be allocated.364@retval EFI_UNSUPPORTED This EFI IPv4 Protocol implementation does not support multicast groups.365@retval EFI_ALREADY_STARTED The group address is already in the group table (when366JoinFlag is TRUE).367@retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE).368@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.369370**/371typedef372EFI_STATUS373(EFIAPI *EFI_IP4_GROUPS)(374IN EFI_IP4_PROTOCOL *This,375IN BOOLEAN JoinFlag,376IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL377);378379/**380Adds and deletes routing table entries.381382The Routes() function adds a route to or deletes a route from the routing table.383384Routes are determined by comparing the SubnetAddress with the destination IPv4385address arithmetically AND-ed with the SubnetMask. The gateway address must be386on the same subnet as the configured station address.387388The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.389The default route matches all destination IPv4 addresses that do not match any390other routes.391392A GatewayAddress that is zero is a nonroute. Packets are sent to the destination393IP address if it can be found in the ARP cache or on the local subnet. One automatic394nonroute entry will be inserted into the routing table for outgoing packets that395are addressed to a local subnet (gateway address of 0.0.0.0).396397Each EFI IPv4 Protocol instance has its own independent routing table. Those EFI398IPv4 Protocol instances that use the default IPv4 address will also have copies399of the routing table that was provided by the EFI_IP4_CONFIG_PROTOCOL, and these400copies will be updated whenever the EIF IPv4 Protocol driver reconfigures its401instances. As a result, client modification to the routing table will be lost.402403@param This The pointer to the EFI_IP4_PROTOCOL instance.404@param DeleteRoute Set to TRUE to delete this route from the routing table. Set to405FALSE to add this route to the routing table. SubnetAddress406and SubnetMask are used as the key to each route entry.407@param SubnetAddress The address of the subnet that needs to be routed.408@param SubnetMask The subnet mask of SubnetAddress.409@param GatewayAddress The unicast gateway IPv4 address for this route.410411@retval EFI_SUCCESS The operation completed successfully.412@retval EFI_NOT_STARTED The driver instance has not been started.413@retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,414RARP, etc.) is not finished yet.415@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:416- This is NULL.417- SubnetAddress is NULL.418- SubnetMask is NULL.419- GatewayAddress is NULL.420- *SubnetAddress is not a valid subnet address.421- *SubnetMask is not a valid subnet mask.422- *GatewayAddress is not a valid unicast IPv4 address.423@retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.424@retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).425@retval EFI_ACCESS_DENIED The route is already defined in the routing table (when426DeleteRoute is FALSE).427428**/429typedef430EFI_STATUS431(EFIAPI *EFI_IP4_ROUTES)(432IN EFI_IP4_PROTOCOL *This,433IN BOOLEAN DeleteRoute,434IN EFI_IPv4_ADDRESS *SubnetAddress,435IN EFI_IPv4_ADDRESS *SubnetMask,436IN EFI_IPv4_ADDRESS *GatewayAddress437);438439/**440Places outgoing data packets into the transmit queue.441442The Transmit() function places a sending request in the transmit queue of this443EFI IPv4 Protocol instance. Whenever the packet in the token is sent out or some444errors occur, the event in the token will be signaled and the status is updated.445446@param This The pointer to the EFI_IP4_PROTOCOL instance.447@param Token The pointer to the transmit token.448449@retval EFI_SUCCESS The data has been queued for transmission.450@retval EFI_NOT_STARTED This instance has not been started.451@retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,452RARP, etc.) is not finished yet.453@retval EFI_INVALID_PARAMETER One or more pameters are invalid.454@retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event455was already in the transmit queue.456@retval EFI_NOT_READY The completion token could not be queued because the transmit457queue is full.458@retval EFI_NOT_FOUND Not route is found to destination address.459@retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.460@retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too461short to transmit.462@retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + total data length is463greater than MTU (or greater than the maximum packet size if464Token.Packet.TxData.OverrideData.465DoNotFragment is TRUE.)466467**/468typedef469EFI_STATUS470(EFIAPI *EFI_IP4_TRANSMIT)(471IN EFI_IP4_PROTOCOL *This,472IN EFI_IP4_COMPLETION_TOKEN *Token473);474475/**476Places a receiving request into the receiving queue.477478The Receive() function places a completion token into the receive packet queue.479This function is always asynchronous.480481The Token.Event field in the completion token must be filled in by the caller482and cannot be NULL. When the receive operation completes, the EFI IPv4 Protocol483driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event484is signaled.485486@param This The pointer to the EFI_IP4_PROTOCOL instance.487@param Token The pointer to a token that is associated with the receive data descriptor.488489@retval EFI_SUCCESS The receive completion token was cached.490@retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.491@retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, RARP, etc.)492is not finished yet.493@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:494- This is NULL.495- Token is NULL.496- Token.Event is NULL.497@retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system498resources (usually memory).499@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.500The EFI IPv4 Protocol instance has been reset to startup defaults.501@retval EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already502in the receive queue.503@retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.504@retval EFI_ICMP_ERROR An ICMP error packet was received.505506**/507typedef508EFI_STATUS509(EFIAPI *EFI_IP4_RECEIVE)(510IN EFI_IP4_PROTOCOL *This,511IN EFI_IP4_COMPLETION_TOKEN *Token512);513514/**515Abort an asynchronous transmit or receive request.516517The Cancel() function is used to abort a pending transmit or receive request.518If the token is in the transmit or receive request queues, after calling this519function, Token->Status will be set to EFI_ABORTED and then Token->Event will520be signaled. If the token is not in one of the queues, which usually means the521asynchronous operation has completed, this function will not signal the token522and EFI_NOT_FOUND is returned.523524@param This The pointer to the EFI_IP4_PROTOCOL instance.525@param Token The pointer to a token that has been issued by526EFI_IP4_PROTOCOL.Transmit() or527EFI_IP4_PROTOCOL.Receive(). If NULL, all pending528tokens are aborted. Type EFI_IP4_COMPLETION_TOKEN is529defined in EFI_IP4_PROTOCOL.Transmit().530531@retval EFI_SUCCESS The asynchronous I/O request was aborted and532Token->Event was signaled. When Token is NULL, all533pending requests were aborted and their events were signaled.534@retval EFI_INVALID_PARAMETER This is NULL.535@retval EFI_NOT_STARTED This instance has not been started.536@retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,537RARP, etc.) is not finished yet.538@retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was539not found in the transmit or receive queue. It has either completed540or was not issued by Transmit() and Receive().541542**/543typedef544EFI_STATUS545(EFIAPI *EFI_IP4_CANCEL)(546IN EFI_IP4_PROTOCOL *This,547IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL548);549550/**551Polls for incoming data packets and processes outgoing data packets.552553The Poll() function polls for incoming data packets and processes outgoing data554packets. Network drivers and applications can call the EFI_IP4_PROTOCOL.Poll()555function to increase the rate that data packets are moved between the communications556device and the transmit and receive queues.557558In some systems the periodic timer event may not poll the underlying communications559device fast enough to transmit and/or receive all data packets without missing560incoming packets or dropping outgoing packets. Drivers and applications that are561experiencing packet loss should try calling the EFI_IP4_PROTOCOL.Poll() function562more often.563564@param This The pointer to the EFI_IP4_PROTOCOL instance.565566@retval EFI_SUCCESS Incoming or outgoing data was processed.567@retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.568@retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,569RARP, etc.) is not finished yet.570@retval EFI_INVALID_PARAMETER This is NULL.571@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.572@retval EFI_NOT_READY No incoming or outgoing data is processed.573@retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.574Consider increasing the polling rate.575576**/577typedef578EFI_STATUS579(EFIAPI *EFI_IP4_POLL)(580IN EFI_IP4_PROTOCOL *This581);582583///584/// The EFI IPv4 Protocol implements a simple packet-oriented interface that can be585/// used by drivers, daemons, and applications to transmit and receive network packets.586///587struct _EFI_IP4_PROTOCOL {588EFI_IP4_GET_MODE_DATA GetModeData;589EFI_IP4_CONFIGURE Configure;590EFI_IP4_GROUPS Groups;591EFI_IP4_ROUTES Routes;592EFI_IP4_TRANSMIT Transmit;593EFI_IP4_RECEIVE Receive;594EFI_IP4_CANCEL Cancel;595EFI_IP4_POLL Poll;596};597598extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid;599extern EFI_GUID gEfiIp4ProtocolGuid;600601#endif602603604