FreeCalypso > hg > themwi-system-sw
annotate liboutrt/route_e164.c @ 148:b51247739897
sip-manual-out: attempt to play along with re-INVITEs
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 08 Oct 2022 23:52:08 -0800 |
parents | 333dbb7ce704 |
children | e4a93ad611f3 |
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 } |