]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
deal with strange reinvite with no sdp
authorAnthony Minessale <anthony.minessale@gmail.com>
Sun, 16 Nov 2008 18:45:21 +0000 (18:45 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sun, 16 Nov 2008 18:45:21 +0000 (18:45 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10421 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index 5950f7f6a18bfefd1ca79c54bf304ab49f500527..f00349286434d50911e045c29844482228a0124c 100644 (file)
@@ -200,7 +200,7 @@ typedef enum {
        TFLAG_REINVITE = (1 << 16),
        TFLAG_REFER = (1 << 17),
        TFLAG_NOHUP = (1 << 18),
-       TFLAG_XFER = (1 << 19),
+       TFLAG_NOSDP_REINVITE = (1 << 19),
        TFLAG_NAT = (1 << 20),
        TFLAG_BUGGY_2833 = (1 << 21),
        TFLAG_SIP_HOLD = (1 << 22),
index 8ef8f21917e99f4b82c76b9ce1877effd65709e3..0ba31968a6ec5844dafb60588fb9609547cc9859 100644 (file)
@@ -2534,7 +2534,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                        }
 
                } else if (tech_pvt && switch_test_flag(tech_pvt, TFLAG_SDP) && !r_sdp) {
-                       nua_respond(tech_pvt->nh, SIP_202_ACCEPTED, TAG_END());
+                       nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
+                       switch_set_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
                        goto done;
                } else {
                        ss_state = nua_callstate_completed;
@@ -2673,6 +2674,45 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                }
                break;
        case nua_callstate_ready:
+
+               if (r_sdp && switch_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
+                       sdp_parser_t *parser;
+                       sdp_session_t *sdp;
+                       uint8_t match = 0;
+                       int is_ok = 1;
+                       
+                       switch_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
+
+                       if (tech_pvt->num_codecs) {
+                               if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
+                                       if ((sdp = sdp_session(parser))) {
+                                               match = sofia_glue_negotiate_sdp(session, sdp);
+                                       }
+                                       sdp_parser_free(parser);
+                               }
+                       }
+
+                       if (match) {
+                               switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
+                               if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP Error!\n");
+                                       switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RTP ERROR");
+                                       is_ok = 0;
+                               }
+                               switch_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
+                       } else {
+                               switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
+                               is_ok = 0;
+                       }
+
+                       if (!is_ok) {
+                               nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+                               switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
+                       }
+
+                       goto done;
+               }
+
                if (channel) {
                        switch_channel_clear_flag(channel, CF_REQ_MEDIA);
                }