# HG changeset patch # User Mychaela Falconia # Date 1717898128 0 # Node ID 33d8b3177540e7fd05b240537dfc81ba674b2070 # Parent e7b192a5dee515c6fae765caee1cf613523bd1a3 mtctest compiles in the new environment diff -r e7b192a5dee5 -r 33d8b3177540 .hgignore --- a/.hgignore Sun Jun 09 00:58:38 2024 +0000 +++ b/.hgignore Sun Jun 09 01:55:28 2024 +0000 @@ -4,3 +4,4 @@ ^config\.defs$ ^mncc/themwi-mncc$ +^mtctest/themwi-test-mtc$ diff -r e7b192a5dee5 -r 33d8b3177540 mtctest/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mtctest/Makefile Sun Jun 09 01:55:28 2024 +0000 @@ -0,0 +1,18 @@ +CPPFLAGS=-I${includedir} +PROG= themwi-test-mtc +OBJS= disconnect.o main.o rtp_sink.o setup.o sig_handler.o sock_conn.o +LIBUTIL=../libutil/libutil.a + +include ../config.defs + +all: ${PROG} + +${PROG}: ${OBJS} ${LIBUTIL} + ${CC} -o $@ ${OBJS} ${LIBUTIL} -L${libdir} -lrtpalloc -lnumdb -lnumutil + +install: + mkdir -p ${DESTDIR}${bindir} + install -c -m 755 ${PROG} ${DESTDIR}${bindir} + +clean: + rm -f *.o ${PROG} errs diff -r e7b192a5dee5 -r 33d8b3177540 mtctest/main.c --- a/mtctest/main.c Sun Jun 09 00:58:38 2024 +0000 +++ b/mtctest/main.c Sun Jun 09 01:55:28 2024 +0000 @@ -10,9 +10,11 @@ #include #include #include +#include extern int mtc_socket; extern int disconnect_mode; +extern struct rtp_alloc_simple rtp_info; struct timeval cur_event_time; @@ -31,7 +33,7 @@ extern char *optarg; char *from; fd_set fds; - int c; + int c, max_fd; from = 0; while ((c = getopt(argc, argv, "f:")) != EOF) { @@ -51,16 +53,23 @@ goto usage; openlog("themwi-test-mtc", 0, LOG_LOCAL5); init_setup_msg(from, argv[optind]); - obtain_dummy_rtp(); + obtain_rtp_endp(); connect_mtc_socket(); send_setup_msg(); /* main select loop */ + max_fd = mtc_socket; + if (rtp_info.gsm_rtp_fd > mtc_socket) + max_fd = rtp_info.gsm_rtp_fd; + if (rtp_info.gsm_rtcp_fd > mtc_socket) + max_fd = rtp_info.gsm_rtcp_fd; for (;;) { FD_ZERO(&fds); FD_SET(mtc_socket, &fds); + FD_SET(rtp_info.gsm_rtp_fd, &fds); + FD_SET(rtp_info.gsm_rtcp_fd, &fds); if (!disconnect_mode) FD_SET(0, &fds); - c = select(mtc_socket+1, &fds, 0, 0, 0); + c = select(max_fd+1, &fds, 0, 0, 0); if (c < 0) { if (errno == EINTR) continue; @@ -74,5 +83,9 @@ drain_stdin(); send_disconnect_req(); } + if (FD_ISSET(rtp_info.gsm_rtp_fd, &fds)) + rtp_rx_select(); + if (FD_ISSET(rtp_info.gsm_rtcp_fd, &fds)) + rtcp_rx_select(); } } diff -r e7b192a5dee5 -r 33d8b3177540 mtctest/rtp_sink.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mtctest/rtp_sink.c Sun Jun 09 01:55:28 2024 +0000 @@ -0,0 +1,45 @@ +/* + * In this module we implement our RTP handling: obtaining a GSM-side + * RTP endpoint from themwi-rtp-mgr, then handling read select on RTP + * and RTCP UDP sockets. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +struct rtp_alloc_simple rtp_info; + +void +obtain_rtp_endp() +{ + int rc; + + rc = rtp_alloc_simple(RTP_ALLOC_TYPE_GSM, &rtp_info); + if (rc < 0) + exit(1); /* error msg already printed */ +} + +void +rtp_rx_select() +{ + u_char buf[512]; + + recv(rtp_info.gsm_rtp_fd, buf, sizeof buf, 0); +} + +void +rtcp_rx_select() +{ + u_char buf[512]; + + recv(rtp_info.gsm_rtcp_fd, buf, sizeof buf, 0); +} diff -r e7b192a5dee5 -r 33d8b3177540 mtctest/setup.c --- a/mtctest/setup.c Sun Jun 09 00:58:38 2024 +0000 +++ b/mtctest/setup.c Sun Jun 09 01:55:28 2024 +0000 @@ -8,13 +8,17 @@ #include #include #include +#include #include #include #include + +#include +#include +#include + #include "../include/mncc.h" #include "../include/gsm48_const.h" -#include "../include/number_db_v2.h" -#include "../libnumdb2/lookup_func.h" struct gsm_mncc setup_msg; @@ -24,7 +28,7 @@ { int rc, ndig; char short_num[5], long_num[12]; - struct short_number_rec *snum; + const struct short_number_rec *snum; if (!strncmp(arg, "imsi:", 5)) { rc = grok_imsi_user_arg(arg, setup_msg.imsi); @@ -42,7 +46,7 @@ "error: plus-format call destination number must begin with 1\n"); exit(1); } - if (grok_number_string(arg+1, 1) != 11) { + if (grok_number_string(arg+1, true) != 11) { bad_plus1: fprintf(stderr, "error: malformed +1 call destination number\n"); exit(1); @@ -55,7 +59,7 @@ setup_msg.fields |= MNCC_F_CALLED; return; } - ndig = grok_number_string(arg, 1); + ndig = grok_number_string(arg, true); switch (ndig) { case 4: dehyphen_number_string(arg, short_num); diff -r e7b192a5dee5 -r 33d8b3177540 mtctest/sig_handler.c --- a/mtctest/sig_handler.c Sun Jun 09 00:58:38 2024 +0000 +++ b/mtctest/sig_handler.c Sun Jun 09 01:55:28 2024 +0000 @@ -12,11 +12,12 @@ #include #include #include +#include #include "../include/mncc.h" #include "../include/gsm48_const.h" extern int disconnect_mode; -extern struct sockaddr_storage dummy_rtp_endp; +extern struct rtp_alloc_simple rtp_info; extern struct timeval cur_event_time; static void @@ -197,7 +198,7 @@ bzero(&rtp, sizeof(struct gsm_mncc_rtp)); rtp.msg_type = MNCC_RTP_CONNECT; rtp.callref = 1; - bcopy(&dummy_rtp_endp, &rtp.addr, sizeof(struct sockaddr_storage)); + bcopy(&rtp_info.gsm_addr, &rtp.addr, sizeof(struct sockaddr_storage)); send_mncc_to_gsm(&rtp, sizeof(struct gsm_mncc_rtp)); }