FreeCalypso > hg > themwi-system-sw
annotate mgw/crcx.c @ 85:70c3c8ebee33
sip-in: handle MNCC RTP bogons from OsmoMSC
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 20 Sep 2022 22:47:53 -0800 |
parents | 020ba624bdd8 |
children | 738be11ac432 |
rev | line source |
---|---|
32
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement our CRCX operation. |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/socket.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <netinet/in.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <arpa/inet.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
38
020ba624bdd8
mgw source: #include <stdlib.h> in files using tmgw_ctrl.h
Mychaela Falconia <falcon@freecalypso.org>
parents:
34
diff
changeset
|
10 #include <stdint.h> |
32
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <syslog.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <unistd.h> |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../include/tmgw_ctrl.h" |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "../include/tmgw_const.h" |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "struct.h" |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "select.h" |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 extern struct endpoint *find_ep_by_id(); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 extern void udp_sink_rcvr(); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 extern struct bind_range_cfg bind_range_gsm, bind_range_pstn; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 static unsigned |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 get_new_ep_id(conn) |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 struct ctrl_conn *conn; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 unsigned id; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 for (;;) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 id = conn->next_ep_id++; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (!find_ep_by_id(conn, id)) |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 return id; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 static int |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 get_local_port_pair(ep, roe, brc) |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 struct endpoint *ep; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 struct rtp_one_end *roe; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 struct bind_range_cfg *brc; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 struct sockaddr_in sin; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 unsigned tries, rtp_port; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 int rc; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 sin.sin_family = AF_INET; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 sin.sin_addr = brc->bind_ip; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 for (tries = brc->port_tries; tries; tries--) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 rtp_port = brc->port_next; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 brc->port_next += 2; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (brc->port_next >= brc->port_range_end) |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 brc->port_next = brc->port_range_start; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 sin.sin_port = htons(rtp_port); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 roe->rtp_fd = socket(AF_INET, SOCK_DGRAM, 0); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 if (roe->rtp_fd < 0) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 syslog(LOG_CRIT, "socket(AF_INET, SOCK_DGRAM, 0): %m"); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 return(-1); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 rc = bind(roe->rtp_fd, (struct sockaddr *) &sin, sizeof sin); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 if (rc < 0) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 close(roe->rtp_fd); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 continue; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 bcopy(&sin, &roe->bound_addr, sizeof(struct sockaddr_in)); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 sin.sin_port = htons(rtp_port+1); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 roe->rtcp_fd = socket(AF_INET, SOCK_DGRAM, 0); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 if (roe->rtcp_fd < 0) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 syslog(LOG_CRIT, "socket(AF_INET, SOCK_DGRAM, 0): %m"); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 close(roe->rtp_fd); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 return(-1); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 rc = bind(roe->rtcp_fd, (struct sockaddr *) &sin, sizeof sin); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 if (rc < 0) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 close(roe->rtp_fd); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 close(roe->rtcp_fd); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 continue; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 /* all good - make the file descriptors live for select */ |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 update_max_fd(roe->rtp_fd); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 FD_SET(roe->rtp_fd, &select_for_read); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 select_handlers[roe->rtp_fd] = udp_sink_rcvr; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 select_data[roe->rtp_fd] = (void *) ep; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 update_max_fd(roe->rtcp_fd); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 FD_SET(roe->rtcp_fd, &select_for_read); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 select_handlers[roe->rtcp_fd] = udp_sink_rcvr; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 select_data[roe->rtcp_fd] = (void *) ep; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 return(0); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 /* couldn't find a free port pair */ |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 return(-1); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 void |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 process_crcx(conn, req, resp) |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 struct ctrl_conn *conn; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 struct tmgw_ctrl_req *req; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 struct tmgw_ctrl_resp *resp; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 struct endpoint *ep; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 int rc; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 /* ep_id in request encodes ep_type */ |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 switch (req->ep_id) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 case TMGW_EP_TYPE_DUMMY_GSM: |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 case TMGW_EP_TYPE_DUMMY_PSTN: |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 case TMGW_EP_TYPE_GATEWAY: |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 break; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 default: |
34
7dae2bae56a1
themwi-mgw: implement MDCX parameter validation
Mychaela Falconia <falcon@freecalypso.org>
parents:
32
diff
changeset
|
112 resp->res = TMGW_RESP_ERR_PARAM; |
32
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 return; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 ep = malloc(sizeof(struct endpoint)); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 if (!ep) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 syslog(LOG_CRIT, "malloc for endpoint: %m"); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 resp->res = TMGW_RESP_ERR_RSRC; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 return; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 bzero(ep, sizeof(struct endpoint)); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 ep->ep_type = req->ep_id; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 ep->ep_id = get_new_ep_id(conn); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 if (ep->ep_type & TMGW_EP_HAS_GSM_SOCK) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 rc = get_local_port_pair(ep, &ep->rtp_gsm, &bind_range_gsm); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 if (rc < 0) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 syslog(LOG_ERR, |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 "unable to get local port pair on GSM side"); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 free(ep); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 resp->res = TMGW_RESP_ERR_RSRC; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 return; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 if (ep->ep_type & TMGW_EP_HAS_PSTN_SOCK) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 rc = get_local_port_pair(ep, &ep->rtp_pstn, &bind_range_pstn); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (rc < 0) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 syslog(LOG_ERR, |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 "unable to get local port pair on PSTN side"); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (ep->ep_type & TMGW_EP_HAS_GSM_SOCK) |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 free_rtp_end(&ep->rtp_gsm); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 free(ep); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 resp->res = TMGW_RESP_ERR_RSRC; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 return; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 rc = mdcx_operation(ep, req, resp); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 if (rc < 0) { |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 if (ep->ep_type & TMGW_EP_HAS_GSM_SOCK) |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 free_rtp_end(&ep->rtp_gsm); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 if (ep->ep_type & TMGW_EP_HAS_PSTN_SOCK) |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 free_rtp_end(&ep->rtp_pstn); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 free(ep); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 return; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 } |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 /* all good - accept the new endpoint and return OK */ |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 ep->next = conn->endp_list; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 conn->endp_list = ep; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 resp->res = TMGW_RESP_OK; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 resp->ep_id = ep->ep_id; |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 bcopy(&ep->rtp_gsm.bound_addr, &resp->gsm_addr, |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 sizeof(struct sockaddr_in)); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 bcopy(&ep->rtp_pstn.bound_addr, &resp->pstn_addr, |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 sizeof(struct sockaddr_in)); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 syslog(LOG_INFO, "CRCX endpoint type %u id %u", ep->ep_type, ep->ep_id); |
b3f74df7b808
beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 } |