From 5f9848854ddf5d4507193df6936ba0305836ce34 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Mon, 29 Aug 2011 11:36:04 -0400
Subject: [PATCH] * #6478: remove throw specs, cleanup in voiplink

---
 daemon/src/iax/iaxvoiplink.cpp |  47 +++-----
 daemon/src/iax/iaxvoiplink.h   |  16 +--
 daemon/src/sip/sipvoiplink.cpp | 198 +++++++++++++++------------------
 daemon/src/sip/sipvoiplink.h   |  18 +--
 daemon/src/voiplink.h          |  16 +--
 5 files changed, 130 insertions(+), 165 deletions(-)

diff --git a/daemon/src/iax/iaxvoiplink.cpp b/daemon/src/iax/iaxvoiplink.cpp
index faadde68d2..61c8b2b761 100644
--- a/daemon/src/iax/iaxvoiplink.cpp
+++ b/daemon/src/iax/iaxvoiplink.cpp
@@ -287,44 +287,34 @@ IAXVoIPLink::sendAudioFromMic (void)
 IAXCall*
 IAXVoIPLink::getIAXCall (const std::string& id)
 {
-    Call* call = getCall (id);
-
-    if (call) {
-        return dynamic_cast<IAXCall*> (call);
-    }
-
-    return NULL;
+    return dynamic_cast<IAXCall*>(getCall(id));
 }
 
