EMANE  1.2.1
netutils.h File Reference
#include <sstream>
#include <vector>
#include <cstdint>
#include <cstring>
#include <arpa/inet.h>

Go to the source code of this file.

Classes

struct  EMANE::Utils::UdpHeader
 Definition of the UDP header. More...
 
struct  EMANE::Utils::Ip4Header
 Definition of the IPv4 header. More...
 
struct  EMANE::Utils::Ip6Header
 Definition of the IPv6 header. More...
 
struct  EMANE::Utils::EtherAddrBytes
 Definition of the ethernet frame address as an array of 6 bytes. More...
 
struct  EMANE::Utils::EtherAddrWords
 Definition of the ethernet frame address as a set of 3 words. More...
 
union  EMANE::Utils::EtherAddr
 Definition of the ethernet frame address as an array of 6 bytes or set of 3 words. More...
 
struct  EMANE::Utils::EtherHeader
 Definition of the ethernet frame header. More...
 
struct  EMANE::Utils::EtherArpHeader
 Definition of the ethernet arp header. More...
 
struct  EMANE::Utils::IP6ICMPHeader
 Definition of the IPv6 ICMP header. More...
 

Namespaces

 EMANE
 
 EMANE::Utils
 

Functions

struct EMANE::Utils::UdpHeader EMANE::Utils::__attribute__ ((packed))
 
std::uint8_t EMANE::Utils::get_ip_version (std::uint8_t vhl)
 
std::uint8_t EMANE::Utils::get_ip_hdrlen (std::uint8_t vhl)
 
std::uint8_t EMANE::Utils::get_ip_dscp (std::uint8_t tos)
 
std::uint8_t EMANE::Utils::get_ip_dscp (std::uint8_t ver, std::uint8_t clas)
 
std::uint8_t EMANE::Utils::get_version (const Ip4Header *ip)
 
std::uint8_t EMANE::Utils::get_hdrlen (const Ip4Header *ip)
 
std::uint16_t EMANE::Utils::get_len (const Ip4Header *ip)
 
std::uint8_t EMANE::Utils::get_dscp (const Ip4Header *ip)
 
void EMANE::Utils::addr_to_string (const std::uint8_t *addr, size_t addrlen, const char *delim, char *buf, size_t buflen)
 
std::uint8_t EMANE::Utils::get_version (const Ip6Header *ip)
 
std::uint8_t EMANE::Utils::get_hdrlen (const Ip6Header *ip)
 
std::uint16_t EMANE::Utils::get_len (const Ip6Header *ip)
 
std::uint8_t EMANE::Utils::get_dscp (const Ip6Header *ip)
 
const EtherAddr * EMANE::Utils::get_srcaddr (const EtherHeader *eth)
 
const EtherAddr * EMANE::Utils::get_dstaddr (const EtherHeader *eth)
 
std::uint16_t EMANE::Utils::get_protocol (const EtherHeader *eth)
 
const char * EMANE::Utils::addr_to_string (const EtherAddr *addr)
 
std::string EMANE::Utils::ethaddr_to_string (const EtherAddr *addr)
 
std::uint16_t EMANE::Utils::get_hwtype (const EtherArpHeader *arp)
 
std::uint16_t EMANE::Utils::get_protocol (const EtherArpHeader *arp)
 
std::uint8_t EMANE::Utils::get_hwaddrlen (const EtherArpHeader *arp)
 
std::uint8_t EMANE::Utils::get_protoaddrlen (const EtherArpHeader *arp)
 
std::uint16_t EMANE::Utils::get_code (const EtherArpHeader *arp)
 
const EtherAddr * EMANE::Utils::get_srchwaddr (const EtherArpHeader *arp)
 
const EtherAddr * EMANE::Utils::get_dsthwaddr (const EtherArpHeader *arp)
 
std::uint32_t EMANE::Utils::get_srcprotoaddr (const EtherArpHeader *arp)
 
std::uint32_t EMANE::Utils::get_dstprotoaddr (const EtherArpHeader *arp)
 
std::uint16_t EMANE::Utils::ethaddr4_to_id (const EtherAddr *addr)
 
std::uint16_t EMANE::Utils::ethaddr6_to_id (const EtherAddr *addr)
 
std::uint8_t EMANE::Utils::get_prefixlen (const in6_addr *prefix)
 
std::uint16_t EMANE::Utils::inet_cksum (const void *buf, int buflen, std::uint16_t prev=0)
 
std::string EMANE::Utils::formatFrequency (const std::uint64_t val, const int precision=6)
 returns a sting with the formatted value and suffix More...
 
std::vector< std::string > EMANE::Utils::getTokens (const std::string &sInput, const char *pzDelimeter)
 

Variables

std::uint16_t u16Udpsrc
 
