diff options
author | Holger Freyther <zecke@selfish.org> | 2009-01-02 00:40:15 +0000 |
---|---|---|
committer | Holger Freyther <zecke@selfish.org> | 2009-01-02 00:40:15 +0000 |
commit | 9a3ee0ff1b5f33cb8476896be3a4fc78615b67a8 (patch) | |
tree | 5fe2059de3be6a1976b1b6e90a29debc614f4d13 /src/bsc_hack.c | |
parent | 355701bcc0bb3da875699ae27dcc7a7954e9906a (diff) |
Add the option to write the communication on the D Channel to a pcap file
When using ISDN as network type and using a fake LAPD encapsulation
wireshark should be able to recognize some bits if dump.
Append a dummy LAPD header. It is not clear to me if the Control field
of the LAPD frame is part of the msg or if we need to add it as well.
TODO:
- Do the same for the B Channel
- Write out time
- Check if more of the LAPD frame needs to be prepended. The
information from the mISDNhead comes into mind. Maybe it makes
sense to start a custom wireshark mISDN dissector.
Diffstat (limited to 'src/bsc_hack.c')
-rw-r--r-- | src/bsc_hack.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/bsc_hack.c b/src/bsc_hack.c index 9fa0157de..c59024a90 100644 --- a/src/bsc_hack.c +++ b/src/bsc_hack.c @@ -27,6 +27,8 @@ #include <string.h> #include <errno.h> #include <signal.h> +#include <fcntl.h> +#include <sys/stat.h> #define _GNU_SOURCE #include <getopt.h> @@ -689,6 +691,20 @@ static int bootstrap_network(void) return 0; } + +static void create_pcap_file(char *file) +{ + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + int fd = open(file, O_WRONLY|O_TRUNC|O_CREAT, mode); + + if (fd < 0) { + perror("Failed to open file for pcap"); + return; + } + + mi_set_pcap_fd(fd); +} + static void print_usage() { printf("Usage: bsc_hack\n"); @@ -704,6 +720,7 @@ static void print_help() printf(" -l --database db-name The database to use\n"); printf(" -a --authorize-everyone Allow everyone into the network.\n"); printf(" -r --reject-cause number The reject cause for LOCATION UPDATING REJECT.\n"); + printf(" -p --pcap file The filename of the pcap file\n"); printf(" -h --help this text\n"); } @@ -720,10 +737,11 @@ static void handle_options(int argc, char** argv) {"database", 1, 0, 'l'}, {"authorize-everyone", 0, 0, 'a'}, {"reject-cause", 1, 0, 'r'}, + {"pcap", 1, 0, 'p'}, {0, 0, 0, 0} }; - c = getopt_long(argc, argv, "hc:n:d:sar:", + c = getopt_long(argc, argv, "hc:n:d:sar:p:", long_options, &option_index); if (c == -1) break; @@ -754,6 +772,9 @@ static void handle_options(int argc, char** argv) case 'r': gsm0408_set_reject_cause(atoi(optarg)); break; + case 'p': + create_pcap_file(optarg); + break; default: /* ignore */ break; |