Tcpdump little book

    1. ......
    2. /*
    3. * We're doing a live capture.
    4. */
    5. if (device == NULL) {
    6. /*
    7. * No interface was specified. Pick one.
    8. */
    9. #ifdef HAVE_PCAP_FINDALLDEVS
    10. * Find the list of interfaces, and pick
    11. * the first interface.
    12. */
    13. if (pcap_findalldevs(&devlist, ebuf) == -1)
    14. error("%s", ebuf);
    15. if (devlist == NULL)
    16. error("no interfaces available for capture");
    17. device = strdup(devlist->name);
    18. pcap_freealldevs(devlist);
    19. /*
    20. * chooses.
    21. */
    22. device = pcap_lookupdev(ebuf);
    23. if (device == NULL)
    24. error("%s", ebuf);
    25. #endif
    26. }