-
 void
 IAXVoIPLink::sendRegister (Account *a)
 {
     _debug ("IAX: Sending registration");
 
-    IAXAccount *account = (IAXAccount*)a;
+    IAXAccount *account = dynamic_cast<IAXAccount*>(a);
 
-    if (account->getHostname().empty()) {
+    if (account->getHostname().empty())
     	throw VoipLinkException("Account hostname is empty");
-    }
 
-    if (account->getUsername().empty()) {
+    if (account->getUsername().empty())
     	throw VoipLinkException("Account username is empty");
-    }
 
     // lock
     _mutexIAX.enterMutex();
 
     // Always use a brand new session
-    if (_regSession) {
+    if (_regSession)
         iax_destroy (_regSession);
-    }
 
     _regSession = iax_session_new();
 
-    if (!_regSession) {
+    if (!_regSession)
         _debug ("IAX: Error when generating new session for register");
-    } else {
+    else {
         _debug ("IAX: Sending registration to %s with user %s", account->getHostname().c_str() , account->getUsername().c_str());
         int val = iax_register (_regSession, account->getHostname().data(), account->getUsername().data(), account->getPassword().data(), 120);
         _debug ("IAX: Return value: %d", val);
@@ -363,7 +353,7 @@ IAXVoIPLink::sendUnregister (Account *a)
 }
 
 Call*
-IAXVoIPLink::newOutgoingCall (const std::string& id, const std::string& toUrl) throw(VoipLinkException)
+IAXVoIPLink::newOutgoingCall (const std::string& id, const std::string& toUrl)
 {
     IAXCall* call = new IAXCall (id, Call::Outgoing);
     call->setCodecMap (Manager::instance().getAudioCodecFactory());
@@ -387,7 +377,7 @@ IAXVoIPLink::newOutgoingCall (const std::string& id, const std::string& toUrl) t
 
 
 void
-IAXVoIPLink::answer (Call *c) throw (VoipLinkException)
+IAXVoIPLink::answer (Call *c)
 {
     IAXCall* call = (IAXCall*) c;
     call->setCodecMap (Manager::instance().getAudioCodecFactory());
@@ -406,14 +396,13 @@ IAXVoIPLink::answer (Call *c) throw (VoipLinkException)
 }
 
 void
-IAXVoIPLink::hangup (const std::string& id) throw (VoipLinkException)
+IAXVoIPLink::hangup (const std::string& id)
 {
     _debug ("IAXVoIPLink: Hangup");
 
     IAXCall* call = getIAXCall (id);
-    if(call == NULL) {
+    if (call == NULL)
     	throw VoipLinkException("Could not find call");
-    }
 
     Manager::instance().getMainBuffer()->unBindAll (call->getCallId());
 
@@ -428,14 +417,13 @@ IAXVoIPLink::hangup (const std::string& id) throw (VoipLinkException)
 
 
 void
-IAXVoIPLink::peerHungup (const std::string& id) throw (VoipLinkException)
+IAXVoIPLink::peerHungup (const std::string& id)
 {
     _debug ("IAXVoIPLink: Peer hung up");
 
     IAXCall* call = getIAXCall (id);
-    if(call == NULL) {
+    if (call == NULL)
     	throw VoipLinkException("Could not find call");
-    }
 
     Manager::instance().getMainBuffer()->unBindAll (call->getCallId());
 
@@ -447,12 +435,11 @@ IAXVoIPLink::peerHungup (const std::string& id) throw (VoipLinkException)
 
 
 bool
-IAXVoIPLink::onhold (const std::string& id) throw (VoipLinkException)
+IAXVoIPLink::onhold (const std::string& id)
 {
     IAXCall* call = getIAXCall (id);
-    if(call == NULL) {
+    if (call == NULL)
     	throw VoipLinkException("Call does not exist");
-    }
 
     Manager::instance().getMainBuffer()->unBindAll (call->getCallId());
 
@@ -467,7 +454,7 @@ IAXVoIPLink::onhold (const std::string& id) throw (VoipLinkException)
 }
 
 bool
-IAXVoIPLink::offhold (const std::string& id) throw (VoipLinkException)
+IAXVoIPLink::offhold (const std::string& id)
 {
     IAXCall* call = getIAXCall (id);
     CHK_VALID_CALL;
@@ -484,7 +471,7 @@ IAXVoIPLink::offhold (const std::string& id) throw (VoipLinkException)
 }
 
 bool
-IAXVoIPLink::transfer (const std::string& id, const std::string& to) throw (VoipLinkException)
+IAXVoIPLink::transfer (const std::string& id, const std::string& to)
 {
     IAXCall* call = getIAXCall (id);
     CHK_VALID_CALL;
diff --git a/daemon/src/iax/iaxvoiplink.h b/daemon/src/iax/iaxvoiplink.h
index 1370387bb9..c02ba537e1 100644
--- a/daemon/src/iax/iaxvoiplink.h
+++ b/daemon/src/iax/iaxvoiplink.h
@@ -104,31 +104,31 @@ class IAXVoIPLink : public VoIPLink
          * @param toUrl The address to call
          * @return Call*  A pointer on the call
          */
-        virtual Call* newOutgoingCall (const std::string& id, const std::string& toUrl) throw(VoipLinkException);
+        virtual Call* newOutgoingCall (const std::string& id, const std::string& toUrl);
 
         /**
          * Answer a call
          * @param c The call
          */
-        virtual void answer (Call *c) throw (VoipLinkException);
+        virtual void answer (Call *c);
 
         /**
          * Hangup a call
          * @param id The ID of the call
          */
-        virtual void hangup (const std::string& id) throw (VoipLinkException);
+        virtual void hangup (const std::string& id);
 
         /**
          * Peer Hungup a call
          * @param id The ID of the call
          */
-        virtual void peerHungup (const std::string& id) throw (VoipLinkException);
+        virtual void peerHungup (const std::string& id);
 
         /**
          * Cancel a call
          * @param id The ID of the call
          */
-        virtual void cancel (const std::string& id UNUSED) throw (VoipLinkException){}
+        virtual void cancel (const std::string& id UNUSED) {}
 
         /**
          * Put a call on hold
@@ -136,7 +136,7 @@ class IAXVoIPLink : public VoIPLink
          * @return bool true on success
          *		  false otherwise
          */
-        virtual bool onhold (const std::string& id) throw (VoipLinkException);
+        virtual bool onhold (const std::string& id);
 
         /**
          * Put a call off hold
@@ -144,7 +144,7 @@ class IAXVoIPLink : public VoIPLink
          * @return bool true on success
          *		  false otherwise
          */
-        virtual bool offhold (const std::string& id) throw (VoipLinkException);
+        virtual bool offhold (const std::string& id);
 
         /**
          * Transfer a call
@@ -153,7 +153,7 @@ class IAXVoIPLink : public VoIPLink
          * @return bool true on success
          *		  false otherwise
          */
-        virtual bool transfer (const std::string& id, const std::string& to) throw (VoipLinkException);
+        virtual bool transfer (const std::string& id, const std::string& to);
 
         /**
          * Perform attended transfer
diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp
index 9171e779af..ee81e82b59 100644
--- a/daemon/src/sip/sipvoiplink.cpp
+++ b/daemon/src/sip/sipvoiplink.cpp
@@ -76,7 +76,8 @@
 
 using namespace sfl;
 
-static const char * invitationStateMap[] = {
+namespace {
+static const char * const invitationStateMap[] = {
     "PJSIP_INV_STATE_NULL",
     "PJSIP_INV_STATE_CALLING",
     "PJSIP_INV_STATE_INCOMING",
@@ -86,7 +87,7 @@ static const char * invitationStateMap[] = {
     "PJSIP_INV_STATE_DISCONNECTED"
 };
 
-static const char * transactionStateMap[] = {
+static const char * const transactionStateMap[] = {
     "PJSIP_TSX_STATE_NULL" ,
     "PJSIP_TSX_STATE_CALLING",
     "PJSIP_TSX_STATE_TRYING",
@@ -113,7 +114,6 @@ pjsip_tpfactory *_localTlsListener = NULL;
  *  Given a SIP call ID (usefull for transaction sucha as transfer)*/
 std::map<std::string, std::string> transferCallID;
 
-
 const pj_str_t STR_USER_AGENT = { (char*) "User-Agent", 10 };
 
 /**************** EXTERN VARIABLES AND FUNCTIONS (callbacks) **************************/
@@ -255,6 +255,8 @@ void transfer_server_cb (pjsip_evsub *sub, pjsip_event *event);
  */
 void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata);
 
+} // end anonymous namespace
+
 /*************************************************************************************************/
 
 SIPVoIPLink* SIPVoIPLink::_instance = NULL;
@@ -505,9 +507,8 @@ void SIPVoIPLink::sendRegister (Account *a)
                 transport->obj_name, transport->info, (int) pj_atomic_get(transport->ref_cnt));
 }
 
-void SIPVoIPLink::sendUnregister (Account *a) throw(VoipLinkException)
+void SIPVoIPLink::sendUnregister (Account *a)
 {
-    pjsip_tx_data *tdata = NULL;
     SIPAccount *account = (SIPAccount *)a;
 
     // If an transport is attached to this account, detach it and decrease reference counter
@@ -527,9 +528,10 @@ void SIPVoIPLink::sendUnregister (Account *a) throw(VoipLinkException)
     }
 
     pjsip_regc *regc = account->getRegistrationInfo();
-    if(!regc)
+    if (!regc)
     	throw VoipLinkException("Registration structure is NULL");
 
+    pjsip_tx_data *tdata = NULL;
     if (pjsip_regc_unregister (regc, &tdata) != PJ_SUCCESS)
     	throw VoipLinkException("Unable to unregister sip account");
 
@@ -539,7 +541,7 @@ void SIPVoIPLink::sendUnregister (Account *a) throw(VoipLinkException)
     account->setRegister (false);
 }
 
-Call *SIPVoIPLink::newOutgoingCall (const std::string& id, const std::string& toUrl) throw (VoipLinkException)
+Call *SIPVoIPLink::newOutgoingCall (const std::string& id, const std::string& toUrl)
 {
     SIPAccount * account = NULL;
     std::string localAddr, addrSdp;
@@ -629,7 +631,7 @@ Call *SIPVoIPLink::newOutgoingCall (const std::string& id, const std::string& to
 }
 
 void
-SIPVoIPLink::answer (Call *c) throw (VoipLinkException)
+SIPVoIPLink::answer (Call *c)
 {
     pjsip_tx_data *tdata;
 
@@ -652,33 +654,28 @@ SIPVoIPLink::answer (Call *c) throw (VoipLinkException)
 }
 
 void
-SIPVoIPLink::hangup (const std::string& id) throw (VoipLinkException)
+SIPVoIPLink::hangup (const std::string& id)
 {
-    pjsip_tx_data *tdata = NULL;
-
     SIPCall* call = getSIPCall (id);
-    if (call == NULL) {
+    if (call == NULL)
         throw VoipLinkException("Call is NULL while hanging up");
-    }
 
     std::string account_id = Manager::instance().getAccountFromCall (id);
     SIPAccount *account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id));
-    if(account == NULL) {
+    if (account == NULL)
     	throw VoipLinkException("Could not find account for this call");
-    }
-
 
     pjsip_inv_session *inv = call->getInvSession();
-    if(inv == NULL) {
+    if (inv == NULL)
     	throw VoipLinkException("No invite session for this call");
-    }
 
     // Looks for sip routes
-    if (! (account->getServiceRoute().empty())) {
+    if (not (account->getServiceRoute().empty())) {
         pjsip_route_hdr *route_set = createRouteSet(account, inv->pool);
         pjsip_dlg_set_route_set (inv->dlg, route_set);
     }
 
+    pjsip_tx_data *tdata = NULL;
     // User hangup current call. Notify peer
     if (pjsip_inv_end_session (inv, 404, NULL, &tdata) != PJ_SUCCESS || !tdata)
         return;
@@ -694,7 +691,7 @@ SIPVoIPLink::hangup (const std::string& id) throw (VoipLinkException)
         if (Manager::instance().isCurrentCall (id))
             call->getAudioRtp()->stop();
     }
-    catch(...) {
+    catch (...) {
     	throw VoipLinkException("Could not stop audio rtp session");
     }
 
@@ -702,7 +699,7 @@ SIPVoIPLink::hangup (const std::string& id) throw (VoipLinkException)
 }
 
 void
-SIPVoIPLink::peerHungup (const std::string& id) throw (VoipLinkException)
+SIPVoIPLink::peerHungup (const std::string& id)
 {
     _info ("UserAgent: Peer hungup");
 
@@ -728,7 +725,7 @@ SIPVoIPLink::peerHungup (const std::string& id) throw (VoipLinkException)
             call->getAudioRtp()->stop();
         }
     }
