Lines Matching refs:rth
30 void rtnl_close(struct rtnl_handle *rth) in rtnl_close() argument
32 if (rth->fd >= 0) { in rtnl_close()
33 close(rth->fd); in rtnl_close()
34 rth->fd = -1; in rtnl_close()
38 int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, in rtnl_open_byproto() argument
44 memset(rth, 0, sizeof(*rth)); in rtnl_open_byproto()
46 rth->fd = socket(AF_NETLINK, SOCK_RAW, protocol); in rtnl_open_byproto()
47 if (rth->fd < 0) { in rtnl_open_byproto()
52 if (setsockopt(rth->fd,SOL_SOCKET,SO_SNDBUF,&sndbuf,sizeof(sndbuf)) < 0) { in rtnl_open_byproto()
57 if (setsockopt(rth->fd,SOL_SOCKET,SO_RCVBUF,&rcvbuf,sizeof(rcvbuf)) < 0) { in rtnl_open_byproto()
62 memset(&rth->local, 0, sizeof(rth->local)); in rtnl_open_byproto()
63 rth->local.nl_family = AF_NETLINK; in rtnl_open_byproto()
64 rth->local.nl_groups = subscriptions; in rtnl_open_byproto()
66 if (bind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)) < 0) { in rtnl_open_byproto()
70 addr_len = sizeof(rth->local); in rtnl_open_byproto()
71 if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) { in rtnl_open_byproto()
75 if (addr_len != sizeof(rth->local)) { in rtnl_open_byproto()
79 if (rth->local.nl_family != AF_NETLINK) { in rtnl_open_byproto()
80 fprintf(stderr, "Wrong address family %d\n", rth->local.nl_family); in rtnl_open_byproto()
83 rth->seq = time(NULL); in rtnl_open_byproto()
87 int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) in rtnl_open() argument
89 return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE); in rtnl_open()
92 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) in rtnl_wilddump_request() argument
107 req.nlh.nlmsg_seq = rth->dump = ++rth->seq; in rtnl_wilddump_request()
114 return send(rth->fd, (void*)&req, sizeof(req), 0); in rtnl_wilddump_request()
117 int rtnl_send(struct rtnl_handle *rth, const void *buf, int len) in rtnl_send() argument
119 return send(rth->fd, buf, len, 0); in rtnl_send()
122 int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int len) in rtnl_send_check() argument
128 status = send(rth->fd, buf, len, 0); in rtnl_send_check()
133 status = recv(rth->fd, resp, sizeof(resp), MSG_DONTWAIT|MSG_PEEK); in rtnl_send_check()
155 int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) in rtnl_dump_request() argument
174 nlh.nlmsg_seq = rth->dump = ++rth->seq; in rtnl_dump_request()
176 return sendmsg(rth->fd, &msg, 0); in rtnl_dump_request()
179 int rtnl_dump_filter_l(struct rtnl_handle *rth, in rtnl_dump_filter_l() argument
200 status = recvmsg(rth->fd, &msg, 0); in rtnl_dump_filter_l()
223 h->nlmsg_pid != rth->local.nl_pid || in rtnl_dump_filter_l()
224 h->nlmsg_seq != rth->dump) in rtnl_dump_filter_l()
265 int rtnl_dump_filter(struct rtnl_handle *rth, in rtnl_dump_filter() argument
274 return rtnl_dump_filter_l(rth, a); in rtnl_dump_filter()