xref: /freebsd/stand/efi/include/efiip.h (revision 0957b409)
1 /* $FreeBSD$ */
2 #ifndef _EFI_IP_H
3 #define _EFI_IP_H
4 
5 /*++
6 Copyright (c) 2013  Intel Corporation
7 
8 --*/
9 
10 #define EFI_IP4_SERVICE_BINDING_PROTOCOL \
11    {0xc51711e7,0xb4bf,0x404a,{0xbf,0xb8,0x0a,0x04, 0x8e,0xf1,0xff,0xe4}}
12 
13 #define EFI_IP4_PROTOCOL \
14     {0x41d94cd2,0x35b6,0x455a,{0x82,0x58,0xd4,0xe5,0x13,0x34,0xaa,0xdd}}
15 
16 #define EFI_IP6_SERVICE_BINDING_PROTOCOL \
17     {0xec835dd3,0xfe0f,0x617b,{0xa6,0x21,0xb3,0x50,0xc3,0xe1,0x33,0x88}}
18 
19 #define EFI_IP6_PROTOCOL \
20     {0x2c8759d5,0x5c2d,0x66ef,{0x92,0x5f,0xb6,0x6c,0x10,0x19,0x57,0xe2}}
21 
22 INTERFACE_DECL(_EFI_IP4);
23 INTERFACE_DECL(_EFI_IP6);
24 
25 typedef struct {
26     EFI_HANDLE       InstanceHandle;
27     EFI_IPv4_ADDRESS Ip4Address;
28     EFI_IPv4_ADDRESS SubnetMask;
29 } EFI_IP4_ADDRESS_PAIR;
30 
31 typedef struct {
32     EFI_HANDLE           DriverHandle;
33     UINT32               AddressCount;
34     EFI_IP4_ADDRESS_PAIR AddressPairs[1];
35 } EFI_IP4_VARIABLE_DATA;
36 
37 typedef struct {
38     UINT8            DefaultProtocol;
39     BOOLEAN          AcceptAnyProtocol;
40     BOOLEAN          AcceptIcmpErrors;
41     BOOLEAN          AcceptBroadcast;
42     BOOLEAN          AcceptPromiscuous;
43     BOOLEAN          UseDefaultAddress;
44     EFI_IPv4_ADDRESS StationAddress;
45     EFI_IPv4_ADDRESS SubnetMask;
46     UINT8            TypeOfService;
47     UINT8            TimeToLive;
48     BOOLEAN          DoNotFragment;
49     BOOLEAN          RawData;
50     UINT32           ReceiveTimeout;
51     UINT32           TransmitTimeout;
52 } EFI_IP4_CONFIG_DATA;
53 
54 typedef struct {
55     EFI_IPv4_ADDRESS SubnetAddress;
56     EFI_IPv4_ADDRESS SubnetMask;
57     EFI_IPv4_ADDRESS GatewayAddress;
58 } EFI_IP4_ROUTE_TABLE;
59 
60 typedef struct {
61     UINT8 Type;
62     UINT8 Code;
63 } EFI_IP4_ICMP_TYPE;
64 
65 typedef struct {
66     BOOLEAN             IsStarted;
67     UINT32              MaxPacketSize;
68     EFI_IP4_CONFIG_DATA ConfigData;
69     BOOLEAN             IsConfigured;
70     UINT32              GroupCount;
71     EFI_IPv4_ADDRESS    *GroupTable;
72     UINT32              RouteCount;
73     EFI_IP4_ROUTE_TABLE *RouteTable;
74     UINT32              IcmpTypeCount;
75     EFI_IP4_ICMP_TYPE   *IcmpTypeList;
76 } EFI_IP4_MODE_DATA;
77 
78 typedef
79 EFI_STATUS
80 (EFIAPI *EFI_IP4_GET_MODE_DATA) (
81     IN struct _EFI_IP4                  *This,
82     OUT EFI_IP4_MODE_DATA               *Ip4ModeData   OPTIONAL,
83     OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
84     OUT EFI_SIMPLE_NETWORK_MODE         *SnpModeData   OPTIONAL
85     );
86 
87 typedef
88 EFI_STATUS
89 (EFIAPI *EFI_IP4_CONFIGURE) (
90     IN struct _EFI_IP4     *This,
91     IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
92     );
93 
94 typedef
95 EFI_STATUS
96 (EFIAPI *EFI_IP4_GROUPS) (
97     IN struct _EFI_IP4  *This,
98     IN BOOLEAN          JoinFlag,
99     IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
100     );
101 
102 typedef
103 EFI_STATUS
104 (EFIAPI *EFI_IP4_ROUTES) (
105     IN struct _EFI_IP4  *This,
106     IN BOOLEAN          DeleteRoute,
107     IN EFI_IPv4_ADDRESS *SubnetAddress,
108     IN EFI_IPv4_ADDRESS *SubnetMask,
109     IN EFI_IPv4_ADDRESS *GatewayAddress
110     );
111 
112 #pragma pack(1)
113 typedef struct {
114     UINT8            HeaderLength:4;
115     UINT8            Version:4;
116     UINT8            TypeOfService;
117     UINT16           TotalLength;
118     UINT16           Identification;
119     UINT16           Fragmentation;
120     UINT8            TimeToLive;
121     UINT8            Protocol;
122     UINT16           Checksum;
123     EFI_IPv4_ADDRESS SourceAddress;
124     EFI_IPv4_ADDRESS DestinationAddress;
125 } EFI_IP4_HEADER;
126 #pragma pack()
127 
128 typedef struct {
129     UINT32 FragmentLength;
130     VOID   *FragmentBuffer;
131 } EFI_IP4_FRAGMENT_DATA;
132 
133 typedef struct {
134     EFI_TIME              TimeStamp;
135     EFI_EVENT             RecycleSignal;
136     UINT32                HeaderLength;
137     EFI_IP4_HEADER        *Header;
138     UINT32                OptionsLength;
139     VOID                  *Options;
140     UINT32                DataLength;
141     UINT32                FragmentCount;
142     EFI_IP4_FRAGMENT_DATA FragmentTable[1];
143 } EFI_IP4_RECEIVE_DATA;
144 
145 typedef struct {
146     EFI_IPv4_ADDRESS SourceAddress;
147     EFI_IPv4_ADDRESS GatewayAddress;
148     UINT8            Protocol;
149     UINT8            TypeOfService;
150     UINT8            TimeToLive;
151     BOOLEAN          DoNotFragment;
152 } EFI_IP4_OVERRIDE_DATA;
153 
154 typedef struct {
155     EFI_IPv4_ADDRESS      DestinationAddress;
156     EFI_IP4_OVERRIDE_DATA *OverrideData;
157     UINT32                OptionsLength;
158     VOID                  *OptionsBuffer;
159     UINT32                TotalDataLength;
160     UINT32                FragmentCount;
161     EFI_IP4_FRAGMENT_DATA FragmentTable[1];
162 } EFI_IP4_TRANSMIT_DATA;
163 
164 typedef struct {
165     EFI_EVENT                 Event;
166     EFI_STATUS                Status;
167     union {
168         EFI_IP4_RECEIVE_DATA  *RxData;
169         EFI_IP4_TRANSMIT_DATA *TxData;
170     } Packet;
171 } EFI_IP4_COMPLETION_TOKEN;
172 
173 typedef
174 EFI_STATUS
175 (EFIAPI *EFI_IP4_TRANSMIT) (
176     IN struct _EFI_IP4          *This,
177     IN EFI_IP4_COMPLETION_TOKEN *Token
178     );
179 
180 typedef
181 EFI_STATUS
182 (EFIAPI *EFI_IP4_RECEIVE) (
183     IN struct _EFI_IP4          *This,
184     IN EFI_IP4_COMPLETION_TOKEN *Token
185     );
186 
187 typedef
188 EFI_STATUS
189 (EFIAPI *EFI_IP4_CANCEL)(
190     IN struct _EFI_IP4          *This,
191     IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
192     );
193 
194 typedef
195 EFI_STATUS
196 (EFIAPI *EFI_IP4_POLL) (
197     IN struct _EFI_IP4 *This
198     );
199 
200 typedef struct _EFI_IP4 {
201     EFI_IP4_GET_MODE_DATA GetModeData;
202     EFI_IP4_CONFIGURE     Configure;
203     EFI_IP4_GROUPS        Groups;
204     EFI_IP4_ROUTES        Routes;
205     EFI_IP4_TRANSMIT      Transmit;
206     EFI_IP4_RECEIVE       Receive;
207     EFI_IP4_CANCEL        Cancel;
208     EFI_IP4_POLL          Poll;
209 } EFI_IP4;
210 
211 typedef struct {
212     UINT8            DefaultProtocol;
213     BOOLEAN          AcceptAnyProtocol;
214     BOOLEAN          AcceptIcmpErrors;
215     BOOLEAN          AcceptPromiscuous;
216     EFI_IPv6_ADDRESS DestinationAddress;
217     EFI_IPv6_ADDRESS StationAddress;
218     UINT8            TrafficClass;
219     UINT8            HopLimit;
220     UINT32           FlowLabel;
221     UINT32           ReceiveTimeout;
222     UINT32           TransmitTimeout;
223 } EFI_IP6_CONFIG_DATA;
224 
225 typedef struct {
226     EFI_IPv6_ADDRESS Address;
227     UINT8            PrefixLength;
228 } EFI_IP6_ADDRESS_INFO;
229 
230 typedef struct {
231     EFI_IPv6_ADDRESS Gateway;
232     EFI_IPv6_ADDRESS Destination;
233     UINT8            PrefixLength;
234 } EFI_IP6_ROUTE_TABLE;
235 
236 typedef enum {
237     EfiNeighborInComplete,
238     EfiNeighborReachable,
239     EfiNeighborStale,
240     EfiNeighborDelay,
241     EfiNeighborProbe
242 } EFI_IP6_NEIGHBOR_STATE;
243 
244 typedef struct {
245     EFI_IPv6_ADDRESS       Neighbor;
246     EFI_MAC_ADDRESS        LinkAddress;
247     EFI_IP6_NEIGHBOR_STATE State;
248 } EFI_IP6_NEIGHBOR_CACHE;
249 
250 typedef struct {
251     UINT8 Type;
252     UINT8 Code;
253 } EFI_IP6_ICMP_TYPE;
254 
255 //***********************************************************
256 // ICMPv6 type definitions for error messages
257 //***********************************************************
258 #define ICMP_V6_DEST_UNREACHABLE     0x1
259 #define ICMP_V6_PACKET_TOO_BIG       0x2
260 #define ICMP_V6_TIME_EXCEEDED        0x3
261 #define ICMP_V6_PARAMETER_PROBLEM    0x4
262 
263 //***********************************************************
264 // ICMPv6 type definition for informational messages
265 //***********************************************************
266 #define ICMP_V6_ECHO_REQUEST         0x80
267 #define ICMP_V6_ECHO_REPLY           0x81
268 #define ICMP_V6_LISTENER_QUERY       0x82
269 #define ICMP_V6_LISTENER_REPORT      0x83
270 #define ICMP_V6_LISTENER_DONE        0x84
271 #define ICMP_V6_ROUTER_SOLICIT       0x85
272 #define ICMP_V6_ROUTER_ADVERTISE     0x86
273 #define ICMP_V6_NEIGHBOR_SOLICIT     0x87
274 #define ICMP_V6_NEIGHBOR_ADVERTISE   0x88
275 #define ICMP_V6_REDIRECT             0x89
276 #define ICMP_V6_LISTENER_REPORT_2    0x8F
277 
278 //***********************************************************
279 // ICMPv6 code definitions for ICMP_V6_DEST_UNREACHABLE
280 //***********************************************************
281 #define ICMP_V6_NO_ROUTE_TO_DEST     0x0
282 #define ICMP_V6_COMM_PROHIBITED      0x1
283 #define ICMP_V6_BEYOND_SCOPE         0x2
284 #define ICMP_V6_ADDR_UNREACHABLE     0x3
285 #define ICMP_V6_PORT_UNREACHABLE     0x4
286 #define ICMP_V6_SOURCE_ADDR_FAILED   0x5
287 #define ICMP_V6_ROUTE_REJECTED       0x6
288 
289 //***********************************************************
290 // ICMPv6 code definitions for ICMP_V6_TIME_EXCEEDED
291 //***********************************************************
292 #define ICMP_V6_TIMEOUT_HOP_LIMIT    0x0
293 #define ICMP_V6_TIMEOUT_REASSEMBLE   0x1
294 
295 //***********************************************************
296 // ICMPv6 code definitions for ICMP_V6_PARAMETER_PROBLEM
297 //***********************************************************
298 #define ICMP_V6_ERRONEOUS_HEADER     0x0
299 #define ICMP_V6_UNRECOGNIZE_NEXT_HDR 0x1
300 #define ICMP_V6_UNRECOGNIZE_OPTION   0x2
301 
302 typedef struct {
303     BOOLEAN                IsStarted;
304     UINT32                 MaxPacketSize;
305     EFI_IP6_CONFIG_DATA    ConfigData;
306     BOOLEAN                IsConfigured;
307     UINT32                 AddressCount;
308     EFI_IP6_ADDRESS_INFO   *AddressList;
309     UINT32                 GroupCount;
310     EFI_IPv6_ADDRESS       *GroupTable;
311     UINT32                 RouteCount;
312     EFI_IP6_ROUTE_TABLE    *RouteTable;
313     UINT32                 NeighborCount;
314     EFI_IP6_NEIGHBOR_CACHE *NeighborCache;
315     UINT32                 PrefixCount;
316     EFI_IP6_ADDRESS_INFO   *PrefixTable;
317     UINT32                 IcmpTypeCount;
318     EFI_IP6_ICMP_TYPE      *IcmpTypeList;
319 } EFI_IP6_MODE_DATA;
320 
321 typedef
322 EFI_STATUS
323 (EFIAPI *EFI_IP6_GET_MODE_DATA) (
324     IN struct _EFI_IP6                  *This,
325     OUT EFI_IP6_MODE_DATA               *Ip6ModeData   OPTIONAL,
326     OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
327     OUT EFI_SIMPLE_NETWORK_MODE         *SnpModeData   OPTIONAL
328     );
329 
330 typedef
331 EFI_STATUS
332 (EFIAPI *EFI_IP6_CONFIGURE) (
333     IN struct _EFI_IP6     *This,
334     IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL
335     );
336 typedef
337 EFI_STATUS
338 (EFIAPI *EFI_IP6_GROUPS) (
339     IN struct _EFI_IP6  *This,
340     IN BOOLEAN          JoinFlag,
341     IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
342     );
343 
344 typedef
345 EFI_STATUS
346 (EFIAPI *EFI_IP6_ROUTES) (
347     IN struct _EFI_IP6  *This,
348     IN BOOLEAN          DeleteRoute,
349     IN EFI_IPv6_ADDRESS *Destination    OPTIONAL,
350     IN UINT8            PrefixLength,
351     IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
352     );
353 
354 typedef
355 EFI_STATUS
356 (EFIAPI *EFI_IP6_NEIGHBORS) (
357     IN struct _EFI_IP6  *This,
358     IN BOOLEAN          DeleteFlag,
359     IN EFI_IPv6_ADDRESS *TargetIp6Address,
360     IN EFI_MAC_ADDRESS  *TargetLinkAddress OPTIONAL,
361     IN UINT32           Timeout,
362     IN BOOLEAN          Override
363     );
364 
365 typedef struct _EFI_IP6_FRAGMENT_DATA {
366     UINT32 FragmentLength;
367     VOID   *FragmentBuffer;
368 } EFI_IP6_FRAGMENT_DATA;
369 
370 typedef struct _EFI_IP6_OVERRIDE_DATA {
371     UINT8  Protocol;
372     UINT8  HopLimit;
373     UINT32 FlowLabel;
374 } EFI_IP6_OVERRIDE_DATA;
375 
376 typedef struct _EFI_IP6_TRANSMIT_DATA {
377     EFI_IPv6_ADDRESS      DestinationAddress;
378     EFI_IP6_OVERRIDE_DATA *OverrideData;
379     UINT32                ExtHdrsLength;
380     VOID                  *ExtHdrs;
381     UINT8                 NextHeader;
382     UINT32                DataLength;
383     UINT32                FragmentCount;
384     EFI_IP6_FRAGMENT_DATA FragmentTable[1];
385 } EFI_IP6_TRANSMIT_DATA;
386 
387 #pragma pack(1)
388 typedef struct _EFI_IP6_HEADER {
389     UINT8            TrafficClassH:4;
390     UINT8            Version:4;
391     UINT8            FlowLabelH:4;
392     UINT8            TrafficClassL:4;
393     UINT16           FlowLabelL;
394     UINT16           PayloadLength;
395     UINT8            NextHeader;
396     UINT8            HopLimit;
397     EFI_IPv6_ADDRESS SourceAddress;
398     EFI_IPv6_ADDRESS DestinationAddress;
399 } EFI_IP6_HEADER;
400 #pragma pack()
401 
402 typedef struct _EFI_IP6_RECEIVE_DATA {
403     EFI_TIME              TimeStamp;
404     EFI_EVENT             RecycleSignal;
405     UINT32                HeaderLength;
406     EFI_IP6_HEADER        *Header;
407     UINT32                DataLength;
408     UINT32                FragmentCount;
409     EFI_IP6_FRAGMENT_DATA FragmentTable[1];
410 } EFI_IP6_RECEIVE_DATA;
411 
412 typedef struct {
413     EFI_EVENT                 Event;
414     EFI_STATUS                Status;
415     union {
416 	EFI_IP6_RECEIVE_DATA  *RxData;
417 	EFI_IP6_TRANSMIT_DATA *TxData;
418     }                         Packet;
419 } EFI_IP6_COMPLETION_TOKEN;
420 
421 typedef
422 EFI_STATUS
423 (EFIAPI *EFI_IP6_TRANSMIT) (
424     IN struct _EFI_IP6          *This,
425     IN EFI_IP6_COMPLETION_TOKEN *Token
426     );
427 
428 typedef
429 EFI_STATUS
430 (EFIAPI *EFI_IP6_RECEIVE) (
431     IN struct _EFI_IP6          *This,
432     IN EFI_IP6_COMPLETION_TOKEN *Token
433     );
434 
435 typedef
436 EFI_STATUS
437 (EFIAPI *EFI_IP6_CANCEL)(
438     IN struct _EFI_IP6          *This,
439     IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
440     );
441 
442 typedef
443 EFI_STATUS
444 (EFIAPI *EFI_IP6_POLL) (
445     IN struct _EFI_IP6 *This
446     );
447 
448 typedef struct _EFI_IP6 {
449     EFI_IP6_GET_MODE_DATA GetModeData;
450     EFI_IP6_CONFIGURE     Configure;
451     EFI_IP6_GROUPS        Groups;
452     EFI_IP6_ROUTES        Routes;
453     EFI_IP6_NEIGHBORS     Neighbors;
454     EFI_IP6_TRANSMIT      Transmit;
455     EFI_IP6_RECEIVE       Receive;
456     EFI_IP6_CANCEL        Cancel;
457     EFI_IP6_POLL          Poll;
458 } EFI_IP6;
459 
460 #endif /* _EFI_IP_H */
461