VirtualBox

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

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

IPRT/RTNetIPv4: Rewrote the RTNETDHCP header as RTNETBOOTP and associated structures and defines. Added RTNetIPv4IsDHCPValid for validating a DHCP packet and dig out the message type option

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.4 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/** @name BOOTP packet opcode values
308 * @{ */
309#define RTNETBOOTP_OP_REQUEST 1
310#define RTNETBOOTP_OP_REPLY 2
311/** @} */
312
313/** @name DHCP flags (RTNETBOOTP::bp_flags)
314 * @{ */
315#define RTNET_DHCP_FLAGS_NO_BROADCAST UINT16_C(0x8000) /** @todo check test!!! */
316/** @} */
317
318/** The DHCP cookie (network endian). */
319#define RTNET_DHCP_COOKIE UINT32_C(0x63825363)
320
321/**
322 * An IPv4 DHCP option header.
323 */
324typedef struct RTNETDHCPOPT
325{
326 /** 00 - The DHCP option. */
327 uint8_t dhcp_opt;
328 /** 01 - The data length (excluding this header). */
329 uint8_t dhcp_len;
330 /* 02 - The option data follows here, optional and of variable length. */
331} RTNETDHCPOPT;
332AssertCompileSize(RTNETDHCPOPT, 2);
333/** Pointer to a DHCP option header. */
334typedef RTNETDHCPOPT *PRTNETDHCPOPT;
335/** Pointer to a const DHCP option header. */
336typedef RTNETDHCPOPT const *PCRTNETDHCPOPT;
337
338/** @name DHCP options
339 * @{ */
340/** 1 byte padding, this has no dhcp_len field. */
341#define RTNET_DHCP_OPT_PAD 0
342/** Have a 8-bit message type value as data, see RTNET_DHCP_MT_*. */
343#define RTNET_DHCP_OPT_MSG_TYPE 53
344/** Marks the end of the DHCP options, this has no dhcp_len field. */
345#define RTNET_DHCP_OPT_END 255
346/** @} */
347
348/** @name DHCP Message Types (option 53)
349 * @{ */
350#define RTNET_DHCP_MT_DISCOVER 1
351#define RTNET_DHCP_MT_OFFER 2
352#define RTNET_DHCP_MT_REQUEST 3
353#define RTNET_DHCP_MT_DECLINE 4
354#define RTNET_DHCP_MT_ACK 5
355#define RTNET_DHCP_MT_NAC 6
356#define RTNET_DHCP_MT_RELEASE 7
357#define RTNET_DHCP_MT_INFORM 8
358/** @} */
359
360RTDECL(bool) RTNetIPv4IsDHCPValid(PCRTNETUDP pUdpHdr, PCRTNETBOOTP pDhcp, size_t cbDhcp, uint8_t *pMsgType);
361
362
363/**
364 * IPv4 DHCP packet.
365 * @obsolete Use RTNETBOOTP.
366 */
367#pragma pack(1)
368typedef struct RTNETDHCP
369{
370 /** 00 - The packet opcode. */
371 uint8_t Op;
372 /** Hardware address type. */
373 uint8_t HType;
374 /** Hardware address length. */
375 uint8_t HLen;
376 uint8_t Hops;
377 uint32_t XID;
378 uint16_t Secs;
379 uint16_t Flags;
380 /** Client IPv4 address. */
381 RTNETADDRIPV4 CIAddr;
382 /** Your IPv4 address. */
383 RTNETADDRIPV4 YIAddr;
384 /** Server IPv4 address. */
385 RTNETADDRIPV4 SIAddr;
386 /** Gateway IPv4 address. */
387 RTNETADDRIPV4 GIAddr;
388 /** Client hardware address. */
389 uint8_t CHAddr[16];
390 /** Server name. */
391 uint8_t SName[64];
392 uint8_t File[128];
393 uint8_t abMagic[4];
394 uint8_t DhcpOpt;
395 uint8_t DhcpLen; /* 1 */
396 uint8_t DhcpReq;
397 uint8_t abOptions[57];
398} RTNETDHCP;
399#pragma pack(0)
400/** @todo AssertCompileSize(RTNETDHCP, ); */
401/** Pointer to a DHCP packet. */
402typedef RTNETDHCP *PRTNETDHCP;
403/** Pointer to a const DHCP packet. */
404typedef RTNETDHCP const *PCRTNETDHCP;
405
406
407/**
408 * TCP packet.
409 */
410#pragma pack(1)
411typedef struct RTNETTCP
412{
413 /** 00 - The source port. */
414 uint16_t th_sport;
415 /** 02 - The destination port. */
416 uint16_t th_dport;
417 /** 04 - The sequence number. */
418 uint32_t th_seq;
419 /** 08 - The acknowledgement number. */
420 uint32_t th_ack;
421#ifdef RT_BIG_ENDIAN
422 unsigned int th_win : 16;
423 unsigned int th_flags : 8;
424 unsigned int th_off : 4;
425 unsigned int th_x2 : 4;
426#else
427 /** 0c:0 - Reserved. */
428 unsigned int th_x2 : 4;
429 /** 0c:4 - The data offset given as a dword count from the start of this header. */
430 unsigned int th_off : 4;
431 /** 0d - flags. */
432 unsigned int th_flags : 8;
433 /** 0e - The window. */
434 unsigned int th_win : 16;
435#endif
436 /** 10 - The checksum of the pseudo header, the TCP header and the data. */
437 uint16_t th_sum;
438 /** 12 - The urgent pointer. */
439 uint16_t th_urp;
440 /* (options follows here and then the data (aka text).) */
441} RTNETTCP;
442#pragma pack(0)
443AssertCompileSize(RTNETTCP, 20);
444/** Pointer to a TCP packet. */
445typedef RTNETTCP *PRTNETTCP;
446/** Pointer to a const TCP packet. */
447typedef RTNETTCP const *PCRTNETTCP;
448
449/** The minimum TCP header length (in bytes). (RTNETTCP::th_off * 4) */
450#define RTNETTCP_MIN_LEN (20)
451
452RTDECL(uint32_t) RTNetIPv4AddTCPChecksum(PCRTNETTCP pTcpHdr, uint32_t u32Sum);
453RTDECL(uint16_t) RTNetIPv4TCPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, void const *pvData);
454RTDECL(bool) RTNetIPv4IsTCPSizeValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, size_t cbPktMax);
455RTDECL(bool) RTNetIPv4IsTCPValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, void const *pvData, size_t cbPktMax);
456
457
458/**
459 * IPv4 ICMP packet header.
460 */
461#pragma pack(1)
462typedef struct RTNETICMPV4HDR
463{
464 /** 00 - The ICMP message type. */
465 uint8_t icmp_type;
466 /** 01 - Type specific code that further qualifies the message. */
467 uint8_t icmp_code;
468 /** 02 - Checksum of the ICMP message. */
469 uint16_t icmp_cksum;
470} RTNETICMPV4HDR;
471#pragma pack(0)
472AssertCompileSize(RTNETICMPV4HDR, 4);
473/** Pointer to an ICMP packet header. */
474typedef RTNETICMPV4HDR *PRTNETICMPV4HDR;
475/** Pointer to a const ICMP packet header. */
476typedef RTNETICMPV4HDR const *PCRTNETICMPV4HDR;
477
478/** @name ICMP (v4) message types.
479 * @{ */
480#define RTNETICMPV4_TYPE_ECHO_REPLY 0
481#define RTNETICMPV4_TYPE_ECHO_REQUEST 8
482#define RTNETICMPV4_TYPE_TRACEROUTE 30
483/** @} */
484
485/**
486 * IPv4 ICMP ECHO Reply & Request packet.
487 */
488#pragma pack(1)
489typedef struct RTNETICMPV4ECHO
490{
491 /** 00 - The ICMP header. */
492 RTNETICMPV4HDR Hdr;
493 /** 04 - The identifier to help the requestor match up the reply.
494 * Can be 0. Typically fixed value. */
495 uint16_t icmp_id;
496 /** 06 - The sequence number to help the requestor match up the reply.
497 * Can be 0. Typically incrementing between requests. */
498 uint16_t icmp_seq;
499 /** 08 - Variable length data that is to be returned unmodified in the reply. */
500 uint8_t icmp_data[1];
501} RTNETICMPV4ECHO;
502#pragma pack(0)
503AssertCompileSize(RTNETICMPV4ECHO, 9);
504/** Pointer to an ICMP ECHO packet. */
505typedef RTNETICMPV4ECHO *PRTNETICMPV4ECHO;
506/** Pointer to a const ICMP ECHO packet. */
507typedef RTNETICMPV4ECHO const *PCRTNETICMPV4ECHO;
508
509/**
510 * IPv4 ICMP TRACEROUTE packet.
511 * This is an reply to an IP packet with the traceroute option set.
512 */
513#pragma pack(1)
514typedef struct RTNETICMPV4TRACEROUTE
515{
516 /** 00 - The ICMP header. */
517 RTNETICMPV4HDR Hdr;
518 /** 04 - Identifier copied from the traceroute option's ID number. */
519 uint16_t icmp_id;
520 /** 06 - Unused. (Possibly an icmp_seq?) */
521 uint16_t icmp_void;
522 /** 08 - Outbound hop count. From the IP packet causing this message. */
523 uint16_t icmp_ohc;
524 /** 0a - Return hop count. From the IP packet causing this message. */
525 uint16_t icmp_rhc;
526 /** 0c - Output link speed, 0 if not known. */
527 uint32_t icmp_speed;
528 /** 10 - Output link MTU, 0 if not known. */
529 uint32_t icmp_mtu;
530} RTNETICMPV4TRACEROUTE;
531#pragma pack(0)
532AssertCompileSize(RTNETICMPV4TRACEROUTE, 20);
533/** Pointer to an ICMP TRACEROUTE packet. */
534typedef RTNETICMPV4TRACEROUTE *PRTNETICMPV4TRACEROUTE;
535/** Pointer to a const ICMP TRACEROUTE packet. */
536typedef RTNETICMPV4TRACEROUTE const *PCRTNETICMPV4TRACEROUTE;
537
538/** @todo add more ICMPv4 as needed. */
539
540/**
541 * IPv4 ICMP union packet.
542 */
543typedef union RTNETICMPV4
544{
545 RTNETICMPV4HDR Hdr;
546 RTNETICMPV4ECHO Echo;
547 RTNETICMPV4TRACEROUTE Traceroute;
548} RTNETICMPV4;
549/** Pointer to an ICMP union packet. */
550typedef RTNETICMPV4 *PRTNETICMPV4;
551/** Pointer to a const ICMP union packet. */
552typedef RTNETICMPV4 const *PCRTNETICMPV4;
553
554
555/** @todo add ICMPv6 when needed. */
556
557
558/**
559 * Ethernet ARP header.
560 */
561#pragma pack(1)
562typedef struct RTNETARPHDR
563{
564 /** The hardware type. */
565 uint16_t ar_htype;
566 /** The protocol type (ethertype). */
567 uint16_t ar_ptype;
568 /** The hardware address length. */
569 uint8_t ar_hlen;
570 /** The protocol address length. */
571 uint8_t ar_plen;
572 /** The operation. */
573 uint16_t ar_oper;
574} RTNETARPHDR;
575#pragma pack(0)
576AssertCompileSize(RTNETARPHDR, 8);
577/** Pointer to an ethernet ARP header. */
578typedef RTNETARPHDR *PRTNETARPHDR;
579/** Pointer to a const ethernet ARP header. */
580typedef RTNETARPHDR const *PCRTNETARPHDR;
581
582/** ARP hardware type - ethernet. */
583#define RTNET_ARP_ETHER UINT16_C(1)
584
585/** @name ARP operations
586 * @{ */
587#define RTNET_ARPOP_REQUEST UINT16_C(1) /**< Request hardward address given a protocol address (ARP). */
588#define RTNET_ARPOP_REPLY UINT16_C(2)
589#define RTNET_ARPOP_REVREQUEST UINT16_C(3) /**< Request protocol address given a hardware address (RARP). */
590#define RTNET_ARPOP_REVREPLY UINT16_C(4)
591#define RTNET_ARPOP_INVREQUEST UINT16_C(8) /**< Inverse ARP. */
592#define RTNET_ARPOP_INVREPLY UINT16_C(9)
593/** Check if an ARP operation is a request or not. */
594#define RTNET_ARPOP_IS_REQUEST(Op) ((Op) & 1)
595/** Check if an ARP operation is a reply or not. */
596#define RTNET_ARPOP_IS_REPLY(Op) (!RTNET_ARPOP_IS_REQUEST(Op))
597/** @} */
598
599
600/**
601 * Ethernet IPv4 + 6-byte MAC ARP request packet.
602 */
603#pragma pack(1)
604typedef struct RTNETARPIPV4
605{
606 /** ARP header. */
607 RTNETARPHDR Hdr;
608 /** The sender hardware address. */
609 RTMAC ar_sha;
610 /** The sender protocol address. */
611 RTNETADDRIPV4 ar_spa;
612 /** The target hardware address. */
613 RTMAC ar_tha;
614 /** The arget protocol address. */
615 RTNETADDRIPV4 ar_tpa;
616} RTNETARPIPV4;
617#pragma pack(0)
618AssertCompileSize(RTNETARPIPV4, 8+6+4+6+4);
619/** Pointer to an ethernet IPv4+MAC ARP request packet. */
620typedef RTNETARPIPV4 *PRTNETARPIPV4;
621/** Pointer to a const ethernet IPv4+MAC ARP request packet. */
622typedef RTNETARPIPV4 const *PCRTNETARPIPV4;
623
624
625/** @todo RTNETNDP (IPv6)*/
626
627
628/** @} */
629
630__END_DECLS
631
632#endif
633
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