Пример #1
0
StateQueuePublisher::StateQueuePublisher(StateQueueAgent * pAgent) :
  _pAgent(pAgent),
  _queue(1000),
  _pThread(0),
  _terminate(false)
{
  _expireHandler = boost::bind(&StateQueuePublisher::onExpiredSubscription, this, _1, _2);
  OS_LOG_INFO(FAC_NET, "StateQueuePublisher CREATED.");
}
RedirectPlugin::LookUpStatus
SipRedirectorAliasDB::lookUp(
   const SipMessage& message,
   UtlString& requestString,
   Url& requestUri,
   const UtlString& method,
   ContactList& contactList,
   RequestSeqNo requestSeqNo,
   int redirectorNo,
   SipRedirectorPrivateStorage*& privateStorage,
   ErrorDescriptor& errorDescriptor)
{
   // If url param sipx-userforward = false, do not redirect to user-forward
   // aliases.
   UtlString userforwardParam;
   requestUri.getUrlParameter("sipx-userforward", userforwardParam);
   bool disableForwarding =
      userforwardParam.compareTo("false", UtlString::ignoreCase) == 0;
   if (disableForwarding)
   {
      Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "%s::lookUp user forwarding disabled by parameter",
                    mLogName.data());
   }

   if (_enableEarlyAliasResolution)
   {
     resolveAlias(message, requestString, requestUri);
   }


   UtlString requestIdentity;
   requestUri.getIdentity(requestIdentity);


   EntityDB::Aliases aliases;
   bool isUserIdentity = false;
   EntityDB* entityDb = SipRegistrar::getInstance(NULL)->getEntityDB();
   entityDb->getAliasContacts(requestUri, aliases, isUserIdentity);
   int numAliasContacts = aliases.size();

   if (numAliasContacts > 0)
   {
      Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "%s::lookUp "
                    "got %d AliasDB contacts", mLogName.data(),
                    numAliasContacts);

      // Check if the request identity is a real user/extension
      UtlString realm;
      UtlString authType;
      

      SipXauthIdentity authIdentity;
      authIdentity.setIdentity(requestIdentity);

      for (EntityDB::Aliases::iterator iter = aliases.begin(); iter != aliases.end(); iter++)
      {

            // If disableForwarding and the relation value is "userforward",
            // do not record this contact.
            if (!(disableForwarding && iter->relation == ALIASDB_RELATION_USERFORWARD))
            {
               UtlString contact = iter->contact.c_str();
               Url contactUri(contact);

               // if the request identity is a real user
               if (isUserIdentity)
               {
                  // Encode AuthIdentity into the URI
                  authIdentity.encodeUri(contactUri, message);
               }

               contactUri.setUrlParameter(SIP_SIPX_CALL_DEST_FIELD, "AL");
               contactList.add( contactUri, *this );

                if (_enableDiversionHeader && contactList.getDiversionHeader().empty())
                {
                  //
                  // Add a Diversion header for all deflections
                  //
                  UtlString stringUri;
                  message.getRequestUri(&stringUri);
                  // The requestUri is an addr-spec, not a name-addr.
                  Url diversionUri(stringUri, TRUE);
                  UtlString userId;
                  diversionUri.getUserId(userId);
                  UtlString host;
                  diversionUri.getHostWithPort(host);


                  std::ostringstream strm;
                  strm << "<sip:";
                  if (!userId.isNull())
                    strm << userId.data() << "@";
                  strm << host.data();
                  strm << ">;reason=unconditional;sipxfwd=" << iter->relation;
                  UtlString diversion = strm.str().c_str();
                  OS_LOG_INFO(FAC_SIP, "SipRedirectorAliasDB::lookUp inserting diversion from " << diversion.data());
                  contactList.setDiversionHeader(diversion.data());
                }
            }
      }
   }
   
   return RedirectPlugin::SUCCESS;
}
Пример #3
0
StateQueuePublisher::~StateQueuePublisher()
{
  stop();
  OS_LOG_INFO(FAC_NET, "StateQueuePublisher DESTROYED.");
}
Пример #4
0
bool CallerAlias::getCallerAlias (
  const UtlString& identity,
  const UtlString& domain,
  UtlString& callerAlias_
) const
{
    if (!_pEntities)
        return false;

    EntityRecord userEntity;
    EntityRecord gatewayEntity;
    bool hasUserEntity = false;
    bool hasGatewayEntity = false;
    std::string callerAlias;
    OS_LOG_INFO(FAC_SIP, "CallerAlias::getCallerAlias - EntityDB::findByIdentity for identity=" << identity.str() << " domain=" << domain.str());

    hasUserEntity = _pEntities->collection().findByIdentity(identity.str(), userEntity);
    hasGatewayEntity = _pEntities->collection().findByIdentity(domain.str(), gatewayEntity);

    if (hasGatewayEntity && gatewayEntity.callerId().transformExtension)
    {
        size_t loc = identity.str().find("@");
        if (loc != std::string::npos)
        {
            std::string userId = identity.str().substr(0, loc);
            //
            // Check if we need to truncate the userId to a certain length
            //
            if (gatewayEntity.callerId().extensionLength > 0 && userId.length() > (size_t)gatewayEntity.callerId().extensionLength)
                userId = string_right(userId, gatewayEntity.callerId().extensionLength);

            //
            // Now check if a prefix is specified
            //
            if (!gatewayEntity.callerId().extensionPrefix.empty())
            {
                std::string buff = gatewayEntity.callerId().extensionPrefix;
                buff += userId;
                userId = userId = buff;
            }

            callerAlias = "<sip:";
            callerAlias += userId;
            callerAlias += identity.str().substr(loc);
            callerAlias += ">";
        }
    }
    else
    {
      if (hasUserEntity && !userEntity.callerId().id.empty())
          callerAlias = userEntity.callerId().id;
      else if (hasGatewayEntity)
          gatewayEntity.callerId().ignoreUserCalleId = true;

      if (hasGatewayEntity && gatewayEntity.callerId().ignoreUserCalleId)
      {
          if (gatewayEntity.callerId().enforcePrivacy)
          {
              callerAlias = "sip:[email protected]";
          }
          else if (!gatewayEntity.callerId().id.empty())
          {
              callerAlias = gatewayEntity.callerId().id;
          }
      }
    }
    
    if (!callerAlias.empty())
        callerAlias_ = callerAlias.c_str();
    else
        OS_LOG_WARNING(FAC_SIP, "CallerAlias::getCallerAlias - No caller alias configured for identity=" << identity.str() << " domain=" << domain.str());
    
    return !callerAlias.empty();
}