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)
104 req.nlh.nlmsg_seq = rth->dump = ++rth->seq;
107 return send(rth->fd, (void*)&req, sizeof(req), 0);
110 int rtnl_send(struct rtnl_handle *rth, const char *buf, int len)
112 return send(rth->fd, buf, len, 0);
115 int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len)
121 status = send(rth->fd, buf, len, 0);
126 status = recv(rth->fd, resp, sizeof(resp), MSG_DONTWAIT|MSG_PEEK);
148 int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
170 nlh.nlmsg_seq = rth->dump = ++rth->seq;
172 return sendmsg(rth->fd, &msg, 0);
175 int rtnl_dump_filter_l(struct rtnl_handle *rth,
194 status = recvmsg(rth->fd, &msg, 0);
216 h->nlmsg_pid != rth->local.nl_pid ||
217 h->nlmsg_seq != rth->dump) {
259 int rtnl_dump_filter(struct rtnl_handle *rth,
270 return rtnl_dump_filter_l(rth, a);