annotate utils/themwi-check-own.c @ 199:e6c7ced3c031

mgw: accept zero-length RTP payload as BFI Mainline OsmoBTS now has an option (rtp continuous-streaming) that causes it to emit an RTP packet every 20 ms without gaps, sending a BFI marker in the form of zero-length RTP payload when it has nothing else to send. These codec-independent BFI markers don't indicate TAF, but this provision is a good start. Accept this BFI packet format in themwi-mgw.
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 29 Mar 2023 20:23:43 -0800
parents 26b98505684e
children 697fe2c87fec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This utility performs a lookup in ThemWi number database to see
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * if a given NANP number is owned by us.
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdlib.h>
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <syslog.h>
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 main(argc, argv)
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 char **argv;
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 char nanp[11];
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 if (argc != 2) {
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 usage: fprintf(stderr, "usage: %s 10-digit-number\n", argv[0]);
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 exit(1);
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 }
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (grok_number_string(argv[1], 1) != 10)
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 goto usage;
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 dehyphen_number_string(argv[1], nanp);
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (!is_nanp_valid_prefix(nanp)) {
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 fprintf(stderr, "error: number violates NANP rules\n");
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 exit(1);
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 openlog("themwi-check-own", 0, LOG_LOCAL5);
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (read_number_db() < 0) {
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 fprintf(stderr, "error reading number database\n");
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 printf("+1-%.3s-%.3s-%s is %s\n", nanp, nanp+3, nanp+6,
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 is_nanp_locally_owned(nanp) ? "locally owned"
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 : "NOT owned by us");
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 exit(0);
26b98505684e themwi-check-own utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }