MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / push_gw_for_usage

Function push_gw_for_usage

modules/drouting/drouting.c:3020–3184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3018
3019
3020inline static int push_gw_for_usage(struct sip_msg *msg,
3021 struct head_db *current_partition, struct sip_uri *uri,
3022 rt_info_t *rt, pgw_list_t *dst, int cr_id, int gw_id, int idx)
3023{
3024 static void *qr_data;
3025
3026 char buf[PTR_STRING_SIZE]; /* a hexa string */
3027 str *ruri;
3028 pgw_t *gw = NULL;
3029 str *c_id = NULL;
3030 str *c_attrs = NULL;
3031 int_str val;
3032 int_str dst_id_acc;
3033 struct dr_acc_call_params acp;
3034
3035 if (rt) { /* rule based routing, e.g. do_routing() */
3036 if (cr_id == -1) { /* it is not a carrier */
3037 gw = rt->pgwl[gw_id].dst.gw;
3038 } else { /* destination is a carrier */
3039 c_id = &rt->pgwl[cr_id].dst.carrier->id;
3040 c_attrs = &rt->pgwl[cr_id].dst.carrier->attrs;
3041 gw = rt->pgwl[cr_id].dst.carrier->pgwl[gw_id].dst.gw;
3042 }
3043
3044 } else if (dst) {
3045 /* routing was not done rule-based => don't use qrouting
3046 (called from route_2gw or route_2cr) */
3047
3048 if (dst->is_carrier) {
3049 gw = dst->dst.carrier->pgwl[gw_id].dst.gw;
3050 c_id = &dst->dst.carrier->id;
3051 c_attrs = &dst->dst.carrier->attrs;
3052 } else {
3053 gw = dst->dst.gw;
3054 }
3055
3056 } else {
3057 LM_BUG("invalid function call, no rule, no destination\n");
3058 return -1;
3059 }
3060
3061 /* build uri*/
3062 ruri = build_ruri( uri, gw->strip, &gw->pri, &gw->ip_str);
3063 if (ruri==0) {
3064 LM_ERR("failed to build new ruri\n");
3065 return -1;
3066 }
3067
3068 LM_DBG("adding gw [%.*s] as \"%.*s\" in order %d\n",
3069 gw->id.len, gw->id.s, ruri->len, ruri->s, idx);
3070
3071 /* first GW to be added ? */
3072 if (idx==0) {
3073
3074 /* add to RURI */
3075 if (set_ruri( msg, ruri)!= 0 ) {
3076 LM_ERR("failed to set new RURI\n");
3077 goto error;

Callers 3

do_routingFunction · 0.85
route2_carrierFunction · 0.85
route2_gwFunction · 0.85

Calls 4

build_ruriFunction · 0.85
set_ruriFunction · 0.85
run_dr_cbsFunction · 0.85
add_avp_lastFunction · 0.85

Tested by

no test coverage detected