-    catch(...) {
+    catch (...) {
     	throw VoipLinkException("Could not stop audio rtp session");
     }
 
@@ -736,21 +733,20 @@ SIPVoIPLink::peerHungup (const std::string& id) throw (VoipLinkException)
 }
 
 void
-SIPVoIPLink::cancel (const std::string& id) throw (VoipLinkException)
+SIPVoIPLink::cancel (const std::string& id)
 {
     _info ("UserAgent: Cancel call %s", id.c_str());
 
     SIPCall* call = getSIPCall (id);
-    if (!call) {
+    if (!call)
     	throw VoipLinkException("Call does not exist");
-    }
 
     removeCall (id);
 }
 
 
 bool
-SIPVoIPLink::onhold (const std::string& id) throw (VoipLinkException)
+SIPVoIPLink::onhold (const std::string& id)
 {
     SIPCall *call = getSIPCall (id);
     if (!call)
@@ -782,42 +778,36 @@ SIPVoIPLink::onhold (const std::string& id) throw (VoipLinkException)
 }
 
 bool
-SIPVoIPLink::offhold (const std::string& id) throw (VoipLinkException)
+SIPVoIPLink::offhold (const std::string& id)
 {
     _debug ("UserAgent: retrive call from hold status");
 
     SIPCall *call = getSIPCall (id);
-    if (call == NULL) {
+    if (call == NULL)
     	throw VoipLinkException("Could not find call");
-    }
 
 	Sdp *sdpSession = call->getLocalSDP();
-    if (sdpSession == NULL) {
+    if (sdpSession == NULL)
     	throw VoipLinkException("Could not find sdp session");
-    }
 
     try {
         // Retreive previously selected codec
         AudioCodecType pl;
         sfl::Codec *sessionMedia = sdpSession->getSessionMedia();
         if (sessionMedia == NULL) {
-            // throw VoipLinkException("Could not find session media");
     	    _warn("UserAgent: Session media not yet initialized, using default (ULAW)");
     	    pl = PAYLOAD_CODEC_ULAW;
         }
-        else {
-    	    // Get PayloadType for this codec
+        else
     	    pl = (AudioCodecType) sessionMedia->getPayloadType();
-        }
 
         _debug ("UserAgent: Payload from session media %d", pl);
 
 
         // Create a new instance for this codec
         sfl::Codec* audiocodec = Manager::instance().getAudioCodecFactory().instantiateCodec (pl);
-        if (audiocodec == NULL) {
+        if (audiocodec == NULL)
     	    throw VoipLinkException("Could not instantiate codec");
-        }
 
         call->getAudioRtp()->initAudioRtpConfig ();
         call->getAudioRtp()->initAudioSymmetricRtpSession ();
@@ -850,13 +840,8 @@ SIPVoIPLink::sendTextMessage (sfl::InstantMessaging *module, const std::string&
     _debug ("SipVoipLink: Send text message to %s, from %s", callID.c_str(), from.c_str());
 
     SIPCall *call = getSIPCall (callID);
-    if (!call) {
-        /* Notify the client of an error */
-        /*Manager::instance ().incomingMessage (	"",
-        										"sflphoned",
-        										"Unable to send a message outside a call.");*/
+    if (!call)
     	return !PJ_SUCCESS;
-    }
 
 	/* Send IM message */
 	sfl::InstantMessaging::UriList list;
@@ -870,69 +855,39 @@ SIPVoIPLink::sendTextMessage (sfl::InstantMessaging *module, const std::string&
 	return module->send_sip_message (call->getInvSession (), callID, formatedMessage);
 }
 
-int SIPSessionReinvite (SIPCall *call)
-{
-    pjsip_tx_data *tdata;
-
-    _debug("UserAgent: Sending re-INVITE request");
-
-    pjmedia_sdp_session *local_sdp = call->getLocalSDP()->getLocalSdpSession();
-    if (!local_sdp) {
-        _debug ("UserAgent: Error: Unable to find local sdp");
-        return !PJ_SUCCESS;
-    }
-
-    // Build the reinvite request
-    pj_status_t status = pjsip_inv_reinvite (call->getInvSession(), NULL, local_sdp, &tdata);
-    if (status != PJ_SUCCESS)
-        return status;
-
-    // Send it
-    return pjsip_inv_send_msg (call->getInvSession(), tdata);
-}
-
 bool
-SIPVoIPLink::transfer (const std::string& id, const std::string& to) throw (VoipLinkException)
+SIPVoIPLink::transfer (const std::string& id, const std::string& to)
 {
-
-    std::string tmp_to;
-    pjsip_evsub *sub;
-    pjsip_tx_data *tdata;
-
-    struct pjsip_evsub_user xfer_cb;
-    pj_status_t status;
-
     SIPCall *call = getSIPCall (id);
-    if (call == NULL) {
+    if (call == NULL)
     	throw VoipLinkException("Could not find call");
-    }
 
     call->stopRecording();
 
-    std::string account_id = Manager::instance().getAccountFromCall (id);
-    SIPAccount *account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id));
-    if (account == NULL) {
+    std::string account_id(Manager::instance().getAccountFromCall(id));
+    SIPAccount *account = dynamic_cast<SIPAccount *>(Manager::instance().getAccount (account_id));
+    if (account == NULL)
     	throw VoipLinkException("Could not find account");
-    }
 
     std::string dest;
     pj_str_t pjDest;
 
     if (to.find ("@") == std::string::npos) {
-        dest = account->getToUri (to);
+        dest = account->getToUri(to);
         pj_cstr (&pjDest, dest.c_str());
     }
 
     _info ("UserAgent: Transfering to %s", dest.c_str());
 
+    pjsip_evsub_user xfer_cb;
     /* Create xfer client subscription. */
     pj_bzero (&xfer_cb, sizeof (xfer_cb));
     xfer_cb.on_evsub_state = &transfer_client_cb;
 
-    status = pjsip_xfer_create_uac (call->getInvSession()->dlg, &xfer_cb, &sub);
-    if (status != PJ_SUCCESS) {
+    pjsip_evsub *sub;
+    pj_status_t status = pjsip_xfer_create_uac (call->getInvSession()->dlg, &xfer_cb, &sub);
+    if (status != PJ_SUCCESS)
     	throw VoipLinkException("Could not create xfer request");
-    }
 
     /* Associate this voiplink of call with the client subscription
      * We can not just associate call with the client subscription
@@ -944,13 +899,14 @@ SIPVoIPLink::transfer (const std::string& id, const std::string& to) throw (Voip
     /*
      * Create REFER request.
      */
+    pjsip_tx_data *tdata;
+
     status = pjsip_xfer_initiate (sub, &pjDest, &tdata);
-    if (status != PJ_SUCCESS) {
+    if (status != PJ_SUCCESS)
     	throw VoipLinkException("Could not create REFER request");
-    }
 
     // Put SIP call id in map in order to retrieve call during transfer callback
-    std::string callidtransfer (call->getInvSession()->dlg->call_id->id.ptr, call->getInvSession()->dlg->call_id->id.slen);
+    std::string callidtransfer(call->getInvSession()->dlg->call_id->id.ptr, call->getInvSession()->dlg->call_id->id.slen);
     transferCallID.insert (std::pair<std::string, std::string> (callidtransfer, call->getCallId()));
 
     /* Send. */
@@ -1031,7 +987,6 @@ bool SIPVoIPLink::attendedTransfer(const std::string& transferId, const std::str
     _debug ("%s", callidtransfer.c_str());
     transferCallID.insert (std::pair<std::string, std::string> (callidtransfer, transferCall->getCallId()));
 
-
     /* Send. */
     return pjsip_xfer_send_request (sub, tdata) == PJ_SUCCESS;
 }
@@ -2411,6 +2366,28 @@ void SIPVoIPLink::pjsipShutdown (void)
     pj_shutdown();
 }
 
+namespace {
+int SIPSessionReinvite (SIPCall *call)
+{
+    pjsip_tx_data *tdata;
+
+    _debug("UserAgent: Sending re-INVITE request");
+
+    pjmedia_sdp_session *local_sdp = call->getLocalSDP()->getLocalSdpSession();
+    if (!local_sdp) {
+        _debug ("UserAgent: Error: Unable to find local sdp");
+        return !PJ_SUCCESS;
+    }
+
+    // Build the reinvite request
+    pj_status_t status = pjsip_inv_reinvite (call->getInvSession(), NULL, local_sdp, &tdata);
+    if (status != PJ_SUCCESS)
+        return status;
+
+    // Send it
+    return pjsip_inv_send_msg (call->getInvSession(), tdata);
+}
+
 int getModId()
 {
     return _mod_ua.id;
@@ -3080,9 +3057,8 @@ transaction_request_cb (pjsip_rx_data *rdata)
         std::string header_value(fetchHeaderValue (rdata->msg_info.msg, Manager::instance().hookPreference.getUrlSipField()));
 
         if (header_value.size () < header_value.max_size()) {
-            if (not header_value.empty()) {
+            if (not header_value.empty())
                 UrlHook::runAction (Manager::instance().hookPreference.getUrlCommand(), header_value);
-            }
         } else
             throw std::length_error ("UserAgent: Url exceeds std::string max_size");
     }
@@ -3486,27 +3462,6 @@ std::string fetchHeaderValue (pjsip_msg *msg, std::string field)
     return value.substr (0, pos);
 }
 
-std::vector<std::string> SIPVoIPLink::getAllIpInterface (void)
-{
-    pj_sockaddr addrList[16];
-    unsigned int addrCnt = PJ_ARRAY_SIZE (addrList);
-
-    std::vector<std::string> ifaceList;
-
-    if (pj_enum_ip_interface (pj_AF_INET(), &addrCnt, addrList) != PJ_SUCCESS)
-        return ifaceList;
-
-    for (int i = 0; i < (int) addrCnt; i++) {
-        char tmpAddr[PJ_INET_ADDRSTRLEN];
-        pj_sockaddr_print (&addrList[i], tmpAddr, sizeof (tmpAddr), 0);
-        ifaceList.push_back (std::string (tmpAddr));
-        _debug ("Local interface %s", tmpAddr);
-    }
-
-    return ifaceList;
-}
-
-
 static int get_iface_list (struct ifconf *ifconf)
 {
     int sock, rval;
@@ -3521,6 +3476,7 @@ static int get_iface_list (struct ifconf *ifconf)
 
     return rval;
 }
+} // end anonymous namespace
 
 std::vector<std::string> SIPVoIPLink::getAllIpInterfaceByName (void)
 {
@@ -3574,3 +3530,25 @@ std::string SIPVoIPLink::getInterfaceAddrFromName (std::string ifaceName)
 
     return addr;
 }
