From b7a834b4cb6a0cdd53d4fb06c1981e8d2af1c949 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 10 Sep 2015 16:45:45 +0200 Subject: gprs: Add a custom GPRS filter Allow to inspect UDP messages and check for GPRS, NS, BSSGP and then filter LLC frames. Parsing the vL datastructure with the libpcap syntax is a pain. It could be done using BPF but we do not want to use bpf asm to specify the entire ruleset. I looked into using libepan/libwireshark but this has memory issues and is painful too. So let's parse UDP, NS, BSSGP using the info we already have. I tried a bit of editcap to generate a bit of broken data. The length check might still be bad. I used my crash_20100602.pcap file to count the LLC frames we detect and compare that to wireshark it ended with the right number. pcap add-filter gprs can be used to enable the new filtering option after the OS has received the packet. Fixes: ONW#1314 --- src/osmo_client_vty.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/osmo_client_vty.c') diff --git a/src/osmo_client_vty.c b/src/osmo_client_vty.c index 0b30eb7..a8739b1 100644 --- a/src/osmo_client_vty.c +++ b/src/osmo_client_vty.c @@ -59,6 +59,8 @@ static int config_write_client(struct vty *vty) pcap_client->filter_string, VTY_NEWLINE); vty_out(vty, " pcap detect-loop %d%s", pcap_client->filter_itself, VTY_NEWLINE); + if (pcap_client->gprs_filtering) + vty_out(vty, " pcap add-filter gprs%s", VTY_NEWLINE); if (pcap_client->srv_ip) vty_out(vty, " server ip %s%s", @@ -80,6 +82,24 @@ DEFUN(cfg_client_device, return CMD_SUCCESS; } +DEFUN(cfg_client_add_gprs, + cfg_client_add_gprs_cmd, + "pcap add-filter gprs", + PCAP_STRING "Add-filter\n" "Custom filtering for GPRS\n") +{ + pcap_client->gprs_filtering = 1; + return CMD_SUCCESS; +} + +DEFUN(cfg_client_del_gprs, + cfg_client_del_gprs_cmd, + "no pcap add-filter gprs", + NO_STR PCAP_STRING "Add-filter\n" "Custom filter for GPRS\n") +{ + pcap_client->gprs_filtering = 0; + return CMD_SUCCESS; +} + DEFUN(cfg_client_filter, cfg_client_filter_cmd, "pcap filter .NAME", @@ -144,5 +164,8 @@ int vty_client_init(struct osmo_pcap_client *pcap) install_element(CLIENT_NODE, &cfg_server_ip_cmd); install_element(CLIENT_NODE, &cfg_server_port_cmd); + install_element(CLIENT_NODE, &cfg_client_add_gprs_cmd); + install_element(CLIENT_NODE, &cfg_client_del_gprs_cmd); + return 0; } -- cgit v1.2.3