rtnl-message.c revision 8facc3498ed037f842891ff55d1f60fe834f4ba0
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering This file is part of systemd.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering Copyright 2013 Tom Gundersen <teg@jklm.no>
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering systemd is free software; you can redistribute it and/or modify it
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering under the terms of the GNU Lesser General Public License as published by
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering (at your option) any later version.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering systemd is distributed in the hope that it will be useful, but
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering Lesser General Public License for more details.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering You should have received a copy of the GNU Lesser General Public License
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
0d39fa9c69b97a2ceb156053deef69c0866c2b97Lennart Poettering#define GET_CONTAINER(m, i) ((i) < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->container_offsets[i]) : NULL)
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#define PUSH_CONTAINER(m, new) (m)->container_offsets[(m)->n_containers ++] = (uint8_t*)(new) - (uint8_t*)(m)->hdr;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering#define RTA_TYPE(rta) ((rta)->rta_type & NLA_TYPE_MASK)
9bf3b53533cdc9b95c921b71da755401f223f765Lennart Poetteringstatic int message_new_empty(sd_rtnl *rtnl, sd_rtnl_message **ret) {
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering /* Note that 'rtnl' is currently unused, if we start using it internally
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering we must take care to avoid problems due to mutual references between
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek busses and their queued messages. See sd-bus.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint message_new(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t type) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = type_system_get_type(NULL, &nl_type, type);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering m->hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
18cd5fe99f70a55a2d6f2303d6ee0624942695b1Zbigniew Jędrzejewski-Szmek m->container_type_system[0] = nl_type->type_system;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_route_set_dst_prefixlen(sd_rtnl_message *m, unsigned char prefixlen) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if ((rtm->rtm_family == AF_INET && prefixlen > 32) ||
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering (rtm->rtm_family == AF_INET6 && prefixlen > 128))
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_route_set_src_prefixlen(sd_rtnl_message *m, unsigned char prefixlen) {
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if ((rtm->rtm_family == AF_INET && prefixlen > 32) ||
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering (rtm->rtm_family == AF_INET6 && prefixlen > 128))
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmekint sd_rtnl_message_route_set_scope(sd_rtnl_message *m, unsigned char scope) {
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmekint sd_rtnl_message_route_get_family(sd_rtnl_message *m, int *family) {
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek assert_return(family, -EINVAL);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmekint sd_rtnl_message_route_get_dst_prefixlen(sd_rtnl_message *m, unsigned char *dst_len) {
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek assert_return(dst_len, -EINVAL);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmekint sd_rtnl_message_route_get_src_prefixlen(sd_rtnl_message *m, unsigned char *src_len) {
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
baf167ee0a2953f98e4e7d4c35752ef737832674Zbigniew Jędrzejewski-Szmek assert_return(src_len, -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering unsigned char rtm_protocol) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_route(nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return((nlmsg_type == RTM_GETROUTE && rtm_family == AF_UNSPEC) ||
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering rtm_family == AF_INET || rtm_family == AF_INET6, -EINVAL);
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek if (nlmsg_type == RTM_NEWROUTE)
c7332b0844e28d9b70c3c763b929f105c1056fe8Zbigniew Jędrzejewski-Szmek (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_APPEND;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_neigh_set_flags(sd_rtnl_message *m, uint8_t flags) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_neigh_set_state(sd_rtnl_message *m, uint16_t state) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_neigh_get_flags(sd_rtnl_message *m, uint8_t *flags) {
18cd5fe99f70a55a2d6f2303d6ee0624942695b1Zbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
97b11eedff9d2e17101ad453caf9e48b73246719David Herrmannint sd_rtnl_message_neigh_get_state(sd_rtnl_message *m, uint16_t *state) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_neigh_get_family(sd_rtnl_message *m, int *family) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_neigh_get_ifindex(sd_rtnl_message *m, int *index) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_new_neigh(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t nlmsg_type, int index, int ndm_family) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_neigh(nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_APPEND;
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmekint sd_rtnl_message_link_set_flags(sd_rtnl_message *m, unsigned flags, unsigned change) {
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
eb56eb9b40950f1edcffdb7313f8de4f8572a6d5Michal Schmidt assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmekint sd_rtnl_message_link_set_type(sd_rtnl_message *m, unsigned type) {
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmekint sd_rtnl_message_link_set_family(sd_rtnl_message *m, unsigned family) {
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmekint sd_rtnl_message_new_link(sd_rtnl *rtnl, sd_rtnl_message **ret,
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek uint16_t nlmsg_type, int index) {
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_link(nlmsg_type), -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(nlmsg_type != RTM_DELLINK || index > 0, -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek r = message_new(rtnl, ret, nlmsg_type);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmekint sd_rtnl_message_request_dump(sd_rtnl_message *m, int dump) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(m->hdr->nlmsg_type == RTM_GETLINK ||
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek m->hdr->nlmsg_type == RTM_GETADDR ||
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek m->hdr->nlmsg_type == RTM_GETROUTE ||
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek m->hdr->nlmsg_flags |= NLM_F_DUMP;
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmekint sd_rtnl_message_addr_set_prefixlen(sd_rtnl_message *m, unsigned char prefixlen) {
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
e3b9d9c8027a7c4c55cf1614e0fe9423fad69e8fZbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if ((ifa->ifa_family == AF_INET && prefixlen > 32) ||
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering (ifa->ifa_family == AF_INET6 && prefixlen > 128))
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_addr_set_flags(sd_rtnl_message *m, unsigned char flags) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_addr_set_scope(sd_rtnl_message *m, unsigned char scope) {
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_addr_get_family(sd_rtnl_message *m, int *family) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_addr_get_prefixlen(sd_rtnl_message *m, unsigned char *prefixlen) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_addr_get_scope(sd_rtnl_message *m, unsigned char *scope) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_addr_get_flags(sd_rtnl_message *m, unsigned char *flags) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_addr_get_ifindex(sd_rtnl_message *m, int *ifindex) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_new_addr(sd_rtnl *rtnl, sd_rtnl_message **ret,
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_addr(nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return((nlmsg_type == RTM_GETADDR && index == 0) ||
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering assert_return((nlmsg_type == RTM_GETADDR && family == AF_UNSPEC) ||
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering family == AF_INET || family == AF_INET6, -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_new_addr_update(sd_rtnl *rtnl, sd_rtnl_message **ret,
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = sd_rtnl_message_new_addr(rtnl, ret, RTM_NEWADDR, index, family);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering (*ret)->hdr->nlmsg_flags |= NLM_F_REPLACE;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringsd_rtnl_message *sd_rtnl_message_ref(sd_rtnl_message *m) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringsd_rtnl_message *sd_rtnl_message_unref(sd_rtnl_message *m) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering for (i = 0; i <= m->n_containers; i++)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_get_type(sd_rtnl_message *m, uint16_t *type) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmekint sd_rtnl_message_is_broadcast(sd_rtnl_message *m) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmekint sd_rtnl_message_link_get_ifindex(sd_rtnl_message *m, int *ifindex) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek assert_return(m->hdr, -EINVAL);
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek assert_return(ifindex, -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_link_get_flags(sd_rtnl_message *m, unsigned *flags) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringint sd_rtnl_message_link_get_type(sd_rtnl_message *m, unsigned *type) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek/* If successful the updated message will be correctly aligned, if
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek unsuccessful the old message is untouched. */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmekstatic int add_rtattr(sd_rtnl_message *m, unsigned short type, const void *data, size_t data_length) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek size_t message_length, padding_length;
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek assert(NLMSG_ALIGN(m->hdr->nlmsg_len) == m->hdr->nlmsg_len);
e53fc357a9bb9d0a5362ccc4246d598cb0febd5eLennart Poettering /* get offset of the new attribute */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek /* get the size of the new rta attribute (with padding at the end) */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek rta_length = RTA_LENGTH(data_length);
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek /* get the new message size (with padding at the end) */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek message_length = offset + RTA_ALIGN(rta_length);
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek /* realloc to fit the new attribute */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek new_hdr = realloc(m->hdr, message_length);
return -ENOMEM;
for (i = 0; i < m->n_containers; i++)
if (data)
return offset;
static int message_attribute_has_type(sd_rtnl_message *m, uint16_t attribute_type, uint16_t data_type) {
return -EINVAL;
if (size) {
return -EINVAL;
int sd_rtnl_message_append_in_addr(sd_rtnl_message *m, unsigned short type, const struct in_addr *data) {
int sd_rtnl_message_append_in6_addr(sd_rtnl_message *m, unsigned short type, const struct in6_addr *data) {
int sd_rtnl_message_append_ether_addr(sd_rtnl_message *m, unsigned short type, const struct ether_addr *data) {
int sd_rtnl_message_append_cache_info(sd_rtnl_message *m, unsigned short type, const struct ifa_cacheinfo *info) {
type);
int sd_rtnl_message_open_container_union(sd_rtnl_message *m, unsigned short type, const char *key) {
r = type_system_get_type_system_union(m->container_type_system[m->n_containers], &type_system_union, type);
key);
m->n_containers --;
return -ENODATA;
void *attr_data;
return -EIO;
if (data)
void *attr_data;
return -EIO;
if (data)
void *attr_data;
return -EIO;
if (data)
void *attr_data;
return -EIO;
if (data)
int sd_rtnl_message_read_ether_addr(sd_rtnl_message *m, unsigned short type, struct ether_addr *data) {
void *attr_data;
return -EIO;
if (data)
int sd_rtnl_message_read_cache_info(sd_rtnl_message *m, unsigned short type, struct ifa_cacheinfo *info) {
void *attr_data;
return -EIO;
if (info)
void *attr_data;
return -EIO;
if (data)
void *attr_data;
return -EIO;
if (data)
void *container;
&nl_type,
type);
type);
const char *key;
type);
key);
return -EINVAL;
m->n_containers ++;
r = rtnl_message_parse(m,
size);
m->n_containers --;
m->n_containers --;
assert(m);
assert_return(m, 0);
if (!sd_rtnl_message_is_error(m))
unsigned short *rta_tb_size,
int max,
unsigned int rt_len) {
unsigned short type;
if(!tb)
return -ENOMEM;
} addr = {
ssize_t k;
assert(m);
bool auth = false;
return -ECONNRESET;
auth = true;
if (!auth) {
if (peek) {
if (group)
return -ENOMEM;
return -EIO;
multi_part = true;
for (new_msg = rtnl->rbuffer; NLMSG_OK(new_msg, len) && !done; new_msg = NLMSG_NEXT(new_msg, len)) {
done = true;
if (r == -ENOTSUP)
if (!m->hdr)
return -ENOMEM;
r = sd_rtnl_message_rewind(m);
if (first)
first = m;
m = NULL;
if (len)
if (!first)
if (!m->sealed)
m->rta_tb_size[i] = 0;
m->n_containers = 0;
if (m->rta_offset_tb[0]) {
r = rtnl_message_parse(m,
assert(m);
m->sealed = true;
return m->next;