Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

net.h

Go to the documentation of this file.
/** @file
 * IPRT - Network Protocols.
 */

/*
 * Copyright (C) 2008 Sun Microsystems, Inc.
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 * VirtualBox OSE distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 * additional information or have any questions.
 */

#ifndef ___iprt_net_h
#define ___iprt_net_h

#include <iprt/cdefs.h>
#include <iprt/types.h>
#include <iprt/assert.h>


__BEGIN_DECLS

/** @defgroup grp_rt_net     RTNet - Network Protocols
 * @ingroup grp_rt
 * @{
 */

/**
 * IPv4 address.
 */
00048 typedef RTUINT32U RTNETADDRIPV4;
AssertCompileSize(RTNETADDRIPV4, 4);
/** Pointer to a IPv4 address. */
00051 typedef RTNETADDRIPV4 *PRTNETADDRIPV4;
/** Pointer to a const IPv4 address. */
00053 typedef RTNETADDRIPV4 const *PCRTNETADDRIPV4;

/**
 * IPv6 address.
 */
00058 typedef RTUINT128U RTNETADDRIPV6;
AssertCompileSize(RTNETADDRIPV6, 16);
/** Pointer to a IPv4 address. */
00061 typedef RTNETADDRIPV6 *PRTNETADDRIPV6;
/** Pointer to a const IPv4 address. */
00063 typedef RTNETADDRIPV6 const *PCRTNETADDRIPV6;

/**
 * IPX address.
 */
#pragma pack(1)
00069 typedef struct RTNETADDRIPX
{
    /** The network ID. */
00072     uint32_t Network;
    /** The node ID. (Defaults to the MAC address apparently.) */
00074     RTMAC Node;
} RTNETADDRIPX;
#pragma pack()
AssertCompileSize(RTNETADDRIPX, 4+6);
/** Pointer to an IPX address. */
00079 typedef RTNETADDRIPX *PRTNETADDRIPX;
/** Pointer to a const IPX address. */
00081 typedef RTNETADDRIPX const *PCRTNETADDRIPX;

/**
 * Address union.
 */
00086 typedef union RTNETADDRU
{
    /** 64-bit view. */
00089     uint64_t au64[2];
    /** 32-bit view. */
00091     uint32_t au32[4];
    /** 16-bit view. */
00093     uint16_t au16[8];
    /** 8-bit view. */
00095     uint8_t  au8[16];
    /** IPv4 view. */
00097     RTNETADDRIPV4 IPv4;
    /** IPv6 view. */
00099     RTNETADDRIPV6 IPv6;
    /** IPX view. */
00101     RTNETADDRIPX Ipx;
    /** MAC address view. */
00103     RTMAC Mac;
} RTNETADDRU;
AssertCompileSize(RTNETADDRU, 16);
/** Pointer to an address union. */
00107 typedef RTNETADDRU *PRTNETADDRU;
/** Pointer to a const address union. */
00109 typedef RTNETADDRU const *PCRTNETADDRU;


/**
 * Ethernet header.
 */
#pragma pack(1)
00116 typedef struct RTNETETHERHDR
{
    RTMAC       DstMac;
    RTMAC       SrcMac;
    /** Ethernet frame type or frame size, depending on the kind of ethernet.
     * This is big endian on the wire. */
00122     uint16_t    EtherType;
} RTNETETHERHDR;
#pragma pack()
AssertCompileSize(RTNETETHERHDR, 14);
/** Pointer to an ethernet header. */
00127 typedef RTNETETHERHDR *PRTNETETHERHDR;
/** Pointer to a const ethernet header. */
00129 typedef RTNETETHERHDR const *PCRTNETETHERHDR;

/** @name EtherType (RTNETETHERHDR::EtherType)
 * @{ */
#define RTNET_ETHERTYPE_IPV4    UINT16_C(0x0800)
#define RTNET_ETHERTYPE_ARP     UINT16_C(0x0806)
#define RTNET_ETHERTYPE_IPV6    UINT16_C(0x86dd)
#define RTNET_ETHERTYPE_VLAN    UINT16_C(0x8100)
#define RTNET_ETHERTYPE_IPX_1   UINT16_C(0x8037)
#define RTNET_ETHERTYPE_IPX_2   UINT16_C(0x8137)
#define RTNET_ETHERTYPE_IPX_3   UINT16_C(0x8138)
/** @} */


