FreeCalypso > hg > themwi-system-sw
annotate liboutrt/route_special.c @ 275:def9f6e4f49e default tip
doc/Use-outside-USA: Fake-NANP-numbers article is here
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 27 Nov 2023 21:49:19 -0800 |
parents | ce02fd05fd9e |
children |
rev | line source |
---|---|
135
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
136
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
2 * In this module we implement routing of calls to special numbers |
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
3 * such as N11. |
135
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 |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/socket.h> |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <netinet/in.h> |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "../include/out_routes.h" |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern struct out_routes_header outrt_hdr; |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern struct sip_out_dest *outrt_dest_array; |
136
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
18 extern struct special_num_route *outrt_spec_array; |
135
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
136
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
20 route_special_number(target_num, destp, specp) |
135
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 char *target_num; |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 struct sip_out_dest **destp; |
136
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
23 struct special_num_route **specp; |
135
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
136
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
25 unsigned rt_index; |
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
26 struct special_num_route *spec; |
135
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 struct sip_out_dest *dest; |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
136
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
29 for (rt_index = 0; rt_index < outrt_hdr.num_special; rt_index++) { |
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
30 spec = outrt_spec_array + rt_index; |
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
31 if (strcmp(spec->special_num, target_num)) |
135
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 continue; |
136
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
33 dest = outrt_dest_array + spec->sip_dest_id; |
135
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 *destp = dest; |
136
ce02fd05fd9e
liboutrt: implement special number routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
135
diff
changeset
|
35 *specp = spec; |
135
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 return 1; |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return 0; |
333dbb7ce704
liboutrt: implement E.164 routing
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |