Changeset 1714

Show
Ignore:
Timestamp:
02/26/07 23:23:05 (23 months ago)
Author:
aturner
Message:

add --listnics (mostly useful for windows boxes). refs #113.
We can use the same logic to provide aliases for Win32

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/tcpreplay_opts.def

    r1700 r1714  
    188188}; 
    189189 
     190flag = { 
     191        name            = listnics; 
     192        value           = N; 
     193        descrip         = "List available network interfaces and exit"; 
     194        immediate; 
     195        doc                     = ""; 
     196        flag-code       = <<- EOFlag 
     197         
     198    char ebuf[PCAP_ERRBUF_SIZE]; 
     199    pcap_if_t *pcap_if, *pcap_if_ptr; 
     200        int i = 0; 
     201 
     202    if (pcap_findalldevs(&pcap_if, ebuf) < 0) 
     203        errx(1, "Error: %s", ebuf); 
     204             
     205    pcap_if_ptr = pcap_if; 
     206    printf("%s", "Available network interfaces:\n"); 
     207#ifdef HAVE_WINPCAP 
     208        printf("Short Name\tName\tDescription\n"); 
     209#endif 
     210        if (geteuid() != 0) 
     211                printf("Warning!  Need to run as root to get complete list.\n"); 
     212 
     213    while (pcap_if_ptr != NULL) { 
     214        if (! pcap_if_ptr->flags & PCAP_IF_LOOPBACK) { 
     215#ifdef HAVE_WINPCAP 
     216            printf("%%%d\t%s\t%s\n", i, pcap_if_ptr->name, pcap_if_ptr->description); 
     217#else 
     218                        printf("%s\n", pcap_if_ptr->name); 
     219#endif 
     220                        i ++; 
     221                } 
     222        pcap_if_ptr = pcap_if_ptr->next; 
     223    } 
     224    pcap_freealldevs(pcap_if); 
     225    exit(0); 
     226         
     227EOFlag; 
     228}; 
     229 
    190230/* 
    191231 * Limits and loops: -l