/**
 * IPv4 header.
 * All is bigendian on the wire.
 */
#pragma pack(1)
00148 typedef struct RTNETIPV4
{
#ifdef RT_BIG_ENDIAN
    unsigned int    ip_v : 4;
    unsigned int    ip_hl : 4;
    unsigned int    ip_tos : 8;
    unsigned int    ip_len : 16;
#else
    /** 00:0 - Header length given as a 32-bit word count. */
00157     unsigned int    ip_hl : 4;
    /** 00:4 - Header version. */
00159     unsigned int    ip_v : 4;
    /** 01 - Type of service. */
00161     unsigned int    ip_tos : 8;
    /** 02 - Total length (header + data). */
00163     unsigned int    ip_len : 16;
#endif
    /** 04 - Packet idenficiation. */
00166     uint16_t        ip_id;
    /** 06 - Offset if fragmented. */
00168     uint16_t        ip_off;
    /** 08 - Time to live. */
00170     uint8_t         ip_ttl;
    /** 09 - Protocol. */
00172     uint8_t         ip_p;
    /** 0a - Header check sum. */
00174     uint16_t        ip_sum;
    /** 0c - Source address. */
00176     RTNETADDRIPV4   ip_src;
    /** 10 - Destination address. */
00178     RTNETADDRIPV4   ip_dst;
    /** 14 - Options (optional). */
00180     uint32_t        ip_options[1];
} RTNETIPV4;
#pragma pack()
AssertCompileSize(RTNETIPV4, 6 * 4);
/** Pointer to a IPv4 header. */
00185 typedef RTNETIPV4 *PRTNETIPV4;
/** Pointer to a const IPv4 header. */
00187 typedef RTNETIPV4 const *PCRTNETIPV4;

/** The minimum IPv4 header length (in bytes).
 * Up to and including RTNETIPV4::ip_dst. */
00191 #define RTNETIPV4_MIN_LEN   (20)


/** @name IPv4 Protocol Numbers
 * @{ */
/** IPv4: ICMP */
00197 #define RTNETIPV4_PROT_ICMP     (1)
/** IPv4: TCP */
00199 #define RTNETIPV4_PROT_TCP      (6)
/** IPv4: UDP */
00201 #define RTNETIPV4_PROT_UDP      (17)
/** @} */

/** @name Common IPv4 Port Assignments
 * @{
 */
/** Boostrap Protocol / DHCP) Server. */
00208 #define RTNETIPV4_PORT_BOOTPS   (67)
/** Boostrap Protocol / DHCP) Client. */
00210 #define RTNETIPV4_PORT_BOOTPC   (68)
/** @} */

RTDECL(uint16_t) RTNetIPv4HdrChecksum(PCRTNETIPV4 pIpHdr);
RTDECL(bool)     RTNetIPv4IsHdrValid(PCRTNETIPV4 pIpHdr, size_t cbHdrMax, size_t cbPktMax);
RTDECL(uint32_t) RTNetIPv4PseudoChecksum(PCRTNETIPV4 pIpHdr);
RTDECL(uint32_t) RTNetIPv4PseudoChecksumBits(RTNETADDRIPV4 SrcAddr, RTNETADDRIPV4 DstAddr, uint8_t bProtocol, uint16_t cbPkt);
RTDECL(uint32_t) RTNetIPv4AddDataChecksum(void const *pvData, size_t cbData, uint32_t u32Sum, bool *pfOdd);
RTDECL(uint16_t) RTNetIPv4FinalizeChecksum(uint32_t u32Sum);


/**
 * UDP header.
 */
#pragma pack(1)
00225 typedef struct RTNETUDP
{
    /** The source port. */
00228     uint16_t    uh_sport;
    /** The destination port. */
00230     uint16_t    uh_dport;
    /** The length of the UDP header and associated data. */
00232     uint16_t    uh_ulen;
    /** The checksum of the pseudo header, the UDP header and the data. */
00234     uint16_t    uh_sum;
} RTNETUDP;
#pragma pack()
AssertCompileSize(RTNETUDP, 8);
/** Pointer to an UDP header. */
00239 typedef RTNETUDP *PRTNETUDP;
/** Pointer to a const UDP header. */
00241 typedef RTNETUDP const *PCRTNETUDP;