std::uint16_t u16Udpdst
 
std::uint16_t u16Udplen
 
std::uint16_t u16Udpcheck
 
const std::uint8_t EMANE::Utils::IP_PROTO_UDP = 0x11
 ip udp protocol More...
 
const std::uint16_t EMANE::Utils::UDP_HEADER_LEN = 8
 udp header len More...
 
std::uint8_t u8Ipv4vhl
 
std::uint8_t u8Ipv4tos
 
std::uint16_t u16Ipv4len
 
std::uint16_t u16Ipv4id
 
std::uint16_t u16Ipv4frag
 
std::uint8_t u8Ipv4hops
 
std::uint8_t u8Ipv4proto
 
std::uint16_t u16Ipv4check
 
std::uint32_t u32Ipv4src
 
std::uint32_t u32Ipv4dst
 
const std::uint16_t EMANE::Utils::IPV4_HEADER_LEN = 20
 ipv4 header len without options More...
 
const std::uint16_t EMANE::Utils::IPV4_ADDR_LEN = 4
 ipv4 addr len More...
 
const std::uint16_t EMANE::Utils::IPV6_ADDR_LEN = 16
 ipv6 addr len More...
 
const std::uint8_t EMANE::Utils::IPV6_P_ICMP = 0x3A
 IPv6 ICMP Protocol. More...
 
struct {
   std::uint8_t   u8Ipv6Ver
 
   std::uint8_t   u8Ipv6Class
 
