|
|
NetlinkSocket class opens a netlink socket and forwards data arriving on the socket to NetlinkSocketObservers. The NetlinkSocket hooks itself into the EventLoop and activity usually happens asynchronously.
NetlinkSocket (EventLoop& e)
| NetlinkSocket |
~NetlinkSocket ()
| ~NetlinkSocket |
int start (int af)
| start |
Start the netlink socket operation.
Parameters:
af | the address family. |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int stop ()
| stop |
Stop the netlink socket operation.
Returns: XORP_OK on success, otherwise XORP_ERROR.
inline bool is_open ()
| is_open |
[const]
Test if the netlink socket is open.
This method is needed because NetlinkSocket may fail to open netlink socket during construction.
Returns: true if the netlink socket is open, otherwise false.
ssize_t write (const void* data, size_t nbytes)
| write |
Write data to netlink socket.
This method also updates the sequence number associated with this netlink socket.
Returns: the number of bytes which were written, or -1 if error.
ssize_t sendto (const void* data, size_t nbytes, int flags,
const struct sockaddr* to, socklen_t tolen)
| sendto |
Sendto data on netlink socket.
This method also updates the sequence number associated with this netlink socket.
Returns: the number of bytes which were written, or -1 if error.
inline uint32_t seqno ()
| seqno |
[const]
Get the sequence number for next message written into the kernel.
The sequence number is derived from the instance number of this netlink socket and a 16-bit counter.
Returns: the sequence number for the next message written into the kernel.
inline pid_t pid ()
| pid |
[const]
Get cached process identifier value.
Returns: the cached process identifier value.
void force_read ()
| force_read |
Force socket to read data.
This usually is performed after writing a request that the kernel will answer (e.g., after writing a route lookup). Use sparingly, with caution, and at your own risk.
void force_recvfrom (int flags, struct sockaddr* from, socklen_t* fromlen)
| force_recvfrom |
Force socket to recvfrom data.
This usually is performed after writing a sendto() request that the kernel will answer (e.g., after writing a route lookup). Use sparingly, with caution, and at your own risk.
void force_recvmsg (int flags)
| force_recvmsg |
Force socket to recvmsg data.
This usually is performed after writing a senmsg() request that the kernel will answer (e.g., after writing a route lookup). Use sparingly, with caution, and at your own risk.
void set_nl_groups (uint32_t v)
| set_nl_groups |
Set the netlink multicast groups to listen for on the netlink socket.
Note that this method must be called before method start() is called. If this method is not called, then the netlink socket will listen to the default set of netlink multicast groups (the empty set).
Parameters:
v | the set of netlink multicast groups to listen for on the netlink socket. |
void set_multipart_message_read (bool v)
| set_multipart_message_read |
Set a flag to expect to read a multipart message that is terminated with NLMSG_DONE.
This flag is required to fix a bug with the Linux kernel: if we try to read the whole forwarding table, the kernel doesn't set the NLM_F_MULTI flag in each part of the multi-part message. The problem is similar when we read all addresses on an interface.
Parameters:
v | if true, set the flag to expect to read a multi-part message that is terminated with NLMSG_DONE. |