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