/** The minimum UDP packet length (in bytes). (RTNETUDP::uh_ulen) */
00244 #define RTNETUDP_MIN_LEN   (8)

RTDECL(uint32_t) RTNetIPv4AddUDPChecksum(PCRTNETUDP pUdpHdr, uint32_t u32Sum);
RTDECL(uint16_t) RTNetIPv4UDPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, void const *pvData);
RTDECL(bool)     RTNetIPv4IsUDPSizeValid(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, size_t cbPktMax);
RTDECL(bool)     RTNetIPv4IsUDPValid(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, void const *pvData, size_t cbPktMax);

/**
 * IPv4 BOOTP / DHCP packet.
 */
#pragma pack(1)
00255 typedef struct RTNETBOOTP
{
    /** 00 - The packet opcode. */
00258     uint8_t         bp_op;
    /** 01 - Hardware address type. Same as RTNETARPHDR::ar_htype.  */
00260     uint8_t         bp_htype;
    /** 02 - Hardware address length. */
00262     uint8_t         bp_hlen;
    /** 03 - Gateway hops. */
00264     uint8_t         bp_hops;
    /** 04 - Transaction ID. */
00266     uint32_t        bp_xid;
    /** 08 - Seconds since boot started. */
00268     uint16_t        bp_secs;
    /** 0a - Unused (BOOTP) / Flags (DHCP). */
00270     uint16_t        bp_flags;
    /** 0c - Client IPv4 address. */
00272     RTNETADDRIPV4   bp_ciaddr;
    /** 10 - Your IPv4 address. */
00274     RTNETADDRIPV4   bp_yiaddr;
    /** 14 - Server IPv4 address. */
00276     RTNETADDRIPV4   bp_siaddr;
    /** 18 - Gateway IPv4 address. */
00278     RTNETADDRIPV4   bp_giaddr;
    /** 1c - Client hardware address. */
    union
    {
        uint8_t     au8[16];
        RTMAC       Mac;
    }               bp_chaddr;
    /** 2c - Server name. */
00286     uint8_t         bp_sname[64];
    /** 6c - File name / more DHCP options. */
00288     uint8_t         bp_file[128];
    /** ec - Vendor specific area (BOOTP) / Options (DHCP).
     * @remark This is really 312 bytes in the DHCP version. */
    union
    {
        uint8_t         au8[128];
        struct DHCP
        {
            /** ec - The DHCP cookie (RTNET_DHCP_COOKIE). */
00297             uint32_t    dhcp_cookie;
            /** f0 - The DHCP options. */
00299             uint8_t     dhcp_opts[124];
        }           Dhcp;
    }               bp_vend;

} RTNETBOOTP;
#pragma pack()
AssertCompileSize(RTNETBOOTP, 0xec + 128);
/** Pointer to a BOOTP / DHCP packet. */
00307 typedef RTNETBOOTP *PRTNETBOOTP;
/** Pointer to a const BOOTP / DHCP packet. */
00309 typedef RTNETBOOTP const *PCRTNETBOOTP;

/** Minimum BOOTP packet length. For quick validation, no standard thing really. */
00312 #define RTNETBOOTP_MIN_LEN          0xec
/** Minimum DHCP packet length. For quick validation, no standard thing really. */
00314 #define RTNETBOOTP_DHCP_MIN_LEN     0xf1

/** @name BOOTP packet opcode values
 * @{ */
#define RTNETBOOTP_OP_REQUEST       1
#define RTNETBOOTP_OP_REPLY         2
/** @} */

/** @name DHCP flags (RTNETBOOTP::bp_flags)
 * @{ */
#define RTNET_DHCP_FLAGS_NO_BROADCAST   UINT16_C(0x8000) /** @todo check test!!! */
/** @} */

/** The DHCP cookie (network endian). */
00328 #define RTNET_DHCP_COOKIE           UINT32_C(0x63825363)

/**
 * An IPv4 DHCP option header.
 */
