mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
sd-netlink: various cleanups
- use uint8_t, uint16_t, and so on, rather than unsigned char, unsigned short, and so on, respectively, - rename output parameters to ret or ret_xyz, - add several missing assertions.
This commit is contained in:
parent
c3069a6bfb
commit
ae298c938b
@ -60,7 +60,7 @@ static bool rtnl_message_type_is_nsid(uint16_t type) {
|
||||
return IN_SET(type, RTM_NEWNSID, RTM_DELNSID, RTM_GETNSID);
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, uint8_t prefixlen) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -78,7 +78,7 @@ int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, uint8_t prefixlen) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -96,7 +96,7 @@ int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_tos(sd_netlink_message *m, unsigned char tos) {
|
||||
int sd_rtnl_message_route_set_tos(sd_netlink_message *m, uint8_t tos) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -110,7 +110,7 @@ int sd_rtnl_message_route_set_tos(sd_netlink_message *m, unsigned char tos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope) {
|
||||
int sd_rtnl_message_route_set_scope(sd_netlink_message *m, uint8_t scope) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -124,7 +124,7 @@ int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags) {
|
||||
int sd_rtnl_message_route_set_flags(sd_netlink_message *m, uint32_t flags) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -138,22 +138,22 @@ int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_flags(sd_netlink_message *m, unsigned *flags) {
|
||||
int sd_rtnl_message_route_get_flags(sd_netlink_message *m, uint32_t *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(flags, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*flags = rtm->rtm_flags;
|
||||
*ret = rtm->rtm_flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table) {
|
||||
int sd_rtnl_message_route_set_table(sd_netlink_message *m, uint8_t table) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -167,37 +167,37 @@ int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *family) {
|
||||
int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(family, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*family = rtm->rtm_family;
|
||||
*ret = rtm->rtm_family;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_type(sd_netlink_message *m, unsigned char *type) {
|
||||
int sd_rtnl_message_route_get_type(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(type, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*type = rtm->rtm_type;
|
||||
*ret = rtm->rtm_type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_type(sd_netlink_message *m, unsigned char type) {
|
||||
int sd_rtnl_message_route_set_type(sd_netlink_message *m, uint8_t type) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -211,105 +211,109 @@ int sd_rtnl_message_route_set_type(sd_netlink_message *m, unsigned char type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, unsigned char *protocol) {
|
||||
int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(protocol, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*protocol = rtm->rtm_protocol;
|
||||
*ret = rtm->rtm_protocol;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_scope(sd_netlink_message *m, unsigned char *scope) {
|
||||
int sd_rtnl_message_route_get_scope(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(scope, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*scope = rtm->rtm_scope;
|
||||
*ret = rtm->rtm_scope;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_tos(sd_netlink_message *m, uint8_t *tos) {
|
||||
int sd_rtnl_message_route_get_tos(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(tos, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*tos = rtm->rtm_tos;
|
||||
*ret = rtm->rtm_tos;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_table(sd_netlink_message *m, unsigned char *table) {
|
||||
int sd_rtnl_message_route_get_table(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(table, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*table = rtm->rtm_table;
|
||||
*ret = rtm->rtm_table;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, unsigned char *dst_len) {
|
||||
int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(dst_len, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*dst_len = rtm->rtm_dst_len;
|
||||
*ret = rtm->rtm_dst_len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, unsigned char *src_len) {
|
||||
int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(src_len, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*src_len = rtm->rtm_src_len;
|
||||
*ret = rtm->rtm_src_len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_route(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type, int rtm_family,
|
||||
unsigned char rtm_protocol) {
|
||||
int sd_rtnl_message_new_route(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int family,
|
||||
uint8_t protocol) {
|
||||
|
||||
struct rtmsg *rtm;
|
||||
int r;
|
||||
|
||||
assert_return(rtnl_message_type_is_route(nlmsg_type), -EINVAL);
|
||||
assert_return((nlmsg_type == RTM_GETROUTE && rtm_family == AF_UNSPEC) ||
|
||||
IN_SET(rtm_family, AF_INET, AF_INET6), -EINVAL);
|
||||
assert_return((nlmsg_type == RTM_GETROUTE && family == AF_UNSPEC) ||
|
||||
IN_SET(family, AF_INET, AF_INET6), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
r = message_new(rtnl, ret, nlmsg_type);
|
||||
@ -321,28 +325,28 @@ int sd_rtnl_message_new_route(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
|
||||
rtm = NLMSG_DATA((*ret)->hdr);
|
||||
|
||||
rtm->rtm_family = rtm_family;
|
||||
rtm->rtm_protocol = rtm_protocol;
|
||||
rtm->rtm_family = family;
|
||||
rtm->rtm_protocol = protocol;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_nexthop(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type, int nh_family,
|
||||
unsigned char nh_protocol) {
|
||||
uint16_t nlmsg_type, int family,
|
||||
uint8_t protocol) {
|
||||
struct nhmsg *nhm;
|
||||
int r;
|
||||
|
||||
assert_return(rtnl_message_type_is_nexthop(nlmsg_type), -EINVAL);
|
||||
switch (nlmsg_type) {
|
||||
case RTM_DELNEXTHOP:
|
||||
assert_return(nh_family == AF_UNSPEC, -EINVAL);
|
||||
assert_return(family == AF_UNSPEC, -EINVAL);
|
||||
_fallthrough_;
|
||||
case RTM_GETNEXTHOP:
|
||||
assert_return(nh_protocol == RTPROT_UNSPEC, -EINVAL);
|
||||
assert_return(protocol == RTPROT_UNSPEC, -EINVAL);
|
||||
break;
|
||||
case RTM_NEWNEXTHOP:
|
||||
assert_return(IN_SET(nh_family, AF_UNSPEC, AF_INET, AF_INET6), -EINVAL);
|
||||
assert_return(IN_SET(family, AF_UNSPEC, AF_INET, AF_INET6), -EINVAL);
|
||||
break;
|
||||
default:
|
||||
assert_not_reached();
|
||||
@ -358,14 +362,14 @@ int sd_rtnl_message_new_nexthop(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
|
||||
nhm = NLMSG_DATA((*ret)->hdr);
|
||||
|
||||
nhm->nh_family = nh_family;
|
||||
nhm->nh_family = family;
|
||||
nhm->nh_scope = RT_SCOPE_UNIVERSE;
|
||||
nhm->nh_protocol = nh_protocol;
|
||||
nhm->nh_protocol = protocol;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_nexthop_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
int sd_rtnl_message_nexthop_set_flags(sd_netlink_message *m, uint32_t flags) {
|
||||
struct nhmsg *nhm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -378,7 +382,7 @@ int sd_rtnl_message_nexthop_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_nexthop_get_flags(sd_netlink_message *m, uint8_t *ret) {
|
||||
int sd_rtnl_message_nexthop_get_flags(sd_netlink_message *m, uint32_t *ret) {
|
||||
struct nhmsg *nhm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -392,30 +396,30 @@ int sd_rtnl_message_nexthop_get_flags(sd_netlink_message *m, uint8_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_nexthop_get_family(sd_netlink_message *m, uint8_t *family) {
|
||||
int sd_rtnl_message_nexthop_get_family(sd_netlink_message *m, int *ret) {
|
||||
struct nhmsg *nhm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_nexthop(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(family, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
nhm = NLMSG_DATA(m->hdr);
|
||||
*family = nhm->nh_family;
|
||||
*ret = nhm->nh_family;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_nexthop_get_protocol(sd_netlink_message *m, uint8_t *protocol) {
|
||||
int sd_rtnl_message_nexthop_get_protocol(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct nhmsg *nhm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_nexthop(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(protocol, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
nhm = NLMSG_DATA(m->hdr);
|
||||
*protocol = nhm->nh_protocol;
|
||||
*ret = nhm->nh_protocol;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -446,58 +450,60 @@ int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *flags) {
|
||||
int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ndm = NLMSG_DATA(m->hdr);
|
||||
*flags = ndm->ndm_flags;
|
||||
*ret = ndm->ndm_flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *state) {
|
||||
int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *ret) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ndm = NLMSG_DATA(m->hdr);
|
||||
*state = ndm->ndm_state;
|
||||
*ret = ndm->ndm_state;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *family) {
|
||||
int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *ret) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(family, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ndm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*family = ndm->ndm_family;
|
||||
*ret = ndm->ndm_family;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *index) {
|
||||
int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *ret) {
|
||||
struct ndmsg *ndm;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_neigh(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(index, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ndm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*index = ndm->ndm_ifindex;
|
||||
*ret = ndm->ndm_ifindex;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -506,14 +512,14 @@ int sd_rtnl_message_new_neigh(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int index,
|
||||
int ndm_family) {
|
||||
int ifindex,
|
||||
int family) {
|
||||
|
||||
struct ndmsg *ndm;
|
||||
int r;
|
||||
|
||||
assert_return(rtnl_message_type_is_neigh(nlmsg_type), -EINVAL);
|
||||
assert_return(IN_SET(ndm_family, AF_UNSPEC, AF_INET, AF_INET6, AF_BRIDGE), -EINVAL);
|
||||
assert_return(IN_SET(family, AF_UNSPEC, AF_INET, AF_INET6, AF_BRIDGE), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
r = message_new(rtnl, ret, nlmsg_type);
|
||||
@ -521,7 +527,7 @@ int sd_rtnl_message_new_neigh(
|
||||
return r;
|
||||
|
||||
if (nlmsg_type == RTM_NEWNEIGH) {
|
||||
if (ndm_family == AF_BRIDGE)
|
||||
if (family == AF_BRIDGE)
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_APPEND;
|
||||
else
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE;
|
||||
@ -529,13 +535,13 @@ int sd_rtnl_message_new_neigh(
|
||||
|
||||
ndm = NLMSG_DATA((*ret)->hdr);
|
||||
|
||||
ndm->ndm_family = ndm_family;
|
||||
ndm->ndm_ifindex = index;
|
||||
ndm->ndm_family = family;
|
||||
ndm->ndm_ifindex = ifindex;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsigned change) {
|
||||
int sd_rtnl_message_link_set_flags(sd_netlink_message *m, uint32_t flags, uint32_t change) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -551,7 +557,7 @@ int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsign
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type) {
|
||||
int sd_rtnl_message_link_set_type(sd_netlink_message *m, uint16_t type) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -565,7 +571,7 @@ int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family) {
|
||||
int sd_rtnl_message_link_set_family(sd_netlink_message *m, int family) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -579,8 +585,7 @@ int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_link(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type, int index) {
|
||||
int sd_rtnl_message_new_link(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int ifindex) {
|
||||
struct ifinfomsg *ifi;
|
||||
int r;
|
||||
|
||||
@ -599,12 +604,12 @@ int sd_rtnl_message_new_link(sd_netlink *rtnl, sd_netlink_message **ret,
|
||||
ifi = NLMSG_DATA((*ret)->hdr);
|
||||
|
||||
ifi->ifi_family = AF_UNSPEC;
|
||||
ifi->ifi_index = index;
|
||||
ifi->ifi_index = ifindex;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, uint8_t prefixlen) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -622,7 +627,7 @@ int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char pref
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags) {
|
||||
int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, uint8_t flags) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -636,7 +641,7 @@ int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope) {
|
||||
int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, uint8_t scope) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -650,77 +655,77 @@ int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *ret_family) {
|
||||
int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *ret) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret_family, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ifa = NLMSG_DATA(m->hdr);
|
||||
|
||||
*ret_family = ifa->ifa_family;
|
||||
*ret = ifa->ifa_family;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, unsigned char *ret_prefixlen) {
|
||||
int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret_prefixlen, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ifa = NLMSG_DATA(m->hdr);
|
||||
|
||||
*ret_prefixlen = ifa->ifa_prefixlen;
|
||||
*ret = ifa->ifa_prefixlen;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, unsigned char *ret_scope) {
|
||||
int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret_scope, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ifa = NLMSG_DATA(m->hdr);
|
||||
|
||||
*ret_scope = ifa->ifa_scope;
|
||||
*ret = ifa->ifa_scope;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, unsigned char *ret_flags) {
|
||||
int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret_flags, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ifa = NLMSG_DATA(m->hdr);
|
||||
|
||||
*ret_flags = ifa->ifa_flags;
|
||||
*ret = ifa->ifa_flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ret_ifindex) {
|
||||
int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ret) {
|
||||
struct ifaddrmsg *ifa;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_addr(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret_ifindex, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ifa = NLMSG_DATA(m->hdr);
|
||||
|
||||
*ret_ifindex = ifa->ifa_index;
|
||||
*ret = ifa->ifa_index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -729,15 +734,15 @@ int sd_rtnl_message_new_addr(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int index,
|
||||
int ifindex,
|
||||
int family) {
|
||||
|
||||
struct ifaddrmsg *ifa;
|
||||
int r;
|
||||
|
||||
assert_return(rtnl_message_type_is_addr(nlmsg_type), -EINVAL);
|
||||
assert_return((nlmsg_type == RTM_GETADDR && index == 0) ||
|
||||
index > 0, -EINVAL);
|
||||
assert_return((nlmsg_type == RTM_GETADDR && ifindex == 0) ||
|
||||
ifindex > 0, -EINVAL);
|
||||
assert_return((nlmsg_type == RTM_GETADDR && family == AF_UNSPEC) ||
|
||||
IN_SET(family, AF_INET, AF_INET6), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
@ -748,7 +753,7 @@ int sd_rtnl_message_new_addr(
|
||||
|
||||
ifa = NLMSG_DATA((*ret)->hdr);
|
||||
|
||||
ifa->ifa_index = index;
|
||||
ifa->ifa_index = ifindex;
|
||||
ifa->ifa_family = family;
|
||||
|
||||
return 0;
|
||||
@ -757,11 +762,11 @@ int sd_rtnl_message_new_addr(
|
||||
int sd_rtnl_message_new_addr_update(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
int index,
|
||||
int ifindex,
|
||||
int family) {
|
||||
int r;
|
||||
|
||||
r = sd_rtnl_message_new_addr(rtnl, ret, RTM_NEWADDR, index, family);
|
||||
r = sd_rtnl_message_new_addr(rtnl, ret, RTM_NEWADDR, ifindex, family);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -770,54 +775,54 @@ int sd_rtnl_message_new_addr_update(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ifindex) {
|
||||
int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ret) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ifindex, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ifi = NLMSG_DATA(m->hdr);
|
||||
|
||||
*ifindex = ifi->ifi_index;
|
||||
*ret = ifi->ifi_index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_get_flags(sd_netlink_message *m, unsigned *flags) {
|
||||
int sd_rtnl_message_link_get_flags(sd_netlink_message *m, uint32_t *ret) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(flags, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ifi = NLMSG_DATA(m->hdr);
|
||||
|
||||
*flags = ifi->ifi_flags;
|
||||
*ret = ifi->ifi_flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned short *type) {
|
||||
int sd_rtnl_message_link_get_type(sd_netlink_message *m, uint16_t *ret) {
|
||||
struct ifinfomsg *ifi;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(type, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
ifi = NLMSG_DATA(m->hdr);
|
||||
|
||||
*type = ifi->ifi_type;
|
||||
*ret = ifi->ifi_type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
int sd_rtnl_message_get_family(sd_netlink_message *m, int *ret) {
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(family, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
assert(m->hdr);
|
||||
|
||||
@ -826,7 +831,7 @@ int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
|
||||
ifi = NLMSG_DATA(m->hdr);
|
||||
|
||||
*family = ifi->ifi_family;
|
||||
*ret = ifi->ifi_family;
|
||||
|
||||
return 0;
|
||||
} else if (rtnl_message_type_is_route(m->hdr->nlmsg_type)) {
|
||||
@ -834,7 +839,7 @@ int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*family = rtm->rtm_family;
|
||||
*ret = rtm->rtm_family;
|
||||
|
||||
return 0;
|
||||
} else if (rtnl_message_type_is_neigh(m->hdr->nlmsg_type)) {
|
||||
@ -842,7 +847,7 @@ int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
|
||||
ndm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*family = ndm->ndm_family;
|
||||
*ret = ndm->ndm_family;
|
||||
|
||||
return 0;
|
||||
} else if (rtnl_message_type_is_addr(m->hdr->nlmsg_type)) {
|
||||
@ -850,7 +855,7 @@ int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
|
||||
ifa = NLMSG_DATA(m->hdr);
|
||||
|
||||
*family = ifa->ifa_family;
|
||||
*ret = ifa->ifa_family;
|
||||
|
||||
return 0;
|
||||
} else if (rtnl_message_type_is_routing_policy_rule(m->hdr->nlmsg_type)) {
|
||||
@ -858,7 +863,7 @@ int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
|
||||
rtm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*family = rtm->rtm_family;
|
||||
*ret = rtm->rtm_family;
|
||||
|
||||
return 0;
|
||||
} else if (rtnl_message_type_is_nexthop(m->hdr->nlmsg_type)) {
|
||||
@ -866,7 +871,7 @@ int sd_rtnl_message_get_family(sd_netlink_message *m, int *family) {
|
||||
|
||||
nhm = NLMSG_DATA(m->hdr);
|
||||
|
||||
*family = nhm->nh_family;
|
||||
*ret = nhm->nh_family;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -879,7 +884,7 @@ int sd_rtnl_message_new_addrlabel(
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int ifindex,
|
||||
int ifal_family) {
|
||||
int family) {
|
||||
|
||||
struct ifaddrlblmsg *addrlabel;
|
||||
int r;
|
||||
@ -896,13 +901,13 @@ int sd_rtnl_message_new_addrlabel(
|
||||
|
||||
addrlabel = NLMSG_DATA((*ret)->hdr);
|
||||
|
||||
addrlabel->ifal_family = ifal_family;
|
||||
addrlabel->ifal_family = family;
|
||||
addrlabel->ifal_index = ifindex;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addrlabel_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
int sd_rtnl_message_addrlabel_set_prefixlen(sd_netlink_message *m, uint8_t prefixlen) {
|
||||
struct ifaddrlblmsg *addrlabel;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -919,16 +924,17 @@ int sd_rtnl_message_addrlabel_set_prefixlen(sd_netlink_message *m, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_addrlabel_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen) {
|
||||
int sd_rtnl_message_addrlabel_get_prefixlen(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct ifaddrlblmsg *addrlabel;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_addrlabel(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
addrlabel = NLMSG_DATA(m->hdr);
|
||||
|
||||
*prefixlen = addrlabel->ifal_prefixlen;
|
||||
*ret = addrlabel->ifal_prefixlen;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -937,7 +943,7 @@ int sd_rtnl_message_new_routing_policy_rule(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int ifal_family) {
|
||||
int family) {
|
||||
|
||||
struct fib_rule_hdr *frh;
|
||||
int r;
|
||||
@ -953,7 +959,7 @@ int sd_rtnl_message_new_routing_policy_rule(
|
||||
(*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
|
||||
|
||||
frh = NLMSG_DATA((*ret)->hdr);
|
||||
frh->family = ifal_family;
|
||||
frh->family = family;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -972,16 +978,17 @@ int sd_rtnl_message_routing_policy_rule_set_tos(sd_netlink_message *m, uint8_t t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_tos(sd_netlink_message *m, uint8_t *tos) {
|
||||
int sd_rtnl_message_routing_policy_rule_get_tos(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_routing_policy_rule(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
frh = NLMSG_DATA(m->hdr);
|
||||
|
||||
*tos = frh->tos;
|
||||
*ret = frh->tos;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1000,16 +1007,17 @@ int sd_rtnl_message_routing_policy_rule_set_table(sd_netlink_message *m, uint8_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_table(sd_netlink_message *m, uint8_t *table) {
|
||||
int sd_rtnl_message_routing_policy_rule_get_table(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_routing_policy_rule(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
frh = NLMSG_DATA(m->hdr);
|
||||
|
||||
*table = frh->table;
|
||||
*ret = frh->table;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1027,15 +1035,16 @@ int sd_rtnl_message_routing_policy_rule_set_flags(sd_netlink_message *m, uint32_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_flags(sd_netlink_message *m, uint32_t *flags) {
|
||||
int sd_rtnl_message_routing_policy_rule_get_flags(sd_netlink_message *m, uint32_t *ret) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_routing_policy_rule(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
frh = NLMSG_DATA(m->hdr);
|
||||
*flags = frh->flags;
|
||||
*ret = frh->flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1054,21 +1063,22 @@ int sd_rtnl_message_routing_policy_rule_set_fib_type(sd_netlink_message *m, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_type(sd_netlink_message *m, uint8_t *type) {
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_type(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_routing_policy_rule(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
frh = NLMSG_DATA(m->hdr);
|
||||
|
||||
*type = frh->action;
|
||||
*ret = frh->action;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen(sd_netlink_message *m, uint8_t len) {
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen(sd_netlink_message *m, uint8_t prefixlen) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1077,26 +1087,27 @@ int sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen(sd_netlink_message
|
||||
|
||||
frh = NLMSG_DATA(m->hdr);
|
||||
|
||||
frh->dst_len = len;
|
||||
frh->dst_len = prefixlen;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen(sd_netlink_message *m, uint8_t *len) {
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_routing_policy_rule(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
frh = NLMSG_DATA(m->hdr);
|
||||
|
||||
*len = frh->dst_len;
|
||||
*ret = frh->dst_len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen(sd_netlink_message *m, uint8_t len) {
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen(sd_netlink_message *m, uint8_t prefixlen) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
@ -1105,21 +1116,22 @@ int sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen(sd_netlink_message
|
||||
|
||||
frh = NLMSG_DATA(m->hdr);
|
||||
|
||||
frh->src_len = len;
|
||||
frh->src_len = prefixlen;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen(sd_netlink_message *m, uint8_t *len) {
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen(sd_netlink_message *m, uint8_t *ret) {
|
||||
struct fib_rule_hdr *frh;
|
||||
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(m->hdr, -EINVAL);
|
||||
assert_return(rtnl_message_type_is_routing_policy_rule(m->hdr->nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
frh = NLMSG_DATA(m->hdr);
|
||||
|
||||
*len = frh->src_len;
|
||||
*ret = frh->src_len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1199,7 +1211,7 @@ int sd_rtnl_message_new_mdb(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type,
|
||||
int mdb_ifindex) {
|
||||
int ifindex) {
|
||||
|
||||
struct br_port_msg *bpm;
|
||||
int r;
|
||||
@ -1216,7 +1228,7 @@ int sd_rtnl_message_new_mdb(
|
||||
|
||||
bpm = NLMSG_DATA((*ret)->hdr);
|
||||
bpm->family = AF_BRIDGE;
|
||||
bpm->ifindex = mdb_ifindex;
|
||||
bpm->ifindex = ifindex;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ static int netlink_message_read_internal(
|
||||
return RTA_PAYLOAD(rta);
|
||||
}
|
||||
|
||||
int sd_netlink_message_read(sd_netlink_message *m, uint16_t attr_type, size_t size, void *data) {
|
||||
int sd_netlink_message_read(sd_netlink_message *m, uint16_t attr_type, size_t size, void *ret) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -767,8 +767,8 @@ int sd_netlink_message_read(sd_netlink_message *m, uint16_t attr_type, size_t si
|
||||
if ((size_t) r > size)
|
||||
return -ENOBUFS;
|
||||
|
||||
if (data)
|
||||
memcpy(data, attr_data, r);
|
||||
if (ret)
|
||||
memcpy(ret, attr_data, r);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -799,7 +799,7 @@ int sd_netlink_message_read_data(sd_netlink_message *m, uint16_t attr_type, size
|
||||
return r;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_string_strdup(sd_netlink_message *m, uint16_t attr_type, char **data) {
|
||||
int sd_netlink_message_read_string_strdup(sd_netlink_message *m, uint16_t attr_type, char **ret) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -813,20 +813,20 @@ int sd_netlink_message_read_string_strdup(sd_netlink_message *m, uint16_t attr_t
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (data) {
|
||||
if (ret) {
|
||||
char *str;
|
||||
|
||||
str = strndup(attr_data, r);
|
||||
if (!str)
|
||||
return -ENOMEM;
|
||||
|
||||
*data = str;
|
||||
*ret = str;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_string(sd_netlink_message *m, uint16_t attr_type, const char **data) {
|
||||
int sd_netlink_message_read_string(sd_netlink_message *m, uint16_t attr_type, const char **ret) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -843,13 +843,13 @@ int sd_netlink_message_read_string(sd_netlink_message *m, uint16_t attr_type, co
|
||||
if (strnlen(attr_data, r) >= (size_t) r)
|
||||
return -EIO;
|
||||
|
||||
if (data)
|
||||
*data = (const char *) attr_data;
|
||||
if (ret)
|
||||
*ret = (const char *) attr_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_u8(sd_netlink_message *m, uint16_t attr_type, uint8_t *data) {
|
||||
int sd_netlink_message_read_u8(sd_netlink_message *m, uint16_t attr_type, uint8_t *ret) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -866,13 +866,13 @@ int sd_netlink_message_read_u8(sd_netlink_message *m, uint16_t attr_type, uint8_
|
||||
if ((size_t) r < sizeof(uint8_t))
|
||||
return -EIO;
|
||||
|
||||
if (data)
|
||||
*data = *(uint8_t *) attr_data;
|
||||
if (ret)
|
||||
*ret = *(uint8_t *) attr_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_u16(sd_netlink_message *m, uint16_t attr_type, uint16_t *data) {
|
||||
int sd_netlink_message_read_u16(sd_netlink_message *m, uint16_t attr_type, uint16_t *ret) {
|
||||
void *attr_data;
|
||||
bool net_byteorder;
|
||||
int r;
|
||||
@ -890,17 +890,17 @@ int sd_netlink_message_read_u16(sd_netlink_message *m, uint16_t attr_type, uint1
|
||||
if ((size_t) r < sizeof(uint16_t))
|
||||
return -EIO;
|
||||
|
||||
if (data) {
|
||||
if (ret) {
|
||||
if (net_byteorder)
|
||||
*data = be16toh(*(uint16_t *) attr_data);
|
||||
*ret = be16toh(*(uint16_t *) attr_data);
|
||||
else
|
||||
*data = *(uint16_t *) attr_data;
|
||||
*ret = *(uint16_t *) attr_data;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_u32(sd_netlink_message *m, uint16_t attr_type, uint32_t *data) {
|
||||
int sd_netlink_message_read_u32(sd_netlink_message *m, uint16_t attr_type, uint32_t *ret) {
|
||||
void *attr_data;
|
||||
bool net_byteorder;
|
||||
int r;
|
||||
@ -918,11 +918,11 @@ int sd_netlink_message_read_u32(sd_netlink_message *m, uint16_t attr_type, uint3
|
||||
if ((size_t) r < sizeof(uint32_t))
|
||||
return -EIO;
|
||||
|
||||
if (data) {
|
||||
if (ret) {
|
||||
if (net_byteorder)
|
||||
*data = be32toh(*(uint32_t *) attr_data);
|
||||
*ret = be32toh(*(uint32_t *) attr_data);
|
||||
else
|
||||
*data = *(uint32_t *) attr_data;
|
||||
*ret = *(uint32_t *) attr_data;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -956,7 +956,7 @@ int sd_netlink_message_read_u64(sd_netlink_message *m, uint16_t attr_type, uint6
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_ether_addr(sd_netlink_message *m, uint16_t attr_type, struct ether_addr *data) {
|
||||
int sd_netlink_message_read_ether_addr(sd_netlink_message *m, uint16_t attr_type, struct ether_addr *ret) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -973,13 +973,13 @@ int sd_netlink_message_read_ether_addr(sd_netlink_message *m, uint16_t attr_type
|
||||
if ((size_t) r < sizeof(struct ether_addr))
|
||||
return -EIO;
|
||||
|
||||
if (data)
|
||||
memcpy(data, attr_data, sizeof(struct ether_addr));
|
||||
if (ret)
|
||||
memcpy(ret, attr_data, sizeof(struct ether_addr));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int netlink_message_read_hw_addr(sd_netlink_message *m, uint16_t attr_type, struct hw_addr_data *data) {
|
||||
int netlink_message_read_hw_addr(sd_netlink_message *m, uint16_t attr_type, struct hw_addr_data *ret) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -996,15 +996,15 @@ int netlink_message_read_hw_addr(sd_netlink_message *m, uint16_t attr_type, stru
|
||||
if (r > HW_ADDR_MAX_SIZE)
|
||||
return -EIO;
|
||||
|
||||
if (data) {
|
||||
memcpy(data->bytes, attr_data, r);
|
||||
data->length = r;
|
||||
if (ret) {
|
||||
memcpy(ret->bytes, attr_data, r);
|
||||
ret->length = r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_cache_info(sd_netlink_message *m, uint16_t attr_type, struct ifa_cacheinfo *info) {
|
||||
int sd_netlink_message_read_cache_info(sd_netlink_message *m, uint16_t attr_type, struct ifa_cacheinfo *ret) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -1021,13 +1021,13 @@ int sd_netlink_message_read_cache_info(sd_netlink_message *m, uint16_t attr_type
|
||||
if ((size_t) r < sizeof(struct ifa_cacheinfo))
|
||||
return -EIO;
|
||||
|
||||
if (info)
|
||||
memcpy(info, attr_data, sizeof(struct ifa_cacheinfo));
|
||||
if (ret)
|
||||
memcpy(ret, attr_data, sizeof(struct ifa_cacheinfo));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int netlink_message_read_in_addr_union(sd_netlink_message *m, uint16_t attr_type, int family, union in_addr_union *data) {
|
||||
int netlink_message_read_in_addr_union(sd_netlink_message *m, uint16_t attr_type, int family, union in_addr_union *ret) {
|
||||
void *attr_data;
|
||||
int r;
|
||||
|
||||
@ -1045,30 +1045,30 @@ int netlink_message_read_in_addr_union(sd_netlink_message *m, uint16_t attr_type
|
||||
if ((size_t) r < FAMILY_ADDRESS_SIZE(family))
|
||||
return -EIO;
|
||||
|
||||
if (data)
|
||||
memcpy(data, attr_data, FAMILY_ADDRESS_SIZE(family));
|
||||
if (ret)
|
||||
memcpy(ret, attr_data, FAMILY_ADDRESS_SIZE(family));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_in_addr(sd_netlink_message *m, uint16_t attr_type, struct in_addr *data) {
|
||||
int sd_netlink_message_read_in_addr(sd_netlink_message *m, uint16_t attr_type, struct in_addr *ret) {
|
||||
union in_addr_union u;
|
||||
int r;
|
||||
|
||||
r = netlink_message_read_in_addr_union(m, attr_type, AF_INET, &u);
|
||||
if (r >= 0 && data)
|
||||
*data = u.in;
|
||||
if (r >= 0 && ret)
|
||||
*ret = u.in;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int sd_netlink_message_read_in6_addr(sd_netlink_message *m, uint16_t attr_type, struct in6_addr *data) {
|
||||
int sd_netlink_message_read_in6_addr(sd_netlink_message *m, uint16_t attr_type, struct in6_addr *ret) {
|
||||
union in_addr_union u;
|
||||
int r;
|
||||
|
||||
r = netlink_message_read_in_addr_union(m, attr_type, AF_INET6, &u);
|
||||
if (r >= 0 && data)
|
||||
*data = u.in6;
|
||||
if (r >= 0 && ret)
|
||||
*ret = u.in6;
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -1413,7 +1413,7 @@ void message_seal(sd_netlink_message *m) {
|
||||
m->sealed = true;
|
||||
}
|
||||
|
||||
sd_netlink_message *sd_netlink_message_next(sd_netlink_message *m) {
|
||||
sd_netlink_message* sd_netlink_message_next(sd_netlink_message *m) {
|
||||
assert_return(m, NULL);
|
||||
|
||||
return m->next;
|
||||
|
@ -105,19 +105,19 @@ static sd_netlink_slot* netlink_slot_free(sd_netlink_slot *slot) {
|
||||
|
||||
DEFINE_TRIVIAL_REF_UNREF_FUNC(sd_netlink_slot, sd_netlink_slot, netlink_slot_free);
|
||||
|
||||
sd_netlink *sd_netlink_slot_get_netlink(sd_netlink_slot *slot) {
|
||||
sd_netlink* sd_netlink_slot_get_netlink(sd_netlink_slot *slot) {
|
||||
assert_return(slot, NULL);
|
||||
|
||||
return slot->netlink;
|
||||
}
|
||||
|
||||
void *sd_netlink_slot_get_userdata(sd_netlink_slot *slot) {
|
||||
void* sd_netlink_slot_get_userdata(sd_netlink_slot *slot) {
|
||||
assert_return(slot, NULL);
|
||||
|
||||
return slot->userdata;
|
||||
}
|
||||
|
||||
void *sd_netlink_slot_set_userdata(sd_netlink_slot *slot, void *userdata) {
|
||||
void* sd_netlink_slot_set_userdata(sd_netlink_slot *slot, void *userdata) {
|
||||
void *ret;
|
||||
|
||||
assert_return(slot, NULL);
|
||||
@ -128,11 +128,11 @@ void *sd_netlink_slot_set_userdata(sd_netlink_slot *slot, void *userdata) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sd_netlink_slot_get_destroy_callback(sd_netlink_slot *slot, sd_netlink_destroy_t *callback) {
|
||||
int sd_netlink_slot_get_destroy_callback(sd_netlink_slot *slot, sd_netlink_destroy_t *ret) {
|
||||
assert_return(slot, -EINVAL);
|
||||
|
||||
if (callback)
|
||||
*callback = slot->destroy_callback;
|
||||
if (ret)
|
||||
*ret = slot->destroy_callback;
|
||||
|
||||
return !!slot->destroy_callback;
|
||||
}
|
||||
@ -172,11 +172,11 @@ int sd_netlink_slot_set_floating(sd_netlink_slot *slot, int b) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sd_netlink_slot_get_description(sd_netlink_slot *slot, const char **description) {
|
||||
int sd_netlink_slot_get_description(sd_netlink_slot *slot, const char **ret) {
|
||||
assert_return(slot, -EINVAL);
|
||||
|
||||
if (description)
|
||||
*description = slot->description;
|
||||
if (ret)
|
||||
*ret = slot->description;
|
||||
|
||||
return !!slot->description;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ DEFINE_TRIVIAL_REF_UNREF_FUNC(sd_netlink, sd_netlink, netlink_free);
|
||||
int sd_netlink_send(
|
||||
sd_netlink *nl,
|
||||
sd_netlink_message *message,
|
||||
uint32_t *serial) {
|
||||
uint32_t *ret_serial) {
|
||||
|
||||
int r;
|
||||
|
||||
@ -163,8 +163,8 @@ int sd_netlink_send(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (serial)
|
||||
*serial = message_get_serial(message);
|
||||
if (ret_serial)
|
||||
*ret_serial = message_get_serial(message);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -626,25 +626,25 @@ int sd_netlink_get_events(sd_netlink *nl) {
|
||||
return ordered_set_isempty(nl->rqueue) ? POLLIN : 0;
|
||||
}
|
||||
|
||||
int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout_usec) {
|
||||
int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *ret) {
|
||||
struct reply_callback *c;
|
||||
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(timeout_usec, -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
||||
|
||||
if (!ordered_set_isempty(nl->rqueue)) {
|
||||
*timeout_usec = 0;
|
||||
*ret = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
c = prioq_peek(nl->reply_callbacks_prioq);
|
||||
if (!c) {
|
||||
*timeout_usec = UINT64_MAX;
|
||||
*ret = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*timeout_usec = c->timeout;
|
||||
*ret = c->timeout;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ typedef struct NextHop {
|
||||
/* struct nhmsg */
|
||||
int family;
|
||||
uint8_t protocol;
|
||||
uint8_t flags;
|
||||
uint32_t flags;
|
||||
|
||||
/* attributes */
|
||||
uint32_t id; /* NHA_ID */
|
||||
|
@ -44,19 +44,18 @@ int sd_netlink_open(sd_netlink **ret);
|
||||
int sd_netlink_open_fd(sd_netlink **ret, int fd);
|
||||
int sd_netlink_increase_rxbuf(sd_netlink *nl, const size_t size);
|
||||
|
||||
sd_netlink *sd_netlink_ref(sd_netlink *nl);
|
||||
sd_netlink *sd_netlink_unref(sd_netlink *nl);
|
||||
sd_netlink* sd_netlink_ref(sd_netlink *nl);
|
||||
sd_netlink* sd_netlink_unref(sd_netlink *nl);
|
||||
|
||||
int sd_netlink_send(sd_netlink *nl, sd_netlink_message *message, uint32_t *serial);
|
||||
int sd_netlink_send(sd_netlink *nl, sd_netlink_message *message, uint32_t *ret_serial);
|
||||
int sd_netlink_call_async(sd_netlink *nl, sd_netlink_slot **ret_slot, sd_netlink_message *message,
|
||||
sd_netlink_message_handler_t callback, sd_netlink_destroy_t destroy_callback,
|
||||
void *userdata, uint64_t usec, const char *description);
|
||||
int sd_netlink_call(sd_netlink *nl, sd_netlink_message *message, uint64_t timeout,
|
||||
sd_netlink_message **reply);
|
||||
int sd_netlink_read(sd_netlink *nl, uint32_t serial, uint64_t timeout, sd_netlink_message **reply);
|
||||
int sd_netlink_call(sd_netlink *nl, sd_netlink_message *message, uint64_t timeout, sd_netlink_message **ret);
|
||||
int sd_netlink_read(sd_netlink *nl, uint32_t serial, uint64_t timeout, sd_netlink_message **ret);
|
||||
|
||||
int sd_netlink_get_events(sd_netlink *nl);
|
||||
int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout);
|
||||
int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *ret);
|
||||
int sd_netlink_process(sd_netlink *nl, sd_netlink_message **ret);
|
||||
int sd_netlink_wait(sd_netlink *nl, uint64_t timeout);
|
||||
|
||||
@ -104,19 +103,19 @@ int sd_netlink_message_open_array(sd_netlink_message *m, uint16_t type);
|
||||
int sd_netlink_message_cancel_array(sd_netlink_message *m);
|
||||
|
||||
/* Reading messages */
|
||||
int sd_netlink_message_read(sd_netlink_message *m, uint16_t attr_type, size_t size, void *data);
|
||||
int sd_netlink_message_read(sd_netlink_message *m, uint16_t attr_type, size_t size, void *ret);
|
||||
int sd_netlink_message_read_data(sd_netlink_message *m, uint16_t attr_type, size_t *ret_size, void **ret_data);
|
||||
int sd_netlink_message_read_string_strdup(sd_netlink_message *m, uint16_t attr_type, char **data);
|
||||
int sd_netlink_message_read_string(sd_netlink_message *m, uint16_t attr_type, const char **data);
|
||||
int sd_netlink_message_read_string_strdup(sd_netlink_message *m, uint16_t attr_type, char **ret);
|
||||
int sd_netlink_message_read_string(sd_netlink_message *m, uint16_t attr_type, const char **ret);
|
||||
int sd_netlink_message_read_strv(sd_netlink_message *m, uint16_t container_type, uint16_t attr_type, char ***ret);
|
||||
int sd_netlink_message_read_u8(sd_netlink_message *m, uint16_t attr_type, uint8_t *data);
|
||||
int sd_netlink_message_read_u16(sd_netlink_message *m, uint16_t attr_type, uint16_t *data);
|
||||
int sd_netlink_message_read_u32(sd_netlink_message *m, uint16_t attr_type, uint32_t *data);
|
||||
int sd_netlink_message_read_u8(sd_netlink_message *m, uint16_t attr_type, uint8_t *ret);
|
||||
int sd_netlink_message_read_u16(sd_netlink_message *m, uint16_t attr_type, uint16_t *ret);
|
||||
int sd_netlink_message_read_u32(sd_netlink_message *m, uint16_t attr_type, uint32_t *ret);
|
||||
int sd_netlink_message_read_u64(sd_netlink_message *m, uint16_t attr_type, uint64_t *ret);
|
||||
int sd_netlink_message_read_ether_addr(sd_netlink_message *m, uint16_t attr_type, struct ether_addr *data);
|
||||
int sd_netlink_message_read_cache_info(sd_netlink_message *m, uint16_t attr_type, struct ifa_cacheinfo *info);
|
||||
int sd_netlink_message_read_in_addr(sd_netlink_message *m, uint16_t attr_type, struct in_addr *data);
|
||||
int sd_netlink_message_read_in6_addr(sd_netlink_message *m, uint16_t attr_type, struct in6_addr *data);
|
||||
int sd_netlink_message_read_ether_addr(sd_netlink_message *m, uint16_t attr_type, struct ether_addr *ret);
|
||||
int sd_netlink_message_read_cache_info(sd_netlink_message *m, uint16_t attr_type, struct ifa_cacheinfo *ret);
|
||||
int sd_netlink_message_read_in_addr(sd_netlink_message *m, uint16_t attr_type, struct in_addr *ret);
|
||||
int sd_netlink_message_read_in6_addr(sd_netlink_message *m, uint16_t attr_type, struct in6_addr *ret);
|
||||
int sd_netlink_message_has_flag(sd_netlink_message *m, uint16_t attr_type);
|
||||
int sd_netlink_message_enter_container(sd_netlink_message *m, uint16_t attr_type);
|
||||
int sd_netlink_message_enter_array(sd_netlink_message *m, uint16_t attr_type);
|
||||
@ -124,98 +123,106 @@ int sd_netlink_message_exit_container(sd_netlink_message *m);
|
||||
|
||||
int sd_netlink_message_rewind(sd_netlink_message *m, sd_netlink *nl);
|
||||
|
||||
sd_netlink_message *sd_netlink_message_next(sd_netlink_message *m);
|
||||
sd_netlink_message* sd_netlink_message_next(sd_netlink_message *m);
|
||||
|
||||
sd_netlink_message *sd_netlink_message_ref(sd_netlink_message *m);
|
||||
sd_netlink_message *sd_netlink_message_unref(sd_netlink_message *m);
|
||||
sd_netlink_message* sd_netlink_message_ref(sd_netlink_message *m);
|
||||
sd_netlink_message* sd_netlink_message_unref(sd_netlink_message *m);
|
||||
|
||||
int sd_netlink_message_set_request_dump(sd_netlink_message *m, int dump);
|
||||
int sd_netlink_message_is_error(sd_netlink_message *m);
|
||||
int sd_netlink_message_get_errno(sd_netlink_message *m);
|
||||
int sd_netlink_message_get_type(sd_netlink_message *m, uint16_t *type);
|
||||
int sd_netlink_message_get_type(sd_netlink_message *m, uint16_t *ret);
|
||||
int sd_netlink_message_set_flags(sd_netlink_message *m, uint16_t flags);
|
||||
int sd_netlink_message_is_broadcast(sd_netlink_message *m);
|
||||
int sd_netlink_message_get_max_attribute(sd_netlink_message *m, uint16_t *ret);
|
||||
|
||||
/* rtnl */
|
||||
int sd_rtnl_message_get_family(sd_netlink_message *m, int *family);
|
||||
int sd_rtnl_message_get_family(sd_netlink_message *m, int *ret);
|
||||
|
||||
int sd_rtnl_message_new_addr(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index, int family);
|
||||
int sd_rtnl_message_new_addr_update(sd_netlink *nl, sd_netlink_message **ret, int index, int family);
|
||||
int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
|
||||
int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope);
|
||||
int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags);
|
||||
int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *family);
|
||||
int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, unsigned char *ret_prefixlen);
|
||||
int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, unsigned char *ret_scope);
|
||||
int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, unsigned char *ret_flags);
|
||||
int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ret_ifindex);
|
||||
int sd_rtnl_message_new_addr(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int ifindex, int family);
|
||||
int sd_rtnl_message_new_addr_update(sd_netlink *nl, sd_netlink_message **ret, int ifindex, int family);
|
||||
/* struct ifaddrmsg */
|
||||
int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ret); /* ifa_index */
|
||||
int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *ret); /* ifa_family */
|
||||
int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, uint8_t prefixlen); /* ifa_prefixlen */
|
||||
int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, uint8_t flags); /* ifa_flags */
|
||||
int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, uint8_t scope); /* ifa_scope */
|
||||
int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, uint8_t *ret);
|
||||
|
||||
int sd_rtnl_message_new_link(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index);
|
||||
int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsigned change);
|
||||
int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type);
|
||||
int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family);
|
||||
int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ifindex);
|
||||
int sd_rtnl_message_link_get_flags(sd_netlink_message *m, unsigned *flags);
|
||||
int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned short *type);
|
||||
int sd_rtnl_message_new_link(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int ifindex);
|
||||
/* struct ifinfomsg */
|
||||
int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ret); /* ifi_index */
|
||||
int sd_rtnl_message_link_set_family(sd_netlink_message *m, int family); /* ifi_family */
|
||||
int sd_rtnl_message_link_set_type(sd_netlink_message *m, uint16_t type); /* ifi_type */
|
||||
int sd_rtnl_message_link_get_type(sd_netlink_message *m, uint16_t *ret);
|
||||
int sd_rtnl_message_link_set_flags(sd_netlink_message *m, uint32_t flags, uint32_t change); /* ifi_flags and ifi_change */
|
||||
int sd_rtnl_message_link_get_flags(sd_netlink_message *m, uint32_t *ret); /* ifi_flags */
|
||||
|
||||
int sd_rtnl_message_new_route(sd_netlink *nl, sd_netlink_message **ret, uint16_t nlmsg_type, int rtm_family, unsigned char rtm_protocol);
|
||||
int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
|
||||
int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
|
||||
int sd_rtnl_message_route_set_tos(sd_netlink_message *m, unsigned char tos);
|
||||
int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope);
|
||||
int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags);
|
||||
int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table);
|
||||
int sd_rtnl_message_route_set_type(sd_netlink_message *m, unsigned char type);
|
||||
int sd_rtnl_message_route_get_flags(sd_netlink_message *m, unsigned *flags);
|
||||
int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *family);
|
||||
int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, unsigned char *protocol);
|
||||
int sd_rtnl_message_route_get_scope(sd_netlink_message *m, unsigned char *scope);
|
||||
int sd_rtnl_message_route_get_tos(sd_netlink_message *m, unsigned char *tos);
|
||||
int sd_rtnl_message_route_get_table(sd_netlink_message *m, unsigned char *table);
|
||||
int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, unsigned char *dst_len);
|
||||
int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, unsigned char *src_len);
|
||||
int sd_rtnl_message_route_get_type(sd_netlink_message *m, unsigned char *type);
|
||||
int sd_rtnl_message_new_route(sd_netlink *nl, sd_netlink_message **ret, uint16_t nlmsg_type, int family, uint8_t protocol);
|
||||
/* struct rtmsg */
|
||||
int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *ret); /* rtm_family */
|
||||
int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, uint8_t prefixlen); /* rtm_dst_len */
|
||||
int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, uint8_t prefixlen); /* rtm_src_len */
|
||||
int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_route_set_tos(sd_netlink_message *m, uint8_t tos); /* rtm_tos */
|
||||
int sd_rtnl_message_route_get_tos(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_route_set_table(sd_netlink_message *m, uint8_t table); /* rtm_table */
|
||||
int sd_rtnl_message_route_get_table(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, uint8_t *ret); /* rtm_protocol */
|
||||
int sd_rtnl_message_route_set_scope(sd_netlink_message *m, uint8_t scope); /* rtm_scope */
|
||||
int sd_rtnl_message_route_get_scope(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_route_set_type(sd_netlink_message *m, uint8_t type); /* rtm_type */
|
||||
int sd_rtnl_message_route_get_type(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_route_set_flags(sd_netlink_message *m, uint32_t flags); /* rtm_flags */
|
||||
int sd_rtnl_message_route_get_flags(sd_netlink_message *m, uint32_t *ret);
|
||||
|
||||
int sd_rtnl_message_new_nexthop(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int nh_family, unsigned char nh_protocol);
|
||||
int sd_rtnl_message_nexthop_set_flags(sd_netlink_message *m, uint8_t flags);
|
||||
int sd_rtnl_message_nexthop_get_flags(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_nexthop_get_family(sd_netlink_message *m, uint8_t *family);
|
||||
int sd_rtnl_message_nexthop_get_protocol(sd_netlink_message *m, uint8_t *protocol);
|
||||
int sd_rtnl_message_new_nexthop(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int family, uint8_t protocol);
|
||||
/* struct nhmsg */
|
||||
int sd_rtnl_message_nexthop_get_family(sd_netlink_message *m, int *ret); /* nh_family */
|
||||
int sd_rtnl_message_nexthop_set_flags(sd_netlink_message *m, uint32_t flags); /* nh_flags, RTNH_F flags */
|
||||
int sd_rtnl_message_nexthop_get_flags(sd_netlink_message *m, uint32_t *ret);
|
||||
int sd_rtnl_message_nexthop_get_protocol(sd_netlink_message *m, uint8_t *ret); /* nh_protocol */
|
||||
|
||||
int sd_rtnl_message_new_neigh(sd_netlink *nl, sd_netlink_message **ret, uint16_t nlmsg_type, int index, int nda_family);
|
||||
int sd_rtnl_message_neigh_set_flags(sd_netlink_message *m, uint8_t flags);
|
||||
int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state);
|
||||
int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *family);
|
||||
int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *index);
|
||||
int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *state);
|
||||
int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *flags);
|
||||
int sd_rtnl_message_new_neigh(sd_netlink *nl, sd_netlink_message **ret, uint16_t nlmsg_type, int ifindex, int family);
|
||||
/* struct ndmsg */
|
||||
int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *ret); /* ndm_ifindex */
|
||||
int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *ret); /* ndm_family */
|
||||
int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state); /* ndm_state */
|
||||
int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *ret);
|
||||
int sd_rtnl_message_neigh_set_flags(sd_netlink_message *m, uint8_t flags); /* ndm_flags */
|
||||
int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *ret);
|
||||
|
||||
int sd_rtnl_message_new_addrlabel(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int ifindex, int ifal_family);
|
||||
int sd_rtnl_message_addrlabel_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
|
||||
int sd_rtnl_message_addrlabel_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen);
|
||||
int sd_rtnl_message_new_addrlabel(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int ifindex, int family);
|
||||
/* struct ifaddrlblmsg */
|
||||
int sd_rtnl_message_addrlabel_set_prefixlen(sd_netlink_message *m, uint8_t prefixlen); /* ifal_prefixlen */
|
||||
int sd_rtnl_message_addrlabel_get_prefixlen(sd_netlink_message *m, uint8_t *ret);
|
||||
|
||||
int sd_rtnl_message_new_routing_policy_rule(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int ifal_family);
|
||||
int sd_rtnl_message_routing_policy_rule_set_tos(sd_netlink_message *m, uint8_t tos);
|
||||
int sd_rtnl_message_routing_policy_rule_get_tos(sd_netlink_message *m, uint8_t *tos);
|
||||
int sd_rtnl_message_routing_policy_rule_set_table(sd_netlink_message *m, uint8_t table);
|
||||
int sd_rtnl_message_routing_policy_rule_get_table(sd_netlink_message *m, uint8_t *table);
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen(sd_netlink_message *m, uint8_t len);
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen(sd_netlink_message *m, uint8_t *len);
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen(sd_netlink_message *m, uint8_t len);
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen(sd_netlink_message *m, uint8_t *len);
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_type(sd_netlink_message *m, uint8_t type);
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_type(sd_netlink_message *m, uint8_t *type);
|
||||
int sd_rtnl_message_routing_policy_rule_set_flags(sd_netlink_message *m, uint32_t flags);
|
||||
int sd_rtnl_message_routing_policy_rule_get_flags(sd_netlink_message *m, uint32_t *flags);
|
||||
int sd_rtnl_message_new_routing_policy_rule(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int family);
|
||||
/* struct fib_rule_hdr */
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen(sd_netlink_message *m, uint8_t prefixlen); /* dst_len */
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen(sd_netlink_message *m, uint8_t prefixlen); /* src_len*/
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_routing_policy_rule_set_tos(sd_netlink_message *m, uint8_t tos); /* tos */
|
||||
int sd_rtnl_message_routing_policy_rule_get_tos(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_routing_policy_rule_set_table(sd_netlink_message *m, uint8_t table); /* table */
|
||||
int sd_rtnl_message_routing_policy_rule_get_table(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_routing_policy_rule_set_fib_type(sd_netlink_message *m, uint8_t type); /* action */
|
||||
int sd_rtnl_message_routing_policy_rule_get_fib_type(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_routing_policy_rule_set_flags(sd_netlink_message *m, uint32_t flags); /* flags */
|
||||
int sd_rtnl_message_routing_policy_rule_get_flags(sd_netlink_message *m, uint32_t *ret);
|
||||
|
||||
int sd_rtnl_message_new_traffic_control(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type,
|
||||
int ifindex, uint32_t handle, uint32_t parent);
|
||||
int sd_rtnl_message_traffic_control_get_ifindex(sd_netlink_message *m, int *ret);
|
||||
int sd_rtnl_message_traffic_control_get_handle(sd_netlink_message *m, uint32_t *ret);
|
||||
int sd_rtnl_message_traffic_control_get_parent(sd_netlink_message *m, uint32_t *ret);
|
||||
/* struct tcmsg */
|
||||
int sd_rtnl_message_traffic_control_get_ifindex(sd_netlink_message *m, int *ret); /* tcm_ifindex */
|
||||
int sd_rtnl_message_traffic_control_get_handle(sd_netlink_message *m, uint32_t *ret); /* tcm_handle */
|
||||
int sd_rtnl_message_traffic_control_get_parent(sd_netlink_message *m, uint32_t *ret); /* tcm_parent */
|
||||
|
||||
int sd_rtnl_message_new_mdb(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int mdb_ifindex);
|
||||
int sd_rtnl_message_new_mdb(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int ifindex);
|
||||
|
||||
int sd_rtnl_message_new_nsid(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type);
|
||||
|
||||
@ -234,14 +241,14 @@ int sd_genl_add_match(sd_netlink *nl, sd_netlink_slot **ret_slot, const char *fa
|
||||
sd_netlink_slot *sd_netlink_slot_ref(sd_netlink_slot *slot);
|
||||
sd_netlink_slot *sd_netlink_slot_unref(sd_netlink_slot *slot);
|
||||
|
||||
sd_netlink *sd_netlink_slot_get_netlink(sd_netlink_slot *slot);
|
||||
void *sd_netlink_slot_get_userdata(sd_netlink_slot *slot);
|
||||
void *sd_netlink_slot_set_userdata(sd_netlink_slot *slot, void *userdata);
|
||||
int sd_netlink_slot_get_destroy_callback(sd_netlink_slot *slot, sd_netlink_destroy_t *callback);
|
||||
sd_netlink* sd_netlink_slot_get_netlink(sd_netlink_slot *slot);
|
||||
void* sd_netlink_slot_get_userdata(sd_netlink_slot *slot);
|
||||
void* sd_netlink_slot_set_userdata(sd_netlink_slot *slot, void *userdata);
|
||||
int sd_netlink_slot_get_destroy_callback(sd_netlink_slot *slot, sd_netlink_destroy_t *ret);
|
||||
int sd_netlink_slot_set_destroy_callback(sd_netlink_slot *slot, sd_netlink_destroy_t callback);
|
||||
int sd_netlink_slot_get_floating(sd_netlink_slot *slot);
|
||||
int sd_netlink_slot_set_floating(sd_netlink_slot *slot, int b);
|
||||
int sd_netlink_slot_get_description(sd_netlink_slot *slot, const char **description);
|
||||
int sd_netlink_slot_get_description(sd_netlink_slot *slot, const char **ret);
|
||||
int sd_netlink_slot_set_description(sd_netlink_slot *slot, const char *description);
|
||||
|
||||
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_netlink, sd_netlink_unref);
|
||||
|
Loading…
Reference in New Issue
Block a user