|
|
Each protocol 'registers' for socket I/O and gets assigned one object of this class.
ProtoComm (MfeaNode& mfea_node, int ip_protocol, xorp_module_id module_id)
| ProtoComm |
Constructor for given MFEA node, IP protocol, and module ID (xorp_module_id).
Parameters:
mfea_node | the MFEA node (MfeaNode) this entry belongs to. |
ip_protocol | the IP protocol number (e.g., IPPROTO_PIM for PIM). |
module_id | the module ID (xorp_module_id) for the protocol. |
~ProtoComm ()
| ~ProtoComm |
[virtual]
int start ()
| start |
Start the ProtoComm.
Returns: XORP_OK on success, otherwise XORP_ERROR.
int stop ()
| stop |
Stop the ProtoComm.
Returns: XORP_OK on success, otherwise XORP_ERROR.
int ip_protocol ()
| ip_protocol |
[const]
Get the IP protocol number.
Returns: the IP protocol number.
XorpFd proto_socket_in ()
| proto_socket_in |
[const]
Get the protocol socket for receiving.
The protocol socket is specific to the particular protocol of this entry.
Returns: the socket value if valid, otherwise XORP_ERROR.
XorpFd proto_socket_out ()
| proto_socket_out |
[const]
Get the protocol socket for sending.
The protocol socket is specific to the particular protocol of this entry.
Returns: the socket value if valid, otherwise XORP_ERROR.
int open_proto_sockets ()
| open_proto_sockets |
Open the protocol sockets.
The protocol sockets are specific to the particular protocol of this entry.
Returns: XORP_OK on success, otherwise XORP_ERROR.
int add_proto_socket_in_callback ()
| add_proto_socket_in_callback |
Add the method to read from the incoming protocol socket.
Returns: XORP_OK on success, otherwise XORP_ERROR.
int close_proto_sockets ()
| close_proto_sockets |
Close the protocol sockets.
Returns: XORP_OK on success, otherwise XORP_ERROR.
int ip_hdr_include (bool is_enabled)
| ip_hdr_include |
Set/reset the "Header Included" option (for IPv4) on the outgoing protocol socket.
If set, 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, set the option, otherwise reset it. |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int recv_pktinfo (bool is_enabled)
| 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. |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int set_multicast_ttl (int ttl)
| 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. |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int set_multicast_loop (bool is_enabled)
| set_multicast_loop |
Set/reset the "Multicast Loop" flag on the outgoing protocol socket.
If the multicast loopback flag is set, 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, set the loopback, otherwise reset it. |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int set_default_multicast_vif (uint32_t vif_index)
| set_default_multicast_vif |
Set default interface for outgoing multicast on the outgoing protocol socket.
Parameters:
vif_index | the vif index of the interface to become the default multicast interface. |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int join_multicast_group (uint32_t vif_index, const IPvX& group)
| join_multicast_group |
Join a multicast group on an interface.
Parameters:
vif_index | the vif index of the interface to join the multicast group. |
group | the multicast group to join. |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int leave_multicast_group (uint32_t vif_index, const IPvX& group)
| leave_multicast_group |
Leave a multicast group on an interface.
Parameters:
vif_index | the vif index of the interface to leave the multicast group. |
group | the multicast group to leave. |
Returns: XORP_OK on success, otherwise XORP_ERROR.
void proto_socket_read (XorpFd fd, IoEventType type)
| proto_socket_read |
Read data from a protocol socket, and then call the appropriate protocol module to process it.
This is called as a IoEventCb callback.
Parameters:
fd | file descriptor that with event caused this method to be called. |
m | mask representing event type. |
int proto_socket_write (uint32_t vif_index,
const IPvX& src, const IPvX& dst,
int ip_ttl, int ip_tos,
bool is_router_alert,
const uint8_t *databuf, size_t datalen,
string& error_msg)
| proto_socket_write |
Send a packet on a protocol socket.
Parameters:
vif_index | the vif index of the vif that will be used to send-out the packet. |
src | the source address of the packet. |
dst | the destination address of the packet. |
ip_ttl | the TTL (a.k.a. Hop-limit in IPv6) of the packet. If it has a negative value, the TTL will be set here or by the lower layers. |
ip_tos | the TOS (a.k.a. Traffic Class in IPv6) of the packet. If it has a negative value, the TOS will be set here or by the lower layers. |
is_router_alert | if true, then the IP packet with the data should have the Router Alert option included. |
databuf | the data buffer. |
datalen | the length of the data in databuf. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
xorp_module_id module_id ()
| module_id |
[const]
Get the module ID (xorp_module_id) for the protocol that created this entry.
Returns: the module ID (xorp_module_id) of the protocol that created this entry.
Reimplemented from ProtoUnit.