1*f439973dSWarner Losh /** @file 2*f439973dSWarner Losh This file defines the EFI IPv4 (Internet Protocol version 4) 3*f439973dSWarner Losh Protocol interface. It is split into the following three main 4*f439973dSWarner Losh sections: 5*f439973dSWarner Losh - EFI IPv4 Service Binding Protocol 6*f439973dSWarner Losh - EFI IPv4 Variable (deprecated in UEFI 2.4B) 7*f439973dSWarner Losh - EFI IPv4 Protocol. 8*f439973dSWarner Losh The EFI IPv4 Protocol provides basic network IPv4 packet I/O services, 9*f439973dSWarner Losh which includes support foR a subset of the Internet Control Message 10*f439973dSWarner Losh Protocol (ICMP) and may include support for the Internet Group Management 11*f439973dSWarner Losh Protocol (IGMP). 12*f439973dSWarner Losh 13*f439973dSWarner Losh Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 14*f439973dSWarner Losh SPDX-License-Identifier: BSD-2-Clause-Patent 15*f439973dSWarner Losh 16*f439973dSWarner Losh @par Revision Reference: 17*f439973dSWarner Losh This Protocol is introduced in UEFI Specification 2.0. 18*f439973dSWarner Losh 19*f439973dSWarner Losh **/ 20*f439973dSWarner Losh 21*f439973dSWarner Losh #ifndef __EFI_IP4_PROTOCOL_H__ 22*f439973dSWarner Losh #define __EFI_IP4_PROTOCOL_H__ 23*f439973dSWarner Losh 24*f439973dSWarner Losh #include <Protocol/ManagedNetwork.h> 25*f439973dSWarner Losh 26*f439973dSWarner Losh #define EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID \ 27*f439973dSWarner Losh { \ 28*f439973dSWarner Losh 0xc51711e7, 0xb4bf, 0x404a, {0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } \ 29*f439973dSWarner Losh } 30*f439973dSWarner Losh 31*f439973dSWarner Losh #define EFI_IP4_PROTOCOL_GUID \ 32*f439973dSWarner Losh { \ 33*f439973dSWarner Losh 0x41d94cd2, 0x35b6, 0x455a, {0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } \ 34*f439973dSWarner Losh } 35*f439973dSWarner Losh 36*f439973dSWarner Losh typedef struct _EFI_IP4_PROTOCOL EFI_IP4_PROTOCOL; 37*f439973dSWarner Losh 38*f439973dSWarner Losh /// 39*f439973dSWarner Losh /// EFI_IP4_ADDRESS_PAIR is deprecated in the UEFI 2.4B and should not be used any more. 40*f439973dSWarner Losh /// The definition in here is only present to provide backwards compatability. 41*f439973dSWarner Losh /// 42*f439973dSWarner Losh typedef struct { 43*f439973dSWarner Losh EFI_HANDLE InstanceHandle; 44*f439973dSWarner Losh EFI_IPv4_ADDRESS Ip4Address; 45*f439973dSWarner Losh EFI_IPv4_ADDRESS SubnetMask; 46*f439973dSWarner Losh } EFI_IP4_ADDRESS_PAIR; 47*f439973dSWarner Losh 48*f439973dSWarner Losh /// 49*f439973dSWarner Losh /// EFI_IP4_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more. 50*f439973dSWarner Losh /// The definition in here is only present to provide backwards compatability. 51*f439973dSWarner Losh /// 52*f439973dSWarner Losh typedef struct { 53*f439973dSWarner Losh EFI_HANDLE DriverHandle; 54*f439973dSWarner Losh UINT32 AddressCount; 55*f439973dSWarner Losh EFI_IP4_ADDRESS_PAIR AddressPairs[1]; 56*f439973dSWarner Losh } EFI_IP4_VARIABLE_DATA; 57*f439973dSWarner Losh 58*f439973dSWarner Losh typedef struct { 59*f439973dSWarner Losh /// 60*f439973dSWarner Losh /// The default IPv4 protocol packets to send and receive. Ignored 61*f439973dSWarner Losh /// when AcceptPromiscuous is TRUE. 62*f439973dSWarner Losh /// 63*f439973dSWarner Losh UINT8 DefaultProtocol; 64*f439973dSWarner Losh /// 65*f439973dSWarner Losh /// Set to TRUE to receive all IPv4 packets that get through the receive filters. 66*f439973dSWarner Losh /// Set to FALSE to receive only the DefaultProtocol IPv4 67*f439973dSWarner Losh /// packets that get through the receive filters. 68*f439973dSWarner Losh /// 69*f439973dSWarner Losh BOOLEAN AcceptAnyProtocol; 70*f439973dSWarner Losh /// 71*f439973dSWarner Losh /// Set to TRUE to receive ICMP error report packets. Ignored when 72*f439973dSWarner Losh /// AcceptPromiscuous or AcceptAnyProtocol is TRUE. 73*f439973dSWarner Losh /// 74*f439973dSWarner Losh BOOLEAN AcceptIcmpErrors; 75*f439973dSWarner Losh /// 76*f439973dSWarner Losh /// Set to TRUE to receive broadcast IPv4 packets. Ignored when 77*f439973dSWarner Losh /// AcceptPromiscuous is TRUE. 78*f439973dSWarner Losh /// Set to FALSE to stop receiving broadcast IPv4 packets. 79*f439973dSWarner Losh /// 80*f439973dSWarner Losh BOOLEAN AcceptBroadcast; 81*f439973dSWarner Losh /// 82*f439973dSWarner Losh /// Set to TRUE to receive all IPv4 packets that are sent to any 83*f439973dSWarner Losh /// hardware address or any protocol address. 84*f439973dSWarner Losh /// Set to FALSE to stop receiving all promiscuous IPv4 packets 85*f439973dSWarner Losh /// 86*f439973dSWarner Losh BOOLEAN AcceptPromiscuous; 87*f439973dSWarner Losh /// 88*f439973dSWarner Losh /// Set to TRUE to use the default IPv4 address and default routing table. 89*f439973dSWarner Losh /// 90*f439973dSWarner Losh BOOLEAN UseDefaultAddress; 91*f439973dSWarner Losh /// 92*f439973dSWarner Losh /// The station IPv4 address that will be assigned to this EFI IPv4Protocol instance. 93*f439973dSWarner Losh /// 94*f439973dSWarner Losh EFI_IPv4_ADDRESS StationAddress; 95*f439973dSWarner Losh /// 96*f439973dSWarner Losh /// The subnet address mask that is associated with the station address. 97*f439973dSWarner Losh /// 98*f439973dSWarner Losh EFI_IPv4_ADDRESS SubnetMask; 99*f439973dSWarner Losh /// 100*f439973dSWarner Losh /// TypeOfService field in transmitted IPv4 packets. 101*f439973dSWarner Losh /// 102*f439973dSWarner Losh UINT8 TypeOfService; 103*f439973dSWarner Losh /// 104*f439973dSWarner Losh /// TimeToLive field in transmitted IPv4 packets. 105*f439973dSWarner Losh /// 106*f439973dSWarner Losh UINT8 TimeToLive; 107*f439973dSWarner Losh /// 108*f439973dSWarner Losh /// State of the DoNotFragment bit in transmitted IPv4 packets. 109*f439973dSWarner Losh /// 110*f439973dSWarner Losh BOOLEAN DoNotFragment; 111*f439973dSWarner Losh /// 112*f439973dSWarner Losh /// Set to TRUE to send and receive unformatted packets. The other 113*f439973dSWarner Losh /// IPv4 receive filters are still applied. Fragmentation is disabled for RawData mode. 114*f439973dSWarner Losh /// 115*f439973dSWarner Losh BOOLEAN RawData; 116*f439973dSWarner Losh /// 117*f439973dSWarner Losh /// The timer timeout value (number of microseconds) for the 118*f439973dSWarner Losh /// receive timeout event to be associated with each assembled 119*f439973dSWarner Losh /// packet. Zero means do not drop assembled packets. 120*f439973dSWarner Losh /// 121*f439973dSWarner Losh UINT32 ReceiveTimeout; 122*f439973dSWarner Losh /// 123*f439973dSWarner Losh /// The timer timeout value (number of microseconds) for the 124*f439973dSWarner Losh /// transmit timeout event to be associated with each outgoing 125*f439973dSWarner Losh /// packet. Zero means do not drop outgoing packets. 126*f439973dSWarner Losh /// 127*f439973dSWarner Losh UINT32 TransmitTimeout; 128*f439973dSWarner Losh } EFI_IP4_CONFIG_DATA; 129*f439973dSWarner Losh 130*f439973dSWarner Losh typedef struct { 131*f439973dSWarner Losh EFI_IPv4_ADDRESS SubnetAddress; 132*f439973dSWarner Losh EFI_IPv4_ADDRESS SubnetMask; 133*f439973dSWarner Losh EFI_IPv4_ADDRESS GatewayAddress; 134*f439973dSWarner Losh } EFI_IP4_ROUTE_TABLE; 135*f439973dSWarner Losh 136*f439973dSWarner Losh typedef struct { 137*f439973dSWarner Losh UINT8 Type; 138*f439973dSWarner Losh UINT8 Code; 139*f439973dSWarner Losh } EFI_IP4_ICMP_TYPE; 140*f439973dSWarner Losh 141*f439973dSWarner Losh typedef struct { 142*f439973dSWarner Losh /// 143*f439973dSWarner Losh /// Set to TRUE after this EFI IPv4 Protocol instance has been successfully configured. 144*f439973dSWarner Losh /// 145*f439973dSWarner Losh BOOLEAN IsStarted; 146*f439973dSWarner Losh /// 147*f439973dSWarner Losh /// The maximum packet size, in bytes, of the packet which the upper layer driver could feed. 148*f439973dSWarner Losh /// 149*f439973dSWarner Losh UINT32 MaxPacketSize; 150*f439973dSWarner Losh /// 151*f439973dSWarner Losh /// Current configuration settings. 152*f439973dSWarner Losh /// 153*f439973dSWarner Losh EFI_IP4_CONFIG_DATA ConfigData; 154*f439973dSWarner Losh /// 155*f439973dSWarner Losh /// Set to TRUE when the EFI IPv4 Protocol instance has a station address and subnet mask. 156*f439973dSWarner Losh /// 157*f439973dSWarner Losh BOOLEAN IsConfigured; 158*f439973dSWarner Losh /// 159*f439973dSWarner Losh /// Number of joined multicast groups. 160*f439973dSWarner Losh /// 161*f439973dSWarner Losh UINT32 GroupCount; 162*f439973dSWarner Losh /// 163*f439973dSWarner Losh /// List of joined multicast group addresses. 164*f439973dSWarner Losh /// 165*f439973dSWarner Losh EFI_IPv4_ADDRESS *GroupTable; 166*f439973dSWarner Losh /// 167*f439973dSWarner Losh /// Number of entries in the routing table. 168*f439973dSWarner Losh /// 169*f439973dSWarner Losh UINT32 RouteCount; 170*f439973dSWarner Losh /// 171*f439973dSWarner Losh /// Routing table entries. 172*f439973dSWarner Losh /// 173*f439973dSWarner Losh EFI_IP4_ROUTE_TABLE *RouteTable; 174*f439973dSWarner Losh /// 175*f439973dSWarner Losh /// Number of entries in the supported ICMP types list. 176*f439973dSWarner Losh /// 177*f439973dSWarner Losh UINT32 IcmpTypeCount; 178*f439973dSWarner Losh /// 179*f439973dSWarner Losh /// Array of ICMP types and codes that are supported by this EFI IPv4 Protocol driver 180*f439973dSWarner Losh /// 181*f439973dSWarner Losh EFI_IP4_ICMP_TYPE *IcmpTypeList; 182*f439973dSWarner Losh } EFI_IP4_MODE_DATA; 183*f439973dSWarner Losh 184*f439973dSWarner Losh #pragma pack(1) 185*f439973dSWarner Losh 186*f439973dSWarner Losh typedef struct { 187*f439973dSWarner Losh UINT8 HeaderLength : 4; 188*f439973dSWarner Losh UINT8 Version : 4; 189*f439973dSWarner Losh UINT8 TypeOfService; 190*f439973dSWarner Losh UINT16 TotalLength; 191*f439973dSWarner Losh UINT16 Identification; 192*f439973dSWarner Losh UINT16 Fragmentation; 193*f439973dSWarner Losh UINT8 TimeToLive; 194*f439973dSWarner Losh UINT8 Protocol; 195*f439973dSWarner Losh UINT16 Checksum; 196*f439973dSWarner Losh EFI_IPv4_ADDRESS SourceAddress; 197*f439973dSWarner Losh EFI_IPv4_ADDRESS DestinationAddress; 198*f439973dSWarner Losh } EFI_IP4_HEADER; 199*f439973dSWarner Losh #pragma pack() 200*f439973dSWarner Losh 201*f439973dSWarner Losh typedef struct { 202*f439973dSWarner Losh UINT32 FragmentLength; 203*f439973dSWarner Losh VOID *FragmentBuffer; 204*f439973dSWarner Losh } EFI_IP4_FRAGMENT_DATA; 205*f439973dSWarner Losh 206*f439973dSWarner Losh typedef struct { 207*f439973dSWarner Losh EFI_TIME TimeStamp; 208*f439973dSWarner Losh EFI_EVENT RecycleSignal; 209*f439973dSWarner Losh UINT32 HeaderLength; 210*f439973dSWarner Losh EFI_IP4_HEADER *Header; 211*f439973dSWarner Losh UINT32 OptionsLength; 212*f439973dSWarner Losh VOID *Options; 213*f439973dSWarner Losh UINT32 DataLength; 214*f439973dSWarner Losh UINT32 FragmentCount; 215*f439973dSWarner Losh EFI_IP4_FRAGMENT_DATA FragmentTable[1]; 216*f439973dSWarner Losh } EFI_IP4_RECEIVE_DATA; 217*f439973dSWarner Losh 218*f439973dSWarner Losh typedef struct { 219*f439973dSWarner Losh EFI_IPv4_ADDRESS SourceAddress; 220*f439973dSWarner Losh EFI_IPv4_ADDRESS GatewayAddress; 221*f439973dSWarner Losh UINT8 Protocol; 222*f439973dSWarner Losh UINT8 TypeOfService; 223*f439973dSWarner Losh UINT8 TimeToLive; 224*f439973dSWarner Losh BOOLEAN DoNotFragment; 225*f439973dSWarner Losh } EFI_IP4_OVERRIDE_DATA; 226*f439973dSWarner Losh 227*f439973dSWarner Losh typedef struct { 228*f439973dSWarner Losh EFI_IPv4_ADDRESS DestinationAddress; 229*f439973dSWarner Losh EFI_IP4_OVERRIDE_DATA *OverrideData; // OPTIONAL 230*f439973dSWarner Losh UINT32 OptionsLength; // OPTIONAL 231*f439973dSWarner Losh VOID *OptionsBuffer; // OPTIONAL 232*f439973dSWarner Losh UINT32 TotalDataLength; 233*f439973dSWarner Losh UINT32 FragmentCount; 234*f439973dSWarner Losh EFI_IP4_FRAGMENT_DATA FragmentTable[1]; 235*f439973dSWarner Losh } EFI_IP4_TRANSMIT_DATA; 236*f439973dSWarner Losh 237*f439973dSWarner Losh typedef struct { 238*f439973dSWarner Losh /// 239*f439973dSWarner Losh /// This Event will be signaled after the Status field is updated 240*f439973dSWarner Losh /// by the EFI IPv4 Protocol driver. The type of Event must be 241*f439973dSWarner Losh /// EFI_NOTIFY_SIGNAL. The Task Priority Level (TPL) of 242*f439973dSWarner Losh /// Event must be lower than or equal to TPL_CALLBACK. 243*f439973dSWarner Losh /// 244*f439973dSWarner Losh EFI_EVENT Event; 245*f439973dSWarner Losh /// 246*f439973dSWarner Losh /// The status that is returned to the caller at the end of the operation 247*f439973dSWarner Losh /// to indicate whether this operation completed successfully. 248*f439973dSWarner Losh /// 249*f439973dSWarner Losh EFI_STATUS Status; 250*f439973dSWarner Losh union { 251*f439973dSWarner Losh /// 252*f439973dSWarner Losh /// When this token is used for receiving, RxData is a pointer to the EFI_IP4_RECEIVE_DATA. 253*f439973dSWarner Losh /// 254*f439973dSWarner Losh EFI_IP4_RECEIVE_DATA *RxData; 255*f439973dSWarner Losh /// 256*f439973dSWarner Losh /// When this token is used for transmitting, TxData is a pointer to the EFI_IP4_TRANSMIT_DATA. 257*f439973dSWarner Losh /// 258*f439973dSWarner Losh EFI_IP4_TRANSMIT_DATA *TxData; 259*f439973dSWarner Losh } Packet; 260*f439973dSWarner Losh } EFI_IP4_COMPLETION_TOKEN; 261*f439973dSWarner Losh 262*f439973dSWarner Losh /** 263*f439973dSWarner Losh Gets the current operational settings for this instance of the EFI IPv4 Protocol driver. 264*f439973dSWarner Losh 265*f439973dSWarner Losh The GetModeData() function returns the current operational mode data for this 266*f439973dSWarner Losh driver instance. The data fields in EFI_IP4_MODE_DATA are read only. This 267*f439973dSWarner Losh function is used optionally to retrieve the operational mode data of underlying 268*f439973dSWarner Losh networks or drivers. 269*f439973dSWarner Losh 270*f439973dSWarner Losh @param This The pointer to the EFI_IP4_PROTOCOL instance. 271*f439973dSWarner Losh @param Ip4ModeData The pointer to the EFI IPv4 Protocol mode data structure. 272*f439973dSWarner Losh @param MnpConfigData The pointer to the managed network configuration data structure. 273*f439973dSWarner Losh @param SnpModeData The pointer to the simple network mode data structure. 274*f439973dSWarner Losh 275*f439973dSWarner Losh @retval EFI_SUCCESS The operation completed successfully. 276*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER This is NULL. 277*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated. 278*f439973dSWarner Losh 279*f439973dSWarner Losh **/ 280*f439973dSWarner Losh typedef 281*f439973dSWarner Losh EFI_STATUS 282*f439973dSWarner Losh (EFIAPI *EFI_IP4_GET_MODE_DATA)( 283*f439973dSWarner Losh IN CONST EFI_IP4_PROTOCOL *This, 284*f439973dSWarner Losh OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, 285*f439973dSWarner Losh OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, 286*f439973dSWarner Losh OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL 287*f439973dSWarner Losh ); 288*f439973dSWarner Losh 289*f439973dSWarner Losh /** 290*f439973dSWarner Losh Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance. 291*f439973dSWarner Losh 292*f439973dSWarner Losh The Configure() function is used to set, change, or reset the operational 293*f439973dSWarner Losh parameters and filter settings for this EFI IPv4 Protocol instance. Until these 294*f439973dSWarner Losh parameters have been set, no network traffic can be sent or received by this 295*f439973dSWarner Losh instance. Once the parameters have been reset (by calling this function with 296*f439973dSWarner Losh IpConfigData set to NULL), no more traffic can be sent or received until these 297*f439973dSWarner Losh parameters have been set again. Each EFI IPv4 Protocol instance can be started 298*f439973dSWarner Losh and stopped independently of each other by enabling or disabling their receive 299*f439973dSWarner Losh filter settings with the Configure() function. 300*f439973dSWarner Losh 301*f439973dSWarner Losh When IpConfigData.UseDefaultAddress is set to FALSE, the new station address will 302*f439973dSWarner Losh be appended as an alias address into the addresses list in the EFI IPv4 Protocol 303*f439973dSWarner Losh driver. While set to TRUE, Configure() will trigger the EFI_IP4_CONFIG_PROTOCOL 304*f439973dSWarner Losh to retrieve the default IPv4 address if it is not available yet. Clients could 305*f439973dSWarner Losh frequently call GetModeData() to check the status to ensure that the default IPv4 306*f439973dSWarner Losh address is ready. 307*f439973dSWarner Losh 308*f439973dSWarner Losh If operational parameters are reset or changed, any pending transmit and receive 309*f439973dSWarner Losh requests will be cancelled. Their completion token status will be set to EFI_ABORTED 310*f439973dSWarner Losh and their events will be signaled. 311*f439973dSWarner Losh 312*f439973dSWarner Losh @param This The pointer to the EFI_IP4_PROTOCOL instance. 313*f439973dSWarner Losh @param IpConfigData The pointer to the EFI IPv4 Protocol configuration data structure. 314*f439973dSWarner Losh 315*f439973dSWarner Losh @retval EFI_SUCCESS The driver instance was successfully opened. 316*f439973dSWarner Losh @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, 317*f439973dSWarner Losh RARP, etc.) is not finished yet. 318*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 319*f439973dSWarner Losh This is NULL. 320*f439973dSWarner Losh IpConfigData.StationAddress is not a unicast IPv4 address. 321*f439973dSWarner Losh IpConfigData.SubnetMask is not a valid IPv4 subnet 322*f439973dSWarner Losh @retval EFI_UNSUPPORTED One or more of the following conditions is TRUE: 323*f439973dSWarner Losh A configuration protocol (DHCP, BOOTP, RARP, etc.) could 324*f439973dSWarner Losh not be located when clients choose to use the default IPv4 325*f439973dSWarner Losh address. This EFI IPv4 Protocol implementation does not 326*f439973dSWarner Losh support this requested filter or timeout setting. 327*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES The EFI IPv4 Protocol driver instance data could not be allocated. 328*f439973dSWarner Losh @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the 329*f439973dSWarner Losh IPv4 address or subnet mask can be changed. The interface must 330*f439973dSWarner Losh also be stopped when switching to/from raw packet mode. 331*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv4 332*f439973dSWarner Losh Protocol driver instance is not opened. 333*f439973dSWarner Losh 334*f439973dSWarner Losh **/ 335*f439973dSWarner Losh typedef 336*f439973dSWarner Losh EFI_STATUS 337*f439973dSWarner Losh (EFIAPI *EFI_IP4_CONFIGURE)( 338*f439973dSWarner Losh IN EFI_IP4_PROTOCOL *This, 339*f439973dSWarner Losh IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL 340*f439973dSWarner Losh ); 341*f439973dSWarner Losh 342*f439973dSWarner Losh /** 343*f439973dSWarner Losh Joins and leaves multicast groups. 344*f439973dSWarner Losh 345*f439973dSWarner Losh The Groups() function is used to join and leave multicast group sessions. Joining 346*f439973dSWarner Losh a group will enable reception of matching multicast packets. Leaving a group will 347*f439973dSWarner Losh disable the multicast packet reception. 348*f439973dSWarner Losh 349*f439973dSWarner Losh If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left. 350*f439973dSWarner Losh 351*f439973dSWarner Losh @param This The pointer to the EFI_IP4_PROTOCOL instance. 352*f439973dSWarner Losh @param JoinFlag Set to TRUE to join the multicast group session and FALSE to leave. 353*f439973dSWarner Losh @param GroupAddress The pointer to the IPv4 multicast address. 354*f439973dSWarner Losh 355*f439973dSWarner Losh @retval EFI_SUCCESS The operation completed successfully. 356*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more of the following is TRUE: 357*f439973dSWarner Losh - This is NULL. 358*f439973dSWarner Losh - JoinFlag is TRUE and GroupAddress is NULL. 359*f439973dSWarner Losh - GroupAddress is not NULL and *GroupAddress is 360*f439973dSWarner Losh not a multicast IPv4 address. 361*f439973dSWarner Losh @retval EFI_NOT_STARTED This instance has not been started. 362*f439973dSWarner Losh @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, 363*f439973dSWarner Losh RARP, etc.) is not finished yet. 364*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES System resources could not be allocated. 365*f439973dSWarner Losh @retval EFI_UNSUPPORTED This EFI IPv4 Protocol implementation does not support multicast groups. 366*f439973dSWarner Losh @retval EFI_ALREADY_STARTED The group address is already in the group table (when 367*f439973dSWarner Losh JoinFlag is TRUE). 368*f439973dSWarner Losh @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE). 369*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 370*f439973dSWarner Losh 371*f439973dSWarner Losh **/ 372*f439973dSWarner Losh typedef 373*f439973dSWarner Losh EFI_STATUS 374*f439973dSWarner Losh (EFIAPI *EFI_IP4_GROUPS)( 375*f439973dSWarner Losh IN EFI_IP4_PROTOCOL *This, 376*f439973dSWarner Losh IN BOOLEAN JoinFlag, 377*f439973dSWarner Losh IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL 378*f439973dSWarner Losh ); 379*f439973dSWarner Losh 380*f439973dSWarner Losh /** 381*f439973dSWarner Losh Adds and deletes routing table entries. 382*f439973dSWarner Losh 383*f439973dSWarner Losh The Routes() function adds a route to or deletes a route from the routing table. 384*f439973dSWarner Losh 385*f439973dSWarner Losh Routes are determined by comparing the SubnetAddress with the destination IPv4 386*f439973dSWarner Losh address arithmetically AND-ed with the SubnetMask. The gateway address must be 387*f439973dSWarner Losh on the same subnet as the configured station address. 388*f439973dSWarner Losh 389*f439973dSWarner Losh The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0. 390*f439973dSWarner Losh The default route matches all destination IPv4 addresses that do not match any 391*f439973dSWarner Losh other routes. 392*f439973dSWarner Losh 393*f439973dSWarner Losh A GatewayAddress that is zero is a nonroute. Packets are sent to the destination 394*f439973dSWarner Losh IP address if it can be found in the ARP cache or on the local subnet. One automatic 395*f439973dSWarner Losh nonroute entry will be inserted into the routing table for outgoing packets that 396*f439973dSWarner Losh are addressed to a local subnet (gateway address of 0.0.0.0). 397*f439973dSWarner Losh 398*f439973dSWarner Losh Each EFI IPv4 Protocol instance has its own independent routing table. Those EFI 399*f439973dSWarner Losh IPv4 Protocol instances that use the default IPv4 address will also have copies 400*f439973dSWarner Losh of the routing table that was provided by the EFI_IP4_CONFIG_PROTOCOL, and these 401*f439973dSWarner Losh copies will be updated whenever the EIF IPv4 Protocol driver reconfigures its 402*f439973dSWarner Losh instances. As a result, client modification to the routing table will be lost. 403*f439973dSWarner Losh 404*f439973dSWarner Losh @param This The pointer to the EFI_IP4_PROTOCOL instance. 405*f439973dSWarner Losh @param DeleteRoute Set to TRUE to delete this route from the routing table. Set to 406*f439973dSWarner Losh FALSE to add this route to the routing table. SubnetAddress 407*f439973dSWarner Losh and SubnetMask are used as the key to each route entry. 408*f439973dSWarner Losh @param SubnetAddress The address of the subnet that needs to be routed. 409*f439973dSWarner Losh @param SubnetMask The subnet mask of SubnetAddress. 410*f439973dSWarner Losh @param GatewayAddress The unicast gateway IPv4 address for this route. 411*f439973dSWarner Losh 412*f439973dSWarner Losh @retval EFI_SUCCESS The operation completed successfully. 413*f439973dSWarner Losh @retval EFI_NOT_STARTED The driver instance has not been started. 414*f439973dSWarner Losh @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, 415*f439973dSWarner Losh RARP, etc.) is not finished yet. 416*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 417*f439973dSWarner Losh - This is NULL. 418*f439973dSWarner Losh - SubnetAddress is NULL. 419*f439973dSWarner Losh - SubnetMask is NULL. 420*f439973dSWarner Losh - GatewayAddress is NULL. 421*f439973dSWarner Losh - *SubnetAddress is not a valid subnet address. 422*f439973dSWarner Losh - *SubnetMask is not a valid subnet mask. 423*f439973dSWarner Losh - *GatewayAddress is not a valid unicast IPv4 address. 424*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table. 425*f439973dSWarner Losh @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE). 426*f439973dSWarner Losh @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when 427*f439973dSWarner Losh DeleteRoute is FALSE). 428*f439973dSWarner Losh 429*f439973dSWarner Losh **/ 430*f439973dSWarner Losh typedef 431*f439973dSWarner Losh EFI_STATUS 432*f439973dSWarner Losh (EFIAPI *EFI_IP4_ROUTES)( 433*f439973dSWarner Losh IN EFI_IP4_PROTOCOL *This, 434*f439973dSWarner Losh IN BOOLEAN DeleteRoute, 435*f439973dSWarner Losh IN EFI_IPv4_ADDRESS *SubnetAddress, 436*f439973dSWarner Losh IN EFI_IPv4_ADDRESS *SubnetMask, 437*f439973dSWarner Losh IN EFI_IPv4_ADDRESS *GatewayAddress 438*f439973dSWarner Losh ); 439*f439973dSWarner Losh 440*f439973dSWarner Losh /** 441*f439973dSWarner Losh Places outgoing data packets into the transmit queue. 442*f439973dSWarner Losh 443*f439973dSWarner Losh The Transmit() function places a sending request in the transmit queue of this 444*f439973dSWarner Losh EFI IPv4 Protocol instance. Whenever the packet in the token is sent out or some 445*f439973dSWarner Losh errors occur, the event in the token will be signaled and the status is updated. 446*f439973dSWarner Losh 447*f439973dSWarner Losh @param This The pointer to the EFI_IP4_PROTOCOL instance. 448*f439973dSWarner Losh @param Token The pointer to the transmit token. 449*f439973dSWarner Losh 450*f439973dSWarner Losh @retval EFI_SUCCESS The data has been queued for transmission. 451*f439973dSWarner Losh @retval EFI_NOT_STARTED This instance has not been started. 452*f439973dSWarner Losh @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, 453*f439973dSWarner Losh RARP, etc.) is not finished yet. 454*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more pameters are invalid. 455*f439973dSWarner Losh @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event 456*f439973dSWarner Losh was already in the transmit queue. 457*f439973dSWarner Losh @retval EFI_NOT_READY The completion token could not be queued because the transmit 458*f439973dSWarner Losh queue is full. 459*f439973dSWarner Losh @retval EFI_NOT_FOUND Not route is found to destination address. 460*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data. 461*f439973dSWarner Losh @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too 462*f439973dSWarner Losh short to transmit. 463*f439973dSWarner Losh @retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + total data length is 464*f439973dSWarner Losh greater than MTU (or greater than the maximum packet size if 465*f439973dSWarner Losh Token.Packet.TxData.OverrideData. 466*f439973dSWarner Losh DoNotFragment is TRUE.) 467*f439973dSWarner Losh 468*f439973dSWarner Losh **/ 469*f439973dSWarner Losh typedef 470*f439973dSWarner Losh EFI_STATUS 471*f439973dSWarner Losh (EFIAPI *EFI_IP4_TRANSMIT)( 472*f439973dSWarner Losh IN EFI_IP4_PROTOCOL *This, 473*f439973dSWarner Losh IN EFI_IP4_COMPLETION_TOKEN *Token 474*f439973dSWarner Losh ); 475*f439973dSWarner Losh 476*f439973dSWarner Losh /** 477*f439973dSWarner Losh Places a receiving request into the receiving queue. 478*f439973dSWarner Losh 479*f439973dSWarner Losh The Receive() function places a completion token into the receive packet queue. 480*f439973dSWarner Losh This function is always asynchronous. 481*f439973dSWarner Losh 482*f439973dSWarner Losh The Token.Event field in the completion token must be filled in by the caller 483*f439973dSWarner Losh and cannot be NULL. When the receive operation completes, the EFI IPv4 Protocol 484*f439973dSWarner Losh driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event 485*f439973dSWarner Losh is signaled. 486*f439973dSWarner Losh 487*f439973dSWarner Losh @param This The pointer to the EFI_IP4_PROTOCOL instance. 488*f439973dSWarner Losh @param Token The pointer to a token that is associated with the receive data descriptor. 489*f439973dSWarner Losh 490*f439973dSWarner Losh @retval EFI_SUCCESS The receive completion token was cached. 491*f439973dSWarner Losh @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started. 492*f439973dSWarner Losh @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, RARP, etc.) 493*f439973dSWarner Losh is not finished yet. 494*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 495*f439973dSWarner Losh - This is NULL. 496*f439973dSWarner Losh - Token is NULL. 497*f439973dSWarner Losh - Token.Event is NULL. 498*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system 499*f439973dSWarner Losh resources (usually memory). 500*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 501*f439973dSWarner Losh The EFI IPv4 Protocol instance has been reset to startup defaults. 502*f439973dSWarner Losh @retval EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already 503*f439973dSWarner Losh in the receive queue. 504*f439973dSWarner Losh @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full. 505*f439973dSWarner Losh @retval EFI_ICMP_ERROR An ICMP error packet was received. 506*f439973dSWarner Losh 507*f439973dSWarner Losh **/ 508*f439973dSWarner Losh typedef 509*f439973dSWarner Losh EFI_STATUS 510*f439973dSWarner Losh (EFIAPI *EFI_IP4_RECEIVE)( 511*f439973dSWarner Losh IN EFI_IP4_PROTOCOL *This, 512*f439973dSWarner Losh IN EFI_IP4_COMPLETION_TOKEN *Token 513*f439973dSWarner Losh ); 514*f439973dSWarner Losh 515*f439973dSWarner Losh /** 516*f439973dSWarner Losh Abort an asynchronous transmit or receive request. 517*f439973dSWarner Losh 518*f439973dSWarner Losh The Cancel() function is used to abort a pending transmit or receive request. 519*f439973dSWarner Losh If the token is in the transmit or receive request queues, after calling this 520*f439973dSWarner Losh function, Token->Status will be set to EFI_ABORTED and then Token->Event will 521*f439973dSWarner Losh be signaled. If the token is not in one of the queues, which usually means the 522*f439973dSWarner Losh asynchronous operation has completed, this function will not signal the token 523*f439973dSWarner Losh and EFI_NOT_FOUND is returned. 524*f439973dSWarner Losh 525*f439973dSWarner Losh @param This The pointer to the EFI_IP4_PROTOCOL instance. 526*f439973dSWarner Losh @param Token The pointer to a token that has been issued by 527*f439973dSWarner Losh EFI_IP4_PROTOCOL.Transmit() or 528*f439973dSWarner Losh EFI_IP4_PROTOCOL.Receive(). If NULL, all pending 529*f439973dSWarner Losh tokens are aborted. Type EFI_IP4_COMPLETION_TOKEN is 530*f439973dSWarner Losh defined in EFI_IP4_PROTOCOL.Transmit(). 531*f439973dSWarner Losh 532*f439973dSWarner Losh @retval EFI_SUCCESS The asynchronous I/O request was aborted and 533*f439973dSWarner Losh Token->Event was signaled. When Token is NULL, all 534*f439973dSWarner Losh pending requests were aborted and their events were signaled. 535*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER This is NULL. 536*f439973dSWarner Losh @retval EFI_NOT_STARTED This instance has not been started. 537*f439973dSWarner Losh @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, 538*f439973dSWarner Losh RARP, etc.) is not finished yet. 539*f439973dSWarner Losh @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was 540*f439973dSWarner Losh not found in the transmit or receive queue. It has either completed 541*f439973dSWarner Losh or was not issued by Transmit() and Receive(). 542*f439973dSWarner Losh 543*f439973dSWarner Losh **/ 544*f439973dSWarner Losh typedef 545*f439973dSWarner Losh EFI_STATUS 546*f439973dSWarner Losh (EFIAPI *EFI_IP4_CANCEL)( 547*f439973dSWarner Losh IN EFI_IP4_PROTOCOL *This, 548*f439973dSWarner Losh IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL 549*f439973dSWarner Losh ); 550*f439973dSWarner Losh 551*f439973dSWarner Losh /** 552*f439973dSWarner Losh Polls for incoming data packets and processes outgoing data packets. 553*f439973dSWarner Losh 554*f439973dSWarner Losh The Poll() function polls for incoming data packets and processes outgoing data 555*f439973dSWarner Losh packets. Network drivers and applications can call the EFI_IP4_PROTOCOL.Poll() 556*f439973dSWarner Losh function to increase the rate that data packets are moved between the communications 557*f439973dSWarner Losh device and the transmit and receive queues. 558*f439973dSWarner Losh 559*f439973dSWarner Losh In some systems the periodic timer event may not poll the underlying communications 560*f439973dSWarner Losh device fast enough to transmit and/or receive all data packets without missing 561*f439973dSWarner Losh incoming packets or dropping outgoing packets. Drivers and applications that are 562*f439973dSWarner Losh experiencing packet loss should try calling the EFI_IP4_PROTOCOL.Poll() function 563*f439973dSWarner Losh more often. 564*f439973dSWarner Losh 565*f439973dSWarner Losh @param This The pointer to the EFI_IP4_PROTOCOL instance. 566*f439973dSWarner Losh 567*f439973dSWarner Losh @retval EFI_SUCCESS Incoming or outgoing data was processed. 568*f439973dSWarner Losh @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started. 569*f439973dSWarner Losh @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, 570*f439973dSWarner Losh RARP, etc.) is not finished yet. 571*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER This is NULL. 572*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 573*f439973dSWarner Losh @retval EFI_NOT_READY No incoming or outgoing data is processed. 574*f439973dSWarner Losh @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. 575*f439973dSWarner Losh Consider increasing the polling rate. 576*f439973dSWarner Losh 577*f439973dSWarner Losh **/ 578*f439973dSWarner Losh typedef 579*f439973dSWarner Losh EFI_STATUS 580*f439973dSWarner Losh (EFIAPI *EFI_IP4_POLL)( 581*f439973dSWarner Losh IN EFI_IP4_PROTOCOL *This 582*f439973dSWarner Losh ); 583*f439973dSWarner Losh 584*f439973dSWarner Losh /// 585*f439973dSWarner Losh /// The EFI IPv4 Protocol implements a simple packet-oriented interface that can be 586*f439973dSWarner Losh /// used by drivers, daemons, and applications to transmit and receive network packets. 587*f439973dSWarner Losh /// 588*f439973dSWarner Losh struct _EFI_IP4_PROTOCOL { 589*f439973dSWarner Losh EFI_IP4_GET_MODE_DATA GetModeData; 590*f439973dSWarner Losh EFI_IP4_CONFIGURE Configure; 591*f439973dSWarner Losh EFI_IP4_GROUPS Groups; 592*f439973dSWarner Losh EFI_IP4_ROUTES Routes; 593*f439973dSWarner Losh EFI_IP4_TRANSMIT Transmit; 594*f439973dSWarner Losh EFI_IP4_RECEIVE Receive; 595*f439973dSWarner Losh EFI_IP4_CANCEL Cancel; 596*f439973dSWarner Losh EFI_IP4_POLL Poll; 597*f439973dSWarner Losh }; 598*f439973dSWarner Losh 599*f439973dSWarner Losh extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid; 600*f439973dSWarner Losh extern EFI_GUID gEfiIp4ProtocolGuid; 601*f439973dSWarner Losh 602*f439973dSWarner Losh #endif 603