LCOV - code coverage report
Current view: top level - src/sip - sipaccountbase_config.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 9 9 100.0 %
Date: 2024-05-02 09:40:27 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  This program is free software; you can redistribute it and/or modify
       5             :  *  it under the terms of the GNU General Public License as published by
       6             :  *  the Free Software Foundation; either version 3, or (at your option)
       7             :  *  any later version.
       8             :  *
       9             :  *  This program is distributed in the hope that it will be useful,
      10             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  *  GNU General Public License for more details.
      13             :  *
      14             :  *  You should have received a copy of the GNU General Public License
      15             :  *  along with this program; if not, see <https://www.gnu.org/licenses/>.
      16             :  */
      17             : #pragma once
      18             : #include "account_config.h"
      19             : 
      20             : namespace jami {
      21             : constexpr static const char* const OVERRTP_STR = "overrtp";
      22             : constexpr static const char* const SIPINFO_STR = "sipinfo";
      23             : constexpr static unsigned MAX_PORT {65536};
      24             : constexpr static unsigned HALF_MAX_PORT {MAX_PORT / 2};
      25             : 
      26             : struct SipAccountBaseConfig: public AccountConfig {
      27         764 :     SipAccountBaseConfig(const std::string& type, const std::string& id, const std::filesystem::path& path)
      28        1528 :         : AccountConfig(type, id, path) {}
      29             : 
      30             :     void serializeDiff(YAML::Emitter& out, const SipAccountBaseConfig& def) const;
      31             :     void unserialize(const YAML::Node& node) override;
      32             : 
      33             :     std::map<std::string, std::string> toMap() const override;
      34             :     void fromMap(const std::map<std::string, std::string>&) override;
      35             : 
      36             :     /**
      37             :      * interface name on which this account is bound
      38             :      */
      39             :     std::string interface {"default"};
      40             : 
      41             :     /**
      42             :      * Flag which determine if localIpAddress_ or publishedIpAddress_ is used in
      43             :      * sip headers
      44             :      */
      45             :     bool publishedSameasLocal {true};
      46             : 
      47             :     std::string publishedIp;
      48             : 
      49             :     /**
      50             :      * Determine if TURN public address resolution is required to register this account. In this
      51             :      * case a TURN server hostname must be specified.
      52             :      */
      53             :     bool turnEnabled {false};
      54             : 
      55             :     /**
      56             :      * The TURN server hostname (optional), used to provide the public IP address in case the
      57             :      * softphone stay behind a NAT.
      58             :      */
      59             :     std::string turnServer;
      60             :     std::string turnServerUserName;
      61             :     std::string turnServerPwd;
      62             :     std::string turnServerRealm;
      63             : 
      64             :     std::string tlsCaListFile;
      65             :     std::string tlsCertificateFile;
      66             :     std::string tlsPrivateKeyFile;
      67             :     std::string tlsPassword;
      68             : 
      69             :     std::string dtmfType {OVERRTP_STR};
      70             :     /*
      71             :      * Port range for audio RTP ports
      72             :      */
      73         764 :     std::pair<uint16_t, uint16_t> audioPortRange {16384, 32766};
      74             : 
      75             :     /**
      76             :      * Port range for video RTP ports
      77             :      */
      78         764 :     std::pair<uint16_t, uint16_t> videoPortRange {49152, (65536) -2};
      79             : };
      80             : 
      81             : inline void
      82        1906 : updateRange(uint16_t min, uint16_t max, std::pair<uint16_t, uint16_t>& range)
      83             : {
      84        1906 :     if (min > 0 and (max > min) and max <= MAX_PORT - 2) {
      85        1024 :         range.first = min;
      86        1024 :         range.second = max;
      87             :     }
      88        1906 : }
      89             : 
      90             : }

Generated by: LCOV version 1.14