FreeCalypso > hg > themwi-system-sw
changeset 55:f1d59210f7b2
sip-in INVITE processing: grok SDP
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Sep 2022 12:58:03 -0800 |
parents | 9f045dcff60e |
children | 7005d5c535e8 |
files | sip-in/invite.c |
diffstat | 1 files changed, 40 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/sip-in/invite.c Thu Sep 08 12:02:22 2022 -0800 +++ b/sip-in/invite.c Thu Sep 08 12:58:03 2022 -0800 @@ -15,8 +15,10 @@ #include "../libsip/uas_basic.h" #include "../libsip/grok_from.h" #include "../libsip/req_supp.h" +#include "../libsip/sdp.h" #include "../libsip/out_msg.h" +extern struct in_addr sip_bind_ip; extern int cfg_use_100rel; extern char *get_single_header(); @@ -32,7 +34,9 @@ struct grok_from gfrom; struct supported_ext supp_ext; char *hval, *unsup_ext; - int ext_100rel_req, ext_100rel_sup, use_100rel; + int ext_100rel_req, ext_100rel_sup, use_100rel, use_pcma; + struct sdp_parse sdp_parse; + struct sdp_gen sdp_gen; int rc; /* check for existing Call-ID will go here */ @@ -120,8 +124,39 @@ start_response_out_msg(&resp, "415 Unsupported Content-Type"); goto error_415; } - /* - * Remaining checks to be implemented: - * SDP message body - */ + rc = parse_incoming_sdp(req->msg_body, req->msg_body_len, &sdp_parse); + if (rc < 0) { + start_response_out_msg(&resp, "488 Malformed SDP body"); + goto error_resp; + } + switch (sdp_parse.codec_mask) { + case SDP_CODEC_MASK_PCMU: + case SDP_CODEC_MASK_BOTH: + use_pcma = 0; + break; + case SDP_CODEC_MASK_PCMA: + case SDP_CODEC_MASK_BOTH | SDP_CODEC_MASK_PCMA_PREF: + use_pcma = 1; + break; + default: + start_response_out_msg(&resp, + "488 Unsupported codec selection"); + rc = add_resp_basic_headers(&resp, ess, req->req_method); + if (rc < 0) + goto error_resp_toolong; + rc = out_msg_add_header(&resp, "Content-Type", + "application/sdp"); + if (rc < 0) + goto error_resp_toolong; + bzero(&sdp_gen, sizeof sdp_gen); + sdp_gen.owner_ip = sip_bind_ip; + sdp_gen.conn_ip = sip_bind_ip; + sdp_gen.codec_mask = SDP_CODEC_MASK_BOTH; + rc = out_msg_finish_sdp(&resp, &sdp_gen); + if (rc < 0) + goto error_resp_toolong; + sip_tx_packet(&resp, sin); + return; + } + /* SIP INVITE validation done - check if GSM service is up */ }