Agora
1.2.0
Agora project
|
Common definitons for Ethernet-based transports. More...
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <linux/if_packet.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <cassert>
#include <sstream>
#include <string>
#include "utils.h"
Go to the source code of this file.
Classes | |
struct | eth_routing_info_t |
struct | eth_hdr_t |
struct | ipv4_hdr_t |
struct | udp_hdr_t |
Functions | |
static std::string | mac_to_string (const uint8_t *mac) |
static uint32_t | ipv4_from_str (const char *ip) |
Get the network-byte-order IPv4 address from a human-readable IP string. More... | |
static std::string | ipv4_to_string (uint32_t ipv4_addr) |
Convert a network-byte-order IPv4 address to a human-readable IP string. More... | |
struct eth_hdr_t | __attribute__ ((packed)) |
std::string | to_string () const |
static std::string | frame_header_to_string (const uint8_t *buf) |
static void | gen_eth_header (eth_hdr_t *eth_header, const uint8_t *src_mac, const uint8_t *dst_mac) |
Fill in Ethernet header eth_header using the source and destination MAC. More... | |
static void | gen_ipv4_header (ipv4_hdr_t *ipv4_hdr, uint32_t src_ip, uint32_t dst_ip, uint16_t data_size) |
static void | gen_udp_header (udp_hdr_t *udp_hdr, uint16_t src_port, uint16_t dst_port, uint16_t data_size) |
static uint32_t | get_interface_ipv4_addr (const std::string &interface) |
Return the IPv4 address of a kernel-visible interface in host-byte order. More... | |
static void | fill_interface_mac (const std::string &interface, uint8_t *mac) |
Fill the MAC address of kernel-visible interface. More... | |
Variables | |
static constexpr uint16_t | kIPEtherType = 0x800 |
static constexpr uint16_t | kIPHdrProtocol = 0x11 |
uint8_t | dst_mac [6] |
uint8_t | src_mac [6] |
uint16_t | eth_type |
uint8_t | ihl |
uint8_t | version |
uint8_t | ecn |
uint8_t | dscp |
uint16_t | tot_len |
uint16_t | id |
uint16_t | frag_off |
uint8_t | ttl |
uint8_t | protocol |
uint16_t | check |
uint32_t | src_ip |
uint32_t | dst_ip |
uint16_t | src_port |
uint16_t | dst_port |
uint16_t | len |
static constexpr size_t | kInetHdrsTotSize |
Common definitons for Ethernet-based transports.
struct eth_hdr_t __attribute__ | ( | (packed) | ) |
|
inlinestatic |
Fill the MAC address of kernel-visible interface.
|
inlinestatic |
Return a string representation of the Ethernet + IPv4 + UDP frame headers starting at buf
|
inlinestatic |
Fill in Ethernet header eth_header
using the source and destination MAC.
|
inlinestatic |
Format the IPv4 header for a UDP packet. All value arguments are in host-byte order. data_size
is the data payload size in the UDP packet.
|
inlinestatic |
Format the UDP header for a UDP packet. All value arguments are in host-byte order. data_size
is the data payload size in the UDP packet.
|
inlinestatic |
Return the IPv4 address of a kernel-visible interface in host-byte order.
|
inlinestatic |
Get the network-byte-order IPv4 address from a human-readable IP string.
|
inlinestatic |
Convert a network-byte-order IPv4 address to a human-readable IP string.
|
inlinestatic |
std::string to_string | ( | ) | const |
uint16_t check |
uint8_t dscp |
uint32_t dst_ip |
uint8_t dst_mac[6] |
uint16_t dst_port |
uint8_t ecn |
uint16_t eth_type |
uint16_t frag_off |
uint16_t id |
uint8_t ihl |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
uint16_t len |
uint8_t protocol |
uint32_t src_ip |
uint8_t src_mac[6] |
uint16_t src_port |
uint16_t tot_len |
uint8_t ttl |
uint8_t version |