class UnixComm

A class for socket I/O communication. More...

Definition#include <mfea_unix_comm.hh>
InheritsProtoUnit (libproto) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

Each protocol 'registers' for socket I/O and gets assigned one object of this class.

 UnixComm (MfeaNode& mfea_node, int ipproto, x_module_id module_id)

UnixComm

Constructor for given MFEA node, IP protocol, and module ID (x_module_id).

Parameters:
mfea_nodethe MFEA node (MfeaNode) this entry belongs to.
ipprotothe IP protocol number (e.g., IPPROTO_PIM for PIM).
module_idthe module ID (x_module_id) for the protocol.

 ~UnixComm ()

~UnixComm

[virtual]

Destructor

int  start ()

start

Start the UnixComm.

Returns: XORP_OK on success, otherwise XORP_ERROR.

Reimplemented from ProtoUnit.

int  stop ()

stop

Stop the UnixComm.

Returns: XORP_OK on success, otherwise XORP_ERROR.

Reimplemented from ProtoUnit.

int  get_mcast_vifs (vector<MfeaVif *>& mfea_vifs_vector)

get_mcast_vifs

Query the kernel to find network interfaces that are multicast-capable.

Parameters:
mfea_vifs_vectorreference to the vector to store the created MFEA-specific vifs (MfeaVif).

Returns: the number of created vifs on success, otherwise %XORP_ERROR.

int  ioctl_socket ()

ioctl_socket

[const]

Get the ioctl socket.

The ioctl socket is used for various ioctl() calls.

Returns: the socket value if valid, otherwise XORP_ERROR.

int  open_ioctl_socket ()

open_ioctl_socket

Open an ioctl socket.

The ioctl socket is used for various ioctl() calls.

Returns: the socket value on success, otherwise XORP_ERROR.

int  close_ioctl_socket ()

close_ioctl_socket

Close the ioctl socket.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  mrib_socket ()

mrib_socket

[const]

Get the MRIB socket.

The MRIB socket is used for obtaining Multicast Routing Information Base information.

Returns: the socket value if valid, otherwise XORP_ERROR.

int  open_mrib_socket ()

open_mrib_socket

Open an MRIB socket.

The MRIB socket is used for obtaining Multicast Routing Information Base information.

Returns: the socket value on success, otherwise XORP_ERROR.

int  close_mrib_socket ()

close_mrib_socket

Close the MRIB socket.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  mrouter_socket ()

mrouter_socket

[const]

Get the mrouter socket.

The mrouter socket is used for various multicast-related access.

Returns: the socket value if valid, otherwise XORP_ERROR.

int  open_mrouter_socket ()

open_mrouter_socket

Open an mrouter socket.

The mrouter socket is used for various multicast-related access. Note that no more than one mrouter socket (per address family) should be open at a time.

Returns: the socket value on success, otherwise XORP_ERROR.

int  close_mrouter_socket ()

close_mrouter_socket

Close the mrouter socket.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  set_my_mrouter_socket ()

set_my_mrouter_socket

Set the mrouter socket value of this entry.

The mrouter socket value of this entry is set by copying the mrouter socket value from the special house-keeping UnixComm with module ID (x_module_id) of X_MODULE_NULL.

Returns: the value of the copied mrouter socket on success, otherwise XORP_ERROR.

int  set_other_mrouter_socket ()

set_other_mrouter_socket

Set the mrouter socket value of the other UnixComm entries.

The mrouter socket value of the other UnixComm entries is set by copying the mrouter socket value of this entry. Note that this method should be applied only to the special house-keeping UnixComm with module ID (x_module_id) of X_MODULE_NULL.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  proto_socket ()

proto_socket

[const]

Get the protocol socket.

The protocol socket is specific to the particular protocol of this entry.

Returns: the socket value if valid, otherwise XORP_ERROR.

int  open_proto_socket ()

open_proto_socket

Open an protocol socket.

The protocol socket is specific to the particular protocol of this entry.

