Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 1 | #include <stdio.h> |
Harald Welte | 74d1e34 | 2016-10-19 00:06:22 +0200 | [diff] [blame] | 2 | #include <time.h> |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 3 | #include <unistd.h> |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 4 | #include <string.h> |
Harald Welte | 74d1e34 | 2016-10-19 00:06:22 +0200 | [diff] [blame] | 5 | |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 6 | #include <sys/time.h> |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 7 | #include <sys/types.h> |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 8 | |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 9 | #include <osmocom/core/bits.h> |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 10 | #include <osmocom/core/signal.h> |
| 11 | #include <osmocom/core/logging.h> |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 12 | #include <osmocom/core/msgb.h> |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 13 | #include <osmocom/core/application.h> |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 14 | #include <osmocom/abis/subchan_demux.h> |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 15 | #include <osmocom/abis/lapd_pcap.h> |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 16 | |
| 17 | #include "storage.h" |
| 18 | #include "recorder.h" |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 19 | #include "flip_bits.h" |
| 20 | #include "hdlc.h" |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 21 | |
Harald Welte | b36921f | 2019-12-03 22:12:45 +0100 | [diff] [blame^] | 22 | #include "config.h" |
| 23 | |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 24 | struct e1_recorder g_recorder; |
| 25 | |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 26 | enum mode { |
| 27 | MODE_PRINT, |
| 28 | MODE_BIN, |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 29 | MODE_SC, |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 30 | }; |
| 31 | |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 32 | #define MAX_TS 32 |
| 33 | #define CHUNK_BYTES 160 |
| 34 | |
| 35 | /* Ericsson super-channel */ |
| 36 | struct sc_state { |
| 37 | uint8_t ts_data[MAX_TS][CHUNK_BYTES]; |
| 38 | uint8_t num_ts; |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 39 | uint32_t ts_mask; |
| 40 | struct hdlc_proc hdlc; |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | static struct sc_state g_sc_state[2]; |
| 44 | |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 45 | static enum mode g_mode = MODE_PRINT; |
| 46 | static int g_filter_line = -1; |
| 47 | static int g_filter_slot = -1; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 48 | static int g_filter_subslot = -1; |
| 49 | static struct osmo_e1cap_pkthdr *g_last_pkthdr; |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 50 | static int g_pcap_fd = -1; |
| 51 | struct msgb *g_pcap_msg = NULL; |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 52 | |
Harald Welte | 74d1e34 | 2016-10-19 00:06:22 +0200 | [diff] [blame] | 53 | static char *timeval2str(struct timeval *tv) |
| 54 | { |
| 55 | time_t nowtime; |
| 56 | struct tm *nowtm; |
| 57 | char tmbuf[64]; |
Harald Welte | 6df0729 | 2019-11-06 16:21:55 +0100 | [diff] [blame] | 58 | static char buf[64+20]; |
Harald Welte | 74d1e34 | 2016-10-19 00:06:22 +0200 | [diff] [blame] | 59 | |
| 60 | nowtime = tv->tv_sec; |
| 61 | nowtm = localtime(&nowtime); |
| 62 | strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", nowtm); |
| 63 | snprintf(buf, sizeof buf, "%s.%06ld", tmbuf, tv->tv_usec); |
| 64 | return buf; |
| 65 | } |
| 66 | |
Harald Welte | 6df0729 | 2019-11-06 16:21:55 +0100 | [diff] [blame] | 67 | #if 0 |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 68 | static int all_bytes_are(unsigned char ch, const uint8_t *data, int len) |
| 69 | { |
| 70 | int i; |
| 71 | |
| 72 | for (i = 0; i < len; i++) { |
| 73 | if (data[i] != ch) |
| 74 | return 0; |
| 75 | } |
| 76 | return 1; |
| 77 | } |
Harald Welte | 6df0729 | 2019-11-06 16:21:55 +0100 | [diff] [blame] | 78 | #endif |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 79 | |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 80 | static void handle_hdlc_frame_content(const uint8_t *data, unsigned int len, |
| 81 | void *priv) |
| 82 | { |
Harald Welte | 3863bee | 2019-11-24 18:54:02 +0100 | [diff] [blame] | 83 | if (g_pcap_fd >= 0 && len >= 4) { |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 84 | uint8_t *cur = msgb_put(g_pcap_msg, len-2); |
| 85 | memcpy(cur, data, len-2); |
| 86 | printf("==> %s\n", msgb_hexdump(g_pcap_msg)); |
| 87 | OSMO_ASSERT(g_pcap_msg->len >= 2); |
| 88 | /* FIXME: timestamp! */ |
| 89 | osmo_pcap_lapd_write(g_pcap_fd, OSMO_LAPD_PCAP_OUTPUT, g_pcap_msg); |
| 90 | msgb_reset(g_pcap_msg); |
| 91 | } |
| 92 | } |
| 93 | |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 94 | static void handle_sc_out(struct sc_state *scs) |
| 95 | { |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 96 | unsigned int num_bytes = scs->num_ts * CHUNK_BYTES; |
| 97 | unsigned int num_bits = num_bytes * 8; |
| 98 | uint8_t out[32*CHUNK_BYTES]; |
| 99 | ubit_t out_bits[32*CHUNK_BYTES*8]; |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 100 | int i, j, k = 0; |
| 101 | |
| 102 | /* re-shuffle the data from columns to lines */ |
| 103 | for (i = 0; i < CHUNK_BYTES; i++) { |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 104 | for (j = 0; j < scs->num_ts; j++) |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 105 | out[k++] = scs->ts_data[j][i]; |
| 106 | } |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 107 | //printf("num_bytes=%u %s\n", num_bytes, osmo_hexdump_nospc(out, num_bytes)); |
| 108 | osmo_pbit2ubit_ext(out_bits, 0, out, 0, num_bits, 1); |
| 109 | //for (i = 0; i < num_bits; i++) fputc(out_bits[i] ? '1' : '.', stdout); fputc('\n', stdout); |
| 110 | process_raw_hdlc(&scs->hdlc, out_bits, num_bits); |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | static void handle_sc_in(struct osmo_e1cap_pkthdr *pkt, const uint8_t *data, unsigned int len) |
| 114 | { |
| 115 | struct sc_state *scs; |
| 116 | |
| 117 | if (pkt->line_nr >= ARRAY_SIZE(g_sc_state)) { |
| 118 | fprintf(stderr, "Line number out of range\n"); |
| 119 | exit(1); |
| 120 | } |
| 121 | |
| 122 | scs = &g_sc_state[pkt->line_nr]; |
| 123 | if (pkt->ts_nr >= ARRAY_SIZE(scs->ts_data)) { |
| 124 | fprintf(stderr, "Timeslot number out of range\n"); |
| 125 | exit(1); |
| 126 | } |
| 127 | |
| 128 | if (len != sizeof(scs->ts_data[pkt->ts_nr])) { |
| 129 | fprintf(stderr, "Insufficient data\n"); |
| 130 | exit(1); |
| 131 | } |
| 132 | |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 133 | if (pkt->ts_nr == 1) { |
| 134 | scs->ts_mask = 0; |
| 135 | memset(scs->ts_data, 0, sizeof(scs->ts_data)); |
| 136 | } |
| 137 | |
| 138 | /* copy over the data */ |
| 139 | memcpy(scs->ts_data[pkt->ts_nr-1], data, len); |
| 140 | /* note that we have valid data for the given timeslot */ |
| 141 | scs->ts_mask |= (1 << (pkt->ts_nr-1)); |
| 142 | |
| 143 | /* make sure we know what's the maximum timeslot number */ |
| 144 | if (pkt->ts_nr > scs->num_ts) |
| 145 | scs->num_ts = pkt->ts_nr; |
| 146 | |
| 147 | /* check if we have data for all needed timeslots */ |
| 148 | uint32_t ts_mask = (1 << scs->num_ts) -1; |
| 149 | //printf("num_ts=%u, ts_mask=0x%x, scs_ts_mask=0x%x\n", scs->num_ts, ts_mask, scs->ts_mask); |
| 150 | if (scs->ts_mask == ts_mask) { |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 151 | handle_sc_out(scs); |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 152 | } |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 156 | static void handle_data(struct osmo_e1cap_pkthdr *pkt, uint8_t *data, int len) |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 157 | { |
Harald Welte | 6df0729 | 2019-11-06 16:21:55 +0100 | [diff] [blame] | 158 | struct timeval tv; |
| 159 | |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 160 | flip_buf_bits(data, len); |
| 161 | #if 0 |
| 162 | /* filter out all-ff/all-fe/all-7f */ |
| 163 | if (all_bytes_are(0xff, data, len) || |
| 164 | all_bytes_are(0x7f, data, len) || |
| 165 | all_bytes_are(0x7e, data, len) || |
| 166 | all_bytes_are(0xe7, data, len) || |
| 167 | all_bytes_are(0x3f, data, len) || |
| 168 | all_bytes_are(0xf3, data, len) || |
| 169 | all_bytes_are(0x9f, data, len) || |
| 170 | all_bytes_are(0xf9, data, len) || |
| 171 | all_bytes_are(0xcf, data, len) || |
| 172 | all_bytes_are(0xfc, data, len) || |
| 173 | all_bytes_are(0xfe, data, len)) |
| 174 | return; |
| 175 | #endif |
| 176 | |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 177 | switch (g_mode) { |
| 178 | case MODE_PRINT: |
Harald Welte | 6df0729 | 2019-11-06 16:21:55 +0100 | [diff] [blame] | 179 | tv.tv_sec = pkt->ts.tv_sec; |
| 180 | tv.tv_usec = pkt->ts.tv_usec; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 181 | printf("%s %02u/%02u %u (%u): %s\n", |
Harald Welte | 6df0729 | 2019-11-06 16:21:55 +0100 | [diff] [blame] | 182 | timeval2str(&tv), |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 183 | pkt->line_nr, pkt->ts_nr, pkt->capture_mode, |
| 184 | pkt->len, |
| 185 | osmo_hexdump_nospc(data, len)); |
| 186 | break; |
| 187 | case MODE_BIN: |
| 188 | write(1, data, len); |
| 189 | break; |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 190 | case MODE_SC: |
| 191 | handle_sc_in(pkt, data, len); |
| 192 | break; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | |
| 196 | static int subch_demux_out_cb(struct subch_demux *dmx, int ch, uint8_t *data, |
| 197 | int len, void *c) |
| 198 | { |
| 199 | OSMO_ASSERT(ch == g_filter_subslot); |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 200 | |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 201 | handle_data(g_last_pkthdr, data, len); |
| 202 | |
| 203 | return 0; |
| 204 | } |
| 205 | |
Harald Welte | b36921f | 2019-12-03 22:12:45 +0100 | [diff] [blame^] | 206 | static void print_help(void) |
| 207 | { |
| 208 | printf( " -h Print this message\n" |
| 209 | " -V Print version of the program\n" |
| 210 | " -l LINE_NR Filter on line number\n" |
| 211 | " -s SLOT_NR Filter on timeslot number\n" |
| 212 | " -b Raw binary output mode (for piping stdout)\n" |
| 213 | " -S Super-Channel mode\n" |
| 214 | " -u SUBSLOT_NR Filter on 16k sub-slot number\n" |
| 215 | " -p PCAP_FILE Write LAPD PCAP file\n" |
| 216 | ); |
| 217 | }; |
| 218 | |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 219 | static int handle_options(int argc, char **argv) |
| 220 | { |
| 221 | int opt; |
| 222 | |
Harald Welte | b36921f | 2019-12-03 22:12:45 +0100 | [diff] [blame^] | 223 | while ((opt = getopt(argc, argv, "hVl:s:bSu:p:")) != -1) { |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 224 | switch (opt) { |
Harald Welte | b36921f | 2019-12-03 22:12:45 +0100 | [diff] [blame^] | 225 | case 'h': |
| 226 | print_help(); |
| 227 | exit(0); |
| 228 | case 'V': |
| 229 | printf("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); |
| 230 | exit(0); |
| 231 | break; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 232 | case 'l': /* Filter on E1 Line Number */ |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 233 | g_filter_line = atoi(optarg); |
| 234 | break; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 235 | case 's': /* Filter on E1 Slot Number */ |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 236 | g_filter_slot = atoi(optarg); |
| 237 | break; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 238 | case 'b': /* Raw binary output mode (for piping) */ |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 239 | g_mode = MODE_BIN; |
| 240 | break; |
Harald Welte | c1b9cab | 2016-10-23 19:36:14 +0200 | [diff] [blame] | 241 | case 'S': /* Super Channel Mode */ |
| 242 | g_mode = MODE_SC; |
| 243 | break; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 244 | case 'u': /* 16k Sub-channel demux + filter */ |
| 245 | g_filter_subslot = atoi(optarg); |
| 246 | if (g_filter_subslot < 0 || g_filter_subslot > 3) |
| 247 | exit(2); |
| 248 | break; |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 249 | case 'p': /* PCAP writing */ |
| 250 | g_pcap_fd = osmo_pcap_lapd_open(optarg, 0640); |
| 251 | if (g_pcap_fd < 0) { |
| 252 | perror("opening pcap file"); |
| 253 | exit(1); |
| 254 | } |
| 255 | g_pcap_msg = msgb_alloc(1024, "pcap"); |
| 256 | break; |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 257 | default: |
| 258 | fprintf(stderr, "Unknown option '%c'\n", opt); |
| 259 | exit(EXIT_FAILURE); |
| 260 | break; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | return 0; |
| 265 | } |
| 266 | |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 267 | static struct log_info_cat log_categories[] = { |
| 268 | }; |
| 269 | |
| 270 | static struct log_info log_info = { |
| 271 | .cat = log_categories, |
| 272 | .num_cat = ARRAY_SIZE(log_categories), |
| 273 | }; |
| 274 | |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 275 | int main(int argc, char **argv) |
| 276 | { |
| 277 | struct osmo_e1cap_file *f; |
| 278 | struct osmo_e1cap_pkthdr *pkt; |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 279 | unsigned long num_pkt = 0; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 280 | struct subch_demux smux; |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 281 | int i; |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 282 | |
| 283 | printf("sizeof(timeval) = %zu\n", sizeof(struct timeval)); |
| 284 | printf("sizeof(osmo_e1cap_pkthdr) = %zu\n", sizeof(*pkt)); |
| 285 | |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 286 | memset(g_sc_state, 0, sizeof(g_sc_state)); |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 287 | for (i = 0; i < ARRAY_SIZE(g_sc_state); i++) |
| 288 | g_sc_state[i].hdlc.out_cb = handle_hdlc_frame_content; |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 289 | init_flip_bits(); |
| 290 | |
Harald Welte | 41a5300 | 2016-11-14 23:22:49 +0100 | [diff] [blame] | 291 | osmo_init_logging(&log_info); |
| 292 | |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 293 | handle_options(argc, argv); |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 294 | |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 295 | if (optind >= argc) { |
| 296 | fprintf(stderr, "Missing input file name\n"); |
| 297 | exit(2); |
| 298 | } |
| 299 | |
Harald Welte | cbf23b6 | 2019-12-03 22:14:20 +0100 | [diff] [blame] | 300 | if (argc > optind+1) { |
| 301 | fprintf(stderr, "Unsupported positional arguments on command line\n"); |
| 302 | exit(2); |
| 303 | } |
| 304 | |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 305 | f = osmo_e1cap_open(NULL, argv[optind++]); |
| 306 | if (!f) { |
| 307 | fprintf(stderr, "Unable to open input file\n"); |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 308 | exit(1); |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 309 | } |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 310 | |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 311 | if (g_filter_subslot >= 0) { |
| 312 | smux.out_cb = subch_demux_out_cb; |
| 313 | subch_demux_init(&smux); |
| 314 | subch_demux_activate(&smux, g_filter_subslot); |
| 315 | } |
| 316 | |
Harald Welte | 1df5cf4 | 2016-11-14 21:29:01 +0100 | [diff] [blame] | 317 | // printf("hdlc=%s\n", osmo_hexdump(&g_sc_state[0].hdlc, sizeof(g_sc_state[0].hdlc))); |
| 318 | |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 319 | while ((pkt = osmo_e1cap_read_next(f))) { |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 320 | num_pkt++; |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 321 | g_last_pkthdr = pkt; |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 322 | |
| 323 | if (g_filter_line >= 0 && pkt->line_nr != g_filter_line) |
| 324 | continue; |
| 325 | if (g_filter_slot >= 0 && pkt->ts_nr != g_filter_slot) |
| 326 | continue; |
| 327 | |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 328 | if (g_filter_subslot >= 0) { |
| 329 | subch_demux_in(&smux, pkt->data, pkt->len); |
| 330 | continue; |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 331 | } |
Harald Welte | 525af18 | 2016-10-19 00:38:46 +0200 | [diff] [blame] | 332 | |
| 333 | handle_data(pkt, pkt->data, pkt->len); |
| 334 | |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 335 | talloc_free(pkt); |
| 336 | } |
Harald Welte | f403232 | 2016-10-19 00:23:10 +0200 | [diff] [blame] | 337 | |
| 338 | fprintf(stderr, "Processed a total of %lu packets\n", num_pkt); |
Harald Welte | dbb0f5a | 2016-10-18 23:51:54 +0200 | [diff] [blame] | 339 | } |