FreeCalypso > hg > themwi-system-sw
comparison utils/rtp-alloc-test.c @ 185:857d78c58f56
rtp-alloc-test program written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 12 Mar 2023 00:14:20 -0800 |
parents | |
children | 068fce34e565 |
comparison
equal
deleted
inserted
replaced
184:f8c40090a0a8 | 185:857d78c58f56 |
---|---|
1 /* | |
2 * This program exercises the path of obtaining an RTP endpoint from | |
3 * themwi-rtp-mgr via rtp_alloc_simple(), serving as a test for | |
4 * the themwi-rtp-mgr daemon and for both upper and lower layers of | |
5 * librtpalloc. | |
6 */ | |
7 | |
8 #include <sys/types.h> | |
9 #include <sys/socket.h> | |
10 #include <netinet/in.h> | |
11 #include <arpa/inet.h> | |
12 #include <stdio.h> | |
13 #include <stdlib.h> | |
14 #include <string.h> | |
15 #include <strings.h> | |
16 #include "../include/tmgw_const.h" | |
17 #include "../librtpalloc/rtp_alloc_simple.h" | |
18 | |
19 static void | |
20 print_ip_port(desc, sin) | |
21 char *desc; | |
22 struct sockaddr_in *sin; | |
23 { | |
24 printf("%s IP %s port %u\n", inet_ntoa(sin->sin_addr), | |
25 ntohs(sin->sin_port)); | |
26 } | |
27 | |
28 main(argc, argv) | |
29 char **argv; | |
30 { | |
31 int ep_type, rc; | |
32 struct rtp_alloc_simple res; | |
33 | |
34 if (argc != 2) { | |
35 fprintf(stderr, "usage: %s ep-type\n", argv[0]); | |
36 exit(1); | |
37 } | |
38 if (!strcmp(argv[1], "gsm")) | |
39 ep_type = TMGW_EP_TYPE_GSM_ONLY; | |
40 else if (!strcmp(argv[1], "pstn")) | |
41 ep_type = TMGW_EP_TYPE_PSTN_ONLY; | |
42 else if (!strcmp(argv[1], "gateway")) | |
43 ep_type = TMGW_EP_TYPE_GATEWAY; | |
44 else { | |
45 fprintf(stderr, "error: unknown endpoint type \"%s\"\n", | |
46 argv[1]); | |
47 exit(1); | |
48 } | |
49 rc = rtp_alloc_simple(ep_type, &res); | |
50 if (rc < 0) | |
51 exit(1); /* error msg already printed */ | |
52 if (ep_type & TMGW_EP_HAS_GSM_SOCK) { | |
53 print_ip_port("GSM", &res.gsm_addr); | |
54 printf("GSM fd %d %d\n", res.gsm_rtp_fd, res.gsm_rtcp_fd); | |
55 } | |
56 if (ep_type & TMGW_EP_HAS_PSTN_SOCK) { | |
57 print_ip_port("PSTN", &res.pstn_addr); | |
58 printf("PSTN fd %d %d\n", res.pstn_rtp_fd, res.pstn_rtcp_fd); | |
59 } | |
60 exit(0); | |
61 } |