Returns: the socket value on success, otherwise XORP_ERROR.

int  close_proto_socket ()

close_proto_socket

Close the protocol socket.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  set_rcvbuf (int recv_socket, int desired_bufsize, int min_bufsize)

set_rcvbuf

Set the receiving buffer size of a socket.

Parameters:
recv_socketthe socket whose receiving buffer size to set.
desired_bufsizethe preferred buffer size.
min_bufsizethe smallest acceptable buffer size.

Returns: the successfully set buffer size on success, otherwise XORP_ERROR

int  ip_hdr_include (bool enable_bool)

ip_hdr_include

Set/reset the "Header Included" option (for IPv4) on the 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 post-RFC-2292, 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:
enable_boolif true, set the option, otherwise reset it.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  recv_pktinfo (bool enable_bool)

recv_pktinfo

Enable/disable receiving information about some of the fields in the IP header on the protocol socket.

If enabled, values such as interface index, destination address and IP TTL (a.k.a. hop-limit in IPv6) will be received as well. Note: used only for IPv6. In IPv4 we don't have this; the whole IP packet is passed to the application listening on a raw socket.

Parameters:
enable_boolif true, set the option, otherwise reset it.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  set_mcast_ttl (int ttl)

set_mcast_ttl

Set the default TTL (or hop-limit in IPv6) for the outgoing multicast packets on the protocol socket.

Parameters:
ttlthe desired IP TTL (a.k.a. hop-limit in IPv6) value.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  set_multicast_loop (bool enable_bool)

set_multicast_loop

Set/reset the "Multicast Loop" flag on the 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:
enable_boolif true, set the loopback, otherwise reset it.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  start_mrt ()

start_mrt

Start/enable the multicast routing in the kernel.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  stop_mrt ()

stop_mrt

Stop/disable the multicast routing in the kernel.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  start_pim ()

start_pim

Start/enable PIM routing in the kernel.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  stop_pim ()

stop_pim

Stop/disable PIM routing in the kernel.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  set_default_multicast_vif (uint16_t vif_index)

set_default_multicast_vif

Set default interface for outgoing multicast on the protocol socket.

Parameters:
vif_indexthe vif index of the interface to become the default multicast interface.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  join_multicast_group (uint16_t vif_index, const IPvX& group)

join_multicast_group

Join a multicast group on an interface.

Parameters:
vif_indexthe vif index of the interface to join the multicast group.
groupthe multicast group to join.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  leave_multicast_group (uint16_t vif_index, const IPvX& group)

leave_multicast_group

Leave a multicast group on an interface.

Parameters:
vif_indexthe vif index of the interface to leave the multicast group.
groupthe multicast group to leave.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  add_multicast_vif (uint16_t vif_index)

add_multicast_vif

Add a virtual multicast interface to the kernel.

Parameters:
vif_indexthe vif index of the virtual interface to add.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  delete_multicast_vif (uint16_t vif_index)

delete_multicast_vif

Delete a virtual multicast interface from the kernel.

Parameters:
vif_indexthe vif index of the interface to delete.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  add_mfc (const IPvX& source, const IPvX& group, uint16_t iif_vif_index, uint8_t *oifs_ttl, uint8_t *oifs_flags, const IPvX& rp_addr)

add_mfc

Install/modify a Multicast Forwarding Cache (MFC) entry in the kernel.

If the MFC entry specified by (@source, @group) pair was not installed before, a new MFC entry will be created in the kernel; otherwise, the existing entry's fields will be modified.

Parameters:
sourcethe MFC source address.
groupthe MFC group address.
iif_vif_indexthe MFC incoming interface index.
oifs_ttlan array with the min. TTL a packet should have to be forwarded.
oifs_flagsan array with misc. flags for the MFC to install. Note that those flags are supported only by the advanced multicast API.
rp_addrthe RP address.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  delete_mfc (const IPvX& source, const IPvX& group)

delete_mfc

