From: gboutwel <gbo...@pr...> - 2004-09-09 22:12:35
|
Fix PCAP Connection Name matching. Current behavior exists finding loop if an partial match is found causing some problems. Changed to keep the first partial match, but to continue finding loop and over-ride partial if an exact match is found. # Old manifest: e63307fe0101460b9fc25e36a61ac6f35c1052fc # New manifest: 7117988302f49dea0dce9856508bf23654c6e18a # Summary of changes: # # patch src/colinux/os/winnt/user/conet-bridged-daemon/main.c # from 8e5a217f4b801e3a216f4bd5cbaaf99ab084ad17 # to 7efdbdb1aff3c5e0be4b448d4f985506cff8e266 # --- src/colinux/os/winnt/user/conet-bridged-daemon/main.c +++ src/colinux/os/winnt/user/conet-bridged-daemon/main.c @@ -365,6 +365,7 @@ { pcap_if_t *alldevs = NULL; pcap_if_t *device = NULL; + pcap_if_t *found_device = NULL; int exit_code = 0; pcap_t *adhandle = NULL; char errbuf[PCAP_ERRBUF_SIZE]; @@ -402,9 +403,23 @@ if (strcmp(connection_name_data, "") != 0) { co_terminal_print("Checking connection: %s\n", connection_name_data); + /* + Do an partial search, if partial search is found, + set this device as he found device, but continue + looping through devices. + */ + if (strstr(connection_name_data, daemon_parameters->interface_name) != NULL && + found_device == NULL) { + found_device = device; + } - if (strstr(connection_name_data, daemon_parameters->interface_name) != NULL) - break; + /* + If an exact match exists, over-ride any found device, + setting exact match device to it. + */ + if (strcmp(connection_name_data, daemon_parameters->interface_name) == 0) { + found_device = device; + } } else { co_terminal_print("Adapter %s doesn't have a connection\n", device->description); @@ -413,12 +427,14 @@ device = device->next; } - if (device == NULL) { + if (found_device == NULL) { co_terminal_print("No matching adapter\n"); exit_code = -1; goto pcap_out_close; } + device = found_device; + /* Open the first adapter. */ if ((adhandle = pcap_open_live(device->name, // name of the device 65536, // captures entire packet. -------------------------------------- Want to download some Christian Stuff? http://www.praize.com/downloads/ |