+
+std::vector<std::string> SIPVoIPLink::getAllIpInterface (void)
+{
+    pj_sockaddr addrList[16];
+    unsigned int addrCnt = PJ_ARRAY_SIZE (addrList);
+
+    std::vector<std::string> ifaceList;
+
+    if (pj_enum_ip_interface (pj_AF_INET(), &addrCnt, addrList) != PJ_SUCCESS)
+        return ifaceList;
+
+    for (int i = 0; i < (int) addrCnt; i++) {
+        char tmpAddr[PJ_INET_ADDRSTRLEN];
+        pj_sockaddr_print (&addrList[i], tmpAddr, sizeof (tmpAddr), 0);
+        ifaceList.push_back (std::string (tmpAddr));
+        _debug ("Local interface %s", tmpAddr);
+    }
+
+    return ifaceList;
+}
+
+
diff --git a/daemon/src/sip/sipvoiplink.h b/daemon/src/sip/sipvoiplink.h
index 3536cdee1d..859fd2d5e3 100644
--- a/daemon/src/sip/sipvoiplink.h
+++ b/daemon/src/sip/sipvoiplink.h
@@ -108,7 +108,7 @@ class SIPVoIPLink : public VoIPLink
         /**
          * Build and send SIP unregistration request
          */
-        virtual void sendUnregister (Account *a) throw(VoipLinkException);
+        virtual void sendUnregister (Account *a);
 
         /**
          * Place a new call
@@ -116,45 +116,45 @@ class SIPVoIPLink : public VoIPLink
          * @param toUrl  The Sip address of the recipient of the call
          * @return Call* The current call
          */
