|
|
Each protocol 'registers' for socket I/O and gets assigned one object of this class.
RawSocket (EventLoop& eventloop, int init_family, uint8_t ip_protocol,
const IfTree& iftree)
| RawSocket |
Constructor for a given address family and protocol.
Parameters:
eventloop | the event loop to use. |
init_family | the address family. |
ip_protocol | the IP protocol number (IPPROTO_*). |
iftree | the interface tree. |
~RawSocket ()
| ~RawSocket |
[virtual]
EventLoop& eventloop ()
| eventloop |
Get the event loop.
Returns: the event loop.
int family ()
| family |
[const]
Get the address family.
Returns: the address family.
int start (string& error_msg)
| start |
Start the RawSocket.
Parameters:
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int stop (string& error_msg)
| stop |
Stop the RawSocket.
Parameters:
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int ip_protocol ()
| ip_protocol |
[const]
Get the IP protocol number.
Returns: the IP protocol number.
int enable_ip_hdr_include (bool is_enabled, string& error_msg)
| enable_ip_hdr_include |
Enable/disable the "Header Included" option (for IPv4) on the outgoing protocol socket.
If enabled, the IP header of a raw packet should be created by the application itself, otherwise the kernel will build it. Note: used only for IPv4. In RFC-3542, IPV6_PKTINFO has similar functions, but because it requires the interface index and outgoing address, it is of little use for our purpose. Also, in RFC-2292 this option was a flag, so for compatibility reasons we better not set it here; instead, we will use sendmsg() to specify the header's field values.
Parameters:
is_enabled | if true, enable the option, otherwise disable it. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int enable_recv_pktinfo (bool is_enabled, string& error_msg)
| enable_recv_pktinfo |
Enable/disable receiving information about a packet received on the incoming protocol socket.
If enabled, values such as interface index, destination address and IP TTL (a.k.a. hop-limit in IPv6), and hop-by-hop options will be received as well.
Parameters:
is_enabled | if true, set the option, otherwise reset it. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int set_multicast_ttl (int ttl, string& error_msg)
| set_multicast_ttl |
Set the default TTL (or hop-limit in IPv6) for the outgoing multicast packets on the outgoing protocol socket.
Parameters:
ttl | the desired IP TTL (a.k.a. hop-limit in IPv6) value. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int enable_multicast_loopback (bool is_enabled, string& error_msg)
| enable_multicast_loopback |
Enable/disable the "Multicast Loop" flag on the outgoing protocol socket.
If the multicast loopback flag is enabled, a multicast datagram sent on that socket will be delivered back to this host (assuming the host is a member of the same multicast group).
Parameters:
is_enabled | if true, enable the loopback, otherwise disable it. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int set_default_multicast_interface (const string& if_name,
const string& vif_name,
string& error_msg)
| set_default_multicast_interface |
Set default interface for outgoing multicast on the outgoing protocol socket.
Parameters:
if_name | the name of the interface that would become the default multicast interface. |
vif_name | the name of the vif that would become the default multicast interface. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int join_multicast_group (const string& if_name,
const string& vif_name,
const IPvX& group,
string& error_msg)
| join_multicast_group |
Join a multicast group on an interface.
Parameters:
if_name | the name of the interface to join the multicast group. |
vif_name | the name of the vif to join the multicast group. |
group | the multicast group to join. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int leave_multicast_group (const string& if_name,
const string& vif_name,
const IPvX& group,
string& error_msg)
| leave_multicast_group |
Leave a multicast group on an interface.
Parameters:
if_name | the name of the interface to leave the multicast group. |
vif_name | the name of the vif to leave the multicast group. |
group | the multicast group to leave. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int proto_socket_write (const string& if_name,
const string& vif_name,
const IPvX& src_address,
const IPvX& dst_address,
int32_t ip_ttl,
int32_t ip_tos,
bool ip_router_alert,
const vector<uint8_t>& ext_headers_type,
const vector<vector<uint8_t> >& ext_headers_payload,
const vector<uint8_t>& payload,
string& error_msg)
| proto_socket_write |
Send a packet on a raw socket.
Parameters:
if_name | the interface to send the packet on. It is essential for multicast. In the unicast case this field may be empty. |
vif_name | the vif to send the packet on. It is essential for multicast. In the unicast case this field may be empty. |
src_address | the IP source address. |
dst_address | the IP destination address. |
ip_ttl | the IP TTL (hop-limit). If it has a negative value, the TTL will be set internally before transmission. |
ip_tos | the Type Of Service (Diffserv/ECN bits for IPv4 or IP traffic class for IPv6). If it has a negative value, the TOS will be set internally before transmission. |
ip_router_alert | if true, then add the IP Router Alert option to the IP packet. |
ext_headers_type | a vector of integers with the types of the optional IPv6 extention headers. |
ext_headers_payload | a vector of payload data, one for each optional IPv6 extention header. The number of entries must match ext_headers_type. |
payload | the payload, everything after the IP header and options. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
void process_recv_data (const string& if_name,
const string& vif_name,
const IPvX& src_address,
const IPvX& dst_address,
int32_t ip_ttl,
int32_t ip_tos,
bool ip_router_alert,
const vector<uint8_t>& ext_headers_type,
const vector<vector<uint8_t> >& ext_headers_payload,
const vector<uint8_t>& payload)
| process_recv_data |
[pure virtual]
Received a packet from a raw socket.
This is a pure virtual method that must be implemented in the class that inherits from this class.
Parameters:
if_name | the interface name the packet arrived on. |
vif_name | the vif name the packet arrived on. |
src_address | the IP source address. |
dst_address | the IP destination address. |
ip_protocol | the IP protocol number. |
ip_ttl | the IP TTL (hop-limit). If it has a negative value, then the received value is unknown. |
ip_tos | The type of service (Diffserv/ECN bits for IPv4). If it has a negative value, then the received value is unknown. |
ip_router_alert | if true, the IP Router Alert option was included in the IP packet. |
ext_headers_type | a vector of integers with the types of the optional IPv6 extention headers. |
ext_headers_payload | a vector of payload data, one for each optional IPv6 extention header. The number of entries must match ext_headers_type. |
packet | the payload, everything after the IP header and options. |
bool find_interface_vif_by_name (
const string& if_name,
const string& vif_name,
const IfTreeInterface*& iftree_if,
const IfTreeVif*& iftree_vif)
| find_interface_vif_by_name |
[const]
Find an interface and a vif by interface and vif name.
Parameters:
if_name | the interface name. |
vif_name | the vif name. |
iftree_if | return-by-reference a pointer to the interface. |
iftree_vif | return-by-reference a pointer to the vif. |
Returns: true if a match is found, otherwise false.
bool find_interface_vif_by_pif_index (
uint32_t pif_index,
const IfTreeInterface*& iftree_if,
const IfTreeVif*& iftree_vif)
| find_interface_vif_by_pif_index |
[const]
Find an interface and a vif by physical interface index.
Parameters:
pif_index | the physical interface index. |
iftree_if | return-by-reference a pointer to the interface. |
iftree_vif | return-by-reference a pointer to the vif. |
Returns: true if a match is found, otherwise false.
bool find_interface_vif_same_subnet_or_p2p (
const IPvX& addr,
const IfTreeInterface*& iftree_if,
const IfTreeVif*& iftree_vif)
| find_interface_vif_same_subnet_or_p2p |
[const]
Find an interface and a vif by an address that shares the same subnet or p2p address.
Parameters:
addr | the address. |
iftree_if | return-by-reference a pointer to the interface. |
iftree_vif | return-by-reference a pointer to the vif. |
Returns: true if a match is found, otherwise false.
bool find_interface_vif_by_addr (
const IPvX& addr,
const IfTreeInterface*& iftree_if,
const IfTreeVif*& iftree_vif)
| find_interface_vif_by_addr |
[const]
Find an interface and a vif by an address that belongs to that interface and vif.
Parameters:
addr | the address. |
iftree_if | return-by-reference a pointer to the interface. |
iftree_vif | return-by-reference a pointer to the vif. |
Returns: true if a match is found, otherwise false.