Add basic netlink writing API.
Usage:
struct snl_state ss = {}; struct snl_writer nw; int nl_type = 0, nl_flags = 0; if (!snl_init(&ss, NETLINK_ROUTE)) return (ENOTSUP); snl_init_writer(&ss, &nw); struct nlmsghdr *hdr = snl_create_msg_request(&nw, nl_type); hdr->nlmsg_flags |= nl_flags; struct rtmsg *rtm = snl_reserve_msg_object(&nw, struct rtmsg); rtm->rtm_family = dst->sa_family; rtm->rtm_protocol = RTPROT_STATIC; rtm->rtm_type = rtm_type; rtm->rtm_dst_len = plen; snl_add_msg_attr_ip(&nw, RTA_DST, dst); snl_add_msg_attr_u32(&nw, RTA_TABLE, fib); hdr = snl_finalize_msg(&nw); if (hdr != NULL) { hdr = snl_get_reply(&ss, hdr); struct snl_errmsg_data e = {}; if (!snl_check_return(&ss, hdr, &e)) return (EINVAL); return (e.error); }
Documentation to follow soon.