00333 typedef struct RTNETDHCPOPT
{
    /** 00 - The DHCP option. */
00336     uint8_t     dhcp_opt;
    /** 01 - The data length (excluding this header). */
00338     uint8_t     dhcp_len;
    /*  02 - The option data follows here, optional and of variable length. */
} RTNETDHCPOPT;
AssertCompileSize(RTNETDHCPOPT, 2);
/** Pointer to a DHCP option header. */
00343 typedef RTNETDHCPOPT *PRTNETDHCPOPT;
/** Pointer to a const DHCP option header. */
00345 typedef RTNETDHCPOPT const *PCRTNETDHCPOPT;

/** @name DHCP options
 * @{ */
/** 1 byte padding, this has no dhcp_len field. */
00350 #define RTNET_DHCP_OPT_PAD          0
/** Have a 8-bit message type value as data, see RTNET_DHCP_MT_*. */
00352 #define RTNET_DHCP_OPT_MSG_TYPE     53
/** Marks the end of the DHCP options, this has no dhcp_len field. */
00354 #define RTNET_DHCP_OPT_END          255
/** @} */

/** @name DHCP Message Types (option 53)
 * @{ */
#define RTNET_DHCP_MT_DISCOVER      1
#define RTNET_DHCP_MT_OFFER         2
#define RTNET_DHCP_MT_REQUEST       3
#define RTNET_DHCP_MT_DECLINE       4
#define RTNET_DHCP_MT_ACK           5
#define RTNET_DHCP_MT_NAC           6
#define RTNET_DHCP_MT_RELEASE       7
#define RTNET_DHCP_MT_INFORM        8
/** @} */

RTDECL(bool) RTNetIPv4IsDHCPValid(PCRTNETUDP pUdpHdr, PCRTNETBOOTP pDhcp, size_t cbDhcp, uint8_t *pMsgType);


/**
 * IPv4 DHCP packet.
 * @obsolete Use RTNETBOOTP.
 */
#pragma pack(1)
00377 typedef struct RTNETDHCP
{
    /** 00 - The packet opcode. */
00380     uint8_t         Op;
    /** Hardware address type. */
00382     uint8_t         HType;
    /** Hardware address length. */
00384     uint8_t         HLen;
    uint8_t         Hops;
    uint32_t        XID;
    uint16_t        Secs;
    uint16_t        Flags;
    /** Client IPv4 address. */
00390     RTNETADDRIPV4   CIAddr;
    /** Your IPv4 address. */
00392     RTNETADDRIPV4   YIAddr;
    /** Server IPv4 address. */
00394     RTNETADDRIPV4   SIAddr;
    /** Gateway IPv4 address. */
00396     RTNETADDRIPV4   GIAddr;
    /** Client hardware address. */
00398     uint8_t         CHAddr[16];
    /** Server name. */
00400     uint8_t         SName[64];
    uint8_t         File[128];
    uint8_t         abMagic[4];
    uint8_t         DhcpOpt;
    uint8_t         DhcpLen; /* 1 */
    uint8_t         DhcpReq;
    uint8_t         abOptions[57];
} RTNETDHCP;
#pragma pack()
/** @todo AssertCompileSize(RTNETDHCP, ); */
/** Pointer to a DHCP packet. */
00411 typedef RTNETDHCP *PRTNETDHCP;
/** Pointer to a const DHCP packet. */
00413 typedef RTNETDHCP const *PCRTNETDHCP;


/**
 * TCP packet.
 */
#pragma pack(1)
00420 typedef struct RTNETTCP
{
    /** 00 - The source port. */
00423     uint16_t        th_sport;
    /** 02 - The destination port. */
00425     uint16_t        th_dport;
    /** 04 - The sequence number. */
00427     uint32_t        th_seq;
    /** 08 - The acknowledgement number. */
00429     uint32_t        th_ack;
#ifdef RT_BIG_ENDIAN
    unsigned int    th_win : 16;
    unsigned int    th_flags : 8;
    unsigned int    th_off : 4;
    unsigned int    th_x2 : 4;
#else
    /** 0c:0 - Reserved. */
00437     unsigned int    th_x2 : 4;
    /** 0c:4 - The data offset given as a dword count from the start of this header. */
00439     unsigned int    th_off : 4;
    /** 0d - flags. */
00441     unsigned int    th_flags : 8;
    /** 0e - The window. */
00443     unsigned int    th_win : 16;
#endif
    /** 10 - The checksum of the pseudo header, the TCP header and the data. */
00446     uint16_t        th_sum;
    /** 12 - The urgent pointer. */
00448     uint16_t        th_urp;
    /* (options follows here and then the data (aka text).) */
} RTNETTCP;
#pragma pack()
AssertCompileSize(RTNETTCP, 20);
/** Pointer to a TCP packet. */
00454 typedef RTNETTCP *PRTNETTCP;
/** Pointer to a const TCP packet. */
00456 typedef RTNETTCP const *PCRTNETTCP;

