return 0;
}
-static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
+static int tcpdiag_send(int fd, int protocol, struct filter *f)
{
- int fd;
struct sockaddr_nl nladdr;
struct {
struct nlmsghdr nlh;
int bclen;
struct msghdr msg;
struct rtattr rta;
- char buf[8192];
struct iovec iov[3];
- if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG)) < 0)
- return -1;
-
memset(&nladdr, 0, sizeof(nladdr));
nladdr.nl_family = AF_NETLINK;
return -1;
}
+ return 0;
+}
+
+static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
+{
+ int fd;
+ struct sockaddr_nl nladdr;
+ struct msghdr msg;
+ char buf[8192];
+ struct iovec iov[3];
+
+ if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG)) < 0)
+ return -1;
+
+ if (tcpdiag_send(fd, protocol, f))
+ return -1;
+
+ memset(&nladdr, 0, sizeof(nladdr));
+ nladdr.nl_family = AF_NETLINK;
+
iov[0] = (struct iovec){
.iov_base = buf,
.iov_len = sizeof(buf)