Lines Matching defs:sock

108 	int sock;
113 sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
114 if (sock < 0)
117 if (setsockopt(sock, SOL_NETLINK, NETLINK_EXT_ACK,
122 if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
128 if (getsockname(sock, (struct sockaddr *)&sa, &addrlen) < 0) {
139 return sock;
142 close(sock);
146 static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,
158 len = recv(sock, buf, sizeof(buf), 0);
220 static int netlink_get_class(int sock, unsigned int nl_pid, int ifindex,
236 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
239 return netlink_recv(sock, nl_pid, seq, __dump_class_nlmsg,
259 static int netlink_get_qdisc(int sock, unsigned int nl_pid, int ifindex,
275 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
278 return netlink_recv(sock, nl_pid, seq, __dump_qdisc_nlmsg,
298 static int netlink_get_filter(int sock, unsigned int nl_pid, int ifindex, int handle,
315 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
318 return netlink_recv(sock, nl_pid, seq, __dump_filter_nlmsg,
337 static int netlink_get_link(int sock, unsigned int nl_pid,
352 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
355 return netlink_recv(sock, nl_pid, seq, __dump_link_nlmsg,
511 static int show_dev_tc_bpf_classic(int sock, unsigned int nl_pid,
523 ret = netlink_get_class(sock, nl_pid, dev->ifindex,
529 ret = netlink_get_qdisc(sock, nl_pid, dev->ifindex,
538 ret = netlink_get_filter(sock, nl_pid, dev->ifindex,
548 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
555 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
562 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
841 int i, sock, ret, filter_idx = -1;
858 sock = netlink_open(&nl_pid);
859 if (sock < 0) {
860 fprintf(stderr, "failed to open netlink sock\n");
873 ret = netlink_get_link(sock, nl_pid, dump_link_nlmsg, &dev_array);
880 ret = show_dev_tc_bpf_classic(sock, nl_pid,
908 close(sock);