changeset 136:ce02fd05fd9e

liboutrt: implement special number routing
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 06 Oct 2022 23:57:38 -0800
parents 333dbb7ce704
children f05183b18d29
files liboutrt/Makefile liboutrt/route_special.c
diffstat 2 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/liboutrt/Makefile	Thu Oct 06 23:44:17 2022 -0800
+++ b/liboutrt/Makefile	Thu Oct 06 23:57:38 2022 -0800
@@ -1,6 +1,6 @@
 CC=	gcc
 CFLAGS=	-O2
-OBJS=	readbin.o refresh.o route_e164.o
+OBJS=	readbin.o refresh.o route_e164.o route_special.o
 LIB=	liboutrt.a
 
 all:	${LIB}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboutrt/route_special.c	Thu Oct 06 23:57:38 2022 -0800
@@ -0,0 +1,39 @@
+/*
+ * In this module we implement routing of calls to special numbers
+ * such as N11.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include "../include/out_routes.h"
+
+extern struct out_routes_header outrt_hdr;
+extern struct sip_out_dest *outrt_dest_array;
+extern struct special_num_route *outrt_spec_array;
+
+route_special_number(target_num, destp, specp)
+	char *target_num;
+	struct sip_out_dest **destp;
+	struct special_num_route **specp;
+{
+	unsigned rt_index;
+	struct special_num_route *spec;
+	struct sip_out_dest *dest;
+
+	for (rt_index = 0; rt_index < outrt_hdr.num_special; rt_index++) {
+		spec = outrt_spec_array + rt_index;
+		if (strcmp(spec->special_num, target_num))
+			continue;
+		dest = outrt_dest_array + spec->sip_dest_id;
+		*destp = dest;
+		*specp = spec;
+		return 1;
+	}
+	return 0;
+}