view libnumdb/check_nanp.c @ 124:7e04d28fae8b

sip-in: default use-100rel to no BulkVS servers act badly when we send a reliable 180 Ringing response to an incoming call, even though they advertise 100rel support in the Supported header in the INVITE packet, and we probably won't be implementing 100rel for outbound because doing per-the-spec PRACK as a UAC is just too burdensome. Therefore, we need to consider 100rel extension as not-really-supported in themwi-system-sw.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 01 Oct 2022 15:54:50 -0800
parents 960ffce6c542
children
line wrap: on
line source

/*
 * The library function implemented in this module consults ThemWi number db
 * to see if a given NANP number is owned by us or not.
 */

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "../include/number_db_file.h"

extern struct numdb_file_hdr numdb_hdr;
extern uint64_t *numdb_owned_numbers;

static int
compare_owned_num(p1, p2)
	uint64_t *p1, *p2;
{
	if (*p1 < *p2)
		return(-1);
	else if (*p1 > *p2)
		return(1);
	else
		return(0);
}

is_nanp_locally_owned(numstr)
	char *numstr;
{
	uint64_t key, *res;

	if (!numdb_owned_numbers || !numdb_hdr.owned_number_count)
		return(0);
	key = strtoull(numstr, 0, 10);
	res = bsearch(&key, numdb_owned_numbers, numdb_hdr.owned_number_count,
			sizeof(uint64_t), compare_owned_num);
	if (res)
		return(1);
	else
		return(0);
}