Remove 'currentdevice' global

This commit is contained in:
Arnout Engelen
2013-05-12 17:42:43 +00:00
parent 6cdf24bf71
commit bb2a4e0480
2 changed files with 4 additions and 7 deletions

View File

@@ -156,8 +156,8 @@ int main (int argc, char** argv)
handle * current_handle = handles; handle * current_handle = handles;
while (current_handle != NULL) while (current_handle != NULL)
{ {
userdata->device = current_handle->devicename;
userdata->sa_family = AF_UNSPEC; userdata->sa_family = AF_UNSPEC;
currentdevice = current_handle->devicename;
int retval = dp_dispatch (current_handle->content, -1, (u_char *)userdata, sizeof (struct dpargs)); int retval = dp_dispatch (current_handle->content, -1, (u_char *)userdata, sizeof (struct dpargs));
if (retval < 0) if (retval < 0)
{ {

View File

@@ -66,8 +66,6 @@ int viewMode = VIEWMODE_KBPS;
//dp_link_type linktype = dp_link_ethernet; //dp_link_type linktype = dp_link_ethernet;
const char version[] = " version " VERSION "." SUBVERSION "." MINORVERSION; const char version[] = " version " VERSION "." SUBVERSION "." MINORVERSION;
const char * currentdevice = NULL;
timeval curtime; timeval curtime;
bool local_addr::contains (const in_addr_t & n_addr) { bool local_addr::contains (const in_addr_t & n_addr) {
@@ -106,6 +104,7 @@ bool local_addr::contains(const struct in6_addr & n_addr) {
} }
struct dpargs { struct dpargs {
const char * device;
int sa_family; int sa_family;
in_addr ip_src; in_addr ip_src;
in_addr ip_dst; in_addr ip_dst;
@@ -145,7 +144,7 @@ int process_tcp (u_char * userdata, const dp_header * header, const u_char * m_p
} else { } else {
/* else: unknown connection, create new */ /* else: unknown connection, create new */
connection = new Connection (packet); connection = new Connection (packet);
getProcess(connection, currentdevice); getProcess(connection, args->device);
} }
delete packet; delete packet;
@@ -161,12 +160,10 @@ int process_tcp (u_char * userdata, const dp_header * header, const u_char * m_p
int process_udp (u_char * userdata, const dp_header * header, const u_char * m_packet) { int process_udp (u_char * userdata, const dp_header * header, const u_char * m_packet) {
struct dpargs * args = (struct dpargs *) userdata; struct dpargs * args = (struct dpargs *) userdata;
//struct tcphdr * tcp = (struct tcphdr *) m_packet;
struct udphdr * udp = (struct udphdr *) m_packet; struct udphdr * udp = (struct udphdr *) m_packet;
curtime = header->ts; curtime = header->ts;
/* TODO get info from userdata, then call getPacket */
Packet * packet; Packet * packet;
switch (args->sa_family) switch (args->sa_family)
{ {
@@ -190,7 +187,7 @@ int process_udp (u_char * userdata, const dp_header * header, const u_char * m_p
} else { } else {
/* else: unknown connection, create new */ /* else: unknown connection, create new */
connection = new Connection (packet); connection = new Connection (packet);
getProcess(connection, currentdevice); getProcess(connection, args->device);
} }
delete packet; delete packet;