예제 #1
0
SIPMessage::Ptr SIPB2BTransactionManager::onAuthenticateTransaction(
  const SIPMessage::Ptr& pRequest, SIPB2BTransaction::Ptr pTransaction)
{
  std::string maxForwards = pRequest->hdrGet("max-forwards");
  if (maxForwards.empty())
  {
    maxForwards = "70";
  }
  int maxF = OSS::string_to_number<int>(maxForwards.c_str());
  if (maxF == 0)
  {
    return pRequest->createResponse(SIPMessage::CODE_483_TooManyHops);
  }
  --maxF;
  pRequest->hdrRemove("max-forwards");
  pRequest->hdrSet("Max-Forwards", OSS::string_from_number(maxF).c_str());

  SIPB2BHandler::Ptr pHandler = findHandler(pRequest);
  if (pHandler)
  {
    return pHandler->onAuthenticateTransaction(pRequest, pTransaction);
  }
  else if (_pDefaultHandler)
  {
    return _pDefaultHandler->onAuthenticateTransaction(pRequest, pTransaction);
  }
  return pRequest->createResponse(405, "No Corresponding Handler");
}
예제 #2
0
SIPMessage::Ptr SIPB2BTransactionManager::onTransactionCreated(
  const SIPMessage::Ptr& pRequest, SIPB2BTransaction::Ptr pTransaction)
{
  SIPB2BHandler::Ptr pHandler = findHandler(pRequest);
  if (pHandler)
  {
    return pHandler->onTransactionCreated(pRequest, pTransaction);
  }
  else if (_pDefaultHandler)
  {
    return _pDefaultHandler->onTransactionCreated(pRequest, pTransaction);
  }
  return pRequest->createResponse(405, "No Corresponding Handler");
}
예제 #3
0
SIPMessage::Ptr SIPB2BTransactionManager::onRouteTransaction(
  SIPMessage::Ptr& pRequest,
  SIPB2BTransaction::Ptr pTransaction,
  OSS::IPAddress& localInterface,
  OSS::IPAddress& target)
{
  SIPB2BHandler::Ptr pHandler = findDomainRouter(pRequest);
  if (pHandler)
  {
    bool handled = false;
    SIPMessage::Ptr result = pHandler->onRouteTransaction(pRequest, pTransaction, localInterface, target, handled);
    if (handled)
      return result;
  }
  
  pHandler = findHandler(pRequest);
  if (pHandler)
  {
    SIPMessage::Ptr result = pHandler->onRouteTransaction(pRequest, pTransaction, localInterface, target);
    //
    // _postRouteCallback is currently set by
    // the SBCStaticRouter class that allows static router
    // to bypass the results of the javascript layer.
    //
    if (_postRouteCallback)
      return _postRouteCallback(pRequest, result, pTransaction, localInterface, target);
    return result;
  }
  else if (_pDefaultHandler)
  {
    SIPMessage::Ptr result = _pDefaultHandler->onRouteTransaction(pRequest, pTransaction, localInterface, target);
    //
    // _postRouteCallback is currently set by
    // the SBCStaticRouter class that allows static router
    // to bypass the results of the javascript layer.
    //
    if (_postRouteCallback)
      return _postRouteCallback(pRequest, result, pTransaction, localInterface, target);
    return result;
  }
  return pRequest->createResponse(405, "No Corresponding Handler");
}