コード例 #1
0
/// Mangelwurzel receives an initial request. It will Record-Route itself,
/// strip off all the Via headers and send the request on. It can also change
/// the request in various ways depending on the configuration in its Route
/// header.
/// - It can mangle the dialog identifiers using its mangalgorithm.
/// - It can mangle the Request URI and Contact URI using its mangalgorithm.
/// - It can mangle the To URI using its mangalgorithm.
/// - It can edit the S-CSCF Route header to turn the request into either an
///   originating or terminating request.
/// - It can edit the S-CSCF Route header to turn the request into an out of
///   the blue request.
/// - It can mangle the Record-Route headers URIs.
void MangelwurzelTsx::on_rx_initial_request(pjsip_msg* req)
{
  // Store off the unmodified request.
  _unmodified_request = original_request();

  // If Mangelwurzel receives a REGISTER, we need to respond with a 200 OK
  // rather than mangling the request and forwarding it on.
  if (req->line.req.method.id == PJSIP_REGISTER_METHOD)
  {
    pjsip_msg* rsp = create_response(req, PJSIP_SC_OK);
    send_response(rsp);
    free_msg(req);
    return;
  }

  pj_pool_t* pool = get_pool(req);

  // Get Mangelwurzel's route header and clone the URI. We use this in the SAS
  // event logging that we've received a request, and then we use it to
  // Record-Route ourselves.
  const pjsip_route_hdr* mangelwurzel_route_hdr = route_hdr();
  pjsip_uri* mangelwurzel_uri =
    (pjsip_uri*)pjsip_uri_clone(pool, mangelwurzel_route_hdr->name_addr.uri);

  SAS::Event event(trail(), SASEvent::MANGELWURZEL_INITIAL_REQ, 0);
  event.add_var_param(PJUtils::uri_to_string(PJSIP_URI_IN_ROUTING_HDR,
                                             mangelwurzel_uri));
  SAS::report_event(event);

  if (_config.dialog)
  {
    mangle_dialog_identifiers(req, pool);
  }

  if (_config.req_uri)
  {
    mangle_req_uri(req, pool);
    mangle_contact(req, pool);
  }

  if (_config.to)
  {
    mangle_to(req, pool);
  }

  edit_scscf_route_hdr(req, pool);

  if (_config.routes)
  {
    mangle_record_routes(req, pool);
  }

  strip_via_hdrs(req);

  record_route(req, pool, mangelwurzel_uri);

  send_request(req);
}
コード例 #2
0
ファイル: rr_mod.c プロジェクト: AndreiPlesa/opensips
static int w_record_route(struct sip_msg *msg, char *key, char *bar)
{
	str s;

	if (ctx_rrdone_get()==1) {
		LM_ERR("Double attempt to record-route\n");
		return -1;
	}

	if (key && pv_printf_s(msg, (pv_elem_t*)key, &s)<0) {
		LM_ERR("failed to print the format\n");
		return -1;
	}
	if ( record_route( msg, key?&s:0 )<0 )
		return -1;

	ctx_rrdone_set(1);
	return 1;
}
コード例 #3
0
ファイル: rr_mod.c プロジェクト: Distrotech/opensips
static int w_record_route(struct sip_msg *msg, char *key, char *bar)
{
	str s;

	if (msg->id == last_rr_msg) {
		LM_ERR("Double attempt to record-route\n");
		return -1;
	}

	if (key && pv_printf_s(msg, (pv_elem_t*)key, &s)<0) {
		LM_ERR("failed to print the format\n");
		return -1;
	}
	if ( record_route( msg, key?&s:0 )<0 )
		return -1;

	last_rr_msg = msg->id;
	return 1;
}
コード例 #4
0
ファイル: rr_mod.c プロジェクト: kingsumos/kamailio
/**
 * wrapper for record_route(msg, params)
 */
static int w_record_route(struct sip_msg *msg, char *key, char *bar)
{
	str s;

	if (msg->msg_flags & FL_RR_ADDED) {
		LM_ERR("Double attempt to record-route\n");
		return -1;
	}

	if (key && pv_printf_s(msg, (pv_elem_t*)key, &s)<0) {
		LM_ERR("failed to print the format\n");
		return -1;
	}
	if ( record_route( msg, key?&s:0 )<0 )
		return -1;

	msg->msg_flags |= FL_RR_ADDED;
	return 1;
}