# HG changeset patch # User Mychaela Falconia # Date 1657441459 28800 # Node ID e8e82a4bf12b309e77ba980c572630228a9c9146 # Parent db7ed6a55ba42daae7391b04906e714f1e3d00e2 themwi-test-mtc: implement dummy RTP via themwi-mgw diff -r db7ed6a55ba4 -r e8e82a4bf12b mtctest/Makefile --- a/mtctest/Makefile Sat Jul 09 23:29:54 2022 -0800 +++ b/mtctest/Makefile Sun Jul 10 00:24:19 2022 -0800 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 PROG= themwi-test-mtc -OBJS= disconnect.o main.o setup.o sig_handler.o sock_conn.o +OBJS= disconnect.o dummy_rtp.o main.o setup.o sig_handler.o sock_conn.o LIBS= ../libnumdb/libnumdb.a ../libutil/libutil.a INSTBIN=/usr/local/bin diff -r db7ed6a55ba4 -r e8e82a4bf12b mtctest/dummy_rtp.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mtctest/dummy_rtp.c Sun Jul 10 00:24:19 2022 -0800 @@ -0,0 +1,65 @@ +/* + * In this module we implement the code that connects to themwi-mgw + * and obtains a dummy GSM-side RTP endpoint. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../include/tmgw_ctrl.h" +#include "../include/tmgw_const.h" + +struct sockaddr_storage dummy_rtp_endp; + +static char tmgw_socket_pathname[] = "/var/gsm/tmgw_socket"; + +obtain_dummy_rtp() +{ + struct sockaddr_un sa; + unsigned sa_len; + int fd, rc; + struct tmgw_ctrl_req req; + struct tmgw_ctrl_resp resp; + + fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); + if (fd < 0) { + perror("socket(AF_UNIX, SOCK_SEQPACKET, 0)"); + exit(1); + } + fill_sockaddr_un(tmgw_socket_pathname, &sa, &sa_len); + rc = connect(fd, (struct sockaddr *) &sa, sa_len); + if (rc < 0) { + perror(tmgw_socket_pathname); + exit(1); + } + bzero(&req, sizeof req); + req.opcode = TMGW_CTRL_OP_CRCX; + req.ep_id = TMGW_EP_TYPE_DUMMY_GSM; + rc = send(fd, &req, sizeof req, 0); + if (rc < 0) { + perror("send to TMGW socket"); + exit(1); + } + rc = recv(fd, &resp, sizeof resp, 0); + if (rc < 0) { + perror("recv from TMGW socket"); + exit(1); + } + if (rc != sizeof resp) { + fprintf(stderr, + "error: response packet from TMGW has wrong length (%d bytes)\n", + rc); + exit(1); + } + if (resp.res != TMGW_RESP_OK) { + fprintf(stderr, "TMGW CRCX returned error %u\n", resp.res); + exit(1); + } + bcopy(&resp.gsm_addr, &dummy_rtp_endp, sizeof(struct sockaddr_storage)); + return(0); +} diff -r db7ed6a55ba4 -r e8e82a4bf12b mtctest/main.c --- a/mtctest/main.c Sat Jul 09 23:29:54 2022 -0800 +++ b/mtctest/main.c Sun Jul 10 00:24:19 2022 -0800 @@ -40,6 +40,7 @@ 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 */ diff -r db7ed6a55ba4 -r e8e82a4bf12b mtctest/sig_handler.c --- a/mtctest/sig_handler.c Sat Jul 09 23:29:54 2022 -0800 +++ b/mtctest/sig_handler.c Sun Jul 10 00:24:19 2022 -0800 @@ -15,6 +15,7 @@ #include "../include/gsm48_const.h" extern int disconnect_mode; +extern struct sockaddr_storage dummy_rtp_endp; static void print_bearer_cap(bcap) @@ -286,6 +287,10 @@ printf("MNCC_RTP_CREATE: RTP info from MSC\n"); printf("payload_type=0x%x payload_msg_type=0x%x\n", msg->payload_type, msg->payload_msg_type); + printf("Responding with MNCC_RTP_CONNECT (dummy RTP endpoint)\n"); + msg->msg_type = MNCC_RTP_CONNECT; + bcopy(&dummy_rtp_endp, &msg->addr, sizeof(struct sockaddr_storage)); + send_mncc_to_gsm(msg, sizeof(struct gsm_mncc_rtp)); } void