VirtualBox

source: vbox/trunk/include/iprt/net.h@ 11270

Last change on this file since 11270 was 11054, checked in by vboxsync, 17 years ago

iprt/net.h: Added dummy IPX ethertypes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.8 KB
Line 
1/** @file
2 * IPRT - Network Protocols.
3 */
4
5/*
6 * Copyright (C) 2008 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___iprt_net_h
31#define ___iprt_net_h
32
33#include <iprt/cdefs.h>
34#include <iprt/types.h>
35#include <iprt/assert.h>
36
37
38__BEGIN_DECLS
39
40/** @defgroup grp_rt_net RTNet - Network Protocols
41 * @ingroup grp_rt
42 * @{
43 */
44
45/**
46 * IPv4 address.
47 */
48typedef RTUINT32U RTNETADDRIPV4;
49AssertCompileSize(RTNETADDRIPV4, 4);
50/** Pointer to a IPv4 address. */
51typedef RTNETADDRIPV4 *PRTNETADDRIPV4;
52/** Pointer to a const IPv4 address. */
53typedef RTNETADDRIPV4 const *PCRTNETADDRIPV4;
54
55/**
56 * IPv6 address.
57 */
58typedef RTUINT128U RTNETADDRIPV6;
59AssertCompileSize(RTNETADDRIPV6, 16);
60/** Pointer to a IPv4 address. */
61typedef RTNETADDRIPV6 *PRTNETADDRIPV6;
62/** Pointer to a const IPv4 address. */
63typedef RTNETADDRIPV6 const *PCRTNETADDRIPV6;
64
65/**
66 * IPX address.
67 */
68#pragma pack(1)
69typedef struct RTNETADDRIPX
70{
71 /** The network ID. */
72 uint32_t Network;
73 /** The node ID. (Defaults to the MAC address apparently.) */
74 RTMAC Node;
75} RTNETADDRIPX;
76#pragma pack(0)
77AssertCompileSize(RTNETADDRIPX, 4+6);
78/** Pointer to an IPX address. */
79typedef RTNETADDRIPX *PRTNETADDRIPX;
80/** Pointer to a const IPX address. */
81typedef RTNETADDRIPX const *PCRTNETADDRIPX;
82
83/**
84 * Address union.
85 */
86typedef union RTNETADDRU
87{
88 /** 64-bit view. */
89 uint64_t au64[2];
90 /** 32-bit view. */
91 uint32_t au32[4];
92 /** 16-bit view. */
93 uint16_t au16[8];
94 /** 8-bit view. */
95 uint8_t au8[16];
96 /** IPv4 view. */
97 RTNETADDRIPV4 IPv4;
98 /** IPv6 view. */
99 RTNETADDRIPV6 IPv6;
100 /** IPX view. */
101 RTNETADDRIPX Ipx;
102 /** MAC address view. */
103 RTMAC Mac;
104} RTNETADDRU;
105AssertCompileSize(RTNETADDRU, 16);
106/** Pointer to an address union. */
107typedef RTNETADDRU *PRTNETADDRU;
108/** Pointer to a const address union. */
109typedef RTNETADDRU const *PCRTNETADDRU;
110
111
112/**
113 * Ethernet header.
114 */
115#pragma pack(1)
116typedef struct RTNETETHERHDR
117{
118 RTMAC DstMac;
119 RTMAC SrcMac;
120 /** Ethernet frame type or frame size, depending on the kind of ethernet.
121 * This is big endian on the wire. */
122 uint16_t EtherType;
123} RTNETETHERHDR;
124#pragma pack()
125AssertCompileSize(RTNETETHERHDR, 14);
126/** Pointer to an ethernet header. */
127typedef RTNETETHERHDR *PRTNETETHERHDR;
128/** Pointer to a const ethernet header. */
129typedef RTNETETHERHDR const *PCRTNETETHERHDR;
130
131/** @name EtherType (RTNETETHERHDR::EtherType)
132 * @{ */
133#define RTNET_ETHERTYPE_IPV4 UINT16_C(0x0800)
134#define RTNET_ETHERTYPE_ARP UINT16_C(0x0806)
135#define RTNET_ETHERTYPE_IPV6 UINT16_C(0x86dd)
136#define RTNET_ETHERTYPE_IPX_1 UINT16_C(0x8037)
137#define RTNET_ETHERTYPE_IPX_2 UINT16_C(0x8137)
138#define RTNET_ETHERTYPE_IPX_3 UINT16_C(0x8138)
139/** @} */
140
141
142/**
143 * IPv4 header.
144 * All is bigendian on the wire.
145 */
146#pragma pack(1)
147typedef struct RTNETIPV4
148{
149#ifdef RT_BIG_ENDIAN
150 unsigned int ip_v : 4;
151 unsigned int ip_hl : 4;
152 unsigned int ip_tos : 8;
153 unsigned int ip_len : 16;
154#else
155 /** 00:0 - Header length given as a 32-bit word count. */
156 unsigned int ip_hl : 4;
157 /** 00:4 - Header version. */
158 unsigned int ip_v : 4;
159 /** 01 - Type of service. */
160 unsigned int ip_tos : 8;
161 /** 02 - Total length (header + data). */
162 unsigned int ip_len : 16;
163#endif
164 /** 04 - Packet idenficiation. */
165 uint16_t ip_id;
166 /** 06 - Offset if fragmented. */
167 uint16_t ip_off;
168 /** 08 - Time to live. */
169 uint8_t ip_ttl;
170 /** 09 - Protocol. */
171 uint8_t ip_p;
172 /** 0a - Header check sum. */
173 uint16_t ip_sum;
174 /** 0c - Source address. */
175 RTNETADDRIPV4 ip_src;
176 /** 10 - Destination address. */
177 RTNETADDRIPV4 ip_dst;
178 /** 14 - Options (optional). */
179 uint32_t ip_options[1];
180} RTNETIPV4;
181#pragma pack(0)
182AssertCompileSize(RTNETIPV4, 6 * 4);
183/** Pointer to a IPv4 header. */
184typedef RTNETIPV4 *PRTNETIPV4;
185/** Pointer to a const IPv4 header. */
186typedef RTNETIPV4 const *PCRTNETIPV4;
187
188/** The minimum IPv4 header length (in bytes).
189 * Up to and including RTNETIPV4::ip_dst. */
190#define RTNETIPV4_MIN_LEN (20)
191
192
193/** @name IPv4 Protocol Numbers
194 * @{ */
195/** IPv4: ICMP */
196#define RTNETIPV4_PROT_ICMP (0)
197/** IPv4: TCP */
198#define RTNETIPV4_PROT_TCP (6)
199/** IPv4: UDP */
200#define RTNETIPV4_PROT_UDP (17)
201/** @} */
202
203/** @name Common IPv4 Port Assignments
204 * @{
205 */
206/** Boostrap Protocol / DHCP) Server. */
207#define RTNETIPV4_PORT_BOOTPS (67)
208/** Boostrap Protocol / DHCP) Client. */
209#define RTNETIPV4_PORT_BOOTPC (68)
210/** @} */
211
212RTDECL(uint16_t) RTNetIPv4HdrChecksum(PCRTNETIPV4 pIpHdr);
213RTDECL(bool) RTNetIPv4IsHdrValid(PCRTNETIPV4 pIpHdr, size_t cbHdrMax, size_t cbPktMax);
214RTDECL(uint32_t) RTNetIPv4PseudoChecksum(PCRTNETIPV4 pIpHdr);
215RTDECL(uint32_t) RTNetIPv4PseudoChecksumBits(RTNETADDRIPV4 SrcAddr, RTNETADDRIPV4 DstAddr, uint8_t bProtocol, uint16_t cbPkt);
216RTDECL(uint32_t) RTNetIPv4AddDataChecksum(void const *pvData, size_t cbData, uint32_t u32Sum, bool *pfOdd);
217RTDECL(uint16_t) RTNetIPv4FinalizeChecksum(uint32_t u32Sum);
218
219
220/**
221 * UDP header.
222 */
223#pragma pack(1)
224typedef struct RTNETUDP
225{
226 /** The source port. */
227 uint16_t uh_sport;
228 /** The destination port. */
229 uint16_t uh_dport;
230 /** The length of the UDP header and associated data. */
231 uint16_t uh_ulen;
232 /** The checksum of the pseudo header, the UDP header and the data. */
233 uint16_t uh_sum;
234} RTNETUDP;
235#pragma pack(0)
236AssertCompileSize(RTNETUDP, 8);
237/** Pointer to an UDP header. */
238typedef RTNETUDP *PRTNETUDP;
239/** Pointer to a const UDP header. */
240typedef RTNETUDP const *PCRTNETUDP;
241
242/** The minimum UDP packet length (in bytes). (RTNETUDP::uh_ulen) */
243#define RTNETUDP_MIN_LEN (8)
244
245RTDECL(uint32_t) RTNetIPv4AddUDPChecksum(PCRTNETUDP pUdpHdr, uint32_t u32Sum);
246RTDECL(uint16_t) RTNetIPv4UDPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, void const *pvData);
247RTDECL(bool) RTNetIPv4IsUDPSizeValid(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, size_t cbPktMax);
248RTDECL(bool) RTNetIPv4IsUDPValid(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, void const *pvData, size_t cbPktMax);
249
250/**
251 * IPv4 BOOTP / DHCP packet.
252 */
253#pragma pack(1)
254typedef struct RTNETBOOTP
255{
256 /** 00 - The packet opcode. */
257 uint8_t bp_op;
258 /** 01 - Hardware address type. Same as RTNETARPHDR::ar_htype. */
259 uint8_t bp_htype;
260 /** 02 - Hardware address length. */
261 uint8_t bp_hlen;
262 /** 03 - Gateway hops. */
263 uint8_t bp_hops;
264 /** 04 - Transaction ID. */
265 uint32_t bp_xid;
266 /** 08 - Seconds since boot started. */
267 uint16_t bp_secs;
268 /** 0a - Unused (BOOTP) / Flags (DHCP). */
269 uint16_t bp_flags;
270 /** 0c - Client IPv4 address. */
271 RTNETADDRIPV4 bp_ciaddr;
272 /** 10 - Your IPv4 address. */
273 RTNETADDRIPV4 bp_yiaddr;
274 /** 14 - Server IPv4 address. */
275 RTNETADDRIPV4 bp_siaddr;
276 /** 18 - Gateway IPv4 address. */
277 RTNETADDRIPV4 bp_giaddr;
278 /** 1c - Client hardware address. */
279 union
280 {
281 uint8_t au8[16];
282 RTMAC Mac;
283 } bp_chaddr;
284 /** 2c - Server name. */
285 uint8_t bp_sname[64];
286 /** 6c - File name / more DHCP options. */
287 uint8_t bp_file[128];
288 /** ec - Vendor specific area (BOOTP) / Options (DHCP).
289 * @remark This is really 312 bytes in the DHCP version. */
290 union
291 {
292 uint8_t au8[128];
293 struct DHCP
294 {
295 /** ec - The DHCP cookie (RTNET_DHCP_COOKIE). */
296 uint32_t dhcp_cookie;
297 /** f0 - The DHCP options. */
298 uint8_t dhcp_opts[124];
299 } Dhcp;
300 } bp_vend;
301
302} RTNETBOOTP;
303#pragma pack(0)
304AssertCompileSize(RTNETBOOTP, 0xec + 128);
305/** Pointer to a BOOTP / DHCP packet. */
306typedef RTNETBOOTP *PRTNETBOOTP;
307/** Pointer to a const BOOTP / DHCP packet. */
308typedef RTNETBOOTP const *PCRTNETBOOTP;
309
310/** Minimum BOOTP packet length. For quick validation, no standard thing really. */
311#define RTNETBOOTP_MIN_LEN 0xec
312/** Minimum DHCP packet length. For quick validation, no standard thing really. */
313#define RTNETBOOTP_DHCP_MIN_LEN 0xf1
314
315/** @name BOOTP packet opcode values
316 * @{ */
317#define RTNETBOOTP_OP_REQUEST 1
318#define RTNETBOOTP_OP_REPLY 2
319/** @} */
320
321/** @name DHCP flags (RTNETBOOTP::bp_flags)
322 * @{ */
323#define RTNET_DHCP_FLAGS_NO_BROADCAST UINT16_C(0x8000) /** @todo check test!!! */
324/** @} */
325
326/** The DHCP cookie (network endian). */
327#define RTNET_DHCP_COOKIE UINT32_C(0x63825363)
328
329/**
330 * An IPv4 DHCP option header.
331 */
332typedef struct RTNETDHCPOPT
333{
334 /** 00 - The DHCP option. */
335 uint8_t dhcp_opt;
336 /** 01 - The data length (excluding this header). */
337 uint8_t dhcp_len;
338 /* 02 - The option data follows here, optional and of variable length. */
339} RTNETDHCPOPT;
340AssertCompileSize(RTNETDHCPOPT, 2);
341/** Pointer to a DHCP option header. */
342typedef RTNETDHCPOPT *PRTNETDHCPOPT;
343/** Pointer to a const DHCP option header. */
344typedef RTNETDHCPOPT const *PCRTNETDHCPOPT;
345
346/** @name DHCP options
347 * @{ */
348/** 1 byte padding, this has no dhcp_len field. */
349#define RTNET_DHCP_OPT_PAD 0
350/** Have a 8-bit message type value as data, see RTNET_DHCP_MT_*. */
351#define RTNET_DHCP_OPT_MSG_TYPE 53
352/** Marks the end of the DHCP options, this has no dhcp_len field. */
353#define RTNET_DHCP_OPT_END 255
354/** @} */
355
356/** @name DHCP Message Types (option 53)
357 * @{ */
358#define RTNET_DHCP_MT_DISCOVER 1
359#define RTNET_DHCP_MT_OFFER 2
360#define RTNET_DHCP_MT_REQUEST 3
361#define RTNET_DHCP_MT_DECLINE 4
362#define RTNET_DHCP_MT_ACK 5
363#define RTNET_DHCP_MT_NAC 6
364#define RTNET_DHCP_MT_RELEASE 7
365#define RTNET_DHCP_MT_INFORM 8
366/** @} */
367
368RTDECL(bool) RTNetIPv4IsDHCPValid(PCRTNETUDP pUdpHdr, PCRTNETBOOTP pDhcp, size_t cbDhcp, uint8_t *pMsgType);
369
370
371/**
372 * IPv4 DHCP packet.
373 * @obsolete Use RTNETBOOTP.
374 */
375#pragma pack(1)
376typedef struct RTNETDHCP
377{
378 /** 00 - The packet opcode. */
379 uint8_t Op;
380 /** Hardware address type. */
381 uint8_t HType;
382 /** Hardware address length. */
383 uint8_t HLen;
384 uint8_t Hops;
385 uint32_t XID;
386 uint16_t Secs;
387 uint16_t Flags;
388 /** Client IPv4 address. */
389 RTNETADDRIPV4 CIAddr;
390 /** Your IPv4 address. */
391 RTNETADDRIPV4 YIAddr;
392 /** Server IPv4 address. */
393 RTNETADDRIPV4 SIAddr;
394 /** Gateway IPv4 address. */
395 RTNETADDRIPV4 GIAddr;
396 /** Client hardware address. */
397 uint8_t CHAddr[16];
398 /** Server name. */
399 uint8_t SName[64];
400 uint8_t File[128];
401 uint8_t abMagic[4];
402 uint8_t DhcpOpt;
403 uint8_t DhcpLen; /* 1 */
404 uint8_t DhcpReq;
405 uint8_t abOptions[57];
406} RTNETDHCP;
407#pragma pack(0)
408/** @todo AssertCompileSize(RTNETDHCP, ); */
409/** Pointer to a DHCP packet. */
410typedef RTNETDHCP *PRTNETDHCP;
411/** Pointer to a const DHCP packet. */
412typedef RTNETDHCP const *PCRTNETDHCP;
413
414
415/**
416 * TCP packet.
417 */
418#pragma pack(1)
419typedef struct RTNETTCP
420{
421 /** 00 - The source port. */
422 uint16_t th_sport;
423 /** 02 - The destination port. */
424 uint16_t th_dport;
425 /** 04 - The sequence number. */
426 uint32_t th_seq;
427 /** 08 - The acknowledgement number. */
428 uint32_t th_ack;
429#ifdef RT_BIG_ENDIAN
430 unsigned int th_win : 16;
431 unsigned int th_flags : 8;
432 unsigned int th_off : 4;
433 unsigned int th_x2 : 4;
434#else
435 /** 0c:0 - Reserved. */
436 unsigned int th_x2 : 4;
437 /** 0c:4 - The data offset given as a dword count from the start of this header. */
438 unsigned int th_off : 4;
439 /** 0d - flags. */
440 unsigned int th_flags : 8;
441 /** 0e - The window. */
442 unsigned int th_win : 16;
443#endif
444 /** 10 - The checksum of the pseudo header, the TCP header and the data. */
445 uint16_t th_sum;
446 /** 12 - The urgent pointer. */
447 uint16_t th_urp;
448 /* (options follows here and then the data (aka text).) */
449} RTNETTCP;
450#pragma pack(0)
451AssertCompileSize(RTNETTCP, 20);
452/** Pointer to a TCP packet. */
453typedef RTNETTCP *PRTNETTCP;
454/** Pointer to a const TCP packet. */
455typedef RTNETTCP const *PCRTNETTCP;
456
457/** The minimum TCP header length (in bytes). (RTNETTCP::th_off * 4) */
458#define RTNETTCP_MIN_LEN (20)
459
460RTDECL(uint32_t) RTNetIPv4AddTCPChecksum(PCRTNETTCP pTcpHdr, uint32_t u32Sum);
461RTDECL(uint16_t) RTNetIPv4TCPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, void const *pvData);
462RTDECL(bool) RTNetIPv4IsTCPSizeValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, size_t cbPktMax);
463RTDECL(bool) RTNetIPv4IsTCPValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, void const *pvData, size_t cbPktMax);
464
465
466/**
467 * IPv4 ICMP packet header.
468 */
469#pragma pack(1)
470typedef struct RTNETICMPV4HDR
471{
472 /** 00 - The ICMP message type. */
473 uint8_t icmp_type;
474 /** 01 - Type specific code that further qualifies the message. */
475 uint8_t icmp_code;
476 /** 02 - Checksum of the ICMP message. */
477 uint16_t icmp_cksum;
478} RTNETICMPV4HDR;
479#pragma pack(0)
480AssertCompileSize(RTNETICMPV4HDR, 4);
481/** Pointer to an ICMP packet header. */
482typedef RTNETICMPV4HDR *PRTNETICMPV4HDR;
483/** Pointer to a const ICMP packet header. */
484typedef RTNETICMPV4HDR const *PCRTNETICMPV4HDR;
485
486/** @name ICMP (v4) message types.
487 * @{ */
488#define RTNETICMPV4_TYPE_ECHO_REPLY 0
489#define RTNETICMPV4_TYPE_ECHO_REQUEST 8
490#define RTNETICMPV4_TYPE_TRACEROUTE 30
491/** @} */
492
493/**
494 * IPv4 ICMP ECHO Reply & Request packet.
495 */
496#pragma pack(1)
497typedef struct RTNETICMPV4ECHO
498{
499 /** 00 - The ICMP header. */
500 RTNETICMPV4HDR Hdr;
501 /** 04 - The identifier to help the requestor match up the reply.
502 * Can be 0. Typically fixed value. */
503 uint16_t icmp_id;
504 /** 06 - The sequence number to help the requestor match up the reply.
505 * Can be 0. Typically incrementing between requests. */
506 uint16_t icmp_seq;
507 /** 08 - Variable length data that is to be returned unmodified in the reply. */
508 uint8_t icmp_data[1];
509} RTNETICMPV4ECHO;
510#pragma pack(0)
511AssertCompileSize(RTNETICMPV4ECHO, 9);
512/** Pointer to an ICMP ECHO packet. */
513typedef RTNETICMPV4ECHO *PRTNETICMPV4ECHO;
514/** Pointer to a const ICMP ECHO packet. */
515typedef RTNETICMPV4ECHO const *PCRTNETICMPV4ECHO;
516
517/**
518 * IPv4 ICMP TRACEROUTE packet.
519 * This is an reply to an IP packet with the traceroute option set.
520 */
521#pragma pack(1)
522typedef struct RTNETICMPV4TRACEROUTE
523{
524 /** 00 - The ICMP header. */
525 RTNETICMPV4HDR Hdr;
526 /** 04 - Identifier copied from the traceroute option's ID number. */
527 uint16_t icmp_id;
528 /** 06 - Unused. (Possibly an icmp_seq?) */
529 uint16_t icmp_void;
530 /** 08 - Outbound hop count. From the IP packet causing this message. */
531 uint16_t icmp_ohc;
532 /** 0a - Return hop count. From the IP packet causing this message. */
533 uint16_t icmp_rhc;
534 /** 0c - Output link speed, 0 if not known. */
535 uint32_t icmp_speed;
536 /** 10 - Output link MTU, 0 if not known. */
537 uint32_t icmp_mtu;
538} RTNETICMPV4TRACEROUTE;
539#pragma pack(0)
540AssertCompileSize(RTNETICMPV4TRACEROUTE, 20);
541/** Pointer to an ICMP TRACEROUTE packet. */
542typedef RTNETICMPV4TRACEROUTE *PRTNETICMPV4TRACEROUTE;
543/** Pointer to a const ICMP TRACEROUTE packet. */
544typedef RTNETICMPV4TRACEROUTE const *PCRTNETICMPV4TRACEROUTE;
545
546/** @todo add more ICMPv4 as needed. */
547
548/**
549 * IPv4 ICMP union packet.
550 */
551typedef union RTNETICMPV4
552{
553 RTNETICMPV4HDR Hdr;
554 RTNETICMPV4ECHO Echo;
555 RTNETICMPV4TRACEROUTE Traceroute;
556} RTNETICMPV4;
557/** Pointer to an ICMP union packet. */
558typedef RTNETICMPV4 *PRTNETICMPV4;
559/** Pointer to a const ICMP union packet. */
560typedef RTNETICMPV4 const *PCRTNETICMPV4;
561
562
563/** @todo add ICMPv6 when needed. */
564
565
566/**
567 * Ethernet ARP header.
568 */
569#pragma pack(1)
570typedef struct RTNETARPHDR
571{
572 /** The hardware type. */
573 uint16_t ar_htype;
574 /** The protocol type (ethertype). */
575 uint16_t ar_ptype;
576 /** The hardware address length. */
577 uint8_t ar_hlen;
578 /** The protocol address length. */
579 uint8_t ar_plen;
580 /** The operation. */
581 uint16_t ar_oper;
582} RTNETARPHDR;
583#pragma pack(0)
584AssertCompileSize(RTNETARPHDR, 8);
585/** Pointer to an ethernet ARP header. */
586typedef RTNETARPHDR *PRTNETARPHDR;
587/** Pointer to a const ethernet ARP header. */
588typedef RTNETARPHDR const *PCRTNETARPHDR;
589
590/** ARP hardware type - ethernet. */
591#define RTNET_ARP_ETHER UINT16_C(1)
592
593/** @name ARP operations
594 * @{ */
595#define RTNET_ARPOP_REQUEST UINT16_C(1) /**< Request hardward address given a protocol address (ARP). */
596#define RTNET_ARPOP_REPLY UINT16_C(2)
597#define RTNET_ARPOP_REVREQUEST UINT16_C(3) /**< Request protocol address given a hardware address (RARP). */
598#define RTNET_ARPOP_REVREPLY UINT16_C(4)
599#define RTNET_ARPOP_INVREQUEST UINT16_C(8) /**< Inverse ARP. */
600#define RTNET_ARPOP_INVREPLY UINT16_C(9)
601/** Check if an ARP operation is a request or not. */
602#define RTNET_ARPOP_IS_REQUEST(Op) ((Op) & 1)
603/** Check if an ARP operation is a reply or not. */
604#define RTNET_ARPOP_IS_REPLY(Op) (!RTNET_ARPOP_IS_REQUEST(Op))
605/** @} */
606
607
608/**
609 * Ethernet IPv4 + 6-byte MAC ARP request packet.
610 */
611#pragma pack(1)
612typedef struct RTNETARPIPV4
613{
614 /** ARP header. */
615 RTNETARPHDR Hdr;
616 /** The sender hardware address. */
617 RTMAC ar_sha;
618 /** The sender protocol address. */
619 RTNETADDRIPV4 ar_spa;
620 /** The target hardware address. */
621 RTMAC ar_tha;
622 /** The arget protocol address. */
623 RTNETADDRIPV4 ar_tpa;
624} RTNETARPIPV4;
625#pragma pack(0)
626AssertCompileSize(RTNETARPIPV4, 8+6+4+6+4);
627/** Pointer to an ethernet IPv4+MAC ARP request packet. */
628typedef RTNETARPIPV4 *PRTNETARPIPV4;
629/** Pointer to a const ethernet IPv4+MAC ARP request packet. */
630typedef RTNETARPIPV4 const *PCRTNETARPIPV4;
631
632
633/** @todo RTNETNDP (IPv6)*/
634
635
636/** @} */
637
638__END_DECLS
639
640#endif
641
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette