FreeCalypso > hg > themwi-system-sw
view utils/rtp-alloc-test.c @ 201:d3c99b41fb04
sip-manual-out TFO: rework for continuous output of TFO_REQ
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 02 Apr 2023 18:01:34 -0800 |
parents | 068fce34e565 |
children |
line wrap: on
line source
/* * This program exercises the path of obtaining an RTP endpoint from * themwi-rtp-mgr via rtp_alloc_simple(), serving as a test for * the themwi-rtp-mgr daemon and for both upper and lower layers of * librtpalloc. */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "../include/tmgw_const.h" #include "../librtpalloc/rtp_alloc_simple.h" static void print_ip_port(desc, sin) char *desc; struct sockaddr_in *sin; { printf("%s IP %s port %u\n", desc, inet_ntoa(sin->sin_addr), ntohs(sin->sin_port)); } main(argc, argv) char **argv; { int ep_type, rc; struct rtp_alloc_simple res; if (argc != 2) { fprintf(stderr, "usage: %s ep-type\n", argv[0]); exit(1); } if (!strcmp(argv[1], "gsm")) ep_type = TMGW_EP_TYPE_GSM_ONLY; else if (!strcmp(argv[1], "pstn")) ep_type = TMGW_EP_TYPE_PSTN_ONLY; else if (!strcmp(argv[1], "gateway")) ep_type = TMGW_EP_TYPE_GATEWAY; else { fprintf(stderr, "error: unknown endpoint type \"%s\"\n", argv[1]); exit(1); } rc = rtp_alloc_simple(ep_type, &res); if (rc < 0) exit(1); /* error msg already printed */ if (ep_type & TMGW_EP_HAS_GSM_SOCK) { print_ip_port("GSM", &res.gsm_addr); printf("GSM fd %d %d\n", res.gsm_rtp_fd, res.gsm_rtcp_fd); } if (ep_type & TMGW_EP_HAS_PSTN_SOCK) { print_ip_port("PSTN", &res.pstn_addr); printf("PSTN fd %d %d\n", res.pstn_rtp_fd, res.pstn_rtcp_fd); } exit(0); }