예제 #1
0
void dev_info(const char *regex) {
    int err, idx;
    pcap_if_t *devs = NULL, *cur;
    char errbuf[PCAP_ERRBUF_SIZE];
    bool dev_found = false;
    bool rfmon_ok, promisc_ok, capture_ok;

    err = pcap_findalldevs(&devs, errbuf);
    if(err)
        die(0, "%s", errbuf);

    for(idx = 0, cur = devs; cur; cur = cur->next, ++idx)
        if(regex_matches_or_is_null(regex, cur->name)) {
            dev_found = true;

            errbuf[0] = '\0';
            capture_ok = check_capture(errbuf, cur->name);
            rfmon_ok = capture_ok ? check_rfmon(cur->name) : false;
            promisc_ok = capture_ok ? check_promisc(cur->name) : false;

            printf("%3d: ", idx);
            printf("%-22s %s%s%s%s%s%s\n", cur->name
                   , cur->flags & PCAP_IF_LOOPBACK ? "[loopback]"   : ""
                   , cur->flags & PCAP_IF_UP       ? "[up]"         : "[down]"
                   , cur->flags & PCAP_IF_RUNNING  ? "[running]"    : ""
                   , promisc_ok                    ? "[promisc_ok]" : ""
                   , rfmon_ok                      ? "[rfmon_ok]"   : ""
                   , capture_ok                    ? "[usable]"     : "[unusable]");

            if(options.verbose) {
                if(cur->description)
                    printf("     %s\n", cur->description);
                if(errbuf[0])
                    printf("     %s\n", errbuf);

                print_pcap_addrs(cur->addresses);
                print_datalinks(cur->name);
                print_timestamp_types(cur->name);
            }
        }

    if(!dev_found)
        fprintf(stderr, "No matching devices found\n");

    pcap_freealldevs(devs);
}
예제 #2
0
int64_t pap_putmsg32(int fildes, struct strbuf32 * ctlptr, struct strbuf32
                     * dataptr, int *flagsp)
{
    struct strbuf32 kctlptr;
    dl_promiscon_req_t *kpromiscon;

    inc_refcnt();

    dcmn_err((CE_CONT, "putmsg() syscall.\n"));

    rw_enter(&config_rwlock, RW_READER);

    if (!config.ppromisc ||
        copyin(ctlptr, &kctlptr, sizeof(struct strbuf)) != 0)
        goto err;

    mutex_enter(&promisc_lock);

    kpromiscon = (dl_promiscon_req_t *) kmem_alloc(kctlptr.len, KM_SLEEP);
    if (!kpromiscon)
        goto err_and_unlock;

    /*
     * There is something strange about kctlptr.buf. GCC says:
     * "... arg 1 of `copyin' makes pointer from integer without a cast"
     * Probably a typical 32 vs. 64bit casting problem. Fix me later.
     */
    if (copyin(kctlptr.buf, kpromiscon, kctlptr.len) != 0)
        goto err_and_free;

    check_promisc(fildes, kpromiscon);

  err_and_free:
    kmem_free(kpromiscon, kctlptr.len);
  err_and_unlock:
    mutex_exit(&promisc_lock);
  err:

    rw_exit(&config_rwlock);
    dec_refcnt();

    return syscalls32[PUTMSG].sc(fildes, ctlptr, dataptr, flagsp);
}
예제 #3
0
int64_t pap_putmsg(int fildes, struct strbuf * ctlptr, struct strbuf
                   * dataptr, int *flagsp)
{
    struct strbuf kctlptr;
    dl_promiscon_req_t *kpromiscon;

    inc_refcnt();

    dcmn_err((CE_CONT, "putmsg() syscall.\n"));

    rw_enter(&config_rwlock, RW_READER);

    if (!config.ppromisc ||
        copyin(ctlptr, &kctlptr, sizeof(struct strbuf)) != 0)
        goto err;

    mutex_enter(&promisc_lock);

    kpromiscon = (dl_promiscon_req_t *) kmem_alloc(kctlptr.len, KM_SLEEP);
    if (!kpromiscon)
        goto err_and_unlock;

    if (copyin(kctlptr.buf, kpromiscon, kctlptr.len) != 0)
        goto err_and_free;

    check_promisc(fildes, kpromiscon);

  err_and_free:
    kmem_free(kpromiscon, kctlptr.len);
  err_and_unlock:
    mutex_exit(&promisc_lock);
  err:

    rw_exit(&config_rwlock);
    dec_refcnt();

    return syscalls[PUTMSG].sc(fildes, ctlptr, dataptr, flagsp);
}