1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
|
//
// This file contains 'Framework Code' and is licensed as such
// under the terms of your license agreement with Intel or your
// vendor. This file may not be modified, except as allowed by
// additional terms of your license agreement.
//
#ifndef _EFI_IP_H_
// GC_TODO: move protective #ifndef after comment header
#define _EFI_IP_H_
/*++
Copyright (c) 2002 Intel Corporation. All rights reserved.
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.
Module Name:
Ip.h
Abstract:
EFI Internet Protocol Definition
--*/
#include "Tiano.h"
#include "TianoTypes.h"
EFI_FORWARD_DECLARATION (EFI_IP_PROTOCOL);
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define EFI_IP_PROTOCOL_GUID \
{ \
0x89DEEF37, 0x31D8, 0x469C, 0x95, 0xB6, 0x01, 0x69, 0xBC, 0x86, 0x6C, 0xFB \
}
extern EFI_GUID gEfiIpProtocolGuid;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//
// Useful macros for byte ordering.
//
//
// EFI_IP_HTONS(x) - converts the value (x) from host byte order to network
// byte order
//
#define EFI_IP_HTONS(x) ((UINT16) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)))
//
// EFI_IP_HTONL(x)
//
#define EFI_IP_HTONL(x) \
((UINT32) ((((x) & 0xFF000000) >> 24) | (((x) & 0xFF0000) >> 8) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24)))
//
// EFI_IP_NSTOH(x) - converts the value *(x) from network byte order to
// host byte order
//
#define EFI_IP_NSTOH(x) (UINT16) ((((UINT16) *((UINT8 *) (x)) & 0xFF) << 8) | ((UINT16) *((UINT8 *) (x) + 1) & 0xFF))
//
// EFI_IP_NLTOH(x)
//
#define EFI_IP_NLTOH(x) \
(UINT32) \
( \
(((UINT32) *((UINT8 *) (x)) & 0xFF) << 24) | (((UINT32) *((UINT8 *) (x) + 1) & 0xFF) << 16) | \
(((UINT32) *((UINT8 *) (x) + 2) & 0xFF) << 8) | ((UINT32) *((UINT8 *) (x) + 3) & 0xFF) \
)
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//
// Typical ethernet IPv4 packet layout:
//
//
// +----- ----- ----- ----- ----- ----- ----- ----- -----+
// | Media header Destination MAC (6 bytes) |
// | Source MAC (6 bytes) |
// | Protocol (2 bytes) [IP, ARP, etc] |
// +----- ----- ----- ----- ----- ----- ----- ----- -----+
// | IPv4 header HeaderLen (4 bits) |
// | Version (4 bits) [IPv4, IPv6] |
// | TypeOfService (1 byte) |
// | TotalLen (2 bytes) |
// | Identification (2 bytes) |
// | FragmentOffset (2 bytes) |
// | TimeToLive (1 byte) |
// | Protocol (1 byte) |
// | HeaderChecksum (2 bytes) |
// | SourceIp (4 bytes) |
// | DestinationIp (4 bytes) |
// +----- ----- ----- ----- ----- ----- ----- ----- -----+
// | IPv4 data |
// +----- ----- ----- ----- ----- ----- ----- ----- -----+
//
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//
// Media header protocol values.
//
#define EFI_IP_MEDIA_HEADER_PROTOCOL_IP 0x0800
#define EFI_IP_MEDIA_HEADER_PROTOCOL_ARP 0x0806
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//
// Detailed information on IPv4 packet contents can be found in RFC 791.
// www.ietf.org
//
//
// IPv4 packet header format (no options).
//
#pragma pack(1)
typedef struct {
UINT8 HeaderLen : 4;
UINT8 Version : 4;
UINT8 TypeOfService;
UINT16 TotalLen;
UINT16 Identification;
UINT16 FragmentOffset;
UINT8 TimeToLive;
UINT8 Protocol;
UINT16 HeaderChecksum;
UINT8 SourceIp[4];
UINT8 DestinationIp[4];
} EFI_IP_IP4_HEADER;
#pragma pack()
//
// Some useful IPv4 constants.
//
#define EFI_IP_IP4_HEADER_VERSION 0x04
#define EFI_IP_IP4_HEADER_PROTOCOL_ICMP 1
#define EFI_IP_IP4_HEADER_PROTOCOL_IGMP 2
#define EFI_IP_IP4_HEADER_PROTOCOL_TCP 6
#define EFI_IP_IP4_HEADER_PROTOCOL_UDP 17
#define EFI_IP_IP4_HEADER_DONT_FRAGMENT 0x4000
#define EFI_IP_IP4_HEADER_MORE_FRAGMENTS 0x2000
#define EFI_IP_IP4_HEADER_FRAGMENT_MASK 0x1FFF
#define EFI_IP_IP4_HEADER_FRAGMENT_SHIFT 3
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//
// Useful Internet Protocol constants.
//
#define EFI_IP_MAX_ROUTE_TABLE_SIZE 8 // # route entries
#define EFI_IP_MAX_ARP_CACHE_SIZE 8 // # packets
#define EFI_IP_ARP_CACHE_TIMEOUT 60000 // milliseconds
#define EFI_IP_ARP_RETRY_COUNT 4 // # requests
#define EFI_IP_ARP_RETRY_TIMEOUT 250 // milliseconds
#define EFI_IP_MAX_RX_QUEUE_SIZE 16 // # assembled packets
#define EFI_IP_RX_QUEUE_TIMEOUT 5000 // milliseconds
#define EFI_IP_MAX_TX_QUEUE_SIZE 32 // # fragments
#define EFI_IP_TX_QUEUE_TIMEOUT 100 // milliseconds
#define EFI_IP_MAX_BUFFER_SIZE 64 // K bytes
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//
// IPv4 protocol definition.
//
//
// IP handle. Returned by Ip->Open() and used when receiving or
// transmitting IP packets.
//
typedef VOID *EFI_IP_HANDLE;
//
// IP handle receive function prototype.
//
typedef
VOID
(EFIAPI *EFI_IP_RECEIVE) (
IN VOID *Context,
IN EFI_IP_ADDRESS * DestinationIp,
IN EFI_IP_ADDRESS * SourceIp,
IN UINT8 Protocol,
IN UINTN BufferLen,
IN VOID *Buffer
);
/*++
* Description:
* A handle's receive function is called when a valid IP packet is
* received that matches the handle's receive filter(s). When the
* receive function returns control to the IP protocol driver, the
* data in the Buffer can no longer be used. If the data in the
* Buffer needs to be preserved, it must be copied out before
* returning control to the IP protocol driver.
*
* Parameters:
* Context - Pointer to context data.
* DestinationIp - Pointer to the destination IP address.
* SourceIp - Pointer to the source IP address.
* Protocol - The encapsulated protocol number.
* BufferLen - The number of data bytes in the receive buffer.
* May be zero.
* Buffer - Pointer to the receive buffer. May be NULL.
*
* Returns:
* n/a
--*/
//
// IP configuration and tuning parameters.
//
typedef struct {
UINTN MaxRouteTableSize;
UINTN MaxArpCacheSize;
UINTN ArpCacheTimeout;
UINTN ArpRetryCount;
UINTN ArpRetryTimeout;
UINTN MaxRxQueueSize;
UINTN RxQueueTimeout;
UINTN MaxTxQueueSize;
UINTN TxQueueTimeout;
} EFI_IP_CONFIG_DATA;
//
// IP configuration function prototype.
//
typedef
EFI_STATUS
(EFIAPI *EFI_IP_CONFIG) (
IN EFI_IP_PROTOCOL * This,
IN BOOLEAN Reset,
IN EFI_IP_CONFIG_DATA * NewData OPTIONAL,
OUT EFI_IP_CONFIG_DATA * OldData OPTIONAL
);
/*++
* Description:
* This function is used to Set and/or Get the IP configuration and tuning
* parameters. The tuning parameters can only be changed when there are
* no open IP handles.
*
* Parameters:
* This - Pointer to the IP protocol driver instance data.
* Reset - Set to TRUE to reset the IP protocol driver configuration
* data back to default values.
* NewData - New IP protocol driver configuration data. May be NULL.
* OldData - Previous IP protocol driver configuration data. May be NULL.
*
* Returns:
* EFI_SUCCESS - Configuration data updated/retrieved as requested.
* EFI_INVALID_PARAMETER - One or more of the parameters or configuration
* data values was invalid.
* EFI_ALREADY_STARTED - One or more IP handles is open.
--*/
//
// IP handle open data.
//
typedef struct {
VOID *Context;
EFI_IP_ADDRESS StationIp;
EFI_IP_ADDRESS SubnetMask;
EFI_IP_ADDRESS GatewayIp;
UINT8 TypeOfService;
UINT8 TimeToLive;
UINT8 Protocol;
BOOLEAN DoNotFragment;
BOOLEAN RawData;
BOOLEAN Promiscuous;
BOOLEAN Broadcast;
BOOLEAN AnyProtocol;
EFI_IP_RECEIVE Receive;
UINTN MulticastIpCount;
EFI_IP_ADDRESS *MulticastIpList;
} EFI_IP_OPEN_DATA;
/*++
* Context - Pointer to context data returned in Receive().
* StationIp - Unicast IP address. Used as the source IP address
* in transmitted packets. Used as the destination IP
* address in received IP packets. Can be set to
* 0.0.0.0.
* SubnetMask - Subnet mask. Used to check if the destination IP
* is on the same subnet as the StationIp.
* Can be set to 0.0.0.0.
* GatewayIp - Default gateway IP address. Used if the destination
* IP is not on the same subnet as the StationIp.
* Can be set to 0.0.0.0 if there is no default gateway.
* TypeOfService - Packet service priority.
* TimeToLive - Number of gateway hops before packet 'dies'.
* Protocol - Protocol number to be used in the IP header of
* transmitted packets. Protocol receive filter
* to be used if AnyProtocol is FALSE.
* DoNotFragment - Set to TRUE if transmitted IP packets must not
* be fragmented.
* Promiscuous - Set to TRUE to receive all valid IP packets.
* Broadcast - Set to TRUE to also receive broadcast IP packets.
* AnyProtocol - Set to TRUE to receive any protocol number.
* Set to FALSE to receive only matching Protocol
* numbers.
* Receive - Pointer to this handle's IP receive function.
* Can not be set to NULL.
* MulticastIpCount - Number of multicast IP addresses in the
* MulticastIpList array. May be zero.
* MulticastIpList - Array of multicast IP addresses. IP packets sent
* to these addresses will be accepted by the IP
* protocol driver if the protocol numbers match.
* Not used if MulticastIpCount is zero.
--*/
//
// Open new IP handle.
//
typedef
EFI_STATUS
(EFIAPI *EFI_IP_OPEN) (
IN EFI_IP_PROTOCOL * This,
IN EFI_IP_OPEN_DATA * Data,
OUT EFI_IP_HANDLE * NewHandle
);
/*++
* Description:
*
* Parameters:
* This - Pointer to IP protocol instance data.
* Data - Pointer to handle configuration data.
* NewHandle - Pointer to new IP handle storage.
*
* Returns:
* EFI_SUCCESS - New IP handle was opened.
* EFI_INVALID_PARAMETER - One or more of the parameters is invalid.
* EFI_OUT_OF_RESOURCES - New buffer(s) could not be allocated.
--*/
//
// Close existing IP handle.
//
typedef
EFI_STATUS
(EFIAPI *EFI_IP_CLOSE) (
IN EFI_IP_HANDLE Handle,
IN BOOLEAN Flush
);
/*++
* Description:
* Close a previously opened IP handle.
*
* Parameters:
* Handle - IP handle returned by Ip->Open().
* Flush - Set to TRUE to flush all pending transmit packets before
* returning control. Pending transmit data may be lost if
* Flush is set to FALSE.
*
* Returns:
* EFI_SUCCESS - IP handle has been closed.
* EFI_INVALID_PARAMETER - One or more of the parameters is invalid.
--*/
//
// Transmit one or more IP packets.
//
typedef
EFI_STATUS
(EFIAPI *EFI_IP_TRANSMIT) (
IN EFI_IP_HANDLE Handle,
IN EFI_IP_ADDRESS * DestinationIp OPTIONAL,
IN UINTN BufferLen,
IN UINT8 *Buffer,
IN BOOLEAN Flush
);
//
//
//
typedef
UINT16
(EFIAPI *EFI_IP_CHECKSUM) (
IN UINTN BufferLen,
IN VOID *Buffer
);
/*++
* Description:
* Compute IP checksum of buffer.
*
* Parameters:
* BufferLen - Number of bytes to checksum. May be zero.
* Buffer - Pointer to buffer to checksum. Not used if BufferLen
* is zero.
*
* Returns:
* IP checksum of buffer. Zero is returned if BufferLen is zero or
* Buffer is NULL.
--*/
//
//
//
typedef
UINT16
(EFIAPI *EFI_IP_IDENTIFICATION) (
VOID
);
/*++
* Description:
* Returns an IP header identification number.
*
* Parameters:
* n/a
*
* Returns:
* An IP header identification number.
--*/
//
// Internet Protocol interface definition.
//
typedef struct _EFI_IP_PROTOCOL {
EFI_IP_CONFIG Config;
EFI_IP_OPEN Open;
EFI_IP_CLOSE Close;
EFI_IP_TRANSMIT Transmit;
EFI_IP_CHECKSUM Checksum;
EFI_IP_IDENTIFICATION Identification;
EFI_EVENT Event;
} EFI_IP_PROTOCOL;
#endif /* _EFI_IP_H */
/* EOF - Ip.h */
|