-        virtual Call* newOutgoingCall (const std::string& id, const std::string& toUrl) throw (VoipLinkException);
+        virtual Call* newOutgoingCall (const std::string& id, const std::string& toUrl);
 
         /**
          * Answer the call
          * @param c The call
          */
-        virtual void answer (Call *c) throw (VoipLinkException);
+        virtual void answer (Call *c);
 
         /**
          * Hang up the call
          * @param id The call identifier
          */
-        virtual void hangup (const std::string& id) throw (VoipLinkException);
+        virtual void hangup (const std::string& id);
 
         /**
          * Hang up the call
          * @param id The call identifier
          */
-        virtual void peerHungup (const std::string& id) throw (VoipLinkException);
+        virtual void peerHungup (const std::string& id);
 
         /**
          * Cancel the call
          * @param id The call identifier
          */
-        virtual void cancel (const std::string& id) throw (VoipLinkException);
+        virtual void cancel (const std::string& id);
 
         /**
          * Put the call on hold
          * @param id The call identifier
          * @return bool True on success
          */
-        virtual bool onhold (const std::string& id) throw (VoipLinkException);
+        virtual bool onhold (const std::string& id);
 
         /**
          * Put the call off hold
          * @param id The call identifier
          * @return bool True on success
          */
-        virtual bool offhold (const std::string& id) throw (VoipLinkException);
+        virtual bool offhold (const std::string& id);
 
         /**
          * Transfer the call
@@ -162,7 +162,7 @@ class SIPVoIPLink : public VoIPLink
          * @param to The recipient of the transfer
          * @return bool True on success
          */
