]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | --*/\r | |
13 | \r | |
14 | #ifndef _IP_H_\r | |
15 | #define _IP_H_\r | |
16 | \r | |
17 | #include "hton.h"\r | |
18 | \r | |
19 | //\r | |
20 | // Client architecture types\r | |
21 | //\r | |
22 | #define IA64 2\r | |
23 | #define SYS_ARCH_EFI32 6\r | |
24 | \r | |
25 | //\r | |
26 | // portability macros\r | |
27 | //\r | |
28 | #define UDP_FILTER_MASK (EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP | \\r | |
29 | EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT | \\r | |
30 | EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP | \\r | |
31 | EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT | \\r | |
32 | EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER \\r | |
33 | )\r | |
34 | \r | |
35 | #define PXE_BOOT_LAYER_MASK 0x7FFF\r | |
36 | #define PXE_BOOT_LAYER_INITIAL 0x0000\r | |
37 | #define PXE_BOOT_LAYER_CREDENTIAL_FLAG 0x8000\r | |
38 | #define MAX_BOOT_SERVERS 32\r | |
39 | \r | |
40 | //\r | |
41 | // macro to evaluate IP address as TRUE if it is a multicast IP address\r | |
42 | //\r | |
43 | #define IS_MULTICAST(ptr) ((*((UINT8 *) ptr) & 0xf0) == 0xe0)\r | |
44 | \r | |
45 | //\r | |
46 | // length macros\r | |
47 | //\r | |
48 | #define IP_ADDRESS_LENGTH(qp) (((qp)->UsingIpv6) ? sizeof (EFI_IPv6_ADDRESS) : sizeof (EFI_IPv4_ADDRESS))\r | |
49 | \r | |
50 | #define MAX_FRAME_DATA_SIZE 1488\r | |
51 | #define ALLOCATE_SIZE(X) (((X) + 7) & 0xfff8)\r | |
52 | #define MODE_ALLOCATE_SIZE ALLOCATE_SIZE (sizeof (EFI_PXE_BASE_CODE_MODE))\r | |
53 | #define BUFFER_ALLOCATE_SIZE (8192 + 512)\r | |
54 | #define ROUTER_ALLOCATE_SIZE ALLOCATE_SIZE ((sizeof (EFI_PXE_BASE_CODE_ROUTE_ENTRY) * PXE_ROUTER_TABLE_SIZE))\r | |
55 | #define ARP_ALLOCATE_SIZE ALLOCATE_SIZE ((sizeof (EFI_PXE_BASE_CODE_ARP_ENTRY) * PXE_ARP_CACHE_SIZE))\r | |
56 | #define FILTER_ALLOCATE_SIZE ALLOCATE_SIZE ((sizeof (EFI_IP_ADDRESS) * PXE_IP_FILTER_SIZE))\r | |
57 | #define PXE_ARP_CACHE_SIZE 8\r | |
58 | #define PXE_ROUTER_TABLE_SIZE 8\r | |
59 | #define PXE_IP_FILTER_SIZE 8\r | |
60 | #define ICMP_ALLOCATE_SIZE ALLOCATE_SIZE (sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR))\r | |
61 | #define TFTP_ERR_ALLOCATE_SIZE ALLOCATE_SIZE (sizeof (EFI_PXE_BASE_CODE_TFTP_ERROR))\r | |
62 | \r | |
63 | //\r | |
64 | // DHCP discover/request packets are sent to this UDP port. ProxyDHCP\r | |
65 | // servers listen on this port for DHCP discover packets that have a\r | |
66 | // class identifier (option 60) with 'PXEClient' in the first 9 bytes.\r | |
67 | // Bootservers also listen on this port for PXE broadcast discover\r | |
68 | // requests from PXE clients.\r | |
69 | //\r | |
70 | #define DHCP_SERVER_PORT 67\r | |
71 | \r | |
72 | //\r | |
73 | // When DHCP, proxyDHCP and Bootservers respond to DHCP and PXE broadcast\r | |
74 | // discover requests by broadcasting the reply packet, the packet is\r | |
75 | // broadcast to this port.\r | |
76 | //\r | |
77 | #define DHCP_CLIENT_PORT 68\r | |
78 | \r | |
79 | //\r | |
80 | // TFTP servers listen for TFTP open requests on this port.\r | |
81 | //\r | |
82 | #define TFTP_OPEN_PORT 69\r | |
83 | \r | |
84 | //\r | |
85 | // proxyDHCP and Bootservers listen on this port for a PXE unicast and/or\r | |
86 | // multicast discover requests from PXE clients. A PXE discover request\r | |
87 | // looks like a DHCP discover or DHCP request packet.\r | |
88 | //\r | |
89 | #define PXE_DISCOVERY_PORT 4011\r | |
90 | \r | |
91 | //\r | |
92 | // This port is used by the PXE client/server protocol tests.\r | |
93 | //\r | |
94 | #define PXE_PORT_PXETEST_PORT 0x8080\r | |
95 | \r | |
96 | //\r | |
97 | // Definitions for Ethertype protocol numbers and interface types\r | |
98 | // Per RFC 1700,\r | |
99 | //\r | |
100 | #define PXE_PROTOCOL_ETHERNET_IP 0x0800\r | |
101 | #define PXE_PROTOCOL_ETHERNET_ARP 0x0806\r | |
102 | #define PXE_PROTOCOL_ETHERNET_RARP 0x8035\r | |
103 | \r | |
104 | #define PXE_IFTYPE_ETHERNET 0x01\r | |
105 | #define PXE_IFTYPE_TOKENRING 0x04\r | |
106 | #define PXE_IFTYPE_FIBRE_CHANNEL 0x12\r | |
107 | \r | |
108 | //\r | |
109 | // Definitions for internet protocol version 4 header\r | |
110 | // Per RFC 791, September 1981.\r | |
111 | //\r | |
112 | #define IPVER4 4\r | |
113 | \r | |
114 | #pragma pack(1) // make network structures packed byte alignment\r | |
115 | typedef union {\r | |
116 | UINT8 B[4];\r | |
117 | UINT32 L;\r | |
118 | } IPV4_ADDR;\r | |
119 | \r | |
120 | #define IPV4_HEADER_LENGTH(IpHeaderPtr) (((IpHeaderPtr)->VersionIhl & 0xf) << 2)\r | |
121 | \r | |
122 | #define SET_IPV4_VER_HDL(IpHeaderPtr, IpHeaderLen) { \\r | |
123 | (IpHeaderPtr)->VersionIhl = (UINT8) ((IPVER4 << 4) | ((IpHeaderLen) >> 2)); \\r | |
124 | }\r | |
125 | \r | |
126 | typedef struct {\r | |
127 | UINT8 VersionIhl;\r | |
128 | UINT8 TypeOfService;\r | |
129 | UINT16 TotalLength;\r | |
130 | UINT16 Id;\r | |
131 | UINT16 FragmentFields;\r | |
132 | UINT8 TimeToLive;\r | |
133 | UINT8 Protocol;\r | |
134 | UINT16 HeaderChecksum;\r | |
135 | IPV4_ADDR SrcAddr;\r | |
136 | IPV4_ADDR DestAddr;\r | |
137 | //\r | |
138 | // options are not implemented\r | |
139 | //\r | |
140 | } IPV4_HEADER;\r | |
141 | \r | |
142 | #define IP_FRAG_RSVD 0x8000 // reserved bit - must be zero\r | |
143 | #define IP_NO_FRAG 0x4000 // do not fragment bit\r | |
144 | #define IP_MORE_FRAG 0x2000 // not last fragment\r | |
145 | #define IP_FRAG_OFF_MSK 0x1fff // fragment offset in 8 byte chunks\r | |
146 | #define DEFAULT_RFC_TTL 64\r | |
147 | \r | |
148 | #define PROT_ICMP 1\r | |
149 | #define PROT_IGMP 2\r | |
150 | #define PROT_TCP 6\r | |
151 | #define PROT_UDP 17\r | |
152 | \r | |
153 | /*\r | |
154 | * Definitions for internet control message protocol version 4 message\r | |
155 | * structure. Per RFC 792, September 1981.\r | |
156 | */\r | |
157 | \r | |
158 | //\r | |
159 | // icmp header for all icmp messages\r | |
160 | //\r | |
161 | typedef struct {\r | |
162 | UINT8 Type; // message type\r | |
163 | UINT8 Code; // type specific - 0 for types we implement\r | |
164 | UINT16 Checksum; // ones complement of ones complement sum of 16 bit words of message\r | |
165 | } ICMPV4_HEADER;\r | |
166 | \r | |
167 | #define ICMP_DEST_UNREACHABLE 3\r | |
168 | #define ICMP_SOURCE_QUENCH 4\r | |
169 | #define ICMP_REDIRECT 5\r | |
170 | #define ICMP_ECHO 8\r | |
171 | #define ICMP_ECHO_REPLY 0\r | |
172 | #define ICMP_ROUTER_ADV 9\r | |
173 | #define ICMP_ROUTER_SOLICIT 10\r | |
174 | #define ICMP_TIME_EXCEEDED 11\r | |
175 | #define ICMP_PARAMETER_PROBLEM 12\r | |
176 | #define ICMP_TIMESTAMP 13\r | |
177 | #define ICMP_TIMESTAMP_REPLY 14\r | |
178 | #define ICMP_INFO_REQ 15\r | |
179 | #define ICMP_INFO_REQ_REPLY 16\r | |
180 | #define ICMP_SUBNET_MASK_REQ 17\r | |
181 | #define ICMP_SUBNET_MASK_REPLY 18\r | |
182 | //\r | |
183 | // other ICMP message types ignored in this implementation\r | |
184 | //\r | |
185 | // icmp general messages\r | |
186 | //\r | |
187 | typedef struct {\r | |
188 | ICMPV4_HEADER Header;\r | |
189 | //\r | |
190 | // generally unused except byte [0] for\r | |
191 | // parameter problem message\r | |
192 | //\r | |
193 | UINT8 GenerallyUnused[4];\r | |
194 | //\r | |
195 | // original message ip header of plus 64\r | |
196 | // bits of data\r | |
197 | //\r | |
198 | IPV4_HEADER IpHeader;\r | |
199 | } ICMPV4_GENERAL_MESSAGE;\r | |
200 | \r | |
201 | //\r | |
202 | // icmp req/rply message header\r | |
203 | //\r | |
204 | typedef struct {\r | |
205 | ICMPV4_HEADER Header;\r | |
206 | UINT16 Id;\r | |
207 | UINT16 SequenceNumber;\r | |
208 | } ICMPV4_REQUEST_REPLY_HEADER;\r | |
209 | \r | |
210 | //\r | |
211 | // icmp echo message\r | |
212 | //\r | |
213 | typedef struct {\r | |
214 | ICMPV4_REQUEST_REPLY_HEADER Header;\r | |
215 | UINT8 EchoData[1]; // variable length data to be echoed\r | |
216 | } ICMPV4_ECHO_MESSAGE;\r | |
217 | \r | |
218 | //\r | |
219 | // icmp timestamp message - times are milliseconds since midnight UT -\r | |
220 | // if non std, set high order bit\r | |
221 | //\r | |
222 | typedef struct {\r | |
223 | ICMPV4_REQUEST_REPLY_HEADER Header;\r | |
224 | UINT32 OriginalTime; // originating timestamp\r | |
225 | UINT32 ReceiveTime; // receiving timestamp\r | |
226 | UINT32 TransmitTime; // transmitting timestamp\r | |
227 | } ICMPV4_TIMESTAMP_MESSAGE;\r | |
228 | \r | |
229 | //\r | |
230 | // icmp info request structure - fill in source and dest net ip address on reply\r | |
231 | //\r | |
232 | typedef struct {\r | |
233 | ICMPV4_REQUEST_REPLY_HEADER Header;\r | |
234 | } ICMPV4_INFO_MESSAGE;\r | |
235 | \r | |
236 | //\r | |
237 | // Definitions for internet control message protocol version 4 message structure\r | |
238 | // Router discovery\r | |
239 | // Per RFC 1256, September 1991.\r | |
240 | //\r | |
241 | //\r | |
242 | // icmp router advertisement message\r | |
243 | //\r | |
244 | typedef struct {\r | |
245 | ICMPV4_HEADER Header;\r | |
246 | UINT8 NumberEntries; // number of address entries\r | |
247 | UINT8 EntrySize; // number of 32 bit words per address entry\r | |
248 | UINT16 Lifetime; // seconds to consider info valid\r | |
249 | UINT32 RouterIp;\r | |
250 | UINT32 Preferance;\r | |
251 | } ICMPV4_ROUTER_ADVERTISE_MESSAGE;\r | |
252 | \r | |
253 | //\r | |
254 | // icmp router solicitation message\r | |
255 | //\r | |
256 | typedef struct {\r | |
257 | ICMPV4_HEADER Header;\r | |
258 | UINT32 Reserved;\r | |
259 | } ICMPV4_ROUTER_SOLICIT_MESSAGE;\r | |
260 | \r | |
261 | #define MAX_SOLICITATION_DELAY 1 // 1 second\r | |
262 | #define SOLICITATION_INTERVAL 3 // 3 seconds\r | |
263 | #define MAX_SOLICITATIONS 3 // 3 transmissions\r | |
264 | #define V1ROUTER_PRESENT_TIMEOUT 400 // 400 second timeout until v2 reports can be sent\r | |
265 | #define UNSOLICITED_REPORT_INTERVAL 10 // 10 seconds between unsolicited reports\r | |
266 | #define BROADCAST_IPv4 0xffffffff\r | |
267 | \r | |
268 | //\r | |
269 | // Definitions for address resolution protocol message structure\r | |
270 | // Per RFC 826, November 1982\r | |
271 | //\r | |
272 | typedef struct {\r | |
273 | UINT16 HwType; // hardware type - e.g. ethernet (1)\r | |
274 | UINT16 ProtType; // protocol type - for ethernet, 0x800 for IP\r | |
275 | UINT8 HwAddLen; // byte length of a hardware address (e.g. 6 for ethernet)\r | |
276 | UINT8 ProtAddLen; // byte length of a protocol address (e.g. 4 for ipv4)\r | |
277 | UINT16 OpCode;\r | |
278 | //\r | |
279 | // source and dest hw and prot addresses follow - see example below\r | |
280 | //\r | |
281 | } ARP_HEADER;\r | |
282 | \r | |
283 | #define ETHERNET_ADD_SPC 1\r | |
284 | \r | |
285 | #define ETHER_TYPE_IP 0x800\r | |
286 | \r | |
287 | #define ARP_REQUEST 1\r | |
288 | #define ARP_REPLY 2\r | |
289 | \r | |
290 | //\r | |
291 | // generic ARP packet\r | |
292 | //\r | |
293 | typedef struct {\r | |
294 | ARP_HEADER ArpHeader;\r | |
295 | EFI_MAC_ADDRESS SrcHardwareAddr;\r | |
296 | EFI_IP_ADDRESS SrcProtocolAddr;\r | |
297 | EFI_MAC_ADDRESS DestHardwareAddr;\r | |
298 | EFI_IP_ADDRESS DestProtocolAddr;\r | |
299 | } ARP_PACKET;\r | |
300 | \r | |
301 | #define ENET_HWADDLEN 6\r | |
302 | #define IPV4_PROTADDLEN 4\r | |
303 | \r | |
304 | //\r | |
305 | // Definitions for user datagram protocol version 4 pseudo header & header\r | |
306 | // Per RFC 768, 28 August 1980\r | |
307 | //\r | |
308 | typedef struct {\r | |
309 | IPV4_ADDR SrcAddr; // source ip address\r | |
310 | IPV4_ADDR DestAddr; // dest ip address\r | |
311 | UINT8 Zero; // 0\r | |
312 | UINT8 Protocol; // protocol\r | |
313 | UINT16 TotalLength; // UDP length - sizeof udpv4hdr + data length\r | |
314 | } UDPV4_PSEUDO_HEADER;\r | |
315 | \r | |
316 | typedef struct {\r | |
317 | UINT16 SrcPort; // source port identifier\r | |
318 | UINT16 DestPort; // destination port identifier\r | |
319 | UINT16 TotalLength; // total length header plus data\r | |
320 | //\r | |
321 | // ones complement of ones complement sum of 16 bit\r | |
322 | // words of pseudo header, UDP header, and data\r | |
323 | // zero checksum is transmitted as -0 (ones comp)\r | |
324 | // zero transmitted means checksum not computed\r | |
325 | // data follows\r | |
326 | //\r | |
327 | UINT16 Checksum; \r | |
328 | } UDPV4_HEADER;\r | |
329 | \r | |
330 | typedef struct {\r | |
331 | UDPV4_PSEUDO_HEADER Udpv4PseudoHeader;\r | |
332 | UDPV4_HEADER Udpv4Header;\r | |
333 | } UDPV4_HEADERS;\r | |
334 | \r | |
335 | //\r | |
336 | // Definitions for transmission control protocol header\r | |
337 | // Per RFC 793, September, 1981\r | |
338 | //\r | |
339 | typedef struct {\r | |
340 | IPV4_ADDR SrcAddr; // source ip address\r | |
341 | IPV4_ADDR DestAddr; // dest ip address\r | |
342 | UINT8 Zero; // 0\r | |
343 | UINT8 Protocol; // protocol\r | |
344 | UINT16 TotalLength; // TCP length - TCP header length + data length\r | |
345 | } TCPV4_PSEUDO_HEADER;\r | |
346 | \r | |
347 | typedef struct {\r | |
348 | UINT16 SrcPort; // source port identifier\r | |
349 | UINT16 DestPort; // destination port identifier\r | |
350 | UINT32 SeqNumber; // Sequence number\r | |
351 | UINT32 AckNumber; // Acknowledgement Number\r | |
352 | //\r | |
353 | // Nibble of HLEN (length of header in 32-bit multiples)\r | |
354 | // 6bits of RESERVED\r | |
355 | // Nibble of Code Bits\r | |
356 | //\r | |
357 | UINT16 HlenResCode;\r | |
358 | UINT16 Window; // Software buffer size (sliding window size) in network-standard byte order\r | |
359 | //\r | |
360 | // ones complement of ones complement sum of 16 bit words of\r | |
361 | // pseudo header, TCP header, and data\r | |
362 | // zero checksum is transmitted as -0 (ones comp)\r | |
363 | // zero transmitted means checksum not computed\r | |
364 | //\r | |
365 | UINT16 Checksum; \r | |
366 | UINT16 UrgentPointer; // pointer to urgent data (allows sender to specify urgent data)\r | |
367 | } TCPV4_HEADER;\r | |
368 | \r | |
369 | typedef struct {\r | |
370 | TCPV4_PSEUDO_HEADER Tcpv4PseudoHeader;\r | |
371 | TCPV4_HEADER Tcpv4Header;\r | |
372 | } TCPV4_HEADERS;\r | |
373 | \r | |
374 | typedef struct {\r | |
375 | UINT8 Kind; // one of the following:\r | |
376 | UINT8 Length; // total option length including Kind and Lth\r | |
377 | UINT8 Data[1]; // length = Lth - 2\r | |
378 | } TCPV4_OPTION;\r | |
379 | \r | |
380 | #define TCP_OP_END 0 // only used to pad to end of TCP header\r | |
381 | #define TCP_NOP 1 // optional - may be used to pad between options to get alignment\r | |
382 | #define TCP_MAX_SEG 2 // maximum receive segment size - only send at initial connection request\r | |
383 | #define MAX_MEDIA_HDR_SIZE 64\r | |
384 | #define MIN_ENET_DATA_SIZE 64\r | |
385 | #define MAX_ENET_DATA_SIZE 1500 // temp def - make a network based var\r | |
386 | #define MAX_IPV4_PKT_SIZE 65535 // maximum IP packet size\r | |
387 | #define MAX_IPV4_DATA_SIZE (MAX_IPV4_PKT_SIZE - sizeof (IPV4_HEADER))\r | |
388 | #define MAX_IPV4_FRAME_DATA_SIZE (MAX_FRAME_DATA_SIZE - sizeof (IPV4_HEADER))\r | |
389 | #define REAS_IPV4_PKT_SIZE 576 // minimum IP packet size all IP host can handle\r | |
390 | #define REAS_IPV4_DATA_SIZE (REAS_IPV4_PKT_SIZE - sizeof (IPV4_HEADER))\r | |
391 | \r | |
392 | //\r | |
393 | //\r | |
394 | //\r | |
395 | typedef union {\r | |
396 | UINT8 Data[MAX_ENET_DATA_SIZE];\r | |
397 | ICMPV4_HEADER IcmpHeader;\r | |
398 | IGMPV2_MESSAGE IgmpMessage;\r | |
399 | struct {\r | |
400 | UDPV4_HEADER UdpHeader;\r | |
401 | UINT8 Data[1];\r | |
402 | } Udp;\r | |
403 | struct {\r | |
404 | TCPV4_HEADER TcpHeader;\r | |
405 | UINT8 Data[1];\r | |
406 | } Tcp;\r | |
407 | } PROTOCOL_UNION;\r | |
408 | \r | |
409 | //\r | |
410 | // out buffer structure\r | |
411 | //\r | |
412 | typedef struct {\r | |
413 | UINT8 MediaHeader[MAX_MEDIA_HDR_SIZE];\r | |
414 | IPV4_HEADER IpHeader;\r | |
415 | //\r | |
416 | // following union placement only valid if no option IP header\r | |
417 | //\r | |
418 | PROTOCOL_UNION u;\r | |
419 | } IPV4_BUFFER;\r | |
420 | \r | |
421 | typedef struct {\r | |
422 | IPV4_HEADER IpHeader;\r | |
423 | //\r | |
424 | // following union placement only valid if no option IP header\r | |
425 | //\r | |
426 | PROTOCOL_UNION u;\r | |
427 | } IPV4_STRUCT;\r | |
428 | \r | |
429 | #pragma pack() // reset to default\r | |
430 | \r | |
431 | ////////////////////////////////////////////////////////////\r | |
432 | //\r | |
433 | // BC IP Filter Routine\r | |
434 | //\r | |
435 | EFI_STATUS\r | |
436 | IpFilter (\r | |
437 | PXE_BASECODE_DEVICE *Private,\r | |
438 | IN EFI_PXE_BASE_CODE_IP_FILTER *Filter\r | |
439 | )\r | |
440 | ;\r | |
441 | \r | |
442 | //\r | |
443 | // //////////////////////////////////////////////////////////////////////\r | |
444 | //\r | |
445 | // Udp Write Routine - called by base code - e.g. TFTP - already locked\r | |
446 | //\r | |
447 | EFI_STATUS\r | |
448 | UdpWrite (\r | |
449 | IN PXE_BASECODE_DEVICE *Private,\r | |
450 | IN UINT16 OpFlags,\r | |
451 | IN EFI_IP_ADDRESS *DestIpPtr,\r | |
452 | IN EFI_PXE_BASE_CODE_UDP_PORT *DestPortptr,\r | |
453 | IN EFI_IP_ADDRESS *GatewayIpPtr, OPTIONAL\r | |
454 | IN EFI_IP_ADDRESS *SrcIpPtr, OPTIONAL\r | |
455 | IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPortPtr, OPTIONAL\r | |
456 | IN UINTN *HeaderSizePtr, OPTIONAL\r | |
457 | IN VOID *HeaderPtr, OPTIONAL\r | |
458 | IN UINTN *BufferSizePtr,\r | |
459 | IN VOID *BufferPtr\r | |
460 | )\r | |
461 | ;\r | |
462 | \r | |
463 | //\r | |
464 | // /////////////////////////////////////////////////////////////////////\r | |
465 | //\r | |
466 | // Udp Read Routine - called by base code - e.g. TFTP - already locked\r | |
467 | //\r | |
468 | EFI_STATUS\r | |
469 | UdpRead (\r | |
470 | IN PXE_BASECODE_DEVICE *Private,\r | |
471 | IN UINT16 OpFlags,\r | |
472 | IN OUT EFI_IP_ADDRESS *DestIpPtr, OPTIONAL\r | |
473 | IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPorPtrt, OPTIONAL\r | |
474 | IN OUT EFI_IP_ADDRESS *SrcIpPtr, OPTIONAL\r | |
475 | IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPortPtr, OPTIONAL\r | |
476 | IN UINTN *HeaderSizePtr, OPTIONAL\r | |
477 | IN VOID *HeaderPtr, OPTIONAL\r | |
478 | IN OUT UINTN *BufferSizePtr,\r | |
479 | IN VOID *BufferPtr,\r | |
480 | IN EFI_EVENT TimeoutEvent\r | |
481 | )\r | |
482 | ;\r | |
483 | \r | |
484 | VOID\r | |
485 | IgmpLeaveGroup (\r | |
486 | PXE_BASECODE_DEVICE *Private,\r | |
487 | EFI_IP_ADDRESS *\r | |
488 | )\r | |
489 | ;\r | |
490 | \r | |
491 | VOID\r | |
492 | IgmpJoinGroup (\r | |
493 | PXE_BASECODE_DEVICE *Private,\r | |
494 | EFI_IP_ADDRESS *\r | |
495 | )\r | |
496 | ;\r | |
497 | \r | |
498 | //\r | |
499 | // convert number to zero filled ascii value of length lth\r | |
500 | //\r | |
501 | VOID\r | |
502 | CvtNum (\r | |
503 | UINTN Number,\r | |
504 | UINT8 *BufferPtr,\r | |
505 | INTN BufferLen\r | |
506 | )\r | |
507 | ;\r | |
508 | \r | |
509 | //\r | |
510 | // convert number to ascii string at ptr\r | |
511 | //\r | |
512 | VOID\r | |
513 | UtoA10 (\r | |
514 | UINTN Number,\r | |
515 | UINT8 *BufferPtr\r | |
516 | )\r | |
517 | ;\r | |
518 | \r | |
519 | //\r | |
520 | // convert ascii numeric string to UINTN\r | |
521 | //\r | |
522 | UINTN\r | |
523 | AtoU (\r | |
524 | UINT8 *BufferPtr\r | |
525 | )\r | |
526 | ;\r | |
527 | \r | |
528 | UINT64\r | |
529 | AtoU64 (\r | |
530 | UINT8 *BufferPtr\r | |
531 | )\r | |
532 | ;\r | |
533 | \r | |
534 | //\r | |
535 | // calculate the internet checksum (RFC 1071)\r | |
536 | // return 16 bit ones complement of ones complement sum of 16 bit words\r | |
537 | //\r | |
538 | UINT16\r | |
539 | IpChecksum (\r | |
540 | UINT16 *MessagePtr,\r | |
541 | UINTN ByteLength\r | |
542 | )\r | |
543 | ;\r | |
544 | \r | |
545 | //\r | |
546 | // do checksum on non contiguous header and data\r | |
547 | //\r | |
548 | UINT16\r | |
549 | IpChecksum2 (\r | |
550 | UINT16 *Header,\r | |
551 | UINTN HeaderLength,\r | |
552 | UINT16 *Message,\r | |
553 | UINTN MessageLength\r | |
554 | )\r | |
555 | ;\r | |
556 | \r | |
557 | //\r | |
558 | // update checksum when only a single word changes\r | |
559 | //\r | |
560 | UINT16\r | |
561 | UpdateChecksum (\r | |
562 | UINT16 OldChecksum,\r | |
563 | UINT16 OldWord,\r | |
564 | UINT16 NewWord\r | |
565 | )\r | |
566 | ;\r | |
567 | \r | |
568 | VOID\r | |
569 | SeedRandom (\r | |
570 | IN PXE_BASECODE_DEVICE *Private,\r | |
571 | IN UINT16 InitialSeed\r | |
572 | )\r | |
573 | ;\r | |
574 | \r | |
575 | UINT16\r | |
576 | Random (\r | |
577 | IN PXE_BASECODE_DEVICE *Private\r | |
578 | )\r | |
579 | ;\r | |
580 | \r | |
581 | EFI_STATUS\r | |
582 | SendPacket (\r | |
583 | PXE_BASECODE_DEVICE *Private,\r | |
584 | VOID *HeaderPtr,\r | |
585 | VOID *PacketPtr,\r | |
586 | INTN PacketLength,\r | |
587 | VOID *HardwareAddress,\r | |
588 | UINT16 MediaProtocol,\r | |
589 | IN EFI_PXE_BASE_CODE_FUNCTION Function\r | |
590 | )\r | |
591 | ;\r | |
592 | \r | |
593 | VOID\r | |
594 | HandleArpReceive (\r | |
595 | PXE_BASECODE_DEVICE *Private,\r | |
596 | ARP_PACKET *ArpPacketPtr,\r | |
597 | VOID *HeaderPtr\r | |
598 | )\r | |
599 | ;\r | |
600 | \r | |
601 | VOID\r | |
602 | HandleIgmp (\r | |
603 | PXE_BASECODE_DEVICE *Private,\r | |
604 | IGMPV2_MESSAGE *IgmpMessageptr,\r | |
605 | UINTN IgmpMessageLen\r | |
606 | )\r | |
607 | ;\r | |
608 | \r | |
609 | VOID\r | |
610 | IgmpCheckTimers (\r | |
611 | PXE_BASECODE_DEVICE *Private\r | |
612 | )\r | |
613 | ; // poll when doing a receive\r | |
614 | // return hw add of IP and TRUE if available, otherwise FALSE\r | |
615 | //\r | |
616 | BOOLEAN\r | |
617 | GetHwAddr (\r | |
618 | IN PXE_BASECODE_DEVICE *Private,\r | |
619 | EFI_IP_ADDRESS *ProtocolAddressPtr,\r | |
620 | EFI_MAC_ADDRESS *HardwareAddressPtr\r | |
621 | )\r | |
622 | ;\r | |
623 | \r | |
624 | EFI_STATUS\r | |
625 | DoArp (\r | |
626 | IN PXE_BASECODE_DEVICE *Private,\r | |
627 | IN EFI_IP_ADDRESS *ProtocolAddressPtr,\r | |
628 | OUT EFI_MAC_ADDRESS *HardwareAddressptr\r | |
629 | )\r | |
630 | ;\r | |
631 | \r | |
632 | BOOLEAN\r | |
633 | OnSameSubnet (\r | |
634 | UINTN IpAddressLen,\r | |
635 | EFI_IP_ADDRESS *Ip1,\r | |
636 | EFI_IP_ADDRESS *Ip2,\r | |
637 | EFI_IP_ADDRESS *SubnetMask\r | |
638 | )\r | |
639 | ;\r | |
640 | \r | |
641 | VOID\r | |
642 | IpAddRouter (\r | |
643 | PXE_BASECODE_DEVICE *Private,\r | |
644 | EFI_IP_ADDRESS *RouterIp\r | |
645 | )\r | |
646 | ;\r | |
647 | \r | |
648 | #define Ip4AddRouter(Private, Ipv4Ptr) IpAddRouter (Private, (EFI_IP_ADDRESS *) Ipv4Ptr)\r | |
649 | \r | |
650 | //\r | |
651 | // routine to send ipv4 packet\r | |
652 | // ipv4 + upper protocol header for length TotHdrLth in xmtbuf, ipv4 header length IpHdrLth\r | |
653 | // routine fills in ipv4hdr Ver_Hdl, TotLth, and Checksum, moves in Data, and gets dest MAC address\r | |
654 | //\r | |
655 | EFI_STATUS\r | |
656 | Ipv4Xmt (\r | |
657 | PXE_BASECODE_DEVICE *Private,\r | |
658 | UINT32 GatewayIP,\r | |
659 | UINTN IpHeaderLen,\r | |
660 | UINTN TotalHeaderLen,\r | |
661 | VOID *Data,\r | |
662 | UINTN DataLen,\r | |
663 | EFI_PXE_BASE_CODE_FUNCTION Function\r | |
664 | )\r | |
665 | ;\r | |
666 | \r | |
667 | //\r | |
668 | // send ipv4 packet with ipv4 option\r | |
669 | //\r | |
670 | EFI_STATUS\r | |
671 | Ipv4SendWOp (\r | |
672 | PXE_BASECODE_DEVICE *Private,\r | |
673 | UINT32 GatewayIP,\r | |
674 | UINT8 *MessagePtr,\r | |
675 | UINTN MessageLth,\r | |
676 | UINT8 Protocol,\r | |
677 | UINT8 *Option,\r | |
678 | UINTN OptionLen,\r | |
679 | UINT32 DestIp,\r | |
680 | EFI_PXE_BASE_CODE_FUNCTION Function\r | |
681 | )\r | |
682 | ;\r | |
683 | \r | |
684 | //\r | |
685 | // send MsgLth message at MsgPtr - higher level protocol header already in xmtbuf, length HdrSize\r | |
686 | //\r | |
687 | EFI_STATUS\r | |
688 | Ip4Send (\r | |
689 | IN PXE_BASECODE_DEVICE *Private, // pointer to instance data\r | |
690 | IN UINTN MayFragment, //\r | |
691 | IN UINT8 Protocol, // protocol\r | |
692 | IN UINT32 SrcIp, // Source IP address\r | |
693 | IN UINT32 DestIp, // Destination IP address\r | |
694 | IN UINT32 GatewayIp, // used if not NULL and needed\r | |
695 | IN UINTN HeaderSize, // protocol header byte length\r | |
696 | IN UINT8 *MsgPtr, // pointer to data\r | |
697 | IN UINTN MsgLength\r | |
698 | )\r | |
699 | ; // data byte length\r | |
700 | // receive up to MsgLth message into MsgPtr for protocol Prot\r | |
701 | // return message length, src/dest ips if select any, and pointer to protocol header\r | |
702 | //\r | |
703 | EFI_STATUS\r | |
704 | IpReceive (\r | |
705 | IN PXE_BASECODE_DEVICE *Private, // pointer to instance data\r | |
706 | UINT16 OpFlags, // Flags to determine if filtering on IP addresses\r | |
707 | EFI_IP_ADDRESS *SrcIpPtr, // if filtering, O if accept any\r | |
708 | EFI_IP_ADDRESS *DstIpPtr, // if filtering, O if accept any\r | |
709 | UINT8 Protocol, // protocol\r | |
710 | VOID *HeaderPtr, // address of where to put protocol header\r | |
711 | UINTN HeaderSize, // protocol header byte length\r | |
712 | UINT8 *MsgPtr, // pointer to data buffer\r | |
713 | UINTN *MsgLenPtr, // pointer to data buffer length/ O - returned data length\r | |
714 | IN EFI_EVENT TimeoutEvent\r | |
715 | )\r | |
716 | ;\r | |
717 | \r | |
718 | #if 0\r | |
719 | VOID\r | |
720 | WaitForTxComplete (\r | |
721 | IN PXE_BASECODE_DEVICE *Private\r | |
722 | )\r | |
723 | ;\r | |
724 | #endif\r | |
725 | //\r | |
726 | // routine to cycle waiting for a receive or timeout\r | |
727 | //\r | |
728 | EFI_STATUS\r | |
729 | WaitForReceive (\r | |
730 | IN PXE_BASECODE_DEVICE *Private,\r | |
731 | IN EFI_PXE_BASE_CODE_FUNCTION Function,\r | |
732 | IN EFI_EVENT TimeoutEvent,\r | |
733 | IN OUT UINTN *HeaderSizePtr,\r | |
734 | IN OUT UINTN *BufferSizePtr,\r | |
735 | IN OUT UINT16 *ProtocolPtr\r | |
736 | )\r | |
737 | ;\r | |
738 | \r | |
739 | #endif /* _IP_H_ */\r | |
740 | \r | |
741 | /* EOF - ip.h */\r |