FreeCalypso > hg > gsm-net-reveng
comparison trau-decode/trau-hr-dump.c @ 96:13d47c9df28b
trau-hr-dump: add -s option for subset sync pattern match
With this option, trau-hr-dump can be used to decode TFO-HRv1
captures that contain embedded TFO messages.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 18 Mar 2025 23:55:29 +0000 |
parents | 7c7ace4999c1 |
children |
comparison
equal
deleted
inserted
replaced
95:7c7ace4999c1 | 96:13d47c9df28b |
---|---|
15 #include <strings.h> | 15 #include <strings.h> |
16 #include <unistd.h> | 16 #include <unistd.h> |
17 | 17 |
18 static uint8_t *filebuf; | 18 static uint8_t *filebuf; |
19 static unsigned total_size; | 19 static unsigned total_size; |
20 static int include_raw; | 20 static int include_raw, sync_subset; |
21 | 21 |
22 static void | 22 static void |
23 read_ts_file(filename, subslot_arg) | 23 read_ts_file(filename, subslot_arg) |
24 char *filename, *subslot_arg; | 24 char *filename, *subslot_arg; |
25 { | 25 { |
80 if (cand[n]) | 80 if (cand[n]) |
81 return 0; | 81 return 0; |
82 } | 82 } |
83 if (!cand[8]) | 83 if (!cand[8]) |
84 return 0; | 84 return 0; |
85 if (cand[16]) | 85 if (cand[16] && !sync_subset) |
86 return 0; | 86 return 0; |
87 if (!cand[17]) | 87 if (!cand[17]) |
88 return 0; | 88 return 0; |
89 for (n = 3; n < 20; n++) { | 89 for (n = 3; n < 20; n++) { |
90 if (sync_subset && (n & 1) == 0) | |
91 continue; | |
90 if (!cand[n * 8]) | 92 if (!cand[n * 8]) |
91 return 0; | 93 return 0; |
92 } | 94 } |
93 return 1; | 95 return 1; |
94 } | 96 } |
154 char **argv; | 156 char **argv; |
155 { | 157 { |
156 extern int optind; | 158 extern int optind; |
157 int c; | 159 int c; |
158 | 160 |
159 while ((c = getopt(argc, argv, "r")) != EOF) { | 161 while ((c = getopt(argc, argv, "rs")) != EOF) { |
160 switch (c) { | 162 switch (c) { |
161 case 'r': | 163 case 'r': |
162 include_raw = 1; | 164 include_raw = 1; |
163 continue; | 165 continue; |
166 case 's': | |
167 sync_subset = 1; | |
168 continue; | |
164 default: | 169 default: |
165 usage: | 170 usage: |
166 fprintf(stderr, "usage: %s [-r] binfile subslot\n", | 171 fprintf(stderr, "usage: %s [-r] [-s] binfile subslot\n", |
167 argv[0]); | 172 argv[0]); |
168 exit(1); | 173 exit(1); |
169 } | 174 } |
170 } | 175 } |
171 if (argc != optind + 2) | 176 if (argc != optind + 2) |