mroute_socket Class Reference
Wrapper for a multicast socket with additional functions to manipulate Linux kernel tables.
#include "mroute_socket.hpp"
Public Member Functions | |
bool | add_extension_header (const unsigned char *buf, unsigned int buf_size) |
bool | add_mroute (int input_vifNum, const char *source_addr, const char *group_addr, unsigned int *output_vifNum, unsigned int output_vifNum_size) |
bool | add_vif (int vifNum, const char *ifName, const char *ipTunnelRemoteAddr) |
u_int16_t | calc_checksum (const unsigned char *buf, int buf_size) |
bool | create_raw_ipv4_socket () |
bool | create_raw_ipv6_socket () |
bool | del_mroute (int input_vifNum, const char *source_addr, const char *group_addr) |
bool | del_vif (int vifNum) |
mroute_socket () | |
bool | set_default_icmp6_checksum_calc (bool enable) |
bool | set_mrt_flag (bool enable) |
bool | set_no_ip_hdr () |
bool | set_recv_hop_by_hop_msg () |
bool | set_recv_icmpv6_msg () |
bool | set_recv_pkt_info () |
virtual | ~mroute_socket () |
Static Public Member Functions | |
static void | print_struct_mf6cctl (struct mf6cctl *mc) |
static void | test_add_route (mroute_socket *m) |
static void | test_add_vifs (mroute_socket *m) |
static void | test_del_route (mroute_socket *m) |
static void | test_del_vifs (mroute_socket *m) |
static void | test_mcrouter_mrt_flag () |
static void | test_mcrouter_vifs_routes (int addrFamily) |
Constructor & Destructor Documentation
mroute_socket::mroute_socket | ( | ) |
Create a mroute_socket.
References HC_LOG_TRACE.
mroute_socket::~mroute_socket | ( | ) | [virtual] |
Close raw socket.
References HC_LOG_TRACE.
Member Function Documentation
bool mroute_socket::add_extension_header | ( | const unsigned char * | buf, | |
unsigned int | buf_size | |||
) |
Add an extension header to a sending packet.
- Parameters:
-
buf extension header buf_size size of the extension header
- Returns:
- Return true on success.
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
bool mroute_socket::add_mroute | ( | int | input_vifNum, | |
const char * | source_addr, | |||
const char * | group_addr, | |||
unsigned int * | output_vifNum, | |||
unsigned int | output_vifNum_size | |||
) |
Adds a multicast route to the kernel. /proc/net$ cat ip_mr_cache display the route.
- Parameters:
-
input_vifNum have to be the same value as in addVIF set source_addr from the receiving packet group_addr from the receiving packet output_vifNum forward to this virtual interface indexes output_vifNum_size size of the interface indexes
- Returns:
- Return true on success.
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, mc_socket::m_sock, and MROUTE_DEFAULT_TTL.
Referenced by test_add_route().
bool mroute_socket::add_vif | ( | int | vifNum, | |
const char * | ifName, | |||
const char * | ipTunnelRemoteAddr | |||
) |
Adds the virtual interface to the mrouted API
- sysctl net.ipv4.conf.eth0.mc_forwarding will be set
- /proc/net$ cat ip_mr_vif displays the added interface.
- Parameters:
-
vifNum musst the same unique number as delVIF (0 > uniqueNumber < MAXVIF ==32) ifName is the interface name e. g. "eth0" ipTunnelRemoteAddr if the interface is a tunnel interface the remote address has to set else it has to be NULL
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, mc_socket::m_sock, MROUTE_RATE_LIMIT_ENDLESS, and MROUTE_TTL_THRESHOLD.
Referenced by test_add_vifs().
u_int16_t mroute_socket::calc_checksum | ( | const unsigned char * | buf, | |
int | buf_size | |||
) |
Calculate an internet checksum needed for IPv4 IGMP header.
- Parameters:
-
buf header of the IGMP packet with a zero checksum field buf_size size of the IGMP packet
References ADD_SIGNED_NUM_U16, and HC_LOG_TRACE.
bool mroute_socket::create_raw_ipv4_socket | ( | ) |
Create IPv4 raw socket.
- Returns:
- Return true on success.
References HC_LOG_DEBUG, HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, mc_socket::m_own_socket, and mc_socket::m_sock.
Referenced by sender::init(), test_mcrouter_mrt_flag(), test_mcrouter_vifs_routes(), and test_mctables().
bool mroute_socket::create_raw_ipv6_socket | ( | ) |
Create IPv6 raw socket (RFC 3542 Section 3).
- Returns:
- Return true on success.
References HC_LOG_DEBUG, HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, mc_socket::m_own_socket, and mc_socket::m_sock.
Referenced by sender::init(), test_mcrouter_mrt_flag(), test_mcrouter_vifs_routes(), and test_mctables().
bool mroute_socket::del_mroute | ( | int | input_vifNum, | |
const char * | source_addr, | |||
const char * | group_addr | |||
) |
Delete a multicast route.
- Parameters:
-
input_vifNum have to be the same value as in addVIF set source_addr from the receiving packet group_addr from the receiving packet
- Returns:
- Return true on success.
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
Referenced by test_del_route().
bool mroute_socket::del_vif | ( | int | vifNum | ) |
Delete the virtual interface from the multicast routing table.
- Parameters:
-
vifNum virtual index of the interface
- Returns:
- Return true on success.
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
Referenced by test_del_vifs().
void mroute_socket::print_struct_mf6cctl | ( | struct mf6cctl * | mc | ) | [static] |
References HC_LOG_TRACE.
bool mroute_socket::set_default_icmp6_checksum_calc | ( | bool | enable | ) |
Calculate the ICMPv6 header checksum by sending an ICMPv6 packet. Per default the ICMP6 checksum (RFC 3542 Section 3.1) will be calculate.
- Parameters:
-
enable if true the checsum will be calculate.
- Returns:
- Return true on success.
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
Referenced by mld_sender::init().
bool mroute_socket::set_mrt_flag | ( | bool | enable | ) |
Enable or disable MRT flag to manipulate the multicast routing tables.
- sysctl net.ipv4.conf.all.mc_forwarding will be set/reset.
- Returns:
- Return true on success.
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
Referenced by test_mcrouter_mrt_flag(), test_mcrouter_vifs_routes(), and test_mctables().
bool mroute_socket::set_no_ip_hdr | ( | ) |
The IPv4 layer generates an IP header when sending a packet unless the IP_HDRINCL socket option is enabled on the socket. When it is enabled, the packet must contain an IP header. For receiving the IP header is always included in the packet.
- Returns:
- Return true on success.
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
bool mroute_socket::set_recv_hop_by_hop_msg | ( | ) |
Set to pass the Hob-by-Hob header to userpace.
- Returns:
- Return true on success
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
bool mroute_socket::set_recv_icmpv6_msg | ( | ) |
Set to pass all icmpv6 packets to userpace.
- Returns:
- Return true on success.
References HC_LOG_ERROR, HC_LOG_TRACE, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
Referenced by mld_receiver::init().
bool mroute_socket::set_recv_pkt_info | ( | ) |
Set to pass the receive packet information to userpace.
- Returns:
- Return true on success
References HC_LOG_ERROR, mc_socket::is_udp_valid(), mc_socket::m_addrFamily, and mc_socket::m_sock.
Referenced by mld_receiver::init().
void mroute_socket::test_add_route | ( | mroute_socket * | m | ) | [static] |
References add_mroute(), mc_socket::get_addr_family(), HC_LOG_TRACE, MROUTE_SOCKET_G_ADDR_V4, MROUTE_SOCKET_G_ADDR_V6, MROUTE_SOCKET_IF_NUM_ONE, MROUTE_SOCKET_IF_NUM_TWO, MROUTE_SOCKET_IF_STR_ONE, MROUTE_SOCKET_IF_STR_TWO, MROUTE_SOCKET_SRC_ADDR_V4, and MROUTE_SOCKET_SRC_ADDR_V6.
Referenced by test_mcrouter_vifs_routes(), and test_mctables().
void mroute_socket::test_add_vifs | ( | mroute_socket * | m | ) | [static] |
References add_vif(), HC_LOG_TRACE, MROUTE_SOCKET_IF_NUM_ONE, MROUTE_SOCKET_IF_NUM_TWO, MROUTE_SOCKET_IF_STR_ONE, and MROUTE_SOCKET_IF_STR_TWO.
Referenced by test_mcrouter_vifs_routes(), and test_mctables().
void mroute_socket::test_del_route | ( | mroute_socket * | m | ) | [static] |
References del_mroute(), mc_socket::get_addr_family(), HC_LOG_TRACE, MROUTE_SOCKET_G_ADDR_V4, MROUTE_SOCKET_G_ADDR_V6, MROUTE_SOCKET_IF_NUM_ONE, MROUTE_SOCKET_IF_STR_ONE, MROUTE_SOCKET_IF_STR_TWO, MROUTE_SOCKET_SRC_ADDR_V4, and MROUTE_SOCKET_SRC_ADDR_V6.
Referenced by test_mcrouter_vifs_routes(), and test_mctables().
void mroute_socket::test_del_vifs | ( | mroute_socket * | m | ) | [static] |
References del_vif(), HC_LOG_TRACE, MROUTE_SOCKET_IF_NUM_ONE, and MROUTE_SOCKET_IF_NUM_TWO.
Referenced by test_mcrouter_vifs_routes(), and test_mctables().
void mroute_socket::test_mcrouter_mrt_flag | ( | ) | [static] |
References create_raw_ipv4_socket(), create_raw_ipv6_socket(), HC_LOG_TRACE, and set_mrt_flag().
void mroute_socket::test_mcrouter_vifs_routes | ( | int | addrFamily | ) | [static] |