Previous: Constants, Up: Common API [Contents][Index]
The (netlink connection)
module defines the following procedures, used
to connect and communicate with another process or the kernel using a netlink
socket.
Return a bytevector that represents a netlink address. family
should be AF_NETLINK
, pid is the PID of the process with which
to communicate or 0 for the kernel. groups is an integer representing
the set of broadcast groups to which the connection subscribes.
Creates a netlink socket for proto and binds it to addr.
proto is the integer representing the protocol. For instance, rtnetlink
can be selected by usin NETLINK_ROUTE
(defined in
(netlink constant)
).
addr is a bytevector, as returned by get-addr
.
flags is a set of additional flags to pass as the second argument
to the socket
system call—e.g., SOCK_NONBLOCK
.
This procedure is a wrapper for connect
that creates a socket for the
rtnetlink protocol, binds it to the kernel and returns it. By passing the
optional groups keyword, you can select broadcast groups to subscribe to.
flags is a set of additional flags to pass as the second argument
to the socket
system call—e.g., SOCK_NONBLOCK
.
Make sock a member of group, an RTNLGRP_
constant,
meaning that it will be subscribed to events of that group.
For example, here is how you could create a netlink socket and subscribe it to the “link” group so that it receives notifications for new and removed links:
(let ((sock (connect-route))) (add-socket-membership sock RTNLGRP_LINK) …)
This procedure is implemented as a setsockopt
call.
Send msg (it must be of type message, See Netlink Headers) to addr using sock. If not passed, addr is the address of the kernel.
Receives a message from sock from addr. This procedure is blocking.
If not passed, addr defaults to the address of the kernel. This
procedure returns the message as a bytevector, that you can deserialize with
deserialize
(See Data Types)
Receives one or more messages from sock from addr. this procedure is blocking. If not passed, addr defaults to the address of the kernel. This procedure returns a list of messages that were decoded using decoder.
When the answer has the NLM_F_MULTI
flag, this procedure decodes the next
message, until it receives a NLMSG_DONE
message. It returns the list
of every netlink messages it received, including the NLMSG_DONE
.
Previous: Constants, Up: Common API [Contents][Index]