diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am index c65900f7fe8da90d61814a0ae82f0f40cd2978e0..bd4f4eb171a95d0463087132831c4d487c19cbec 100644 --- a/daemon/src/Makefile.am +++ b/daemon/src/Makefile.am @@ -85,6 +85,7 @@ libsflphone_la_SOURCES = conference.cpp \ numbercleaner.cpp \ fileutils.cpp \ sflthread.cpp \ + ip_utils.cpp \ sflthread.h \ conference.h \ voiplink.h \ diff --git a/daemon/src/call.h b/daemon/src/call.h index 839306a80748fad4723fcaf71986c9a078325607..a8b34d15a7a99fa269602c914ee0437e60c72566 100644 --- a/daemon/src/call.h +++ b/daemon/src/call.h @@ -35,7 +35,7 @@ #include "logger.h" #include "audio/recordable.h" -#include "sip/sip_utils.h" +#include "ip_utils.h" #include <mutex> #include <map> @@ -189,7 +189,7 @@ class Call : public Recordable { */ void setLocalIp(const pj_sockaddr& ip) { pj_sockaddr_cp(&localIPAddr_, &ip); - localIPAddress_ = sip_utils::addrToStr(localIPAddr_); + localIPAddress_ = ip_utils::addrToStr(localIPAddr_); } /** diff --git a/daemon/src/iax/iaxvoiplink.h b/daemon/src/iax/iaxvoiplink.h index d0ecd06bcba29c4d8287e8051248121d52e92b2d..1d8d7e3fbb8d548d1d307263213899fcbc5e0cca 100644 --- a/daemon/src/iax/iaxvoiplink.h +++ b/daemon/src/iax/iaxvoiplink.h @@ -75,8 +75,9 @@ class IAXVoIPLink : public VoIPLink { /* Returns a list of all callIDs */ - static std::vector<std::string> - getCallIDs(); + static std::vector<std::string> getCallIDs(); + + virtual std::vector<Call*> getCalls(const std::string &account_id) const; /** * Return the internal account map for all VOIP links diff --git a/daemon/src/ip_utils.cpp b/daemon/src/ip_utils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3d2a9783b76d97c18d9aa38f0a9c73b6bdbca451 --- /dev/null +++ b/daemon/src/ip_utils.cpp @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. + * + * Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#include "ip_utils.h" +#include "logger.h" + +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> +#include <arpa/inet.h> + +std::vector<pj_sockaddr> +ip_utils::getAddrList(const std::string &name) +{ + std::vector<pj_sockaddr> ipList; + if (name.empty()) + return ipList; + + static const unsigned MAX_ADDR_NUM = 128; + pj_addrinfo res[MAX_ADDR_NUM]; + unsigned addr_num = MAX_ADDR_NUM; + pj_str_t pjname; + pj_cstr(&pjname, name.c_str()); + auto status = pj_getaddrinfo(pj_AF_UNSPEC(), &pjname, &addr_num, res); + if (status != PJ_SUCCESS) { + ERROR("Error resolving %s :", name.c_str()); + //sip_strerror(status); + return ipList; + } + + for (unsigned i=0; i<addr_num; i++) { + bool found = false; + for (const auto& ip : ipList) + if (!pj_sockaddr_cmp(&ip, &res[i].ai_addr)) { + found = true; + break; + } + if (!found) + ipList.push_back(res[i].ai_addr); + } + + return ipList; +} + +std::string +ip_utils::addrToStr(const pj_sockaddr& ip, bool include_port, bool force_ipv6_brackets) +{ + std::string str(PJ_INET6_ADDRSTRLEN, (char)0); + if(include_port) force_ipv6_brackets = true; + pj_sockaddr_print(&ip, &(*str.begin()), PJ_INET6_ADDRSTRLEN, (include_port?1:0)|(force_ipv6_brackets?2:0)); + return str; +} + +std::string +ip_utils::addrToStr(const std::string& ip_str, bool include_port, bool force_ipv6_brackets) +{ + pj_sockaddr ip = strToAddr(ip_str); + if (ip.addr.sa_family == pj_AF_UNSPEC()) + return ip_str; + return addrToStr(ip, include_port, force_ipv6_brackets); +} + +pj_sockaddr +ip_utils::strToAddr(const std::string& str) +{ + pj_str_t pjstring; + pj_cstr(&pjstring, str.c_str()); + pj_sockaddr ip; + auto status = pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &pjstring, &ip); + if (status != PJ_SUCCESS) + ip.addr.sa_family = pj_AF_UNSPEC(); + return ip; +} + +pj_sockaddr +ip_utils::getAnyHostAddr(pj_uint16_t family) +{ + if (family == pj_AF_UNSPEC()) family = pj_AF_INET(); + pj_sockaddr addr = {}; + addr.addr.sa_family = family; + return addr; +} + +bool +ip_utils::isIPv6(const std::string &address) +{ + return isValidAddr(address, pj_AF_INET6()); +} + +bool +ip_utils::isValidAddr(const std::string &address, pj_uint16_t family) +{ + pj_str_t pjstring; + pj_cstr(&pjstring, address.c_str()); + pj_str_t ret_str; + pj_uint16_t ret_port; + int ret_family; + auto status = pj_sockaddr_parse2(pj_AF_UNSPEC(), 0, &pjstring, &ret_str, &ret_port, &ret_family); + if (status != PJ_SUCCESS || (family != pj_AF_UNSPEC() && ret_family != family)) + return false; + + char buf[PJ_INET6_ADDRSTRLEN]; + pj_str_t addr_with_null = {buf, 0}; + pj_strncpy_with_null(&addr_with_null, &ret_str, sizeof(buf)); + struct sockaddr sa; + return inet_pton(ret_family==pj_AF_INET6()?AF_INET6:AF_INET, buf, &(sa.sa_data)) == 1; +} diff --git a/daemon/src/ip_utils.h b/daemon/src/ip_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..e6410cf4f7efcc8e37c40067d5ae7b3c6f195dc4 --- /dev/null +++ b/daemon/src/ip_utils.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. + * + * Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#ifndef IP_UTILS_H_ +#define IP_UTILS_H_ + +#include <pjlib.h> + +#include <string> +#include <vector> + +namespace ip_utils { + /** + * Convert a binary IP address to a standard string representation. + */ + std::string addrToStr(const pj_sockaddr& ip, bool include_port = false, bool force_ipv6_brackets = false); + + /** + * Format an IP address string. If formating the address fails, the original string is returned. + */ + std::string addrToStr(const std::string& ip, bool include_port = false, bool force_ipv6_brackets = false); + + /** + * Convert a string representation of an IP adress to its binary counterpart. + * + * Performs hostname resolution if necessary. + * If conversion fails, returned adress will have its family set to PJ_AF_UNSPEC. + */ + pj_sockaddr strToAddr(const std::string& str); + + /** + * Returns true if address is a valid IPv6. + */ + bool isIPv6(const std::string &address); + bool isValidAddr(const std::string &address, pj_uint16_t family = pj_AF_UNSPEC()); + + std::vector<pj_sockaddr> getAddrList(const std::string &name); + + pj_sockaddr getAnyHostAddr(pj_uint16_t family = pj_AF_UNSPEC()); +} + +#endif // IP_UTILS_H_ diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp index 15b00e591583395be9a8fd97b4ac9dd28ae1ea67..f386128ed227bdbcd977cb31c049b642d1136939 100644 --- a/daemon/src/sip/sdp.cpp +++ b/daemon/src/sip/sdp.cpp @@ -30,18 +30,16 @@ * as that of the covered work. */ +#include "sdp.h" + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "sdp.h" -#include "logger.h" -#include "manager.h" - -#include <algorithm> -#include "sipaccount.h" #include "sipaccount.h" - +#include "manager.h" +#include "logger.h" +#include "ip_utils.h" #ifdef SFL_VIDEO #include "video/libav_utils.h" @@ -353,14 +351,14 @@ void Sdp::addRTCPAttribute(pjmedia_sdp_media *med) void Sdp::setPublishedIP(const std::string &ip_addr) { - setPublishedIP(sip_utils::strToAddr(ip_addr)); + setPublishedIP(ip_utils::strToAddr(ip_addr)); } void Sdp::setPublishedIP(const pj_sockaddr& ip_addr) { publishedIpAddr_ = ip_addr; - publishedIpAddrStr_ = sip_utils::addrToStr(publishedIpAddr_); + publishedIpAddrStr_ = ip_utils::addrToStr(publishedIpAddr_); if (localSession_) { if (publishedIpAddr_.addr.sa_family == pj_AF_INET6()) diff --git a/daemon/src/sip/sip_utils.cpp b/daemon/src/sip/sip_utils.cpp index d8110b7f9e97092bf630610ab04a43e11da850cb..48df5f46759180770650918ee4e40d853e335624 100644 --- a/daemon/src/sip/sip_utils.cpp +++ b/daemon/src/sip/sip_utils.cpp @@ -33,13 +33,11 @@ #include "logger.h" #include <pjsip.h> -#include <pjlib.h> #include <pjsip_ua.h> #include <pjlib-util.h> #include <pjnath.h> #include <pjnath/stun_config.h> #include <pj/string.h> -#include <pjsip/sip_msg.h> #include <pjsip/sip_types.h> #include <pjsip/sip_uri.h> #include <pj/list.h> @@ -193,9 +191,11 @@ sip_utils::getIPList(const std::string &name) if (name.empty()) return ipList; + //ERROR("sip_utils::getIPList %s", name.c_str()); + struct addrinfo *result; - struct addrinfo hints; - memset(&hints, '\0', sizeof(hints)); + struct addrinfo hints = {}; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_ADDRCONFIG; /* resolve the domain name into a list of addresses */ @@ -234,70 +234,6 @@ sip_utils::getIPList(const std::string &name) return ipList; } -std::string -sip_utils::addrToStr(const pj_sockaddr& ip, bool include_port, bool force_ipv6_brackets) -{ - std::string str(PJ_INET6_ADDRSTRLEN, (char)0); - if(include_port) force_ipv6_brackets = true; - pj_sockaddr_print(&ip, &(*str.begin()), PJ_INET6_ADDRSTRLEN, (include_port?1:0)|(force_ipv6_brackets?2:0)); - return str; -} - -std::string -sip_utils::addrToStr(const std::string& ip_str, bool include_port, bool force_ipv6_brackets) -{ - pj_sockaddr ip = strToAddr(ip_str); - if (ip.addr.sa_family == pj_AF_UNSPEC()) - return ip_str; - return addrToStr(ip, include_port, force_ipv6_brackets); -} - -pj_sockaddr -sip_utils::strToAddr(const std::string& str) -{ - pj_str_t pjstring; - pj_cstr(&pjstring, str.c_str()); - pj_sockaddr ip; - auto status = pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &pjstring, &ip); - if (status != PJ_SUCCESS) - ip.addr.sa_family = pj_AF_UNSPEC(); - return ip; -} - -pj_sockaddr -sip_utils::getAnyHostAddr(pj_uint16_t family) -{ - if (family == pj_AF_UNSPEC()) family = pj_AF_INET(); - pj_sockaddr addr = {}; - addr.addr.sa_family = family; - return addr; -} - -bool -sip_utils::isIPv6(const std::string &address) -{ - return isValidAddr(address, pj_AF_INET6()); -} - -bool -sip_utils::isValidAddr(const std::string &address, pj_uint16_t family) -{ - pj_str_t pjstring; - pj_cstr(&pjstring, address.c_str()); - pj_str_t ret_str; - pj_uint16_t ret_port; - int ret_family; - auto status = pj_sockaddr_parse2(pj_AF_UNSPEC(), 0, &pjstring, &ret_str, &ret_port, &ret_family); - if (status != PJ_SUCCESS || (family != pj_AF_UNSPEC() && ret_family != family)) - return false; - - char buf[PJ_INET6_ADDRSTRLEN]; - pj_str_t addr_with_null = {buf, 0}; - pj_strncpy_with_null(&addr_with_null, &ret_str, sizeof(buf)); - struct sockaddr sa; - return inet_pton(ret_family==pj_AF_INET6()?AF_INET6:AF_INET, buf, &(sa.sa_data)) == 1; -} - void sip_utils::addContactHeader(const pj_str_t *contact_str, pjsip_tx_data *tdata) { @@ -308,3 +244,12 @@ sip_utils::addContactHeader(const pj_str_t *contact_str, pjsip_tx_data *tdata) pjsip_msg_find_remove_hdr(tdata->msg, PJSIP_H_CONTACT, NULL); pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) contact); } + + +void +sip_utils::sip_strerror(pj_status_t code) +{ + char err_msg[PJ_ERR_MSG_SIZE]; + pj_strerror(code, err_msg, sizeof err_msg); + ERROR("%d: %s", code, err_msg); +} diff --git a/daemon/src/sip/sip_utils.h b/daemon/src/sip/sip_utils.h index 5bc69fa30422a926ba5707662957f59b3bc63225..c4d1188151e79ed922d192292d3c107ef28bc740 100644 --- a/daemon/src/sip/sip_utils.h +++ b/daemon/src/sip/sip_utils.h @@ -57,35 +57,11 @@ namespace sip_utils { std::string getHostFromUri(const std::string& sipUri); - /** - * Convert a binary IP address to a standard string representation. - */ - std::string addrToStr(const pj_sockaddr& ip, bool include_port = false, bool force_ipv6_brackets = false); - - /** - * Format an IP address string. If formating the address fails, the original string is returned. - */ - std::string addrToStr(const std::string& ip, bool include_port = false, bool force_ipv6_brackets = false); - - /** - * Convert a string representation of an IP adress to its binary counterpart. - * - * Performs hostname resolution if necessary. - * If conversion fails, returned adress will have its family set to PJ_AF_UNSPEC. - */ - pj_sockaddr strToAddr(const std::string& str); - - /** - * Returns true if address is a valid IPv6. - */ - bool isIPv6(const std::string &address); - bool isValidAddr(const std::string &address, pj_uint16_t family = pj_AF_UNSPEC()); - std::vector<std::string> getIPList(const std::string &name); - pj_sockaddr getAnyHostAddr(pj_uint16_t family = pj_AF_UNSPEC()); - void addContactHeader(const pj_str_t *contactStr, pjsip_tx_data *tdata); + + void sip_strerror(pj_status_t code); } #endif // SIP_UTILS_H_ diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index 55c05cff4787b1763fcdf4194b6c6c39e18fc859..61e0f8891c1faf73b060bb18b2c14175368b8dc5 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -31,28 +31,32 @@ */ #include "sipaccount.h" + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "account_schema.h" #include "sipvoiplink.h" -#include "config/yamlnode.h" -#include "config/yamlemitter.h" -#include "logger.h" -#include "manager.h" +#include "sip_utils.h" #ifdef SFL_PRESENCE #include "sippresence.h" #include "client/configurationmanager.h" #endif +#include "account_schema.h" +#include "config/yamlnode.h" +#include "config/yamlemitter.h" +#include "logger.h" +#include "manager.h" + #ifdef SFL_VIDEO #include "video/libav_utils.h" #endif #include <unistd.h> #include <pwd.h> + #include <algorithm> #include <array> #include <memory> @@ -1237,8 +1241,8 @@ SIPAccount::getContactHeader() port = publishedPort_; DEBUG("Using published address %s and port %d", address.c_str(), port); } else if (stunEnabled_) { - link_->sipTransport->findLocalAddressFromSTUN(transport_, &stunServerName_, stunPort_, address, port); - setPublishedAddress(sip_utils::strToAddr(address)); + link_.sipTransport->findLocalAddressFromSTUN(transport_, &stunServerName_, stunPort_, address, port); + setPublishedAddress(ip_utils::strToAddr(address)); publishedPort_ = port; usePublishedAddressPortInVIA(); } else { @@ -1258,8 +1262,8 @@ SIPAccount::getContactHeader() std::string transport; /* Enclose IPv6 address in square brackets */ - if (transportType > PJSIP_TRANSPORT_IPV6 || sip_utils::isIPv6(address)) { - address = sip_utils::addrToStr(address, false, true); + if (transportType > PJSIP_TRANSPORT_IPV6 || ip_utils::isIPv6(address)) { + address = ip_utils::addrToStr(address, false, true); } if (transportType != PJSIP_TRANSPORT_UDP and transportType != PJSIP_TRANSPORT_UDP6) { diff --git a/daemon/src/sip/sipaccount.h b/daemon/src/sip/sipaccount.h index accf25b2ff17a4363fff55039bf7fe7366627add..837d8cbe454c65d35bc1cd56c024d6996f81eb58 100644 --- a/daemon/src/sip/sipaccount.h +++ b/daemon/src/sip/sipaccount.h @@ -39,8 +39,7 @@ #include "config.h" #endif #include "noncopyable.h" -#include "account.h" -#include "sip_utils.h" +#include "ip_utils.h" #include <pjsip/sip_transport_tls.h> #include <pjsip/sip_types.h> @@ -477,7 +476,7 @@ class SIPAccount : public Account { void setPublishedAddress(const pj_sockaddr& ip_addr) { pj_sockaddr_cp(&publishedIp_, &ip_addr); - publishedIpAddress_ = sip_utils::addrToStr(ip_addr); + publishedIpAddress_ = ip_utils::addrToStr(ip_addr); } std::string getServiceRoute() const { diff --git a/daemon/src/sip/siptransport.cpp b/daemon/src/sip/siptransport.cpp index 9e689bb5cfc6cd6f23243ed264cc99fb2c08d3df..30222c77e052b36772acc507c6e2eab620b234e8 100644 --- a/daemon/src/sip/siptransport.cpp +++ b/daemon/src/sip/siptransport.cpp @@ -31,9 +31,12 @@ #include "siptransport.h" #include "sipaccount.h" +#include "sipvoiplink.h" +#include "sip_utils.h" #include "manager.h" #include "client/configurationmanager.h" +#include "ip_utils.h" #include <pjsip.h> #include <pjsip_ua.h> @@ -236,7 +239,7 @@ SipTransport::createUdpTransport(const std::string &interface, pj_uint16_t port, { pj_sockaddr listeningAddress; if (interface == DEFAULT_INTERFACE) - listeningAddress = sip_utils::getAnyHostAddr(family); + listeningAddress = ip_utils::getAnyHostAddr(family); else listeningAddress = getInterfaceAddr(interface, family == pj_AF_INET6()); @@ -251,19 +254,19 @@ SipTransport::createUdpTransport(const std::string &interface, pj_uint16_t port, status = pjsip_udp_transport_start(endpt_, &listeningAddress.ipv4, nullptr, 1, &transport); if (status != PJ_SUCCESS) { ERROR("UDP IPV4 Transport did not start"); - sip_strerror(status); + sip_utils::sip_strerror(status); return nullptr; } } else if (listeningAddress.addr.sa_family == pj_AF_INET6()) { status = pjsip_udp_transport_start6(endpt_, &listeningAddress.ipv6, nullptr, 1, &transport); if (status != PJ_SUCCESS) { ERROR("UDP IPV6 Transport did not start"); - sip_strerror(status); + sip_utils::sip_strerror(status); return nullptr; } } - DEBUG("Created UDP transport on %s : %s", interface.c_str(), sip_utils::addrToStr(listeningAddress, true, true).c_str()); + DEBUG("Created UDP transport on %s : %s", interface.c_str(), ip_utils::addrToStr(listeningAddress, true, true).c_str()); // dump debug information to stdout pjsip_tpmgr_dump_transports(pjsip_endpt_get_tpmgr(endpt_)); return transport; @@ -278,7 +281,7 @@ SipTransport::createTlsListener(SIPAccount &account, pj_uint16_t family) std::string interface(account.getLocalInterface()); pj_sockaddr listeningAddress; if (interface == DEFAULT_INTERFACE) - listeningAddress = sip_utils::getAnyHostAddr(family); + listeningAddress = ip_utils::getAnyHostAddr(family); else listeningAddress = getInterfaceAddr(interface, family==pj_AF_INET6()); @@ -286,15 +289,15 @@ SipTransport::createTlsListener(SIPAccount &account, pj_uint16_t family) RETURN_IF_FAIL(not listeningAddress.addr.sa_family == pj_AF_UNSPEC(), nullptr, "Could not determine IP address for this transport"); - DEBUG("Creating Listener..."); + DEBUG("Creating Listener on %s...", ip_utils::addrToStr(listeningAddress).c_str()); DEBUG("CRT file : %s", account.getTlsSetting()->ca_list_file.ptr); DEBUG("PEM file : %s", account.getTlsSetting()->cert_file.ptr); pjsip_tpfactory *listener = nullptr; const pj_status_t status = pjsip_tls_transport_start2(endpt_, account.getTlsSetting(), &listeningAddress, nullptr, 1, &listener); if (status != PJ_SUCCESS) { - ERROR("TLS IPv6 Transport did not start"); - sip_strerror(status); + ERROR("TLS Transport did not start"); + sip_utils::sip_strerror(status); return nullptr; } return listener; @@ -478,10 +481,3 @@ SipTransport::findLocalAddressFromSTUN(pjsip_transport *transport, } #undef RETURN_IF_NULL - -void sip_strerror(pj_status_t code) -{ - char err_msg[PJ_ERR_MSG_SIZE]; - pj_strerror(code, err_msg, sizeof err_msg); - ERROR("%d: %s", code, err_msg); -} diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 31f11740029e99c2b15951c90846231b79fd406d..dec8ad5c5423fd48835f11cdd782dcb02a2ffd43 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -338,7 +338,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) peerNumber = remote_user + "@" + remote_hostname; //DEBUG("transaction_request_cb host %s userName %s addrToUse %s addrSdp %s remote_user %s remote_hostname %s" , - //server.c_str(), userName.c_str(), sip_utils::addrToStr(addrToUse).c_str(), sip_utils::addrToStr(addrSdp).c_str(), remote_user.c_str(), remote_hostname.c_str()); + //server.c_str(), userName.c_str(), ip_utils::addrToStr(addrToUse).c_str(), ip_utils::addrToStr(addrSdp).c_str(), remote_user.c_str(), remote_hostname.c_str()); call->setConnectionState(Call::PROGRESSING); call->setPeerNumber(peerNumber); @@ -727,7 +727,7 @@ bool SIPVoIPLink::getEvent() pj_status_t ret; if ((ret = pjsip_endpt_handle_events(endpt_, &timeout)) != PJ_SUCCESS) - sip_strerror(ret); + sip_utils::sip_strerror(ret); #ifdef SFL_VIDEO dequeKeyframeRequests(); @@ -830,7 +830,7 @@ SIPVoIPLink::sendRegister(Account& a) pj_status_t status; if ((status = pjsip_regc_send(regc, tdata)) != PJ_SUCCESS) { - sip_strerror(status); + sip_utils::sip_strerror(status); throw VoipLinkException("Unable to send account registration request"); } @@ -860,7 +860,7 @@ void SIPVoIPLink::sendUnregister(Account& a) pj_status_t status; if ((status = pjsip_regc_send(regc, tdata)) != PJ_SUCCESS) { - sip_strerror(status); + sip_utils::sip_strerror(status); throw VoipLinkException("Unable to send request to unregister sip account"); } @@ -914,7 +914,7 @@ Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toU sip_utils::stripSipUriPrefix(toCpy); - const bool IPToIP = sip_utils::isValidAddr(toCpy); + const bool IPToIP = ip_utils::isValidAddr(toCpy); Manager::instance().setIPToIPForCall(id, IPToIP); if (IPToIP) { @@ -926,8 +926,8 @@ Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toU Call *SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to_raw) { - bool ipv6 = sip_utils::isIPv6(to_raw); - const std::string& to = ipv6 ? sip_utils::addrToStr(to_raw, false, true) : to_raw; + bool ipv6 = ip_utils::isIPv6(to_raw); + const std::string& to = ipv6 ? ip_utils::addrToStr(to_raw, false, true) : to_raw; DEBUG("New %s IP to IP call to %s", ipv6?"IPv6":"IPv4", to.c_str()); SIPAccount *account = Manager::instance().getIP2IPAccount(); @@ -1640,7 +1640,7 @@ SIPVoIPLink::SIPStartCall(SIPCall *call) std::string account_id(call->getAccountId()); SIPAccount *account = Manager::instance().getSipAccount(account_id); - if (account == NULL) { + if (!account) { ERROR("Account is NULL in SIPStartCall"); return false; }