view mtctest/main.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 a065b4a62a8a
children c8e9b295e88f
line wrap: on
line source

/*
 * Main module for ThemWi test MT call generator.
 */

#include <sys/types.h>
#include <sys/errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>

extern int mtc_socket;
extern int disconnect_mode;

static void
drain_stdin()
{
	char buf[256];

	read(0, buf, sizeof buf);
}

main(argc, argv)
	char **argv;
{
	extern int optind;
	extern char *optarg;
	char *from;
	fd_set fds;
	int c;

	from = 0;
	while ((c = getopt(argc, argv, "f:")) != EOF) {
		switch (c) {
		case 'f':
			from = optarg;
			continue;
		default:
		usage:
			fprintf(stderr,
				"usage: %s [-f from-number] to-number\n",
				argv[0]);
			exit(1);
		}
	}
	if (argc != optind + 1)
		goto usage;
	openlog("themwi-test-mtc", 0, LOG_LOCAL5);
	init_setup_msg(from, argv[optind]);
	obtain_dummy_rtp();
	connect_mtc_socket();
	send_setup_msg();
	/* main select loop */
	for (;;) {
		FD_ZERO(&fds);
		FD_SET(mtc_socket, &fds);
		if (!disconnect_mode)
			FD_SET(0, &fds);
		c = select(mtc_socket+1, &fds, 0, 0, 0);
		if (c < 0) {
			if (errno == EINTR)
				continue;
			perror("select");
			exit(1);
		}
		if (FD_ISSET(mtc_socket, &fds))
			mtc_socket_select();
		if (!disconnect_mode && FD_ISSET(0, &fds)) {
			drain_stdin();
			send_disconnect_req();
		}
	}
}