/** The minimum TCP header length (in bytes). (RTNETTCP::th_off * 4) */
00459 #define RTNETTCP_MIN_LEN    (20)

RTDECL(uint32_t) RTNetIPv4AddTCPChecksum(PCRTNETTCP pTcpHdr, uint32_t u32Sum);
RTDECL(uint16_t) RTNetIPv4TCPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, void const *pvData);
RTDECL(bool)     RTNetIPv4IsTCPSizeValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, size_t cbPktMax);
RTDECL(bool)     RTNetIPv4IsTCPValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, void const *pvData, size_t cbPktMax);


/**
 * IPv4 ICMP packet header.
 */
#pragma pack(1)
00471 typedef struct RTNETICMPV4HDR
{
    /** 00 - The ICMP message type. */
00474     uint8_t         icmp_type;
    /** 01 - Type specific code that further qualifies the message. */
00476     uint8_t         icmp_code;
    /** 02 - Checksum of the ICMP message. */
00478     uint16_t        icmp_cksum;
} RTNETICMPV4HDR;
#pragma pack()
AssertCompileSize(RTNETICMPV4HDR, 4);
/** Pointer to an ICMP packet header. */
00483 typedef RTNETICMPV4HDR *PRTNETICMPV4HDR;
/** Pointer to a const ICMP packet header. */
00485 typedef RTNETICMPV4HDR const *PCRTNETICMPV4HDR;

/** @name ICMP (v4) message types.
 * @{  */
#define RTNETICMPV4_TYPE_ECHO_REPLY     0
#define RTNETICMPV4_TYPE_ECHO_REQUEST   8
#define RTNETICMPV4_TYPE_TRACEROUTE     30
/** @} */

/**
 * IPv4 ICMP ECHO Reply & Request packet.
 */
#pragma pack(1)
00498 typedef struct RTNETICMPV4ECHO
{
    /** 00 - The ICMP header. */
00501     RTNETICMPV4HDR  Hdr;
    /** 04 - The identifier to help the requestor match up the reply.
     *       Can be 0. Typically fixed value. */
00504     uint16_t        icmp_id;
    /** 06 - The sequence number to help the requestor match up the reply.
     *       Can be 0. Typically incrementing between requests. */
00507     uint16_t        icmp_seq;
    /** 08 - Variable length data that is to be returned unmodified in the reply. */
00509     uint8_t         icmp_data[1];
} RTNETICMPV4ECHO;
#pragma pack()
AssertCompileSize(RTNETICMPV4ECHO, 9);
/** Pointer to an ICMP ECHO packet. */
00514 typedef RTNETICMPV4ECHO *PRTNETICMPV4ECHO;
/** Pointer to a const ICMP ECHO packet. */
00516 typedef RTNETICMPV4ECHO const *PCRTNETICMPV4ECHO;

/**
 * IPv4 ICMP TRACEROUTE packet.
 * This is an reply to an IP packet with the traceroute option set.
 */
#pragma pack(1)
00523 typedef struct RTNETICMPV4TRACEROUTE
{
    /** 00 - The ICMP header. */
00526     RTNETICMPV4HDR  Hdr;
    /** 04 - Identifier copied from the traceroute option's ID number. */
00528     uint16_t        icmp_id;
    /** 06 - Unused. (Possibly an icmp_seq?) */
00530     uint16_t        icmp_void;
    /** 08 - Outbound hop count. From the IP packet causing this message. */
00532     uint16_t        icmp_ohc;
    /** 0a - Return hop count. From the IP packet causing this message. */
00534     uint16_t        icmp_rhc;
    /** 0c - Output link speed, 0 if not known. */
00536     uint32_t        icmp_speed;
    /** 10 - Output link MTU, 0 if not known. */
00538     uint32_t        icmp_mtu;
} RTNETICMPV4TRACEROUTE;
#pragma pack()
AssertCompileSize(RTNETICMPV4TRACEROUTE, 20);
/** Pointer to an ICMP TRACEROUTE packet. */
00543 typedef RTNETICMPV4TRACEROUTE *PRTNETICMPV4TRACEROUTE;
/** Pointer to a const ICMP TRACEROUTE packet. */
00545 typedef RTNETICMPV4TRACEROUTE const *PCRTNETICMPV4TRACEROUTE;

