Lines Matching refs:rth

16 void rtnl_close(struct rtnl_handle *rth)  in rtnl_close()  argument
18 if (rth->fd >= 0) { in rtnl_close()
19 close(rth->fd); in rtnl_close()
20 rth->fd = -1; in rtnl_close()
24 int rtnl_open_byproto(struct rtnl_handle *rth, unsigned int subscriptions, in rtnl_open_byproto() argument
31 memset(rth, 0, sizeof(*rth)); in rtnl_open_byproto()
32 rth->proto = protocol; in rtnl_open_byproto()
33 rth->fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, protocol); in rtnl_open_byproto()
34 if (rth->fd < 0) { in rtnl_open_byproto()
38 if (setsockopt(rth->fd, SOL_SOCKET, SO_SNDBUF, in rtnl_open_byproto()
43 if (setsockopt(rth->fd, SOL_SOCKET, SO_RCVBUF, in rtnl_open_byproto()
50 setsockopt(rth->fd, SOL_NETLINK, NETLINK_EXT_ACK, in rtnl_open_byproto()
53 memset(&rth->local, 0, sizeof(rth->local)); in rtnl_open_byproto()
54 rth->local.nl_family = AF_NETLINK; in rtnl_open_byproto()
55 rth->local.nl_groups = subscriptions; in rtnl_open_byproto()
57 if (bind(rth->fd, (struct sockaddr *)&rth->local, in rtnl_open_byproto()
58 sizeof(rth->local)) < 0) { in rtnl_open_byproto()
62 addr_len = sizeof(rth->local); in rtnl_open_byproto()
63 if (getsockname(rth->fd, (struct sockaddr *)&rth->local, in rtnl_open_byproto()
68 if (addr_len != sizeof(rth->local)) { in rtnl_open_byproto()
72 if (rth->local.nl_family != AF_NETLINK) { in rtnl_open_byproto()
74 rth->local.nl_family); in rtnl_open_byproto()
77 rth->seq = time(NULL); in rtnl_open_byproto()
80 rtnl_close(rth); in rtnl_open_byproto()
84 int rtnl_open(struct rtnl_handle *rth, unsigned int subscriptions) in rtnl_open() argument
86 return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE); in rtnl_open()