Lines Matching refs:sd
113 static int nl_sendreq(int sd, int request, int flags, int *seq)
134 return (sendto(sd, (void *) req_hdr, req_hdr->nlmsg_len, 0, (struct sockaddr *) &nladdr, sizeof(nladdr)));
137 static int nl_recvmsg(int sd, int request, int seq, void *buf, size_t buflen, int *flags)
152 read_len = recvmsg(sd, &msg, 0);
163 static int nl_getmsg(int sd, int request, int seq, struct nlmsghdr **nlhp, int *done)
179 result = read_size = nl_recvmsg(sd, request, seq, buff, bufsize, &msg_flags);
218 static int nl_getlist(int sd, int seq, int request, struct nlmsg_list **nlm_list, struct nlmsg_list **nlm_end)
224 status = nl_sendreq(sd, request, NLM_F_ROOT | NLM_F_MATCH, &seq);
230 status = nl_getmsg(sd, request, seq, &nlh, &done);
286 static void nl_close(int sd)
289 if (sd >= 0)
290 close(sd);
298 int sd;
300 sd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
301 if (sd < 0)
305 if (bind(sd, (struct sockaddr *) &nladdr, sizeof(nladdr)) < 0) {
306 nl_close(sd);
309 return sd;
315 int sd;
337 sd = nl_open();
338 if (sd < 0)
343 if ((seq = nl_getlist(sd, seq + 1, RTM_GETADDR, &nlmsg_list, &nlmsg_end)) < 0) {
345 nl_close(sd);
534 nl_close(sd);