~ubuntu-branches/ubuntu/precise/iproute/precise

« back to all changes in this revision

Viewing changes to misc/ss.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt, Andreas Henriksson, Ben Finney, Justin Pryzby, Daniel Silverstone, Alexander Wirt
  • Date: 2007-12-16 14:30:31 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071216143031-cbd111kybw3o9mpv
Tags: 20071016-1
[ Andreas Henriksson ]
* New upstream release (v2.6.23 aka snapshot 071016) (Closes: #445944)
  - time2tick overflow patch applied upstream (Closes: #175462)
  - tc ematch cmp/nbyte help patch applied upstream (Closes: #438653)
  - mpath support dropped upstream (Closes: #428440, #428442)
  - new manpages included upstream (Closes: #438994)
  - linux header files updated to v2.6.23 (Closes: #409047)
* Drop patches which has been applied upstream or deprecated by
  upstream changes.
  - debian/patches/lartc applied upstream.
  - debian/patches/netbug_fix deprecated, upstream dropped netbug script.
  - debian/patches/empty_linkname.dpatch deprecated, fixed upstream.
* Add .dpatch suffix to wrr-qdisc patch to make dpatch-edit-patch work.
* Update patches to apply:
  - wrr-qdisc, moo, ip_route_usage
* Don't install removed netbug script.
* Fix corruption when using batch files with comments and broken
  lines. (cherry-picked from upstream. Closes: #398912)
* Update build-dependencies:
  - libdb4.3-dev -> libdb-dev. (Closes: #442653)
  - linux-kernel-headers -> linux-libc-dev.
* Drop debian/patches/ip_address_flush_loop.dpatch,
  instead we'll use Daniel Silverstones patch imported from Ubuntu.
* Add Homepage and Vcs-{Browser,Git} fields to debian/control.
* Remove dead/leftover code from tc/q_htb.c, include/linux/pkt_sched.h
* Remove outdated README.Debian.
* Drop our own (buggy) RTAX_INITCWND support, in favor of upstreams.
* fix dotted-quad support patch to work on big-endian.
  (upstream applied a broken patch, which we cherry-picked for #357172)

[ Ben Finney ]
* Add dh_md5sums to generate md5sums control file (Closes: #439439)

[ Justin Pryzby ]
* ss(8) manpage formatting breaks EXAMPLE (Closes: #443071)

[ Daniel Silverstone ]
* Avoid infinite loop in ip addr flush.

[ Alexander Wirt ]
* Add Andreas Henriksson to uploaders
* Bump standards version
* Support dotted-quad netmasks in iproute (Closes: #357172) (Cherry picked
  from upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
};
106
106
 
107
107
struct filter default_filter = {
108
 
        dbs: (1<<TCP_DB),
109
 
        states: SS_ALL & ~((1<<SS_LISTEN)|(1<<SS_CLOSE)|(1<<SS_TIME_WAIT)|(1<<SS_SYN_RECV)),
110
 
        families: (1<<AF_INET)|(1<<AF_INET6),
 
108
        .dbs    =  (1<<TCP_DB),
 
109
        .states = SS_ALL & ~((1<<SS_LISTEN)|(1<<SS_CLOSE)|(1<<SS_TIME_WAIT)|(1<<SS_SYN_RECV)),
 
110
        .families= (1<<AF_INET)|(1<<AF_INET6),
111
111
};
112
112
 
113
113
struct filter current_filter;
114
114
 
115
 
int generic_proc_open(char *env, char *name)
 
115
static FILE *generic_proc_open(const char *env, const char *name)
116
116
{
 
117
        const char *p = getenv(env);
117
118
        char store[128];
118
 
        char *p = getenv(env);
 
119
 
119
120
        if (!p) {
120
121
                p = getenv("PROC_ROOT") ? : "/proc";
121
122
                snprintf(store, sizeof(store)-1, "%s/%s", p, name);
122
123
                p = store;
123
124
        }
124
 
        return open(p, O_RDONLY);
 
125
 
 
126
        return fopen(p, "r");
125
127
}
126
128
 
127
 
int net_tcp_open(void)
 
129
static FILE *net_tcp_open(void)
128
130
{
129
131
        return generic_proc_open("PROC_NET_TCP", "net/tcp");
130
132
}
131
133
 
132
 
int net_tcp6_open(void)
 
134
static FILE *net_tcp6_open(void)
133
135
{
134
136
        return generic_proc_open("PROC_NET_TCP6", "net/tcp6");
135
137
}
136
138
 
137
 
int net_udp_open(void)
 
139
static FILE *net_udp_open(void)
138
140
{
139
141
        return generic_proc_open("PROC_NET_UDP", "net/udp");
140
142
}
141
143
 
142
 
int net_udp6_open(void)
 
144
static FILE *net_udp6_open(void)
143
145
{
144
146
        return generic_proc_open("PROC_NET_UDP6", "net/udp6");
145
147
}
146
148
 
147
 
int net_raw_open(void)
 
149
static FILE *net_raw_open(void)
148
150
{
149
151
        return generic_proc_open("PROC_NET_RAW", "net/raw");
150
152
}
151
153
 
152
 
int net_raw6_open(void)
 
154
static FILE *net_raw6_open(void)
153
155
{
154
156
        return generic_proc_open("PROC_NET_RAW6", "net/raw6");
155
157
}
156
158
 
157
 
int net_unix_open(void)
 
159
static FILE *net_unix_open(void)
158
160
{
159
161
        return generic_proc_open("PROC_NET_UNIX", "net/unix");
160
162
}
161
163
 
162
 
int net_packet_open(void)
 
164
static FILE *net_packet_open(void)
163
165
{
164
166
        return generic_proc_open("PROC_NET_PACKET", "net/packet");
165
167
}
166
168
 
167
 
int net_netlink_open(void)
 
169
static FILE *net_netlink_open(void)
168
170
{
169
171
        return generic_proc_open("PROC_NET_NETLINK", "net/netlink");
170
172
}
171
173
 
172
 
int slabinfo_open(void)
 
174
static FILE *slabinfo_open(void)
173
175
{
174
176
        return generic_proc_open("PROC_SLABINFO", "slabinfo");
175
177
}
176
178
 
177
 
int net_sockstat_open(void)
 
179
static FILE *net_sockstat_open(void)
178
180
{
179
181
        return generic_proc_open("PROC_NET_SOCKSTAT", "net/sockstat");
180
182
}
181
183
 
182
 
int net_sockstat6_open(void)
 
184
static FILE *net_sockstat6_open(void)
183
185
{
184
186
        return generic_proc_open("PROC_NET_SOCKSTAT6", "net/sockstat6");
185
187
}
186
188
 
187
 
int net_snmp_open(void)
 
189
static FILE *net_snmp_open(void)
188
190
{
189
191
        return generic_proc_open("PROC_NET_SNMP", "net/snmp");
190
192
}
191
193
 
192
 
int net_netstat_open(void)
193
 
{
194
 
        return generic_proc_open("PROC_NET_NETSTAT", "net/netstat");
195
 
}
196
 
 
197
 
int ephemeral_ports_open(void)
 
194
static FILE *ephemeral_ports_open(void)
198
195
{
199
196
        return generic_proc_open("PROC_IP_LOCAL_PORT_RANGE", "sys/net/ipv4/ip_local_port_range");
200
197
}
201
198
 
202
 
int find_users(int ino, char *buf, int buflen)
 
199
int find_users(unsigned ino, char *buf, int buflen)
203
200
{
204
201
        char pattern[64];
205
202
        int  pattern_len;
213
210
        if (!ino)
214
211
                return 0;
215
212
 
216
 
        sprintf(pattern, "socket:[%d]", ino);
 
213
        sprintf(pattern, "socket:[%u]", ino);
217
214
        pattern_len = strlen(pattern);
218
215
 
219
216
        strncpy(name, getenv("PROC_ROOT") ? : "/proc/", sizeof(name)/2);
313
310
 
314
311
        memset(s, 0, sizeof(*s));
315
312
 
316
 
        if ((fp = fdopen(slabinfo_open(), "r")) == NULL)
 
313
        fp = slabinfo_open();
 
314
        if (!fp)
317
315
                return -1;
318
316
 
319
317
        cnt = sizeof(*s)/sizeof(int);
377
375
        int             timer;
378
376
        int             timeout;
379
377
        int             retrs;
380
 
        int             ino;
 
378
        unsigned        ino;
381
379
        int             probes;
382
 
        int             uid;
 
380
        unsigned        uid;
383
381
        int             refcnt;
384
382
        unsigned long long sk;
385
383
        int             rto, ato, qack, cwnd, ssthresh;
419
417
        if (msecs)
420
418
                sprintf(buf+strlen(buf), "%03dms", msecs);
421
419
        return buf;
422
 
};
 
420
}
423
421
 
424
422
const char *print_hz_timer(int timeout)
425
423
{
426
424
        int hz = get_hz();
427
425
        return print_ms_timer(((timeout*1000) + hz-1)/hz);
428
 
};
 
426
}
429
427
 
430
428
struct scache
431
429
{
478
476
static int is_ephemeral(int port)
479
477
{
480
478
        if (!ip_local_port_min) {
481
 
                FILE *f = fdopen(ephemeral_ports_open(), "r");
 
479
                FILE *f = ephemeral_ports_open();
482
480
                if (f) {
483
481
                        fscanf(f, "%d %d",
484
482
                               &ip_local_port_min, &ip_local_port_max);
655
653
                        return s->lport < 0;
656
654
 
657
655
                if (!low) {
658
 
                        FILE *fp = fdopen(ephemeral_ports_open(), "r");
 
656
                        FILE *fp = ephemeral_ports_open();
659
657
                        if (fp) {
660
658
                                fscanf(fp, "%d%d", &low, &high);
661
659
                                fclose(fp);
1103
1101
        return res;
1104
1102
}
1105
1103
 
1106
 
static int tcp_show_line(char *line, struct filter *f, int family)
 
1104
static int tcp_show_line(char *line, const struct filter *f, int family)
1107
1105
{
1108
1106
        struct tcpstat s;
1109
1107
        char *loc, *rem, *data;
1157
1155
                return 0;
1158
1156
 
1159
1157
        opt[0] = 0;
1160
 
        n = sscanf(data, "%x %x:%x %x:%x %x %d %d %d %d %llx %d %d %d %d %d %[^\n]\n",
 
1158
        n = sscanf(data, "%x %x:%x %x:%x %x %d %d %u %d %llx %d %d %d %d %d %[^\n]\n",
1161
1159
                   &s.state, &s.wq, &s.rq,
1162
1160
                   &s.timer, &s.timeout, &s.retrs, &s.uid, &s.probes, &s.ino,
1163
1161
                   &s.refcnt, &s.sk, &s.rto, &s.ato, &s.qack,
1215
1213
        if (show_details) {
1216
1214
                if (s.uid)
1217
1215
                        printf(" uid:%u", (unsigned)s.uid);
1218
 
                printf(" ino:%u", (unsigned)s.ino);
 
1216
                printf(" ino:%u", s.ino);
1219
1217
                printf(" sk:%llx", s.sk);
1220
1218
                if (opt[0])
1221
1219
                        printf(" opt:\"%s\"", opt);
1225
1223
        return 0;
1226
1224
}
1227
1225
 
1228
 
static int generic_record_read(int fd, char *buf, int bufsize,
1229
 
                        int (*worker)(char*, struct filter *, int),
1230
 
                        struct filter *f, int fam)
 
1226
static int generic_record_read(FILE *fp,
 
1227
                               int (*worker)(char*, const struct filter *, int),
 
1228
                               const struct filter *f, int fam)
1231
1229
{
1232
 
        int n;
1233
 
        int recsize;
1234
 
        int eof = 0;
1235
 
        char *p;
 
1230
        char line[256];
1236
1231
 
1237
 
        /* Load the first chunk and calculate record length from it. */
1238
 
        n = read(fd, buf, bufsize);
1239
 
        if (n < 0)
 
1232
        /* skip header */
 
1233
        if (fgets(line, sizeof(line), fp) == NULL)
1240
1234
                goto outerr;
1241
 
        /* I _know_ that this is wrong, do not remind. :-)
1242
 
         * But this works nowadays. */
1243
 
        if (n < bufsize)
1244
 
                eof = 1;
1245
 
        p = memchr(buf, '\n', n);
1246
 
        if (p == NULL || (p-buf) >= n)
1247
 
                goto outwrongformat;
1248
 
        recsize = (p-buf)+1;
1249
 
        p = buf+recsize;
1250
 
 
1251
 
        for (;;) {
1252
 
                while ((p+recsize) - buf <= n) {
1253
 
                        if (p[recsize-1] != '\n')
1254
 
                                goto outwrongformat;
1255
 
                        p[recsize-1] = 0;
1256
 
                        if (worker(p, f, fam) < 0)
1257
 
                                goto done;
1258
 
                        p += recsize;
1259
 
                }
1260
 
                if (!eof) {
1261
 
                        int remains = (buf+bufsize) - p;
1262
 
                        memcpy(buf, p, remains);
1263
 
                        p = buf+remains;
1264
 
                        n = read(fd, p, (buf+bufsize) - p);
1265
 
                        if (n < 0)
1266
 
                                goto outerr;
1267
 
                        if (n < (buf+bufsize) - p) {
1268
 
                                eof = 1;
1269
 
                                if (n == 0) {
1270
 
                                        if (remains)
1271
 
                                                goto outwrongformat;
1272
 
                                        goto done;
1273
 
                                }
1274
 
                        }
1275
 
                        n += remains;
1276
 
                        p = buf;
1277
 
                } else {
1278
 
                        if (p != buf+n)
1279
 
                                goto outwrongformat;
1280
 
                        goto done;
1281
 
                }
 
1235
 
 
1236
        while (fgets(line, sizeof(line), fp) != NULL) {
 
1237
                int n = strlen(line);
 
1238
                if (n == 0 || line[n-1] != '\n') {
 
1239
                        errno = -EINVAL;
 
1240
                        return -1;
 
1241
                }
 
1242
                line[n-1] = 0;
 
1243
 
 
1244
                if (worker(line, f, fam) < 0)
 
1245
                        return 0;
1282
1246
        }
1283
 
done:
1284
 
        return 0;
1285
 
 
1286
 
outwrongformat:
1287
 
        errno = EINVAL;
1288
1247
outerr:
1289
 
        return -1;
 
1248
 
 
1249
        return ferror(fp) ? -1 : 0;
1290
1250
}
1291
1251
 
1292
1252
static char *sprint_bw(char *buf, double bw)
1384
1344
        }
1385
1345
}
1386
1346
 
1387
 
int tcp_show_sock(struct nlmsghdr *nlh, struct filter *f)
 
1347
static int tcp_show_sock(struct nlmsghdr *nlh, struct filter *f)
1388
1348
{
1389
1349
        struct inet_diag_msg *r = NLMSG_DATA(nlh);
1390
1350
        struct tcpstat s;
1432
1392
        if (show_details) {
1433
1393
                if (r->idiag_uid)
1434
1394
                        printf(" uid:%u", (unsigned)r->idiag_uid);
1435
 
                printf(" ino:%u", (unsigned)r->idiag_inode);
 
1395
                printf(" ino:%u", r->idiag_inode);
1436
1396
                printf(" sk:%08x", r->id.idiag_cookie[0]);
1437
1397
                if (r->id.idiag_cookie[1] != 0)
1438
1398
                        printf("%08x", r->id.idiag_cookie[1]);
1447
1407
        return 0;
1448
1408
}
1449
1409
 
1450
 
int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
 
1410
static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
1451
1411
{
1452
1412
        int fd;
1453
1413
        struct sockaddr_nl nladdr;
1581
1541
        return 0;
1582
1542
}
1583
1543
 
1584
 
int tcp_show_netlink_file(struct filter *f)
 
1544
static int tcp_show_netlink_file(struct filter *f)
1585
1545
{
1586
1546
        FILE    *fp;
1587
1547
        char    buf[8192];
1637
1597
        }
1638
1598
}
1639
1599
 
1640
 
int tcp_show(struct filter *f, int socktype)
 
1600
static int tcp_show(struct filter *f, int socktype)
1641
1601
{
1642
 
        int fd = -1;
 
1602
        FILE *fp = NULL;
1643
1603
        char *buf = NULL;
1644
1604
        int bufsize = 64*1024;
1645
1605
 
1654
1614
 
1655
1615
        /* Sigh... We have to parse /proc/net/tcp... */
1656
1616
 
 
1617
 
1657
1618
        /* Estimate amount of sockets and try to allocate
1658
1619
         * huge buffer to read all the table at one read.
1659
1620
         * Limit it by 16MB though. The assumption is: as soon as
1681
1642
        }
1682
1643
 
1683
1644
        if (f->families & (1<<AF_INET)) {
1684
 
                if ((fd = net_tcp_open()) < 0)
1685
 
                        goto outerr;
1686
 
                if (generic_record_read(fd, buf, bufsize, tcp_show_line, f, AF_INET))
1687
 
                        goto outerr;
1688
 
                close(fd);
 
1645
                if ((fp = net_tcp_open()) < 0)
 
1646
                        goto outerr;
 
1647
 
 
1648
                setbuffer(fp, buf, bufsize);
 
1649
                if (generic_record_read(fp, tcp_show_line, f, AF_INET))
 
1650
                        goto outerr;
 
1651
                fclose(fp);
1689
1652
        }
1690
1653
 
1691
1654
        if ((f->families & (1<<AF_INET6)) &&
1692
 
            (fd = net_tcp6_open()) >= 0) {
1693
 
                if (generic_record_read(fd, buf, bufsize, tcp_show_line, f, AF_INET6))
 
1655
            (fp = net_tcp6_open()) >= 0) {
 
1656
                setbuffer(fp, buf, bufsize);
 
1657
                if (generic_record_read(fp, tcp_show_line, f, AF_INET6))
1694
1658
                        goto outerr;
1695
 
                close(fd);
 
1659
                fclose(fp);
1696
1660
        }
1697
1661
 
1698
1662
        free(buf);
1703
1667
                int saved_errno = errno;
1704
1668
                if (buf)
1705
1669
                        free(buf);
1706
 
                if (fd >= 0)
1707
 
                        close(fd);
 
1670
                if (fp)
 
1671
                        fclose(fp);
1708
1672
                errno = saved_errno;
1709
1673
                return -1;
1710
1674
        } while (0);
1711
1675
}
1712
1676
 
1713
1677
 
1714
 
int dgram_show_line(char *line, struct filter *f, int family)
 
1678
int dgram_show_line(char *line, const struct filter *f, int family)
1715
1679
{
1716
1680
        struct tcpstat s;
1717
1681
        char *loc, *rem, *data;
1765
1729
                return 0;
1766
1730
 
1767
1731
        opt[0] = 0;
1768
 
        n = sscanf(data, "%x %x:%x %*x:%*x %*x %d %*d %d %d %llx %[^\n]\n",
 
1732
        n = sscanf(data, "%x %x:%x %*x:%*x %*x %d %*d %u %d %llx %[^\n]\n",
1769
1733
               &s.state, &s.wq, &s.rq,
1770
1734
               &s.uid, &s.ino,
1771
1735
               &s.refcnt, &s.sk, opt);
1792
1756
        if (show_details) {
1793
1757
                if (s.uid)
1794
1758
                        printf(" uid=%u", (unsigned)s.uid);
1795
 
                printf(" ino=%u", (unsigned)s.ino);
 
1759
                printf(" ino=%u", s.ino);
1796
1760
                printf(" sk=%llx", s.sk);
1797
1761
                if (opt[0])
1798
1762
                        printf(" opt:\"%s\"", opt);
1805
1769
 
1806
1770
int udp_show(struct filter *f)
1807
1771
{
1808
 
        int fd = -1;
1809
 
        char buf[8192];
1810
 
        int  bufsize = sizeof(buf);
 
1772
        FILE *fp = NULL;
1811
1773
 
1812
1774
        dg_proto = UDP_PROTO;
1813
1775
 
1814
1776
        if (f->families&(1<<AF_INET)) {
1815
 
                if ((fd = net_udp_open()) < 0)
1816
 
                        goto outerr;
1817
 
                if (generic_record_read(fd, buf, bufsize, dgram_show_line, f, AF_INET))
1818
 
                        goto outerr;
1819
 
                close(fd);
 
1777
                if ((fp = net_udp_open()) < 0)
 
1778
                        goto outerr;
 
1779
                if (generic_record_read(fp, dgram_show_line, f, AF_INET))
 
1780
                        goto outerr;
 
1781
                fclose(fp);
1820
1782
        }
1821
1783
 
1822
1784
        if ((f->families&(1<<AF_INET6)) &&
1823
 
            (fd = net_udp6_open()) >= 0) {
1824
 
                if (generic_record_read(fd, buf, bufsize, dgram_show_line, f, AF_INET6))
 
1785
            (fp = net_udp6_open()) >= 0) {
 
1786
                if (generic_record_read(fp, dgram_show_line, f, AF_INET6))
1825
1787
                        goto outerr;
1826
 
                close(fd);
 
1788
                fclose(fp);
1827
1789
        }
1828
1790
        return 0;
1829
1791
 
1830
1792
outerr:
1831
1793
        do {
1832
1794
                int saved_errno = errno;
1833
 
                if (fd >= 0)
1834
 
                        close(fd);
 
1795
                if (fp)
 
1796
                        fclose(fp);
1835
1797
                errno = saved_errno;
1836
1798
                return -1;
1837
1799
        } while (0);
1839
1801
 
1840
1802
int raw_show(struct filter *f)
1841
1803
{
1842
 
        int fd = -1;
1843
 
        char buf[8192];
1844
 
        int  bufsize = sizeof(buf);
 
1804
        FILE *fp = NULL;
1845
1805
 
1846
1806
        dg_proto = RAW_PROTO;
1847
1807
 
1848
1808
        if (f->families&(1<<AF_INET)) {
1849
 
                if ((fd = net_raw_open()) < 0)
1850
 
                        goto outerr;
1851
 
                if (generic_record_read(fd, buf, bufsize, dgram_show_line, f, AF_INET))
1852
 
                        goto outerr;
1853
 
                close(fd);
 
1809
                if ((fp = net_raw_open()) < 0)
 
1810
                        goto outerr;
 
1811
                if (generic_record_read(fp, dgram_show_line, f, AF_INET))
 
1812
                        goto outerr;
 
1813
                fclose(fp);
1854
1814
        }
1855
1815
 
1856
1816
        if ((f->families&(1<<AF_INET6)) &&
1857
 
            (fd = net_raw6_open()) >= 0) {
1858
 
                if (generic_record_read(fd, buf, bufsize, dgram_show_line, f, AF_INET6))
 
1817
            (fp = net_raw6_open()) >= 0) {
 
1818
                if (generic_record_read(fp, dgram_show_line, f, AF_INET6))
1859
1819
                        goto outerr;
1860
 
                close(fd);
 
1820
                fclose(fp);
1861
1821
        }
1862
1822
        return 0;
1863
1823
 
1864
1824
outerr:
1865
1825
        do {
1866
1826
                int saved_errno = errno;
1867
 
                if (fd >= 0)
1868
 
                        close(fd);
 
1827
                if (fp)
 
1828
                        fclose(fp);
1869
1829
                errno = saved_errno;
1870
1830
                return -1;
1871
1831
        } while (0);
1970
1930
        int  cnt;
1971
1931
        struct unixstat *list = NULL;
1972
1932
 
1973
 
        if ((fp = fdopen(net_unix_open(), "r")) == NULL)
 
1933
        if ((fp = net_unix_open()) == NULL)
1974
1934
                return -1;
1975
1935
        fgets(buf, sizeof(buf)-1, fp);
1976
1936
 
2058
2018
        if (!(f->states & (1<<SS_CLOSE)))
2059
2019
                return 0;
2060
2020
 
2061
 
        if ((fp = fdopen(net_packet_open(), "r")) == NULL)
 
2021
        if ((fp = net_packet_open()) == NULL)
2062
2022
                return -1;
2063
2023
        fgets(buf, sizeof(buf)-1, fp);
2064
2024
 
2131
2091
        if (!(f->states & (1<<SS_CLOSE)))
2132
2092
                return 0;
2133
2093
 
2134
 
        if ((fp = fdopen(net_netlink_open(), "r")) == NULL)
 
2094
        if ((fp = net_netlink_open()) == NULL)
2135
2095
                return -1;
2136
2096
        fgets(buf, sizeof(buf)-1, fp);
2137
2097
 
2217
2177
 
2218
2178
        *result = 0;
2219
2179
 
2220
 
        if ((fp = fdopen(net_snmp_open(), "r")) == NULL)
 
2180
        if ((fp = net_snmp_open()) == NULL)
2221
2181
                return -1;
2222
2182
 
2223
2183
        while (fgets(buf, sizeof(buf), fp) != NULL) {
2310
2270
 
2311
2271
        memset(s, 0, sizeof(*s));
2312
2272
 
2313
 
        if ((fp = fdopen(net_sockstat_open(), "r")) == NULL)
 
2273
        if ((fp = net_sockstat_open()) == NULL)
2314
2274
                return -1;
2315
2275
        while(fgets(buf, sizeof(buf), fp) != NULL)
2316
2276
                get_sockstat_line(buf, s);
2317
2277
        fclose(fp);
2318
2278
 
2319
 
        if ((fp = fdopen(net_sockstat6_open(), "r")) == NULL)
 
2279
        if ((fp = net_sockstat6_open()) == NULL)
2320
2280
                return 0;
2321
2281
        while(fgets(buf, sizeof(buf), fp) != NULL)
2322
2282
                get_sockstat_line(buf, s);
2800
2760
               addr_width, "Local Address", serv_width, "Port",
2801
2761
               addr_width, "Peer Address", serv_width, "Port");
2802
2762
 
2803
 
//printf("%08x %08x %08x\n", current_filter.dbs, current_filter.states, current_filter.families);
2804
2763
        fflush(stdout);
2805
2764
 
2806
2765
        if (current_filter.dbs & (1<<NETLINK_DB))