Skip to content
Snippets Groups Projects
Select Git revision
  • 39cd6e5c12bfb7fdc635c48e48d00798a0afe46d
  • master default protected
  • react
3 results

ServerParameters.tsx

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ip_utils.cpp 9.84 KiB
    /*
     *  Copyright (C) 2004-2019 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.
     */
    
    #include "ip_utils.h"
    #ifdef s_addr
        #undef s_addr
    #endif
    #include "logger.h"
    
    #include "sip/sip_utils.h"
    
    #include <sys/types.h>
    #include <unistd.h>
    #include <limits.h>
    
    #if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
    #include "client/ring_signal.h"
    #endif
    
    #ifdef _WIN32
    #define InetPtonA inet_pton
    WINSOCK_API_LINKAGE INT WSAAPI InetPtonA(INT Family, LPCSTR pStringBuf, PVOID pAddr);
    #endif
    
    #ifndef HOST_NAME_MAX
    #ifdef MAX_COMPUTERNAME_LENGTH
    #define HOST_NAME_MAX MAX_COMPUTERNAME_LENGTH
    #else
    // Max 255 chars as per RFC 1035
    #define HOST_NAME_MAX 255
    #endif
    #endif
    
    namespace jami {
    
    std::string
    ip_utils::getHostname()
    {
        char hostname[HOST_NAME_MAX];
        if (gethostname(hostname, HOST_NAME_MAX))
            return {};
        return hostname;
    }
    
    std::string
    ip_utils::getDeviceName()
    {
    #if defined(__ANDROID__) || defined(RING_UWP) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
        std::vector<std::string> deviceNames;
        emitSignal<DRing::ConfigurationSignal::GetDeviceName>(&deviceNames);
        if (not deviceNames.empty()) {
            return deviceNames[0];
        }