EXAMPLE
Creating a rtnetlink message to set a MTU of a device.
struct {
struct nlmsghdr nh;
struct ifinfomsg if;
char attrbuf[512];
} req;
struct rtattr *rta;
unsigned int mtu = 1000;
int rtnetlink_sk = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
memset(&req, 0, sizeof(req));
req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
req.nh.nlmsg_flags = NLM_F_REQUEST;
req.nh.nlmsg_type = RTML_NEWLINK;
req.if.ifi_family = AF_UNSPEC;
req.if.ifi_index = INTERFACE_INDEX;
req.if.ifi_change = 0xffffffff; /* ???*/
rta = (struct rtattr *)(((char *) &req) +
NLMSG_ALIGN(n->nlmsg_len));
rta->rta_type = IFLA_MTU;
rta->rta_len = sizeof(unsigned int);
req.n.nlmsg_len = NLMSG_ALIGN(req.n.nlmsg_len) +
RTA_LENGTH(sizeof(mtu));
memcpy(RTA_DATA(rta), &mtu, sizeof (mtu));
send(rtnetlink_sk, &req, req.n.nlmsg_len);
BUGS
This manual page is lacking and incomplete.
"SEE ALSO"
rtnetlink(7), netlink(7), netlink(3)