/** @todo add more ICMPv4 as needed. */

/**
 * IPv4 ICMP union packet.
 */
00552 typedef union RTNETICMPV4
{
    RTNETICMPV4HDR Hdr;
    RTNETICMPV4ECHO Echo;
    RTNETICMPV4TRACEROUTE Traceroute;
} RTNETICMPV4;
/** Pointer to an ICMP union packet. */
00559 typedef RTNETICMPV4 *PRTNETICMPV4;
/** Pointer to a const ICMP union packet. */
00561 typedef RTNETICMPV4 const *PCRTNETICMPV4;


/** @todo add ICMPv6 when needed. */


/**
 * Ethernet ARP header.
 */
#pragma pack(1)
00571 typedef struct RTNETARPHDR
{
    /** The hardware type. */
00574     uint16_t    ar_htype;
    /** The protocol type (ethertype). */
00576     uint16_t    ar_ptype;
    /** The hardware address length. */
00578     uint8_t     ar_hlen;
    /** The protocol address length. */
00580     uint8_t     ar_plen;
    /** The operation. */
00582     uint16_t    ar_oper;
} RTNETARPHDR;
#pragma pack()
AssertCompileSize(RTNETARPHDR, 8);
/** Pointer to an ethernet ARP header. */
00587 typedef RTNETARPHDR *PRTNETARPHDR;
/** Pointer to a const ethernet ARP header. */
00589 typedef RTNETARPHDR const *PCRTNETARPHDR;

/** ARP hardware type - ethernet. */
00592 #define RTNET_ARP_ETHER            UINT16_C(1)

/** @name ARP operations
 * @{ */
00596 #define RTNET_ARPOP_REQUEST        UINT16_C(1) /**< Request hardward address given a protocol address (ARP). */
#define RTNET_ARPOP_REPLY          UINT16_C(2)
00598 #define RTNET_ARPOP_REVREQUEST     UINT16_C(3) /**< Request protocol address given a hardware address (RARP). */
#define RTNET_ARPOP_REVREPLY       UINT16_C(4)
00600 #define RTNET_ARPOP_INVREQUEST     UINT16_C(8) /**< Inverse ARP.  */
#define RTNET_ARPOP_INVREPLY       UINT16_C(9)
/** Check if an ARP operation is a request or not. */
00603 #define RTNET_ARPOP_IS_REQUEST(Op) ((Op) & 1)
/** Check if an ARP operation is a reply or not. */
00605 #define RTNET_ARPOP_IS_REPLY(Op)   (!RTNET_ARPOP_IS_REQUEST(Op))
/** @} */


/**
 * Ethernet IPv4 + 6-byte MAC ARP request packet.
 */
#pragma pack(1)
00613 typedef struct RTNETARPIPV4
{
    /** ARP header. */
00616     RTNETARPHDR     Hdr;
    /** The sender hardware address. */
00618     RTMAC           ar_sha;
    /** The sender protocol address. */
00620     RTNETADDRIPV4   ar_spa;
    /** The target hardware address. */
00622     RTMAC           ar_tha;
    /** The arget protocol address. */
00624     RTNETADDRIPV4   ar_tpa;
} RTNETARPIPV4;
#pragma pack()
AssertCompileSize(RTNETARPIPV4, 8+6+4+6+4);
/** Pointer to an ethernet IPv4+MAC ARP request packet. */
00629 typedef RTNETARPIPV4 *PRTNETARPIPV4;
/** Pointer to a const ethernet IPv4+MAC ARP request packet. */
00631 typedef RTNETARPIPV4 const *PCRTNETARPIPV4;


/** @todo RTNETNDP (IPv6)*/


/** @} */

__END_DECLS

#endif


Generated by  Doxygen 1.6.0   Back to index