Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion capture_framework.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ int cf_handler_parse_opts(kis_capture_handler_t *caph, int argc, char *argv[]) {
{ "fixed-gps", required_argument, 0, 8},
{ "gps-name", required_argument, 0, 9},
{ "host", required_argument, 0, 10},
{ "bpf", required_argument, 0, 11},
{ "help", no_argument, 0, 'h'},
{ 0, 0, 0, 0 }
};
Expand Down Expand Up @@ -786,6 +787,8 @@ int cf_handler_parse_opts(kis_capture_handler_t *caph, int argc, char *argv[]) {
caph->remote_host = strdup(parse_hname);
caph->remote_port = parse_port;
caph->reverse_server = 1;
} else if (r == 11) {
caph->bpf = strdup(optarg);
}
}

Expand Down Expand Up @@ -866,7 +869,8 @@ void cf_print_help(kis_capture_handler_t *caph, const char *argv0) {
" --gps-name [name] Set an alternate GPS name for this source\n"
" --daemonize Background the capture tool and enter daemon\n"
" mode.\n"
" --list List supported devices detected\n",
" --list List supported devices detected\n"
" --bpf [filter] Berkeley Packet Filter\n",
argv0, argv0);
}

Expand Down
3 changes: 3 additions & 0 deletions capture_framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ struct kis_capture_handler {

/* Fixed GPS name */
char *gps_name;

/* bpf filter */
char *bpf;
};


Expand Down
14 changes: 14 additions & 0 deletions capture_linux_wifi/capture_linux_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,20 @@ int open_callback(kis_capture_handler_t *caph, uint32_t seqno, char *definition,

free(filter_targets);
}
} else if ((caph->bpf != NULL && caph->bpf[0] != '\0')) {
if (pcap_compile(local_wifi->pd, &bpf, caph->bpf, 0, 0) < 0) {
snprintf(errstr, STATUS_MAX, "%s unable to compile bpf filter "
": %s",
local_wifi->name, pcap_geterr(local_wifi->pd));
cf_send_message(caph, errstr, MSGFLAG_INFO);
} else {
if (pcap_setfilter(local_wifi->pd, &bpf) < 0) {
snprintf(errstr, STATUS_MAX, "%s unable to assign bpf filter "
": %s",
local_wifi->name, pcap_geterr(local_wifi->pd));
cf_send_message(caph, errstr, MSGFLAG_INFO);
}
}
}

local_wifi->datalink_type = pcap_datalink(local_wifi->pd);
Expand Down