FreeCalypso > hg > themwi-system-sw
comparison liboutrt/route_e164.c @ 135:333dbb7ce704
liboutrt: implement E.164 routing
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 06 Oct 2022 23:44:17 -0800 |
| parents | |
| children | e4a93ad611f3 |
comparison
equal
deleted
inserted
replaced
| 134:2b03d2584f88 | 135:333dbb7ce704 |
|---|---|
| 1 /* | |
| 2 * In this module we implement routing of calls to E.164 numbers. | |
| 3 */ | |
| 4 | |
| 5 #include <sys/types.h> | |
| 6 #include <sys/socket.h> | |
| 7 #include <netinet/in.h> | |
| 8 #include <stdio.h> | |
| 9 #include <stdint.h> | |
| 10 #include <stdlib.h> | |
| 11 #include <string.h> | |
| 12 #include <strings.h> | |
| 13 #include "../include/out_routes.h" | |
| 14 | |
| 15 extern struct out_routes_header outrt_hdr; | |
| 16 extern struct sip_out_dest *outrt_dest_array; | |
| 17 extern struct inn_route *outrt_inn_array; | |
| 18 | |
| 19 route_e164_number(target_num, destp) | |
| 20 char *target_num; | |
| 21 struct sip_out_dest **destp; | |
| 22 { | |
| 23 unsigned inn_index; | |
| 24 struct inn_route *rec; | |
| 25 struct sip_out_dest *dest; | |
| 26 char *pp, *tp; | |
| 27 | |
| 28 for (inn_index = 0; inn_index < outrt_hdr.num_inn; inn_index++) { | |
| 29 rec = outrt_inn_array + inn_index; | |
| 30 pp = rec->prefix; | |
| 31 tp = target_num; | |
| 32 while (*pp && *pp == *tp) { | |
| 33 pp++; | |
| 34 tp++; | |
| 35 } | |
| 36 if (*pp) | |
| 37 continue; | |
| 38 dest = outrt_dest_array + rec->sip_dest_id; | |
| 39 *destp = dest; | |
| 40 return 1; | |
| 41 } | |
| 42 return 0; | |
| 43 } |
