Home | History | Annotate | Download | only in lib

Lines Matching refs:rth

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