# HG changeset patch # User Mychaela Falconia # Date 1665128657 28800 # Node ID 333dbb7ce704de1112b47207316f5f0aa2190d2d # Parent 2b03d2584f88136aa52343af83be3d1063492af2 liboutrt: implement E.164 routing diff -r 2b03d2584f88 -r 333dbb7ce704 liboutrt/Makefile --- a/liboutrt/Makefile Thu Oct 06 23:31:37 2022 -0800 +++ b/liboutrt/Makefile Thu Oct 06 23:44:17 2022 -0800 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -OBJS= readbin.o refresh.o +OBJS= readbin.o refresh.o route_e164.o LIB= liboutrt.a all: ${LIB} diff -r 2b03d2584f88 -r 333dbb7ce704 liboutrt/route_e164.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboutrt/route_e164.c Thu Oct 06 23:44:17 2022 -0800 @@ -0,0 +1,43 @@ +/* + * In this module we implement routing of calls to E.164 numbers. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../include/out_routes.h" + +extern struct out_routes_header outrt_hdr; +extern struct sip_out_dest *outrt_dest_array; +extern struct inn_route *outrt_inn_array; + +route_e164_number(target_num, destp) + char *target_num; + struct sip_out_dest **destp; +{ + unsigned inn_index; + struct inn_route *rec; + struct sip_out_dest *dest; + char *pp, *tp; + + for (inn_index = 0; inn_index < outrt_hdr.num_inn; inn_index++) { + rec = outrt_inn_array + inn_index; + pp = rec->prefix; + tp = target_num; + while (*pp && *pp == *tp) { + pp++; + tp++; + } + if (*pp) + continue; + dest = outrt_dest_array + rec->sip_dest_id; + *destp = dest; + return 1; + } + return 0; +}