pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37322?usp=email )
Change subject: asterisk: IMS: fix SDP precondition validation ......................................................................
asterisk: IMS: fix SDP precondition validation
Change-Id: I8e22f76f7c0a8e6fda70252b330b1b174ca5c66f --- M asterisk/IMS_ConnectionHandler.ttcn M library/SDP_Templates.ttcn 2 files changed, 39 insertions(+), 24 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/22/37322/1
diff --git a/asterisk/IMS_ConnectionHandler.ttcn b/asterisk/IMS_ConnectionHandler.ttcn index 95f6852..3e2ca45 100644 --- a/asterisk/IMS_ConnectionHandler.ttcn +++ b/asterisk/IMS_ConnectionHandler.ttcn @@ -1201,9 +1201,12 @@ f_tr_Via_response(via), g_pars.subscr.cp.sip_seq_nr, "INVITE", require := tr_Require(superset("100rel", "precondition")), - rseq := tr_RSeq(?)); + rseq := tr_RSeq(?), + body := ?); alt { - [] SIP.receive(exp) -> value g_rx_sip_resp; + [] SIP.receive(exp) -> value g_rx_sip_resp { + f_SDP_decodeMessage(g_rx_sip_resp.messageBody, g_pars.subscr.cp.peer_sdp); + }; [] SIP.receive(tr_SIP_Response_Ringing(?, ?, ?)) -> value g_rx_sip_resp { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(g_name & ": Expected 183 Session Progress instead of 180 Ringing: ", @@ -1224,11 +1227,11 @@ tr_SDP_des(c_SDP_PRECON_STRENGTH_TAG_mandatory, c_SDP_PRECON_STATUS_TYPE_local, c_SDP_PRECON_DIR_TAG_sendrecv), tr_SDP_des(c_SDP_PRECON_STRENGTH_TAG_mandatory, c_SDP_PRECON_STATUS_TYPE_remote, c_SDP_PRECON_DIR_TAG_sendrecv), tr_SDP_conf(c_SDP_PRECON_STATUS_TYPE_remote, c_SDP_PRECON_DIR_TAG_sendrecv)); - if (not ispresent(g_pars.subscr.cp.peer_sdp.attributes) or - not match(g_pars.subscr.cp.peer_sdp.attributes, preconds)) { + if (not ispresent(g_pars.subscr.cp.peer_sdp.media_list[0].attributes) or + not match(g_pars.subscr.cp.peer_sdp.media_list[0].attributes, preconds)) { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(g_name & ": Unexpected precondition attrs in Session Progress : ", - g_pars.subscr.cp.peer_sdp.attributes)); + g_pars.subscr.cp.peer_sdp.media_list[0].attributes)); }
/* Tx PRACK */ @@ -1295,11 +1298,11 @@ tr_SDP_curr(c_SDP_PRECON_STATUS_TYPE_remote, c_SDP_PRECON_DIR_TAG_sendrecv), tr_SDP_des(c_SDP_PRECON_STRENGTH_TAG_mandatory, c_SDP_PRECON_STATUS_TYPE_local, c_SDP_PRECON_DIR_TAG_sendrecv), tr_SDP_des(c_SDP_PRECON_STRENGTH_TAG_mandatory, c_SDP_PRECON_STATUS_TYPE_remote, c_SDP_PRECON_DIR_TAG_sendrecv)); - if (not ispresent(g_pars.subscr.cp.peer_sdp.attributes) or - not match(g_pars.subscr.cp.peer_sdp.attributes, preconds)) { + if (not ispresent(g_pars.subscr.cp.peer_sdp.media_list[0].attributes) or + not match(g_pars.subscr.cp.peer_sdp.media_list[0].attributes, preconds)) { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(g_name & ": Unexpected precondition attrs in 200 OK (UPDATE): ", - g_pars.subscr.cp.peer_sdp.attributes)); + g_pars.subscr.cp.peer_sdp.media_list[0].attributes)); }
g_pars.subscr.cp.sip_seq_nr := g_rx_sip_resp.msgHeader.cSeq.seqNumber + 1; @@ -1499,11 +1502,12 @@ tr_SDP_curr(c_SDP_PRECON_STATUS_TYPE_remote, c_SDP_PRECON_DIR_TAG_none), tr_SDP_des(c_SDP_PRECON_STRENGTH_TAG_mandatory, c_SDP_PRECON_STATUS_TYPE_local, c_SDP_PRECON_DIR_TAG_sendrecv), tr_SDP_des(c_SDP_PRECON_STRENGTH_TAG_optional, c_SDP_PRECON_STATUS_TYPE_remote, c_SDP_PRECON_DIR_TAG_sendrecv)); - if (not ispresent(g_pars.subscr.cp.peer_sdp.attributes) or - not match(g_pars.subscr.cp.peer_sdp.attributes, preconds)) { + if (not ispresent(g_pars.subscr.cp.peer_sdp.media_list[0].attributes) or + not match(g_pars.subscr.cp.peer_sdp.media_list[0].attributes, preconds)) { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(g_name & ": Unexpected precondition attrs in INVITE : ", - g_pars.subscr.cp.peer_sdp.attributes)); + g_pars.subscr.cp.peer_sdp.media_list[0].attributes, + " vs exp: ", preconds)); }
/* Tx 183 Session Progress */ @@ -1550,6 +1554,7 @@ supported := tr_Supported(superset("100rel", "timer")), body := ?); as_SIP_expect_req(exp_req); + f_SDP_decodeMessage(g_rx_sip_req.messageBody, g_pars.subscr.cp.peer_sdp);
/* Validate SDP in UPDATE contains the preconditions: * a=curr:qos local sendrecv @@ -1562,11 +1567,12 @@ tr_SDP_curr(c_SDP_PRECON_STATUS_TYPE_remote, c_SDP_PRECON_DIR_TAG_none), tr_SDP_des(c_SDP_PRECON_STRENGTH_TAG_mandatory, c_SDP_PRECON_STATUS_TYPE_local, c_SDP_PRECON_DIR_TAG_sendrecv), tr_SDP_des(c_SDP_PRECON_STRENGTH_TAG_mandatory, c_SDP_PRECON_STATUS_TYPE_remote, c_SDP_PRECON_DIR_TAG_sendrecv)); - if (not ispresent(g_pars.subscr.cp.peer_sdp.attributes) or - not match(g_pars.subscr.cp.peer_sdp.attributes, preconds)) { + if (not ispresent(g_pars.subscr.cp.peer_sdp.media_list[0].attributes) or + not match(g_pars.subscr.cp.peer_sdp.media_list[0].attributes, preconds)) { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(g_name & ": Unexpected precondition attrs in UPDATE: ", - g_pars.subscr.cp.peer_sdp.attributes)); + g_pars.subscr.cp.peer_sdp.media_list[0].attributes, + "vs exp: ", preconds)); }
/* Tx 200 OK (UPDATE) */ @@ -1589,13 +1595,13 @@ tx_sdp := omit; } else { /* Check no precondition is sent in SDP */ - if (ispresent(g_pars.subscr.cp.peer_sdp.attributes) and - match (g_pars.subscr.cp.peer_sdp.attributes, superset(tr_SDP_curr_present, - tr_SDP_des_present, - tr_SDP_conf_present))) { + if (ispresent(g_pars.subscr.cp.peer_sdp.media_list[0].attributes) and + match (g_pars.subscr.cp.peer_sdp.media_list[0].attributes, superset(tr_SDP_curr_present, + tr_SDP_des_present, + tr_SDP_conf_present))) { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str(g_name & ": Unexpected precondition attrs in INVITE: ", - g_pars.subscr.cp.peer_sdp.attributes)); + g_pars.subscr.cp.peer_sdp.media_list[0].attributes)); } /* 200 OK (INVITE) has SDP if no precondition is used: */ tx_sdp := f_gen_sdp(); diff --git a/library/SDP_Templates.ttcn b/library/SDP_Templates.ttcn index ef91953..782c672 100644 --- a/library/SDP_Templates.ttcn +++ b/library/SDP_Templates.ttcn @@ -190,11 +190,11 @@ } }
-template (present) SDP_attribute tr_SDP_des(charstring status_type, - charstring strength_tag, +template (present) SDP_attribute tr_SDP_des(charstring strength_tag, + charstring status_type, charstring dir_tag, charstring precondition_type := c_SDP_PRECON_TYPE_qos) := { - curr := { + des := { attr_value := precondition_type & " " & strength_tag & " " & status_type & " " & dir_tag } } @@ -203,8 +203,8 @@ attr_value := ? } } -template (value) SDP_attribute ts_SDP_des(charstring status_type, - charstring strength_tag, +template (value) SDP_attribute ts_SDP_des(charstring strength_tag, + charstring status_type, charstring dir_tag, charstring precondition_type := c_SDP_PRECON_TYPE_qos) := { des := {