comparison sip-in/invite.c @ 55:f1d59210f7b2

sip-in INVITE processing: grok SDP
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Sep 2022 12:58:03 -0800
parents 36a30349b490
children d61d0136f6a5
comparison
equal deleted inserted replaced
54:9f045dcff60e 55:f1d59210f7b2
13 #include <unistd.h> 13 #include <unistd.h>
14 #include "../libsip/parse.h" 14 #include "../libsip/parse.h"
15 #include "../libsip/uas_basic.h" 15 #include "../libsip/uas_basic.h"
16 #include "../libsip/grok_from.h" 16 #include "../libsip/grok_from.h"
17 #include "../libsip/req_supp.h" 17 #include "../libsip/req_supp.h"
18 #include "../libsip/sdp.h"
18 #include "../libsip/out_msg.h" 19 #include "../libsip/out_msg.h"
19 20
21 extern struct in_addr sip_bind_ip;
20 extern int cfg_use_100rel; 22 extern int cfg_use_100rel;
21 23
22 extern char *get_single_header(); 24 extern char *get_single_header();
23 25
24 void 26 void
30 char uri_user[13], *called_nanp; 32 char uri_user[13], *called_nanp;
31 struct sip_msg_out resp; 33 struct sip_msg_out resp;
32 struct grok_from gfrom; 34 struct grok_from gfrom;
33 struct supported_ext supp_ext; 35 struct supported_ext supp_ext;
34 char *hval, *unsup_ext; 36 char *hval, *unsup_ext;
35 int ext_100rel_req, ext_100rel_sup, use_100rel; 37 int ext_100rel_req, ext_100rel_sup, use_100rel, use_pcma;
38 struct sdp_parse sdp_parse;
39 struct sdp_gen sdp_gen;
36 int rc; 40 int rc;
37 41
38 /* check for existing Call-ID will go here */ 42 /* check for existing Call-ID will go here */
39 /* extract called number from Request-URI */ 43 /* extract called number from Request-URI */
40 rc = user_from_sip_uri(req->req_uri, uri_user, 12); 44 rc = user_from_sip_uri(req->req_uri, uri_user, 12);
118 } 122 }
119 if (strcasecmp(hval, "application/sdp")) { 123 if (strcasecmp(hval, "application/sdp")) {
120 start_response_out_msg(&resp, "415 Unsupported Content-Type"); 124 start_response_out_msg(&resp, "415 Unsupported Content-Type");
121 goto error_415; 125 goto error_415;
122 } 126 }
123 /* 127 rc = parse_incoming_sdp(req->msg_body, req->msg_body_len, &sdp_parse);
124 * Remaining checks to be implemented: 128 if (rc < 0) {
125 * SDP message body 129 start_response_out_msg(&resp, "488 Malformed SDP body");
126 */ 130 goto error_resp;
131 }
132 switch (sdp_parse.codec_mask) {
133 case SDP_CODEC_MASK_PCMU:
134 case SDP_CODEC_MASK_BOTH:
135 use_pcma = 0;
136 break;
137 case SDP_CODEC_MASK_PCMA:
138 case SDP_CODEC_MASK_BOTH | SDP_CODEC_MASK_PCMA_PREF:
139 use_pcma = 1;
140 break;
141 default:
142 start_response_out_msg(&resp,
143 "488 Unsupported codec selection");
144 rc = add_resp_basic_headers(&resp, ess, req->req_method);
145 if (rc < 0)
146 goto error_resp_toolong;
147 rc = out_msg_add_header(&resp, "Content-Type",
148 "application/sdp");
149 if (rc < 0)
150 goto error_resp_toolong;
151 bzero(&sdp_gen, sizeof sdp_gen);
152 sdp_gen.owner_ip = sip_bind_ip;
153 sdp_gen.conn_ip = sip_bind_ip;
154 sdp_gen.codec_mask = SDP_CODEC_MASK_BOTH;
155 rc = out_msg_finish_sdp(&resp, &sdp_gen);
156 if (rc < 0)
157 goto error_resp_toolong;
158 sip_tx_packet(&resp, sin);
159 return;
160 }
161 /* SIP INVITE validation done - check if GSM service is up */
127 } 162 }