2
* nl-list-sockets.c Pretty-print /proc/net/netlink
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation version 2.1
9
* Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch>
12
#include <netlink/cli/utils.h>
14
#define PROC_NETLINK "/proc/net/netlink"
16
int main(int argc, char *argv[])
19
char buf[2048], p[64];
21
fd = fopen(PROC_NETLINK, "r");
27
printf("Address Family PID Groups rmem "
30
while (fgets(buf, sizeof(buf), fd)) {
32
int ret, proto, pid, rmem, wmem, refcnt;
35
ret = sscanf(buf, "%lx %d %d %08x %d %d %lx %d\n",
36
&sk, &proto, &pid, &groups, &rmem, &wmem,
41
printf("0x%016lx %-16s %-6d %08x %-6d %-6d 0x%08lx %d\n",
42
sk, nl_nlfamily2str(proto, p, sizeof(p)), pid,
43
groups, rmem, wmem, cb, refcnt);