annotate liboutrt/route_e164.c @ 219:9ba474e918c0

smpp-test1: try sending some ID strings
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 01 Aug 2023 22:56:52 -0800
parents 333dbb7ce704
children e4a93ad611f3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
135
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement routing of calls to E.164 numbers.
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/socket.h>
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <netinet/in.h>
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdint.h>
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <string.h>
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <strings.h>
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "../include/out_routes.h"
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern struct out_routes_header outrt_hdr;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern struct sip_out_dest *outrt_dest_array;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 extern struct inn_route *outrt_inn_array;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 route_e164_number(target_num, destp)
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 char *target_num;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 struct sip_out_dest **destp;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 unsigned inn_index;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 struct inn_route *rec;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 struct sip_out_dest *dest;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 char *pp, *tp;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 for (inn_index = 0; inn_index < outrt_hdr.num_inn; inn_index++) {
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 rec = outrt_inn_array + inn_index;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 pp = rec->prefix;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 tp = target_num;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 while (*pp && *pp == *tp) {
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 pp++;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 tp++;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (*pp)
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 continue;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 dest = outrt_dest_array + rec->sip_dest_id;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 *destp = dest;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return 1;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 return 0;
333dbb7ce704 liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 }