Delete a Multicast Forwarding Cache (MFC) entry in the kernel.

Parameters:
sourcethe MFC source address.
groupthe MFC group address.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  add_bw_upcall (const IPvX& source, const IPvX& group, const struct timeval& threshold_interval, uint32_t threshold_packets, uint32_t threshold_bytes, bool is_threshold_in_packets, bool is_threshold_in_bytes, bool is_geq_upcall, bool is_leq_upcall)

add_bw_upcall

Add a dataflow monitor entry in the kernel.

Note: either is_threshold_in_packets or is_threshold_in_bytes (or both) must be true. Note: either is_geq_upcall or is_leq_upcall (but not both) must be true.

Parameters:
sourcethe source address.
groupthe group address.
threshold_intervalthe dataflow threshold interval.
threshold_packetsthe threshold (in number of packets) to compare against.
threshold_bytesthe threshold (in number of bytes) to compare against.
is_threshold_in_packetsif true, threshold_packets is valid.
is_threshold_in_bytesif true, threshold_bytes is valid.
is_geq_upcallif true, the operation for comparison is ">=".
is_leq_upcallif true, the operation for comparison is "<=".

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  delete_bw_upcall (const IPvX& source, const IPvX& group, const struct timeval& threshold_interval, uint32_t threshold_packets, uint32_t threshold_bytes, bool is_threshold_in_packets, bool is_threshold_in_bytes, bool is_geq_upcall, bool is_leq_upcall)

delete_bw_upcall

Delete a dataflow monitor entry from the kernel.

Note: either is_threshold_in_packets or is_threshold_in_bytes (or both) must be true. Note: either is_geq_upcall or is_leq_upcall (but not both) must be true.

Parameters:
sourcethe source address.
groupthe group address.
threshold_intervalthe dataflow threshold interval.
threshold_packetsthe threshold (in number of packets) to compare against.
threshold_bytesthe threshold (in number of bytes) to compare against.
is_threshold_in_packetsif true, threshold_packets is valid.
is_threshold_in_bytesif true, threshold_bytes is valid.
is_geq_upcallif true, the operation for comparison is ">=".
is_leq_upcallif true, the operation for comparison is "<=".

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  delete_all_bw_upcall (const IPvX& source, const IPvX& group)

delete_all_bw_upcall

Delete all dataflow monitor entries from the kernel for a given source and group address.

Parameters:
sourcethe source address.
groupthe group address.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  get_sg_count (const IPvX& source, const IPvX& group, SgCount& sg_count)

get_sg_count

Get various counters per (S,G) entry.

Get the number of packets and bytes forwarded by a particular Multicast Forwarding Cache (MFC) entry in the kernel, and the number of packets arrived on wrong interface for that entry.

Parameters:
sourcethe MFC source address.
groupthe MFC group address.
sg_counta reference to a SgCount class to place the result.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  get_vif_count (uint16_t vif_index, VifCount& vif_count)

get_vif_count

Get various counters per virtual interface.

Get the number of packets and bytes received on, or forwarded on a particular multicast interface.

Parameters:
vif_indexthe vif index of the virtual multicast interface whose statistics we need.
vif_counta reference to a VifCount class to store the result.

Returns: XORP_OK on success, otherwise XORP_ERROR.

bool  is_multicast_capable (uint16_t vif_index)

is_multicast_capable

[const]

Test if an interface in the kernel is multicast-capable.

Parameters:
vif_indexthe vif index of the interface to test whether is multicast capable.

Returns: true if the interface is multicast-capable, otherwise false.

int  proto_socket_read ()

proto_socket_read

Read data from a protocol socket, and then call the appropriate protocol module to process it.

Note: this function should not be called directly, but should be called by its wrapper: unix_comm_proto_socket_read().

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  proto_socket_write (uint16_t vif_index, const IPvX& src, const IPvX& dst, int ip_ttl, int ip_tos, bool router_alert_bool, const uint8_t *databuf, size_t datalen)

proto_socket_write

Send a packet on a protocol socket.

Parameters:
vif_indexthe vif index of the vif that will be used to send-out the packet.
srcthe source address of the packet.
dstthe destination address of the packet.
ip_ttlthe 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_tosthe 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.
router_alert_boolif true, then the IP packet with the data should have the Router Alert option included.
databufthe data buffer.
datalenthe length of the data in databuf.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  get_mrib (const IPvX& dest_addr, Mrib& mrib)

get_mrib

Get the Multicast Routing Information Base (MRIB) information for a given address (Mrib).

The MRIB information contains the next hop router and the vif to send out packets toward a given destination.

Parameters:
dest_addrthe destination address to lookup.
mriba reference to a Mrib structure to return the MRIB information.

Returns: XORP_OK on success, otherwise XORP_ERROR.

int  get_mrib_table (Mrib **mrib_table)

get_mrib_table

Get all MRIB (Mrib) information from the kernel.

Parameters:
mrib_tablea pointer to the routing table array composed of Mrib elements.

Returns: the number of entries in return_mrib_table, or XORP_ERROR if there was an error

void  set_ignore_my_packets (bool v)

set_ignore_my_packets

Set/reset the flag whether to ignore the receiving my own packets.

Parameters:
vif true, ignore my own packets on receiving, otherwise don't ignore them.

void  set_allow_kernel_signal_messages (bool v)

set_allow_kernel_signal_messages

Set/reset the flag whether to allow signal messages from the kernel.

Parameters:
vif true, allow delivery of signal messages from the kernel for this protocol.

bool  is_allow_kernel_signal_messages ()

is_allow_kernel_signal_messages

[const]

Test if the the kernel signal messages are allowed for this protocol.

Returns: true if the kernel signal messages are allowed, otherwise false.

void  set_allow_mrib_messages (bool v)

set_allow_mrib_messages

Set/reset the flag whether to allow MRIB (Mrib) messages for this protocol.

Parameters:
vif true, allow delivery of MRIB (Mrib) messages for this protocol.

bool  is_allow_mrib_messages ()

is_allow_mrib_messages

[const]

Test if the the delivery of MRIB (Mrib) messages are allowed for this protocol.

Returns: true if the delivery is allowed.

bool  mrt_api_mrt_mfc_flags_disable_wrongvif ()

mrt_api_mrt_mfc_flags_disable_wrongvif

[const]

Get the flag that indicates whether the kernel supports disabling of WRONGVIF signal per (S,G) per interface.

Returns: true if the kernel supports disabling of WRONGVIF signal per (S,G) per interface, otherwise false.

bool  mrt_api_mrt_mfc_flags_border_vif ()

mrt_api_mrt_mfc_flags_border_vif

[const]

Get the flag that indicates whether the kernel supports setting of the Border bit flag per (S,G) per interface.

The Border bit flag is used for PIM-SM Register encapsulation in the kernel.

Returns: true if the kernel supports setting of the Border bit flag per (S,G) per interface, otherwise false.

bool  mrt_api_mrt_mfc_rp ()

mrt_api_mrt_mfc_rp

[const]

Get the flag that indicates whether the kernel supports adding the RP address to the kernel.

The RP address is used for PIM-SM Register encapsulation in the kernel.

Returns: true if the kernel supports adding the RP address to the kernel, otherwise false.

bool  mrt_api_mrt_mfc_bw_upcall ()

mrt_api_mrt_mfc_bw_upcall

[const]

Get the flag that indicates whether the kernel supports the bandwidth upcall mechanism.

Returns: true if the kernel supports the bandwidth upcall mechanism.

x_module_id  module_id ()

module_id

[const]

Get the module ID (x_module_id) for the protocol that created this entry.

Returns: the module ID (x_module_id) of the protocol that created this entry.

Reimplemented from ProtoUnit.


Generated by: pavlin on possum.icir.org on Mon Mar 10 19:34:53 2003, using kdoc 2.0a54+XORP.