VirtualBox

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

Last change on this file since 11052 was 11052, checked in by vboxsync, 16 years ago

iprt/net.h: Added minimum lengths for DHCP and BOOTP packets.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.6 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/** @} */
137
138
139/**
140 * IPv4 header.
141 * All is bigendian on the wire.
142 */
143#pragma pack(1)
144typedef struct RTNETIPV4
145{
146#ifdef RT_BIG_ENDIAN
147 unsigned int ip_v : 4;
148 unsigned int ip_hl : 4;
149 unsigned int ip_tos : 8;
150 unsigned int ip_len : 16;
151#else
152 /** 00:0 - Header length given as a 32-bit word count. */
153 unsigned int ip_hl : 4;
154 /** 00:4 - Header version. */
155 unsigned int ip_v : 4;
156 /** 01 - Type of service. */
157 unsigned int ip_tos : 8;
158 /** 02 - Total length (header + data). */
159 unsigned int ip_len : 16;
160#endif
161 /** 04 - Packet idenficiation. */
162 uint16_t ip_id;
163 /** 06 - Offset if fragmented. */
164 uint16_t ip_off;
165 /** 08 - Time to live. */
166 uint8_t ip_ttl;
167 /** 09 - Protocol. */
168 uint8_t ip_p;
169 /** 0a - Header check sum. */
170 uint16_t ip_sum;
171 /** 0c - Source address. */
172 RTNETADDRIPV4 ip_src;
173 /** 10 - Destination address. */
174 RTNETADDRIPV4 ip_dst;
175 /** 14 - Options (optional). */
176 uint32_t ip_options[1];
177} RTNETIPV4;
178#pragma pack(0)
179AssertCompileSize(RTNETIPV4, 6 * 4);
180/** Pointer to a IPv4 header. */
181typedef RTNETIPV4 *PRTNETIPV4;
182/** Pointer to a const IPv4 header. */
183typedef RTNETIPV4 const *PCRTNETIPV4;
184
185/** The minimum IPv4 header length (in bytes).
186 * Up to and including RTNETIPV4::ip_dst. */
187#define RTNETIPV4_MIN_LEN (20)
188
189
190/** @name IPv4 Protocol Numbers
191 * @{ */
192/** IPv4: ICMP */
193#define RTNETIPV4_PROT_ICMP (0)
194/** IPv4: TCP */
195#define RTNETIPV4_PROT_TCP (6)
196/** IPv4: UDP */
197#define RTNETIPV4_PROT_UDP (17)
198/** @} */
199
200/** @name Common IPv4 Port Assignments
201 * @{
202 */
203/** Boostrap Protocol / DHCP) Server. */
204#define RTNETIPV4_PORT_BOOTPS (67)
205/** Boostrap Protocol / DHCP) Client. */
206#define RTNETIPV4_PORT_BOOTPC (68)
207/** @} */
208
209RTDECL(uint16_t) RTNetIPv4HdrChecksum(PCRTNETIPV4 pIpHdr);
210RTDECL(bool) RTNetIPv4IsHdrValid(PCRTNETIPV4 pIpHdr, size_t cbHdrMax, size_t cbPktMax);
211RTDECL(uint32_t) RTNetIPv4PseudoChecksum(PCRTNETIPV4 pIpHdr);
212RTDECL(uint32_t) RTNetIPv4PseudoChecksumBits(RTNETADDRIPV4 SrcAddr, RTNETADDRIPV4 DstAddr, uint8_t bProtocol, uint16_t cbPkt);
213RTDECL(uint32_t) RTNetIPv4AddDataChecksum(void const *pvData, size_t cbData, uint32_t u32Sum, bool *pfOdd);
214RTDECL(uint16_t) RTNetIPv4FinalizeChecksum(uint32_t u32Sum);
215
216
217/**
218 * UDP header.
219 */
220#pragma pack(1)
221typedef struct RTNETUDP
222{
223 /** The source port. */
224 uint16_t uh_sport;
225 /** The destination port. */
226 uint16_t uh_dport;
227 /** The length of the UDP header and associated data. */
228 uint16_t uh_ulen;
229 /** The checksum of the pseudo header, the UDP header and the data. */
230 uint16_t uh_sum;
231} RTNETUDP;
232#pragma pack(0)
233AssertCompileSize(RTNETUDP, 8);
234/** Pointer to an UDP header. */
235typedef RTNETUDP *PRTNETUDP;
236/** Pointer to a const UDP header. */
237typedef RTNETUDP const *PCRTNETUDP;
238
239/** The minimum UDP packet length (in bytes). (RTNETUDP::uh_ulen) */
240#define RTNETUDP_MIN_LEN (8)
241
242RTDECL(uint32_t) RTNetIPv4AddUDPChecksum(PCRTNETUDP pUdpHdr, uint32_t u32Sum);
243RTDECL(uint16_t) RTNetIPv4UDPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, void const *pvData);
244RTDECL(bool) RTNetIPv4IsUDPSizeValid(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, size_t cbPktMax);
245RTDECL(bool) RTNetIPv4IsUDPValid(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, void const *pvData, size_t cbPktMax);
246
247/**
248 * IPv4 BOOTP / DHCP packet.
249 */
250#pragma pack(1)
251typedef struct RTNETBOOTP
252{
253 /** 00 - The packet opcode. */
254 uint8_t bp_op;
255 /** 01 - Hardware address type. Same as RTNETARPHDR::ar_htype. */
256 uint8_t bp_htype;
257 /** 02 - Hardware address length. */
258 uint8_t bp_hlen;
259 /** 03 - Gateway hops. */
260 uint8_t bp_hops;
261 /** 04 - Transaction ID. */
262 uint32_t bp_xid;
263 /** 08 - Seconds since boot started. */
264 uint16_t bp_secs;
265 /** 0a - Unused (BOOTP) / Flags (DHCP). */
266 uint16_t bp_flags;
267 /** 0c - Client IPv4 address. */
268 RTNETADDRIPV4 bp_ciaddr;
269 /** 10 - Your IPv4 address. */
270 RTNETADDRIPV4 bp_yiaddr;
271 /** 14 - Server IPv4 address. */
272 RTNETADDRIPV4 bp_siaddr;
273 /** 18 - Gateway IPv4 address. */
274 RTNETADDRIPV4 bp_giaddr;
275 /** 1c - Client hardware address. */
276 union
277 {
278 uint8_t au8[16];
279 RTMAC Mac;
280 } bp_chaddr;
281 /** 2c - Server name. */
282 uint8_t bp_sname[64];
283 /** 6c - File name / more DHCP options. */
284 uint8_t bp_file[128];
285 /** ec - Vendor specific area (BOOTP) / Options (DHCP).
286 * @remark This is really 312 bytes in the DHCP version. */
287 union
288 {
289 uint8_t au8[128];
290 struct DHCP
291 {
292 /** ec - The DHCP cookie (RTNET_DHCP_COOKIE). */
293 uint32_t dhcp_cookie;
294 /** f0 - The DHCP options. */
295 uint8_t dhcp_opts[124];
296 } Dhcp;
297 } bp_vend;
298
299} RTNETBOOTP;
300#pragma pack(0)
301AssertCompileSize(RTNETBOOTP, 0xec + 128);
302/** Pointer to a BOOTP / DHCP packet. */
303typedef RTNETBOOTP *PRTNETBOOTP;
304/** Pointer to a const BOOTP / DHCP packet. */
305typedef RTNETBOOTP const *PCRTNETBOOTP;
306
307/** Minimum BOOTP packet length. For quick validation, no standard thing really. */
308#define RTNETBOOTP_MIN_LEN 0xec
309/** Minimum DHCP packet length. For quick validation, no standard thing really. */
310#define RTNETBOOTP_DHCP_MIN_LEN 0xf1
311
312/** @name BOOTP packet opcode values
313 * @{ */
314#define RTNETBOOTP_OP_REQUEST 1
315#define RTNETBOOTP_OP_REPLY 2
316/** @} */
317
318/** @name DHCP flags (RTNETBOOTP::bp_flags)
319 * @{ */
320#define RTNET_DHCP_FLAGS_NO_BROADCAST UINT16_C(0x8000) /** @todo check test!!! */
321/** @} */
322
323/** The DHCP cookie (network endian). */
324#define RTNET_DHCP_COOKIE UINT32_C(0x63825363)
325
326/**
327 * An IPv4 DHCP option header.
328 */
329typedef struct RTNETDHCPOPT
330{
331 /** 00 - The DHCP option. */
332 uint8_t dhcp_opt;
333 /** 01 - The data length (excluding this header). */
334 uint8_t dhcp_len;
335 /* 02 - The option data follows here, optional and of variable length. */
336} RTNETDHCPOPT;
337AssertCompileSize(RTNETDHCPOPT, 2);
338/** Pointer to a DHCP option header. */
339typedef RTNETDHCPOPT *PRTNETDHCPOPT;
340/** Pointer to a const DHCP option header. */
341typedef RTNETDHCPOPT const *PCRTNETDHCPOPT;
342
343/** @name DHCP options
344 * @{ */
345/** 1 byte padding, this has no dhcp_len field. */
346#define RTNET_DHCP_OPT_PAD 0
347/** Have a 8-bit message type value as data, see RTNET_DHCP_MT_*. */
348#define RTNET_DHCP_OPT_MSG_TYPE 53
349/** Marks the end of the DHCP options, this has no dhcp_len field. */
350#define RTNET_DHCP_OPT_END 255
351/** @} */
352
353/** @name DHCP Message Types (option 53)
354 * @{ */
355#define RTNET_DHCP_MT_DISCOVER 1
356#define RTNET_DHCP_MT_OFFER 2
357#define RTNET_DHCP_MT_REQUEST 3
358#define RTNET_DHCP_MT_DECLINE 4
359#define RTNET_DHCP_MT_ACK 5
360#define RTNET_DHCP_MT_NAC 6
361#define RTNET_DHCP_MT_RELEASE 7
362#define RTNET_DHCP_MT_INFORM 8
363/** @} */
364
365RTDECL(bool) RTNetIPv4IsDHCPValid(PCRTNETUDP pUdpHdr, PCRTNETBOOTP pDhcp, size_t cbDhcp, uint8_t *pMsgType);
366
367
368/**
369 * IPv4 DHCP packet.
370 * @obsolete Use RTNETBOOTP.
371 */
372#pragma pack(1)
373typedef struct RTNETDHCP
374{
375 /** 00 - The packet opcode. */
376 uint8_t Op;
377 /** Hardware address type. */
378 uint8_t HType;
379 /** Hardware address length. */
380 uint8_t HLen;
381 uint8_t Hops;
382 uint32_t XID;
383 uint16_t Secs;
384 uint16_t Flags;
385 /** Client IPv4 address. */
386 RTNETADDRIPV4 CIAddr;
387 /** Your IPv4 address. */
388 RTNETADDRIPV4 YIAddr;
389 /** Server IPv4 address. */
390 RTNETADDRIPV4 SIAddr;
391 /** Gateway IPv4 address. */
392 RTNETADDRIPV4 GIAddr;
393 /** Client hardware address. */
394 uint8_t CHAddr[16];
395 /** Server name. */
396 uint8_t SName[64];
397 uint8_t File[128];
398 uint8_t abMagic[4];
399 uint8_t DhcpOpt;
400 uint8_t DhcpLen; /* 1 */
401 uint8_t DhcpReq;
402 uint8_t abOptions[57];
403} RTNETDHCP;
404#pragma pack(0)
405/** @todo AssertCompileSize(RTNETDHCP, ); */
406/** Pointer to a DHCP packet. */
407typedef RTNETDHCP *PRTNETDHCP;
408/** Pointer to a const DHCP packet. */
409typedef RTNETDHCP const *PCRTNETDHCP;
410
411
412/**
413 * TCP packet.
414 */
415#pragma pack(1)
416typedef struct RTNETTCP
417{
418 /** 00 - The source port. */
419 uint16_t th_sport;
420 /** 02 - The destination port. */
421 uint16_t th_dport;
422 /** 04 - The sequence number. */
423 uint32_t th_seq;
424 /** 08 - The acknowledgement number. */
425 uint32_t th_ack;
426#ifdef RT_BIG_ENDIAN
427 unsigned int th_win : 16;
428 unsigned int th_flags : 8;
429 unsigned int th_off : 4;
430 unsigned int th_x2 : 4;
431#else
432 /** 0c:0 - Reserved. */
433 unsigned int th_x2 : 4;
434 /** 0c:4 - The data offset given as a dword count from the start of this header. */
435 unsigned int th_off : 4;
436 /** 0d - flags. */
437 unsigned int th_flags : 8;
438 /** 0e - The window. */
439 unsigned int th_win : 16;
440#endif
441 /** 10 - The checksum of the pseudo header, the TCP header and the data. */
442 uint16_t th_sum;
443 /** 12 - The urgent pointer. */
444 uint16_t th_urp;
445 /* (options follows here and then the data (aka text).) */
446} RTNETTCP;
447#pragma pack(0)
448AssertCompileSize(RTNETTCP, 20);
449/** Pointer to a TCP packet. */
450typedef RTNETTCP *PRTNETTCP;
451/** Pointer to a const TCP packet. */
452typedef RTNETTCP const *PCRTNETTCP;
453
454/** The minimum TCP header length (in bytes). (RTNETTCP::th_off * 4) */
455#define RTNETTCP_MIN_LEN (20)
456
457RTDECL(uint32_t) RTNetIPv4AddTCPChecksum(PCRTNETTCP pTcpHdr, uint32_t u32Sum);
458RTDECL(uint16_t) RTNetIPv4TCPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, void const *pvData);
459RTDECL(bool) RTNetIPv4IsTCPSizeValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, size_t cbPktMax);
460RTDECL(bool) RTNetIPv4IsTCPValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, void const *pvData, size_t cbPktMax);
461
462
463/**
464 * IPv4 ICMP packet header.
465 */
466#pragma pack(1)
467typedef struct RTNETICMPV4HDR
468{
469 /** 00 - The ICMP message type. */
470 uint8_t icmp_type;
471 /** 01 - Type specific code that further qualifies the message. */
472 uint8_t icmp_code;
473 /** 02 - Checksum of the ICMP message. */
474 uint16_t icmp_cksum;
475} RTNETICMPV4HDR;
476#pragma pack(0)
477AssertCompileSize(RTNETICMPV4HDR, 4);
478/** Pointer to an ICMP packet header. */
479typedef RTNETICMPV4HDR *PRTNETICMPV4HDR;
480/** Pointer to a const ICMP packet header. */
481typedef RTNETICMPV4HDR const *PCRTNETICMPV4HDR;
482
483/** @name ICMP (v4) message types.
484 * @{ */
485#define RTNETICMPV4_TYPE_ECHO_REPLY 0
486#define RTNETICMPV4_TYPE_ECHO_REQUEST 8
487#define RTNETICMPV4_TYPE_TRACEROUTE 30
488/** @} */
489
490/**
491 * IPv4 ICMP ECHO Reply & Request packet.
492 */
493#pragma pack(1)
494typedef struct RTNETICMPV4ECHO
495{
496 /** 00 - The ICMP header. */
497 RTNETICMPV4HDR Hdr;
498 /** 04 - The identifier to help the requestor match up the reply.
499 * Can be 0. Typically fixed value. */
500 uint16_t icmp_id;
501 /** 06 - The sequence number to help the requestor match up the reply.
502 * Can be 0. Typically incrementing between requests. */
503 uint16_t icmp_seq;
504 /** 08 - Variable length data that is to be returned unmodified in the reply. */
505 uint8_t icmp_data[1];
506} RTNETICMPV4ECHO;
507#pragma pack(0)
508AssertCompileSize(RTNETICMPV4ECHO, 9);
509/** Pointer to an ICMP ECHO packet. */
510typedef RTNETICMPV4ECHO *PRTNETICMPV4ECHO;
511/** Pointer to a const ICMP ECHO packet. */
512typedef RTNETICMPV4ECHO const *PCRTNETICMPV4ECHO;
513
514/**
515 * IPv4 ICMP TRACEROUTE packet.
516 * This is an reply to an IP packet with the traceroute option set.
517 */
518#pragma pack(1)
519typedef struct RTNETICMPV4TRACEROUTE
520{
521 /** 00 - The ICMP header. */
522 RTNETICMPV4HDR Hdr;
523 /** 04 - Identifier copied from the traceroute option's ID number. */
524 uint16_t icmp_id;
525 /** 06 - Unused. (Possibly an icmp_seq?) */
526 uint16_t icmp_void;
527 /** 08 - Outbound hop count. From the IP packet causing this message. */
528 uint16_t icmp_ohc;
529 /** 0a - Return hop count. From the IP packet causing this message. */
530 uint16_t icmp_rhc;
531 /** 0c - Output link speed, 0 if not known. */
532 uint32_t icmp_speed;
533 /** 10 - Output link MTU, 0 if not known. */
534 uint32_t icmp_mtu;
535} RTNETICMPV4TRACEROUTE;
536#pragma pack(0)
537AssertCompileSize(RTNETICMPV4TRACEROUTE, 20);
538/** Pointer to an ICMP TRACEROUTE packet. */
539typedef RTNETICMPV4TRACEROUTE *PRTNETICMPV4TRACEROUTE;
540/** Pointer to a const ICMP TRACEROUTE packet. */
541typedef RTNETICMPV4TRACEROUTE const *PCRTNETICMPV4TRACEROUTE;
542
543/** @todo add more ICMPv4 as needed. */
544
545/**
546 * IPv4 ICMP union packet.
547 */
548typedef union RTNETICMPV4
549{
550 RTNETICMPV4HDR Hdr;
551 RTNETICMPV4ECHO Echo;
552 RTNETICMPV4TRACEROUTE Traceroute;
553} RTNETICMPV4;
554/** Pointer to an ICMP union packet. */
555typedef RTNETICMPV4 *PRTNETICMPV4;
556/** Pointer to a const ICMP union packet. */
557typedef RTNETICMPV4 const *PCRTNETICMPV4;
558
559
560/** @todo add ICMPv6 when needed. */
561
562
563/**
564 * Ethernet ARP header.
565 */
566#pragma pack(1)
567typedef struct RTNETARPHDR
568{
569 /** The hardware type. */
570 uint16_t ar_htype;
571 /** The protocol type (ethertype). */
572 uint16_t ar_ptype;
573 /** The hardware address length. */
574 uint8_t ar_hlen;
575 /** The protocol address length. */
576 uint8_t ar_plen;
577 /** The operation. */
578 uint16_t ar_oper;
579} RTNETARPHDR;
580#pragma pack(0)
581AssertCompileSize(RTNETARPHDR, 8);
582/** Pointer to an ethernet ARP header. */
583typedef RTNETARPHDR *PRTNETARPHDR;
584/** Pointer to a const ethernet ARP header. */
585typedef RTNETARPHDR const *PCRTNETARPHDR;
586
587/** ARP hardware type - ethernet. */
588#define RTNET_ARP_ETHER UINT16_C(1)
589
590/** @name ARP operations
591 * @{ */
592#define RTNET_ARPOP_REQUEST UINT16_C(1) /**< Request hardward address given a protocol address (ARP). */
593#define RTNET_ARPOP_REPLY UINT16_C(2)
594#define RTNET_ARPOP_REVREQUEST UINT16_C(3) /**< Request protocol address given a hardware address (RARP). */
595#define RTNET_ARPOP_REVREPLY UINT16_C(4)
596#define RTNET_ARPOP_INVREQUEST UINT16_C(8) /**< Inverse ARP. */
597#define RTNET_ARPOP_INVREPLY UINT16_C(9)
598/** Check if an ARP operation is a request or not. */
599#define RTNET_ARPOP_IS_REQUEST(Op) ((Op) & 1)
600/** Check if an ARP operation is a reply or not. */
601#define RTNET_ARPOP_IS_REPLY(Op) (!RTNET_ARPOP_IS_REQUEST(Op))
602/** @} */
603
604
605/**
606 * Ethernet IPv4 + 6-byte MAC ARP request packet.
607 */
608#pragma pack(1)
609typedef struct RTNETARPIPV4
610{
611 /** ARP header. */
612 RTNETARPHDR Hdr;
613 /** The sender hardware address. */
614 RTMAC ar_sha;
615 /** The sender protocol address. */
616 RTNETADDRIPV4 ar_spa;
617 /** The target hardware address. */
618 RTMAC ar_tha;
619 /** The arget protocol address. */
620 RTNETADDRIPV4 ar_tpa;
621} RTNETARPIPV4;
622#pragma pack(0)
623AssertCompileSize(RTNETARPIPV4, 8+6+4+6+4);
624/** Pointer to an ethernet IPv4+MAC ARP request packet. */
625typedef RTNETARPIPV4 *PRTNETARPIPV4;
626/** Pointer to a const ethernet IPv4+MAC ARP request packet. */
627typedef RTNETARPIPV4 const *PCRTNETARPIPV4;
628
629
630/** @todo RTNETNDP (IPv6)*/
631
632
633/** @} */
634
635__END_DECLS
636
637#endif
638
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