Module: sems
Branch: master
Commit: f7b3e53d8c7241275e1beaefa73bde1ce574e2a6
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=f7b3e53d8c7241275e1beaefa73bde1ce574e2a6

Author: Stefan Sayer <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Wed Feb 16 16:46:09 2011 +0100

reply back error if setting RTP port fails

---

 core/AmB2BSession.cpp |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp
index cfe5e0b..cac03cb 100644
--- a/core/AmB2BSession.cpp
+++ b/core/AmB2BSession.cpp
@@ -352,7 +352,7 @@ bool AmB2BSession::replaceConnectionAddress(const string& 
content_type,
       replaced_ports += (!media_index) ? int2str(it->port) : 
"/"+int2str(it->port);
     } catch (const string& s) {
       ERROR("setting port: '%s'\n", s.c_str());
-      return false; // TODO: or throw?
+      throw string("error setting RTP port\n");
     }
 
     media_index++;
@@ -529,7 +529,7 @@ bool AmB2BSession::updateSessionDescription(const string& 
content_type,
   return false;
 }
 
-int AmB2BSession::sendEstablishedReInvite() {
+int AmB2BSession::sendEstablishedReInvite() {  
   if (established_content_type.empty() || established_body.empty()) {
     ERROR("trying to re-INVITE with saved description, but none saved\n");
     return -1;
@@ -537,15 +537,20 @@ int AmB2BSession::sendEstablishedReInvite() {
 
   DBG("sending re-INVITE with saved session description\n");
 
-  const string* body = &established_body;
-  string r_body;
-  if (rtp_relay_enabled &&
-      replaceConnectionAddress(established_content_type, *body, r_body)) {
-       body = &r_body;
-  }
+  try {
+    const string* body = &established_body;
+    string r_body;
+    if (rtp_relay_enabled &&
+       replaceConnectionAddress(established_content_type, *body, r_body)) {
+      body = &r_body;
+    }
 
-  return dlg.reinvite("", established_content_type, *body,
-                     SIP_FLAGS_VERBATIM);
+    return dlg.reinvite("", established_content_type, *body,
+                       SIP_FLAGS_VERBATIM);
+  } catch (const string& s) {
+    ERROR("sending established SDP reinvite: %s\n", s.c_str());
+    return -1;
+  }
 }
 
 bool AmB2BSession::refresh(int flags) {
@@ -1034,12 +1039,21 @@ void AmB2BCalleeSession::onB2BEvent(B2BEvent* ev)
     const string* body = &co_ev->body;
     string r_body;
     if (rtp_relay_enabled) {
-      if (replaceConnectionAddress(co_ev->content_type, *body, r_body)) {
-       body = &r_body;
+      try {
+       if (replaceConnectionAddress(co_ev->content_type, *body, r_body)) {
+         body = &r_body;
+       } 
+      } catch (const string& s) {
+       AmSipReply n_reply;
+       n_reply.code = 500;
+       n_reply.reason = SIP_REPLY_SERVER_INTERNAL_ERROR;
+       n_reply.cseq = co_ev->r_cseq;
+       n_reply.local_tag = dlg.local_tag;
+       relayEvent(new B2BSipReplyEvent(n_reply, co_ev->relayed_invite, 
SIP_METH_INVITE));
+         throw;
       }
     }
 
-
     if (dlg.sendRequest(SIP_METH_INVITE,
                        co_ev->content_type, *body,
                        co_ev->hdrs, SIP_FLAGS_VERBATIM) < 0) {

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to