view liboutrt/route_special.c @ 136:ce02fd05fd9e

liboutrt: implement special number routing
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 06 Oct 2022 23:57:38 -0800
parents liboutrt/route_e164.c@333dbb7ce704
children
line wrap: on
line source

/*
 * 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;
}