-        virtual bool transfer (const std::string& id, const std::string& to) throw (VoipLinkException);
+        virtual bool transfer (const std::string& id, const std::string& to);
 
         /**
          * Attended transfer
diff --git a/daemon/src/voiplink.h b/daemon/src/voiplink.h
index c7a96994a4..74f327bb3b 100644
--- a/daemon/src/voiplink.h
+++ b/daemon/src/voiplink.h
@@ -107,45 +107,45 @@ class VoIPLink
          * @param toUrl  The address of the recipient of the call
          * @return Call* The current call
          */
-        virtual Call* newOutgoingCall (const std::string& id, const std::string& toUrl) throw (VoipLinkException) = 0;
+        virtual Call* newOutgoingCall (const std::string& id, const std::string& toUrl) = 0;
 
         /**
          * Answer the call
          * @param c The call
          */
-        virtual void answer (Call *c) throw (VoipLinkException) = 0;
+        virtual void answer (Call *c) = 0;
 
         /**
          * Hang up a call
          * @param id The call identifier
          */
-        virtual void hangup (const std::string& id)  throw (VoipLinkException) = 0;
+        virtual void hangup (const std::string& id) = 0;
 
         /**
         * Peer Hung up a call
         * @param id The call identifier
         */
-        virtual void peerHungup (const std::string& id) throw (VoipLinkException) = 0;
+        virtual void peerHungup (const std::string& id) = 0;
 
         /**
          * Cancel the call dialing
          * @param id The call identifier
          */
-        virtual void cancel (const std::string& id) throw (VoipLinkException) = 0;
+        virtual void cancel (const std::string& id) = 0;
 
         /**
          * Put a call on hold
          * @param id The call identifier
          * @return bool True on success
          */
-        virtual bool onhold (const std::string& id) throw (VoipLinkException) = 0;
+        virtual bool onhold (const std::string& id) = 0;
 
         /**
          * Resume a call from hold state
          * @param id The call identifier
          * @return bool True on success
          */
-        virtual bool offhold (const std::string& id) throw (VoipLinkException) = 0;
+        virtual bool offhold (const std::string& id) = 0;
 
         /**
          * Transfer a call to specified URI
@@ -153,7 +153,7 @@ class VoIPLink
          * @param to The recipient of the call
          * @return bool True on success
          */
-        virtual bool transfer (const std::string& id, const std::string& to) throw (VoipLinkException) = 0;
+        virtual bool transfer (const std::string& id, const std::string& to) = 0;
 
         /**
          * Attended transfer
-- 
GitLab