diff options
Diffstat (limited to 'include/iprt/net.h')
-rw-r--r-- | include/iprt/net.h | 77 |
1 files changed, 72 insertions, 5 deletions
diff --git a/include/iprt/net.h b/include/iprt/net.h index 38e066b9..14c32f8b 100644 --- a/include/iprt/net.h +++ b/include/iprt/net.h @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 2008-2012 Oracle Corporation + * Copyright (C) 2008-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -39,6 +39,19 @@ RT_C_DECLS_BEGIN */ /** + * Converts an stringified Ethernet MAC address into the RTMAC representation. + * + * @todo This should be move to some generic part of the runtime. + * + * @returns VINF_SUCCESS on success, VERR_GETOPT_INVALID_ARGUMENT_FORMAT on + * failure. + * + * @param pszValue The value to convert. + * @param pAddr Where to store the result. + */ +RTDECL(int) RTNetStrToMacAddr(const char *pszAddr, PRTMAC pMacAddr); + +/** * IPv4 address. */ typedef RTUINT32U RTNETADDRIPV4; @@ -56,6 +69,17 @@ typedef RTNETADDRIPV4 const *PCRTNETADDRIPV4; */ RTDECL(bool) RTNetIsIPv4AddrStr(const char *pszAddress); +/** + * Converts an stringified IPv4 address into the RTNETADDRIPV4 representation. + * + * @returns VINF_SUCCESS on success, VERR_INVALID_PARAMETER on + * failure. + * + * @param pszAddr The value to convert. + * @param pAddr Where to store the result. + */ +RTDECL(int) RTNetStrToIPv4Addr(const char *pszAddr, PRTNETADDRIPV4 pAddr); + /** * IPv6 address. @@ -323,7 +347,8 @@ typedef RTNETIPV6 const *PCRTNETIPV6; /** The minimum IPv6 header length (in bytes). * Up to and including RTNETIPV6::ip6_dst. */ -#define RTNETIPV6_MIN_LEN (40) +#define RTNETIPV6_MIN_LEN (40) +#define RTNETIPV6_ICMPV6_ND_WITH_LLA_OPT_MIN_LEN (32) RTDECL(uint32_t) RTNetIPv6PseudoChecksum(PCRTNETIPV6 pIpHdr); RTDECL(uint32_t) RTNetIPv6PseudoChecksumEx(PCRTNETIPV6 pIpHdr, uint8_t bProtocol, uint16_t cbPkt); @@ -737,6 +762,51 @@ typedef RTNETICMPV4 const *PCRTNETICMPV4; /** @todo add ICMPv6 when needed. */ +#define RTNETIPV6_PROT_ICMPV6 (58) +#define RTNETIPV6_ICMPV6_CODE_0 (0) +#define RTNETIPV6_ICMP_NS_TYPE (135) +#define RTNETIPV6_ICMP_NA_TYPE (136) +#define RTNETIPV6_ICMP_ND_SLLA_OPT (1) +#define RTNETIPV6_ICMP_ND_TLLA_OPT (2) +#define RTNETIPV6_ICMP_ND_LLA_LEN (1) + +/** ICMPv6 ND Source Link Layer Address option */ +#pragma pack(1) +typedef struct RTNETNDP_SLLA_OPT +{ + uint8_t type; + uint8_t len; + RTMAC slla; +} RTNETNDP_SLLA_OPT; +#pragma pack() + +AssertCompileSize(RTNETNDP_SLLA_OPT, 1+1+6); + +typedef RTNETNDP_SLLA_OPT *PRTNETNDP_SLLA_OPT; +typedef RTNETNDP_SLLA_OPT const *PCRTNETNDP_SLLA_OPT; + +/** ICMPv6 ND Neighbor Sollicitation */ +#pragma pack(1) +typedef struct RTNETNDP +{ + /** ICMPv6 type. */ + uint8_t icmp6_type; + /** ICMPv6 code. */ + uint8_t icmp6_code; + /** ICMPv6 checksum */ + uint16_t icmp6_cksum; + /** reserved */ + uint32_t reserved; + /** target address */ + RTNETADDRIPV6 target_address; +} RTNETNDP; +#pragma pack() +AssertCompileSize(RTNETNDP, 1+1+2+4+16); +/** Pointer to a NDP ND packet. */ +typedef RTNETNDP *PRTNETNDP; +/** Pointer to a const NDP NS packet. */ +typedef RTNETNDP const *PCRTNETNDP; + /** * Ethernet ARP header. @@ -805,9 +875,6 @@ typedef RTNETARPIPV4 *PRTNETARPIPV4; typedef RTNETARPIPV4 const *PCRTNETARPIPV4; -/** @todo RTNETNDP (IPv6)*/ - - /** @} */ RT_C_DECLS_END |