Fix compiler error on mac (?)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* conninode.cpp
|
* conninode.cpp
|
||||||
*
|
*
|
||||||
* Copyright (c) 2008,2009 Arnout Engelen
|
* Copyright (c) 2008,2009 Arnout Engelen
|
||||||
@@ -35,7 +35,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern local_addr * local_addrs;
|
extern local_addr * local_addrs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* connection-inode table. takes information from /proc/net/tcp.
|
* connection-inode table. takes information from /proc/net/tcp.
|
||||||
* key contains source ip, source port, destination ip, destination
|
* key contains source ip, source port, destination ip, destination
|
||||||
@@ -47,8 +46,8 @@ std::map <std::string, unsigned long> conninode;
|
|||||||
/*
|
/*
|
||||||
* parses a /proc/net/tcp-line of the form:
|
* parses a /proc/net/tcp-line of the form:
|
||||||
* sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
|
* sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
|
||||||
* 10: 020310AC:1770 9DD8A9C3:A525 01 00000000:00000000 00:00000000 00000000 0 0 2119 1 c0f4f0c0 206 40 10 3 -1
|
* 10: 020310AC:1770 9DD8A9C3:A525 01 00000000:00000000 00:00000000 00000000 0 0 2119 1 c0f4f0c0 206 40 10 3 -1
|
||||||
* 11: 020310AC:0404 936B2ECF:0747 01 00000000:00000000 00:00000000 00000000 1000 0 2109 1 c0f4fc00 368 40 20 2 -1
|
* 11: 020310AC:0404 936B2ECF:0747 01 00000000:00000000 00:00000000 00000000 1000 0 2109 1 c0f4fc00 368 40 20 2 -1
|
||||||
*
|
*
|
||||||
* and of the form:
|
* and of the form:
|
||||||
* 2: 0000000000000000FFFF0000020310AC:0016 0000000000000000FFFF00009DD8A9C3:A526 01 00000000:00000000 02:000A7214 00000000 0 0 2525 2 c732eca0 201 40 1 2 -1
|
* 2: 0000000000000000FFFF0000020310AC:0016 0000000000000000FFFF00009DD8A9C3:A526 01 00000000:00000000 02:000A7214 00000000 0 0 2525 2 c732eca0 201 40 1 2 -1
|
||||||
@@ -76,9 +75,9 @@ void addtoconninode (char * buffer)
|
|||||||
fprintf(stderr,"Unexpected buffer: '%s'\n",buffer);
|
fprintf(stderr,"Unexpected buffer: '%s'\n",buffer);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inode == 0) {
|
if (inode == 0) {
|
||||||
/* connection is in TIME_WAIT state. We rely on
|
/* connection is in TIME_WAIT state. We rely on
|
||||||
* the old data still in the table. */
|
* the old data still in the table. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -88,7 +87,7 @@ void addtoconninode (char * buffer)
|
|||||||
/* this is an IPv6-style row */
|
/* this is an IPv6-style row */
|
||||||
|
|
||||||
/* Demangle what the kernel gives us */
|
/* Demangle what the kernel gives us */
|
||||||
sscanf(local_addr, "%08X%08X%08X%08X",
|
sscanf(local_addr, "%08X%08X%08X%08X",
|
||||||
&in6_local.s6_addr32[0], &in6_local.s6_addr32[1],
|
&in6_local.s6_addr32[0], &in6_local.s6_addr32[1],
|
||||||
&in6_local.s6_addr32[2], &in6_local.s6_addr32[3]);
|
&in6_local.s6_addr32[2], &in6_local.s6_addr32[3]);
|
||||||
sscanf(rem_addr, "%08X%08X%08X%08X",
|
sscanf(rem_addr, "%08X%08X%08X%08X",
|
||||||
@@ -141,14 +140,14 @@ void addtoconninode (char * buffer)
|
|||||||
|
|
||||||
/* workaround: sometimes, when a connection is actually from 172.16.3.1 to
|
/* workaround: sometimes, when a connection is actually from 172.16.3.1 to
|
||||||
* 172.16.3.3, packages arrive from 195.169.216.157 to 172.16.3.3, where
|
* 172.16.3.3, packages arrive from 195.169.216.157 to 172.16.3.3, where
|
||||||
* 172.16.3.1 and 195.169.216.157 are the local addresses of different
|
* 172.16.3.1 and 195.169.216.157 are the local addresses of different
|
||||||
* interfaces */
|
* interfaces */
|
||||||
struct local_addr * current_local_addr = local_addrs;
|
for (class local_addr *current_local_addr = local_addrs;
|
||||||
while (current_local_addr != NULL) {
|
current_local_addr != NULL;
|
||||||
|
current_local_addr = current_local_addr->next) {
|
||||||
/* TODO maybe only add the ones with the same sa_family */
|
/* TODO maybe only add the ones with the same sa_family */
|
||||||
snprintf(hashkey, HASHKEYSIZE * sizeof(char), "%s:%d-%s:%d", current_local_addr->string, local_port, remote_string, rem_port);
|
snprintf(hashkey, HASHKEYSIZE * sizeof(char), "%s:%d-%s:%d", current_local_addr->string, local_port, remote_string, rem_port);
|
||||||
conninode[hashkey] = inode;
|
conninode[hashkey] = inode;
|
||||||
current_local_addr = current_local_addr->next;
|
|
||||||
}
|
}
|
||||||
free (hashkey);
|
free (hashkey);
|
||||||
free (remote_string);
|
free (remote_string);
|
||||||
@@ -162,7 +161,7 @@ int addprocinfo (const char * filename) {
|
|||||||
|
|
||||||
if (procinfo == NULL)
|
if (procinfo == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fgets(buffer, sizeof(buffer), procinfo);
|
fgets(buffer, sizeof(buffer), procinfo);
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* nethogs.h
|
* nethogs.h
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004-2006,2008,2010 Arnout Engelen
|
* Copyright (c) 2004-2006,2008,2010 Arnout Engelen
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
#define VIEWMODE_TOTAL_B 2
|
#define VIEWMODE_TOTAL_B 2
|
||||||
#define VIEWMODE_TOTAL_MB 3
|
#define VIEWMODE_TOTAL_MB 3
|
||||||
#define VIEWMODE_COUNT 4
|
#define VIEWMODE_COUNT 4
|
||||||
|
|
||||||
#define NORETURN __attribute__ ((__noreturn__))
|
#define NORETURN __attribute__ ((__noreturn__))
|
||||||
|
|
||||||
void forceExit(bool success, const char *msg, ...) NORETURN;
|
void forceExit(bool success, const char *msg, ...) NORETURN;
|
||||||
|
|||||||
Reference in New Issue
Block a user