view utils/themwi-check-own.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 26b98505684e
children 697fe2c87fec
line wrap: on
line source

/*
 * This utility performs a lookup in ThemWi number database to see
 * if a given NANP number is owned by us.
 */

#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>

main(argc, argv)
	char **argv;
{
	char nanp[11];

	if (argc != 2) {
usage:		fprintf(stderr, "usage: %s 10-digit-number\n", argv[0]);
		exit(1);
	}
	if (grok_number_string(argv[1], 1) != 10)
		goto usage;
	dehyphen_number_string(argv[1], nanp);
	if (!is_nanp_valid_prefix(nanp)) {
		fprintf(stderr, "error: number violates NANP rules\n");
		exit(1);
	}
	openlog("themwi-check-own", 0, LOG_LOCAL5);
	if (read_number_db() < 0) {
		fprintf(stderr, "error reading number database\n");
		exit(1);
	}
	printf("+1-%.3s-%.3s-%s is %s\n", nanp, nanp+3, nanp+6,
		is_nanp_locally_owned(nanp) ? "locally owned"
					    : "NOT owned by us");
	exit(0);
}