   std::uint16_t   u16Ipv6Flow
 
vcf
 
std::uint16_t u16Ipv6len
 
std::uint8_t u8Ipv6next
 
std::uint8_t u8Ipv6hops
 
std::uint8_t Ipv6src [IPV6_ADDR_LEN]
 
std::uint8_t Ipv6dst [IPV6_ADDR_LEN]
 
const std::uint16_t EMANE::Utils::IPV6_HEADER_LEN = 40
 ipv6 header len More...
 
const std::uint16_t EMANE::Utils::IPV6_MAX_BIT_LEN = 128
 ipv6 max addr len More...
 
const std::uint16_t EMANE::Utils::ETH_ALEN = 6
 Ethernet hardware address length. More...
 
const std::uint16_t EMANE::Utils::ETH_HEADER_LEN = 14
 Ethernet header length. More...
 
const std::uint16_t EMANE::Utils::ETHARP_HEADER_LEN = 28
 Ethernet Arp header length. More...
 
const std::uint16_t EMANE::Utils::IP_MAX_PACKET = 0xFFFF
 Max ip packet len. More...
 
const std::uint16_t EMANE::Utils::ARPHRD_ETHER = 0x0001
 Ethernet hardware type. More...
 
const std::uint16_t EMANE::Utils::ETH_P_IPV4 = 0x0800
 Ethernet ipv4 protocol. More...
 
const std::uint16_t EMANE::Utils::ETH_P_ARP = 0x0806
 Ethernet arp protocol. More...
 
const std::uint16_t EMANE::Utils::ETH_P_IPV6 = 0x86DD
 Ethernet ipv6 protocol. More...
 
std::uint8_t buff [ETH_ALEN]
 
std::uint16_t word1
 
std::uint16_t word2
 
std::uint16_t word3
 
struct EtherAddrBytes bytes
 
struct EtherAddrWords words
 
union EtherAddr dst
 
union EtherAddr src
 
std::uint16_t u16proto
 
std::uint16_t u16hwType
 
std::uint16_t u16protocol
 
std::uint8_t u8hwAddrLen
 
std::uint8_t u8protoAddrLen
 
std::uint16_t u16code
 
EtherAddr srcHwAddr
 
std::uint32_t u32srcProtoAddr
 
EtherAddr dstHwAddr
 
std::uint32_t u32dstProtoAddr
 
const std::uint16_t EMANE::Utils::ETH_ARPOP_REQUEST = 0x0001
 Ethernet arp request. More...
 
const std::uint16_t EMANE::Utils::ETH_ARPOP_REPLY = 0x0002
 Ethernet arp reply. More...
 
std::uint8_t u8Type
 
std::uint8_t u8Code
 
std::uint16_t u16Checksum
 
std::uint32_t u32Flags
 
sockaddr_in6 targetAddr
 
const std::uint8_t EMANE::Utils::IP6_ICMP_NEIGH_SOLICIT = 135
 IPv6 ICMP Neighbor Soliciation. More...
 
const std::uint8_t EMANE::Utils::IP6_ICMP_NEIGH_ADVERT = 136
 IPv6 ICMP Neighbor Advertisement. More...
 

Variable Documentation

◆ buff

std::uint8_t buff[ETH_ALEN]

Definition at line 390 of file netutils.h.

◆ bytes

struct EtherAddrBytes bytes

Definition at line 390 of file netutils.h.

◆ dst

union EtherAddr dst

Definition at line 390 of file netutils.h.

◆ dstHwAddr

EtherAddr dstHwAddr

Definition at line 516 of file netutils.h.

◆ Ipv6dst

std::uint8_t Ipv6dst[IPV6_ADDR_LEN]

Definition at line 259 of file netutils.h.

◆ Ipv6src

std::uint8_t Ipv6src[IPV6_ADDR_LEN]

Definition at line 258 of file netutils.h.

◆ src

union EtherAddr src

Definition at line 391 of file netutils.h.

◆ srcHwAddr

EtherAddr srcHwAddr

Definition at line 514 of file netutils.h.

◆ targetAddr

sockaddr_in6 targetAddr

Definition at line 797 of file netutils.h.

◆ u16Checksum

std::uint16_t u16Checksum

Definition at line 795 of file netutils.h.

◆ u16code

std::uint16_t u16code

Definition at line 513 of file netutils.h.

◆ u16hwType

std::uint16_t u16hwType

Definition at line 509 of file netutils.h.

◆ u16Ipv4check

std::uint16_t u16Ipv4check

Definition at line 134 of file netutils.h.

◆ u16Ipv4frag

std::uint16_t u16Ipv4frag

Definition at line 131 of file netutils.h.

◆ u16Ipv4id

std::uint16_t u16Ipv4id

Definition at line 130 of file netutils.h.

◆ u16Ipv4len

std::uint16_t u16Ipv4len

Definition at line 129 of file netutils.h.

◆ u16Ipv6Flow

std::uint16_t u16Ipv6Flow

Definition at line 252 of file netutils.h.

◆ u16Ipv6len

std::uint16_t u16Ipv6len

Definition at line 255 of file netutils.h.

◆ u16proto

std::uint16_t u16proto

Definition at line 392 of file netutils.h.

◆ u16protocol

std::uint16_t u16protocol

Definition at line 510 of file netutils.h.

◆ u16Udpcheck

std::uint16_t u16Udpcheck

Definition at line 59 of file netutils.h.

◆ u16Udpdst

std::uint16_t u16Udpdst

Definition at line 57 of file netutils.h.

◆ u16Udplen

std::uint16_t u16Udplen

Definition at line 58 of file netutils.h.

◆ u16Udpsrc

std::uint16_t u16Udpsrc

Definition at line 56 of file netutils.h.

◆ u32dstProtoAddr

std::uint32_t u32dstProtoAddr

Definition at line 517 of file netutils.h.

◆ u32Flags

std::uint32_t u32Flags

Definition at line 796 of file netutils.h.

◆ u32Ipv4dst

std::uint32_t u32Ipv4dst

Definition at line 136 of file netutils.h.

◆ u32Ipv4src

std::uint32_t u32Ipv4src

Definition at line 135 of file netutils.h.

◆ u32srcProtoAddr

std::uint32_t u32srcProtoAddr

Definition at line 515 of file netutils.h.

◆ u8Code

std::uint8_t u8Code

Definition at line 794 of file netutils.h.

◆ u8hwAddrLen

std::uint8_t u8hwAddrLen

Definition at line 511 of file netutils.h.

◆ u8Ipv4hops

std::uint8_t u8Ipv4hops

Definition at line 132 of file netutils.h.

◆ u8Ipv4proto

std::uint8_t u8Ipv4proto

Definition at line 133 of file netutils.h.

◆ u8Ipv4tos

std::uint8_t u8Ipv4tos

Definition at line 128 of file netutils.h.

◆ u8Ipv4vhl

std::uint8_t u8Ipv4vhl

Definition at line 127 of file netutils.h.

◆ u8Ipv6Class

std::uint8_t u8Ipv6Class

Definition at line 251 of file netutils.h.

◆ u8Ipv6hops

std::uint8_t u8Ipv6hops

Definition at line 257 of file netutils.h.

◆ u8Ipv6next

std::uint8_t u8Ipv6next

Definition at line 256 of file netutils.h.

◆ u8Ipv6Ver

std::uint8_t u8Ipv6Ver

Definition at line 250 of file netutils.h.

◆ u8protoAddrLen

std::uint8_t u8protoAddrLen

Definition at line 512 of file netutils.h.

◆ u8Type

std::uint8_t u8Type

Definition at line 793 of file netutils.h.

◆ vcf

struct { ... } vcf

◆ word1

std::uint16_t word1

Definition at line 390 of file netutils.h.

◆ word2

std::uint16_t word2

Definition at line 391 of file netutils.h.

◆ word3

std::uint16_t word3

Definition at line 392 of file netutils.h.

◆ words

struct EtherAddrWords words

Definition at line 391 of file netutils.h.