----- Original Message ----- From: "Christophe Sollet" <csollet@xxxxxxxxxxxxxxxx> To: <openh323gk-developer@xxxxxxxxxxxxxxxxxxxxx> Sent: Thursday, February 19, 2004 3:52 PM Subject: [Openh323gk-developer] Various 2.0 branch patch > Hi all, > > I've wrote several GnuGK V2.0.X patch for the need of our VoIP Network, > mostly based on GnuGK and Quintum equipments. > There are all used on our production servers without any problems for now. > Review and comments are welcome. > > Regards, > Christophe. > > ======================================== > > Basic LCR (basiclcr.patch) > ------------ > > Introduce two new Configuration section: [RasSrv::GWMaxCall] and > [RasSrv::GWPriority] . This two sections can be used to do basic LCR > > Section [RasSrv::GWMaxCall] > This section places a limit on the number of call that can be > simultaneously routed to a specific gateway. The default gateway max > call value is –1 (ie: no limit) > > Format*:* > |gw-alias=gw-capacity| > > Section [RasSrv::GWPriority] > This section allow to associate a priority to a specific gateway. The > priority is used to select a gateway when more than one gateway can > handle a call with the same prefix match. The default gateway priority > is 0 (lowest priority). When gateways have the same priority, default > round-robin selection applies. > > Format*:* > |gw-alias=gw-priority| > > ======================================== > > URQ Features (urqfeatures.patch) > ----------------- > > Introduce a new Configuration section, [RasSrv::URQFeatures]. > > Section [RasSrv::URQFeatures] > > - ExpireWithCallInProgress = 0 > Default : 1 > > When set to 0, a gateway will not be unregistered with reason ttlExpired > while there are active calls on this gateway. > > - RejectWithCallInProgress = 1 > Default : 0 > > When set to 1, URQ from gateway are rejected with URJ reason > callInProgress if there are active calls on the gateway. > > > ======================================== > > > Unconditional accept of call signalling address (uacsa.patch) > ------------------------------------------------------- > > A bit more exotic patch that allow the gatekeeper to accept invalid call > signalling address. We need this function to dynamically and externally > NAT the private address to publics ones. > > Add a configuration option to the section [RoutedMode] > > UnconditionalAcceptCSANetwork = 192.168.3.0/24 > Default : 0.0.0.0/32 > > IP address that in the defined network will be accepted even if it’s > doesn’t match the RRQ source. > > -- > Christophe Sollet > > Phone Systems & Network > 22, rue Mozart > 92110 Clichy > Telephone: +33 (0) 1 41 40 30 00 > Fax: +33 (0) 1 41 40 30 16 > > http://www.phonesystems.fr/ > > > > ---------------------------------------------------------------------------- ---- > Index: RasSrv.cxx > =================================================================== > RCS file: /cvsroot/openh323gk/openh323gk/RasSrv.cxx,v > retrieving revision 1.65.2.121 > diff -u -r1.65.2.121 RasSrv.cxx > --- RasSrv.cxx 18 Feb 2004 00:52:44 -0000 1.65.2.121 > +++ RasSrv.cxx 19 Feb 2004 08:45:56 -0000 > @@ -1887,7 +1889,21 @@ > endptr ep = obj_rr.HasOptionalField(H225_UnregistrationRequest::e_endpointIdentifier) ? > EndpointTable->FindByEndpointId(obj_rr.m_endpointIdentifier) : > obj_rr.m_callSignalAddress.GetSize() ? EndpointTable->FindBySignalAdr(obj_rr.m_callSignalAddress[0], rx_addr) : endptr(0); > + > if (ep) { > + if (Toolkit::AsBool(GkConfig()->GetString("RasSrv::URQFeatures", "RejectWithCallInProgress", "0")) && CallTbl->FindCallRec(ep)) { > + // Return URJ > + obj_rpl.SetTag(H225_RasMessage::e_unregistrationReject); > + H225_UnregistrationReject & urj = obj_rpl; > + urj.m_requestSeqNum = obj_rr.m_requestSeqNum; > + urj.m_rejectReason.SetTag(H225_UnregRejectReason::e_callInProgress); > + CopyNonStandardData(obj_rr, urj); > + > + msg = PString(PString::Printf, "URJ|%s|%s|%s;", > + inet_ntoa(rx_addr), > + (const unsigned char *) endpointIdentifierString, > + (const unsigned char *) urj.m_rejectReason.GetTagName() ); > + } else { > // Disconnect all calls of the endpoint > SoftPBX::DisconnectEndpoint(ep); > // Remove from the table > @@ -1904,6 +1920,7 @@ > msg = PString(PString::Printf, "UCF|%s|%s;", > inet_ntoa(rx_addr), > (const unsigned char *) endpointIdentifierString) ; > + } > } else { > // Return URJ > obj_rpl.SetTag(H225_RasMessage::e_unregistrationReject); > Index: RasTbl.cxx > =================================================================== > RCS file: /cvsroot/openh323gk/openh323gk/RasTbl.cxx,v > retrieving revision 1.50.2.82 > diff -u -r1.50.2.82 RasTbl.cxx > --- RasTbl.cxx 18 Feb 2004 00:52:44 -0000 1.50.2.82 > +++ RasTbl.cxx 19 Feb 2004 08:45:57 -0000 > @@ -345,7 +345,7 @@ > > bool EndpointRec::SendIRQ() > { > - if (m_pollCount-- == 0 || GetRasAddress().GetTag() != H225_TransportAddress::e_ipAddress) > + if (m_pollCount-- <= 0 || GetRasAddress().GetTag() != H225_TransportAddress::e_ipAddress) > return false; > > H225_RasMessage ras_msg; > @@ -1094,7 +1108,9 @@ > while (Iter != eIter) { > iterator i = Iter++; > EndpointRec *ep = *i; > - if (!ep->IsUpdated(&now) && !ep->SendIRQ()) { > + if (!ep->IsUpdated(&now) && !ep->SendIRQ() > + && (Toolkit::AsBool(GkConfig()->GetString("RasSrv::URQFeatures", "ExpireWithCallInProgress", "1")) || !ep->HasActiveCall())) { > + > SoftPBX::DisconnectEndpoint(endptr(ep)); > ep->Expired(); > RemovedList.push_back(ep); > Index: RasTbl.h > =================================================================== > RCS file: /cvsroot/openh323gk/openh323gk/RasTbl.h,v > retrieving revision 1.35.2.46 > diff -u -r1.35.2.46 RasTbl.h > --- RasTbl.h 18 Feb 2004 00:52:44 -0000 1.35.2.46 > +++ RasTbl.h 19 Feb 2004 08:45:57 -0000 > @@ -165,8 +165,10 @@ > > bool SendIRQ(); > > + bool HasActiveCall() const { return (m_activeCall > 0);} > + > // smart pointer for EndpointRec > typedef SmartPtr<EndpointRec> Ptr; > > ---------------------------------------------------------------------------- ---- > Index: RasSrv.cxx > =================================================================== > RCS file: /cvsroot/openh323gk/openh323gk/RasSrv.cxx,v > retrieving revision 1.65.2.121 > diff -u -r1.65.2.121 RasSrv.cxx > --- RasSrv.cxx 18 Feb 2004 00:52:44 -0000 1.65.2.121 > +++ RasSrv.cxx 19 Feb 2004 08:45:56 -0000 > @@ -680,6 +680,8 @@ > AcceptUnregCalls = Toolkit::AsBool(GkConfig()->GetString(RoutedSec, "AcceptUnregisteredCalls", "0")); > bRemoveCallOnDRQ = Toolkit::AsBool(GkConfig()->GetString(RoutedSec, "RemoveCallOnDRQ", 1)); > > + Toolkit::GetNetworkFromString(GkConfig()->GetString(RoutedSec, "UnconditionalAcceptCSANetwork", "0.0.0.0/32"), UnconditionalAcceptCSANetwork, UnconditionalAcceptCSANetMask); > + > GetAlternateGK(); > > // add authenticators > @@ -1078,7 +1080,7 @@ > for (PINDEX s = 0; s < obj_rr.m_callSignalAddress.GetSize(); ++s) { > SignalAdr = obj_rr.m_callSignalAddress[s]; > if (GetIPFromTransportAddr(SignalAdr, ipaddr)) > - if ((validaddress = (rx_addr == ipaddr || rx_addr == GKHome))) > + if ((validaddress = (rx_addr == ipaddr || rx_addr == GKHome || ((ipaddr & UnconditionalAcceptCSANetMask) == (UnconditionalAcceptCSANetwork & UnconditionalAcceptCSANetMask))))) > break; > } > if (!bShellSendReply) // is forwarded RRQ? > > Index: RasSrv.h > =================================================================== > RCS file: /cvsroot/openh323gk/openh323gk/RasSrv.h,v > retrieving revision 1.19.2.22 > diff -u -r1.19.2.22 RasSrv.h > --- RasSrv.h 26 Dec 2003 13:59:31 -0000 1.19.2.22 > +++ RasSrv.h 19 Feb 2004 08:45:56 -0000 > @@ -202,7 +202,7 @@ > bool bRemoveCallOnDRQ; > WORD GKRasPort, GKCallSigPort; > > - PIPSocket::Address GKHome; > + PIPSocket::Address GKHome, UnconditionalAcceptCSANetwork, UnconditionalAcceptCSANetMask; > PUDPSocket listener; > PMutex writeMutex, loadLock; > ---------------------------------------------------------------------------- ---- > Index: RasTbl.cxx > =================================================================== > RCS file: /cvsroot/openh323gk/openh323gk/RasTbl.cxx,v > retrieving revision 1.50.2.82 > diff -u -r1.50.2.82 RasTbl.cxx > --- RasTbl.cxx 18 Feb 2004 00:52:44 -0000 1.50.2.82 > +++ RasTbl.cxx 19 Feb 2004 08:45:57 -0000 > @@ -45,7 +45,7 @@ > : m_RasMsg(completeRAS), m_timeToLive(1), m_pollCount(2), > m_nat(false), m_natsocket(0) > { > - m_activeCall = m_connectedCall = m_totalCall = m_usedCount = 0; > + m_activeCall = m_connectedCall = m_totalCall = m_usedCount = m_priority = m_maxCall = 0; > switch (m_RasMsg.GetTag()) > { > case H225_RasMessage::e_registrationRequest: > @@ -307,7 +307,7 @@ > if (m_timeToLive == 0) > msg += " (permanent)"; > PString natstring(m_nat ? m_natip.AsString() : PString()); > - msg += PString(PString::Printf, " C(%d/%d/%d) %s <%d>\r\n", m_activeCall, m_connectedCall, m_totalCall, (const unsigned char *)natstring, m_usedCount); > + msg += PString(PString::Printf, " C(%d/%d/%d) %s <%d> L(%d/%d)\r\n", m_activeCall, m_connectedCall, m_totalCall, (const unsigned char *)natstring, m_usedCount, m_priority, m_maxCall); > } > return msg; > } > @@ -488,8 +488,12 @@ > if (Toolkit::AsBool(GkConfig()->GetString(RRQFeaturesSection, "AcceptGatewayPrefixes", "1"))) > if (m_terminalType->m_gateway.HasOptionalField(H225_GatewayInfo::e_protocol)) > AddPrefixes(m_terminalType->m_gateway.m_protocol); > - for (PINDEX i=0; i<m_terminalAliases.GetSize(); i++) > - AddPrefixes(GkConfig()->GetString("RasSrv::GWPrefixes", H323GetAliasAddressString(m_terminalAliases[i]), "")); > + for (PINDEX i=0; i<m_terminalAliases.GetSize(); i++) { > + AddPrefixes(GkConfig()->GetString("RasSrv::GWPrefixes", H323GetAliasAddressString(m_terminalAliases[i]), "")); > + m_priority = GkConfig()->GetInteger("RasSrv::GWPriority", H323GetAliasAddressString(m_terminalAliases[i]), 0); > + m_maxCall = GkConfig()->GetInteger("RasSrv::GWMaxCall", H323GetAliasAddressString(m_terminalAliases[i]), -1); > + } > + > SortPrefixes(); > return true; > } > @@ -870,11 +874,13 @@ > > // build a list of gateways with the longest prefix match for the aliases > int maxlen = 0; > + int maxprio = 0; > + > list<EndpointRec *> gwlist; > listLock.StartRead(); > const_iterator Iter = eplist->begin(), IterLast = eplist->end(); > while (Iter != IterLast) { > - if ((*Iter)->IsGateway()) { > + if ((*Iter)->IsGateway() && ! (*Iter)->IsGatewayOverloaded()) { > const int len = matchedalias > ? dynamic_cast<GatewayRec *>(*Iter)->PrefixMatch(aliases,*matchedalias) > : dynamic_cast<GatewayRec *>(*Iter)->PrefixMatch(aliases); > @@ -883,9 +889,17 @@ > if (maxlen < len) { > gwlist.clear(); > maxlen = len; > + maxprio = (*Iter)->GetGatewayPriority(); > + } > + > + if (maxlen == len) { > + if((*Iter)->GetGatewayPriority() > maxprio) { > + maxprio = (*Iter)->GetGatewayPriority(); > + gwlist.push_front(*Iter); > + } else { > + gwlist.push_back(*Iter); > + } > } > - if (maxlen == len) > - gwlist.push_back(*Iter); > } > ++Iter; > } > Index: RasTbl.h > =================================================================== > RCS file: /cvsroot/openh323gk/openh323gk/RasTbl.h,v > retrieving revision 1.35.2.46 > diff -u -r1.35.2.46 RasTbl.h > --- RasTbl.h 18 Feb 2004 00:52:44 -0000 1.35.2.46 > +++ RasTbl.h 19 Feb 2004 08:45:57 -0000 > @@ -165,6 +165,9 @@ > > bool SendIRQ(); > > + int GetGatewayPriority() const {return m_priority;} > + bool IsGatewayOverloaded() const {return (m_maxCall == -1) ? false : (m_activeCall >= m_maxCall);} > + > // smart pointer for EndpointRec > typedef SmartPtr<EndpointRec> Ptr; > > @@ -191,7 +195,9 @@ > int m_timeToLive; // seconds > > int m_activeCall, m_connectedCall, m_totalCall; > + int m_maxCall; > int m_pollCount, m_usedCount; > + int m_priority; > mutable PMutex m_usedLock; > > PTime m_updatedTime; >
Attachment:
urqfeatures.patch
Description: Binary data
Attachment:
uacsa.patch
Description: Binary data
Attachment:
basiclcr.patch
Description: Binary data