⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 provisioninterface.cxx

📁 SIP(Session Initiation Protocol)是由IETF定义
💻 CXX
📖 第 1 页 / 共 3 页
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0  *  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. *  * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. *  * 3. The names "VOCAL", "Vovida Open Communication Application Library", *    and "Vovida Open Communication Application Library (VOCAL)" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor *    may "VOCAL" appear in their name, without prior written *    permission of Vovida Networks, Inc. *  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *  * ==================================================================== *  * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc.  For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const ProvisionInterface_cxx_Version =    "$Id: ProvisionInterface.cxx,v 1.73.2.1 2003/01/23 02:50:05 sprajpat Exp $";#include <stdlib.h>#include <stdio.h>#include <algorithm>#include <strstream.h>#include <unistd.h>#include <errno.h>#include "ProvisionInterface.hxx"#include "VException.hxx"#include "VBadDataException.hxx"#include "VMissingDataException.hxx"#include "VNetworkException.hxx"#include "PSListener.hxx"#include "cpLog.h"#include "VPs_def.h"#include "VXmlParser.hxx"#include "NetworkAddress.h"#include "PSSecret.hxx"ProvisionInterface* ProvisionInterface::_instance = NULL;ProvisionInterface&ProvisionInterface::instance(const char* primHost, const int primPort,                             const char* altHost, const int altPort,			     const char* readSecretFile,			     const char* writeSecretFile)throw (VException&){    if (!_instance)    {        if (primHost == 0 || primPort == 0 || altHost == 0 || altPort == 0 ||	    readSecretFile == 0 || writeSecretFile == 0)        {            throw VNetworkException("PServer hostname and port not specified",                                    __FILE__, __LINE__, 0);        }        _instance = new ProvisionInterface(primHost, primPort,                                           altHost, altPort, 					   readSecretFile, writeSecretFile);    }    return *_instance;}ProvisionInterface::ProvisionInterface(const char* primHostname,                                       const int primPort,                                       const char *altHostname,                                       const int altPort,				       const char* readSecretFile,				       const char* writeSecretFile)     :    _interface(primHostname, primPort, altHostname, altPort){    PSSecret::create(readSecretFile, writeSecretFile);    _listener = new PSListener();#if defined(__linux__)    //Destroy when program exits    if (atexit(ProvisionInterface::destroy) < 0)    {        cpLog(LOG_ALERT, "Failed to register ProvisionInterface::destroy");    }#endif    char buf[256];    gethostname(buf, 256);    _hostName = buf;}ProvisionInterface::~ProvisionInterface(){}voidProvisionInterface::destroy(){    delete ProvisionInterface::_instance;    ProvisionInterface::_instance = NULL;}/// Reads an item from provision serverstringProvisionInterface::readItem(const string& group, const string &name)throw (VException&){    return _interface.readItem(group, name);}/** Gets an item from Provision server -- called readFile for backwards comp.    this one is called only by feature servers */stringProvisionInterface::readFile(const string& host, int port,                             PContext context, const string& name)throw (VException&){    // this is a backward compat thing. name is either Called/<user>    // or Calling/<user>, need to find out which...    string whichList;    string realName;    if (name.find("Called") == string::npos)    {        whichList = "Calling";    }    else    {        whichList = "Called";    }    // needs to have a "/" since it should be as above...    size_t loc = name.find("/");    if (loc == string::npos)    {        throw VNetworkException("Invalid name given", __FILE__, __LINE__, 0);    }    realName = name.substr(loc + 1, name.size());    char buf[256];    string cntxt = dirContext(context);    sprintf(buf, "%s_%s_%d_%s", cntxt.c_str(), host.c_str(), port,            whichList.c_str());    string group(buf);    return _interface.readItem(group, realName);}/// Reads a list of items in a given group from the provision servervoidProvisionInterface::getList(const string& group, vector < Data > & retList)throw (VException&){    _interface.getList(group, retList);    return ;}/// Write a data item to the provision servervoidProvisionInterface::writeItem(const string& group, const string &name,                              const string& contents)throw (VException&){    _interface.writeItem(group, name, contents);    return ;}voidProvisionInterface::getConfigData(VGlobalConfigData &retVal)throw(VException&){    string dRead = _interface.readItem(VSYS_CONF, GLOBAL_CONFIG_ITEM);    assert(dRead.size());    retVal.parse(dRead);}voidProvisionInterface::getOspServer(VOspServerData &retVal)throw(VException&){    string dRead = _interface.readItem(VSYS_CONF, OSP_CONFIG_ITEM);    assert(dRead.size());    retVal.parse(dRead);}voidProvisionInterface::getJtapiServers(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeJtapiServerList();    ListOfServers tList = _jtapiServerGrpCont.getServerList();    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getFeatureServers(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeFeatureServerList();    ListOfServers tList = _featureServerGrpCont.getServerList();    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getMarshalServers(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeMarshalServerList();    ListOfServers tList = _marshalServerGrpCont.getServerList();    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getCdrServers(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeCdrServerList();    ListOfServers tList = _cdrServerGrpCont.getServerList();    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getHeartbeatServers(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeHeartbeatServerList();    ListOfServers tList = _heartbeatServerGrpCont.getServerList();    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getRedirectServers(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeRedirectServerList();    ListOfServers tList = _redirectServerGrpCont.getServerList();    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getPolicyServers(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializePolicyServerList();    ListOfServers tList = _policyServerGrpCont.getServerList();    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getJtapiGroups(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeJtapiServerList();    list < string > tList;    _jtapiServerGrpCont.getGroupList(tList);    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getFeatureGroups(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeFeatureServerList();    list < string > tList;    _featureServerGrpCont.getGroupList(tList);    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getMarshalGroups(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeMarshalServerList();    list < string > tList;    _marshalServerGrpCont.getGroupList(tList);    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getCdrGroups(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeCdrServerList();    list < string > tList;    _cdrServerGrpCont.getGroupList(tList);    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getHeartbeatGroups(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeHeartbeatServerList();    list < string > tList;    _heartbeatServerGrpCont.getGroupList(tList);    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getRedirectGroups(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializeRedirectServerList();    list < string > tList;    _redirectServerGrpCont.getGroupList(tList);    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getPolicyGroups(list < string > &retList)throw(VException&){    // delete anything in there when it is passed    retList.clear();    initializePolicyServerList();    list < string > tList;    _policyServerGrpCont.getGroupList(tList);    for (ListOfServers::iterator itr = tList.begin();            itr != tList.end(); itr++)    {        retList.push_back(*itr);    }}voidProvisionInterface::getJtapiHostToGroupMap(HostToGroupMap &retList)throw(VException&){    initializeJtapiServerList();    _jtapiServerGrpCont.getHostToGroupMap(retList);}voidProvisionInterface::getFeatureHostToGroupMap(HostToGroupMap &retList)throw(VException&){    initializeFeatureServerList();    _featureServerGrpCont.getHostToGroupMap(retList);}voidProvisionInterface::getMarshalHostToGroupMap(HostToGroupMap &retList)throw(VException&){    initializeMarshalServerList();    _marshalServerGrpCont.getHostToGroupMap(retList);}voidProvisionInterface::getCdrHostToGroupMap(HostToGroupMap &retList)throw(VException&){    initializeCdrServerList();    _cdrServerGrpCont.getHostToGroupMap(retList);}voidProvisionInterface::getRedirectHostToGroupMap(HostToGroupMap &retList)throw(VException&){    initializeRedirectServerList();    _redirectServerGrpCont.getHostToGroupMap(retList);}voidProvisionInterface::getHeartbeatHostToGroupMap(HostToGroupMap &retList)throw(VException&){    initializeHeartbeatServerList();    _heartbeatServerGrpCont.getHostToGroupMap(retList);}voidProvisionInterface::getPolicyHostToGroupMap(HostToGroupMap &retList)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -