diff --git a/src/doc/man/svxlink.conf.5 b/src/doc/man/svxlink.conf.5 index caa1161d..13a2cdd4 100644 --- a/src/doc/man/svxlink.conf.5 +++ b/src/doc/man/svxlink.conf.5 @@ -870,6 +870,16 @@ a compressor with a very steep compression ratio like 10:1. The limiter is used to help keeping down the audio level from Sip network for overmodulating stations. Try values from -6 to -12 if the incoming Sip audio is to high. Set to 0 to deactivate it. +.TP +.B PHONENUMBER_TO_TG +Comma-separated list of assignments of phonenumber(full||substring):Talkgroup. +When a phone call is received, the call is assigned to the defined TG according +to the recognized number. This can be used to prevent the transfer of an SIP +call to a network or to carry out a country-specific assignment. The number +format transmitted must match the configuration (+49 != 0049). Whole SIP +numbers as well as parts of phone numbers can be configured, with the +evaluation taking place on the left-hand side. +Example: PHONENUMBER_TO_TG=0049:262,0034:214,0043:232,0049123454543:991 . .SS QSO Recorder Section . diff --git a/src/svxlink/svxlink/SipLogic.cpp b/src/svxlink/svxlink/SipLogic.cpp index 0bd01349..36fb72ed 100644 --- a/src/svxlink/svxlink/SipLogic.cpp +++ b/src/svxlink/svxlink/SipLogic.cpp @@ -56,6 +56,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include +#include /**************************************************************************** @@ -88,7 +89,7 @@ using namespace pj; * ****************************************************************************/ #define DEFAULT_SIPLIMITER_THRESH -1.0 -#define PJSIP_VERSION "30052022" +#define PJSIP_VERSION "03062022" /**************************************************************************** @@ -532,6 +533,30 @@ bool SipLogic::initialize(void) return false; } + // set Tg's depending on the incoming sip phone number + std::string phonenumbers_to_tg; + if (cfg().getValue(name(), "PHONENUMBERS_TO_TG", phonenumbers_to_tg)) + { + vector nrlist; + SvxLink::splitStr(nrlist, phonenumbers_to_tg, ","); + for (vector::const_iterator nr_it = nrlist.begin(); + nr_it != nrlist.end(); nr_it++) + { + size_t pos; + if ((pos = (*nr_it).find(':')) != string::npos) + { + std::string r = (*nr_it).substr(0, pos); + uint32_t t = atoi((*nr_it).substr(pos+1, (*nr_it).length()-pos).c_str()); + phoneNrTgVec[r] = t; + } + else + { + cout << "+++ WARNING: Wrong format in param " << name() + << "/PHONENUMBERS_TO_TG, ignoring." << endl; + } + } + } + // create SipEndpoint - init library try { pj::EpConfig ep_cfg; @@ -886,6 +911,17 @@ void SipLogic::onIncomingCall(sip::_Account *acc, pj::OnIncomingCallParam &iprm) std::string caller = getCallerNumber(ci.remoteUri); + for (std::map::const_iterator it = phoneNrTgVec.begin(); + it != phoneNrTgVec.end(); it++) + { + size_t pos; + if ((pos = caller.find(it->first)) == 0) + { + uint32_t tg = it->second; + setReceivedTg(tg); + } + } + stringstream ss; ss << "ringing \"" << caller << "\""; processLogicEvent(ss.str()); @@ -1086,6 +1122,8 @@ void SipLogic::onCallState(sip::_Call *call, pj::OnCallStateParam &prm) << ci.totalDuration.sec << "." << ci.totalDuration.msec; + setReceivedTg(0); + // if no one is connected anymore, call out to autoconnect party if (calls.empty() && m_autoconnect.length() > 0) { diff --git a/src/svxlink/svxlink/SipLogic.h b/src/svxlink/svxlink/SipLogic.h index 55f36d4f..6860c300 100644 --- a/src/svxlink/svxlink/SipLogic.h +++ b/src/svxlink/svxlink/SipLogic.h @@ -203,6 +203,7 @@ class SipLogic : public LogicBase EventHandler *sip_event_handler; MsgHandler *sip_msg_handler; Async::AudioSelector *sipselector; + std::map phoneNrTgVec; SipLogic(const SipLogic&); SipLogic& operator=(const SipLogic&); diff --git a/src/svxlink/svxlink/svxlink.conf.in b/src/svxlink/svxlink/svxlink.conf.in index 9b774138..7085226b 100644 --- a/src/svxlink/svxlink/svxlink.conf.in +++ b/src/svxlink/svxlink/svxlink.conf.in @@ -135,6 +135,7 @@ SIP_CTRL_PTY=/tmp/sip_pty EVENT_HANDLER=@SVX_SHARE_INSTALL_DIR@/events.tcl SIP_PREAMP=3 SIP_LIMITER_THRESH=-1.0 +PHONENUMBER_TO_TG=0049:262,0034:232,0041:222,017612345678:9999 [LinkToR4] CONNECT_LOGICS=RepeaterLogic:94:SK3AB,SimplexLogic:92:SK3CD