Exemple #1
0
void *pjsip_p_c_v_hdr_shallow_clone(pj_pool_t* pool, const void* o)
{
  pjsip_p_c_v_hdr* hdr = pjsip_p_c_v_hdr_create(pool);
  pjsip_p_c_v_hdr* other = (pjsip_p_c_v_hdr*)o;
  hdr->icid = other->icid;
  hdr->orig_ioi = other->orig_ioi;
  hdr->term_ioi = other->term_ioi;
  hdr->icid_gen_addr = other->icid_gen_addr;
  pjsip_param_shallow_clone(pool, &hdr->other_param, &other->other_param);
  return hdr;
}
Exemple #2
0
void *pjsip_p_c_v_hdr_clone(pj_pool_t* pool, const void* o)
{
  pjsip_p_c_v_hdr* hdr = pjsip_p_c_v_hdr_create(pool);
  pjsip_p_c_v_hdr* other = (pjsip_p_c_v_hdr*)o;
  pj_strdup(pool, &hdr->icid, &other->icid);
  pj_strdup(pool, &hdr->orig_ioi, &other->orig_ioi);
  pj_strdup(pool, &hdr->term_ioi, &other->term_ioi);
  pj_strdup(pool, &hdr->icid_gen_addr, &other->icid_gen_addr);
  pjsip_param_clone(pool, &hdr->other_param, &other->other_param);
  return hdr;
}
/// Add P-Charging headers on incoming out-of-dialog/dialog initiating requests
static void proxy_add_p_charging_header(pjsip_tx_data *tdata)
{
  LOG_DEBUG("Add P-Charging headers");

  std::string cdf_domain = PJUtils::pj_str_to_string(&stack_data.cdf_domain);

  if (cdf_domain != "")
  {
    // Add the P-Charging-Function-Addresses. The value of the CDF is passed in
    // as a parameter in bono - if this isn't present then don't set these
    // headers.
    pjsip_p_c_f_a_hdr* p_c_f_a = pjsip_p_c_f_a_hdr_create(tdata->pool);
    pjsip_param* new_param = (pjsip_param*) pj_pool_alloc(tdata->pool, sizeof(pjsip_param));
    new_param->name = STR_CCF;
    new_param->value = stack_data.cdf_domain;

    pj_list_insert_before(&p_c_f_a->ccf, new_param);
    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)p_c_f_a);

    // Add the P-Charging-Vector Id. The icid-value is the Call-ID, and the
    // icid-generated-at is the bono hostname - it must be unique to the node that
    // generates it.
    pjsip_cid_hdr* call_id = (pjsip_cid_hdr*)pjsip_msg_find_hdr_by_name(tdata->msg,
                                                                        &STR_CALL_ID,
                                                                        NULL);
    std::string c_id = PJUtils::pj_str_to_string(&call_id->id);
    c_id.erase(std::remove(c_id.begin(), c_id.end(), '@'), c_id.end());
    c_id.erase(std::remove(c_id.begin(), c_id.end(), '"'), c_id.end());

    pjsip_p_c_v_hdr* p_c_v = pjsip_p_c_v_hdr_create(tdata->pool);

    pj_strdup2(tdata->pool, &p_c_v->icid, c_id.c_str());
    p_c_v->icid_gen_addr = stack_data.public_host;

    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)p_c_v);
  }
}
Exemple #4
0
pjsip_hdr* parse_hdr_p_charging_vector(pjsip_parse_ctx* ctx)
{
  // The P-Charging-Vector header has the following ABNF:
  //
  // P-Charging-Vector     = "P-Charging-Vector" HCOLON icid-value
  //                         *(SEMI charge-params)
  // charge-params         = icid-gen-addr / orig-ioi /
  //                         term-ioi / generic-param
  // icid-value            = "icid-value" EQUAL gen-value
  // icid-gen-addr         = "icid-generated-at" EQUAL host
  // orig-ioi              = "orig-ioi" EQUAL gen-value
  // term-ioi              = "term-ioi" EQUAL gen-value

  pj_pool_t* pool = ctx->pool;
  pj_scanner* scanner = ctx->scanner;
  pjsip_p_c_v_hdr* hdr = pjsip_p_c_v_hdr_create(pool);
  pj_str_t name;
  pj_str_t value;

  // Parse the required icid-value parameter first.
  pjsip_parse_param_imp(scanner, pool, &name, &value,
                        PJSIP_PARSE_REMOVE_QUOTE);

  if (!pj_stricmp2(&name, "icid-value")) {
    hdr->icid = value;
  } else {
    PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); // LCOV_EXCL_LINE
  }

  for (;;) {
    pj_scan_skip_whitespace(scanner);

    // If we just parsed the last parameter we will have reached the end of the
    // header and have nothing more to do.
    if (pj_scan_is_eof(scanner) ||
        (*scanner->curptr == '\r') ||
        (*scanner->curptr == '\n')) {
      break;
    }

    // There's more content in the header so the next character must be the ";"
    // separator.
    if (*scanner->curptr == ';') {
      pj_scan_get_char(scanner);
    } else {
      PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); // LCOV_EXCL_LINE
    }

    pjsip_parse_param_imp(scanner, pool, &name, &value,
                          PJSIP_PARSE_REMOVE_QUOTE);

    if (!pj_stricmp2(&name, "orig-ioi")) {
      hdr->orig_ioi = value;
    } else if (!pj_stricmp2(&name, "term-ioi")) {
      hdr->term_ioi = value;
    } else if (!pj_stricmp2(&name, "icid-generated-at")) {
      hdr->icid_gen_addr = value;
    } else {
      pjsip_param *param = PJ_POOL_ALLOC_T(pool, pjsip_param);
      param->name = name;
      param->value = value;
      pj_list_insert_before(&hdr->other_param, param);
    }
  }

  // We're done parsing this header.
  pjsip_parse_end_hdr_imp(scanner);

  return (pjsip_hdr*)hdr;
}