Пример #1
0
/// Create an AsChain.
//
// Ownership of `ifcs` passes to this object.
//
// See `AsChainLink::create_as_chain` for rules re releasing the
// created references.
AsChain::AsChain(AsChainTable* as_chain_table,
                 const SessionCase& session_case,
                 const std::string& served_user,
                 bool is_registered,
                 SAS::TrailId trail,
                 Ifcs& ifcs,
                 ACR* acr,
                 FIFCService* fifc_service,
                 IFCConfiguration ifc_configuration) :
  _as_chain_table(as_chain_table),
  _refs(1),  // for the initial chain link being returned
  _as_info(ifcs.size() + 1),
  _odi_tokens(),
  _responsive(ifcs.size() + 1),
  _session_case(session_case),
  _served_user(served_user),
  _is_registered(is_registered),
  _trail(trail),
  _ifcs(ifcs),
  _acr(acr),
  _fallback_ifcs({}),
  _ifc_configuration(ifc_configuration),
  _using_standard_ifcs(true),
  _root(NULL)
{
  TRC_DEBUG("Creating AsChain %p with %d IFCs and adding to map", this, ifcs.size());
  _as_chain_table->register_(this, _odi_tokens);
  TRC_DEBUG("Attached ACR (%p) to chain", _acr);

  // We need to initialize `_responsive` as bools are PODs which are not
  // initialized.
  for(std::vector<bool>::iterator it = _responsive.begin();
      it != _responsive.end();
      ++it)
  {
    *it = false;
  }

  if ((fifc_service) && (_ifc_configuration._apply_fallback_ifcs))
  {
    _root = new rapidxml::xml_document<>;
    _fallback_ifcs = fifc_service->get_fallback_ifcs(_root);
  }
}
Пример #2
0
/// Create an AsChain.
//
// Ownership of `ifcs` passes to this object.
//
// See `AsChainLink::create_as_chain` for rules re releasing the
// created references.
AsChain::AsChain(AsChainTable* as_chain_table,
                 const SessionCase& session_case,
                 const std::string& served_user,
                 bool is_registered,
                 SAS::TrailId trail,
                 Ifcs& ifcs,
                 ACR* acr) :
  _as_chain_table(as_chain_table),
  _refs(1),  // for the initial chain link being returned
  _as_info(ifcs.size() + 1),
  _odi_tokens(),
  _session_case(session_case),
  _served_user(served_user),
  _is_registered(is_registered),
  _trail(trail),
  _ifcs(ifcs),
  _acr(acr)
{
  LOG_DEBUG("Creating AsChain %p with %d IFC and adding to map", this, ifcs.size());
  _as_chain_table->register_(this, _odi_tokens);
  LOG_DEBUG("Attached ACR (%p) to chain", _acr);
}
Пример #3
0
void RegistrationUtils::register_with_application_servers(Ifcs& ifcs,
                                                          RegStore* store,
                                                          pjsip_rx_data *received_register,
                                                          pjsip_tx_data *ok_response, // Can only be NULL if received_register is
                                                          int expires,
                                                          bool is_initial_registration,
                                                          const std::string& served_user,
                                                          SAS::TrailId trail)
{
  // Function preconditions
  if (received_register == NULL)
  {
    // We should have both messages or neither
    assert(ok_response == NULL);
  }
  else
  {
    // We should have both messages or neither
    assert(ok_response != NULL);
  }

  std::vector<AsInvocation> as_list;
  // Choice of SessionCase::Originating is not arbitrary - we don't expect iFCs to specify SessionCase
  // constraints for REGISTER messages, but we only get the served user from the From address in an
  // Originating message, otherwise we use the Request-URI. We need to use the From for REGISTERs.
  // See 3GPP TS 23.218 s5.2.1 note 2: "REGISTER is considered part of the UE-originating".

  if (received_register == NULL)
  {
    pj_status_t status;
    pjsip_method method;
    pjsip_method_set(&method, PJSIP_REGISTER_METHOD);
    pjsip_tx_data *tdata;

    std::string served_user_uri_string = "<"+served_user+">";
    const pj_str_t served_user_uri = pj_str(const_cast<char *>(served_user_uri_string.c_str()));

    LOG_INFO("Generating a fake REGISTER to send to IfcHandler using AOR %s", served_user.c_str());

    SAS::Event event(trail, SASEvent::REGISTER_AS_START, 0);
    event.add_var_param(served_user);
    SAS::report_event(event);

    status = pjsip_endpt_create_request(stack_data.endpt,
                               &method,       // Method
                               &stack_data.scscf_uri, // Target
                               &served_user_uri,      // From
                               &served_user_uri,      // To
                               &served_user_uri,      // Contact
                               NULL,          // Auto-generate Call-ID
                               1,             // CSeq
                               NULL,          // No body
                               &tdata);       // OUT

    assert(status == PJ_SUCCESS);

    // As per TS 24.229, section 5.4.1.7, note 1, we don't fill in any P-Associated-URI details.
    ifcs.interpret(SessionCase::Originating, true, is_initial_registration, tdata->msg, as_list, trail);

    status = pjsip_tx_data_dec_ref(tdata);
    assert(status == PJSIP_EBUFDESTROYED);
  }
  else
  {
    ifcs.interpret(SessionCase::Originating, true, is_initial_registration, received_register->msg_info.msg, as_list, trail);
  }
  LOG_INFO("Found %d Application Servers", as_list.size());

  // Loop through the as_list
  for (std::vector<AsInvocation>::iterator as_iter = as_list.begin();
       as_iter != as_list.end();
       as_iter++)
  {
    send_register_to_as(received_register, ok_response, *as_iter, expires, served_user, trail);
  }
}