int select_via_params_spec(str* res, select_t* s, struct sip_msg* msg) { struct via_body *p = NULL; if (s->params[s->n-1].type != SEL_PARAM_DIV) { BUG("Last parameter should have type DIV (converted)\n"); return -1; } // it's not neccessary to test if (s->n > 1) if (s->params[1].type != SEL_PARAM_INT) { if(parse_via_header(msg, 1, &p)<0) return -1; } else if (parse_via_header(msg, s->params[1].v.i, &p)<0) return -1; if (!p) return -1; switch (s->params[s->n-1].v.i) { case SEL_PARAM_BRANCH: TEST_RET_res_value(p->branch); case SEL_PARAM_RECEIVED: TEST_RET_res_value(p->received); case SEL_PARAM_RPORT: TEST_RET_res_value(p->rport); case SEL_PARAM_I: TEST_RET_res_value(p->i); case SEL_PARAM_ALIAS: TEST_RET_res_value(p->alias); default: BUG("Unexpected parameter value \"%d\"\n", s->params[s->n-1].v.i); return -1; } return -1; }
int select_via_comment(str* res, select_t* s, struct sip_msg* msg) { struct via_body *p = NULL; // it's not neccessary to test if (s->n > 1) if ((s->params[1].type == SEL_PARAM_STR) && (parse_via_header(msg, 1, &p)<0)) return -1; else if (parse_via_header(msg, s->params[1].v.i, &p)<0) return -1; if (!p) return -1; RETURN0_res(p->comment); }
int select_via(str* res, select_t* s, struct sip_msg* msg) { struct via_body *p = NULL; if (((s->n == 1) || (s->params[1].type == SEL_PARAM_STR)) && (parse_via_header(msg, 1, &p)<0)) return -1; else if (parse_via_header(msg, s->params[1].v.i, &p)<0) return -1; if (!p) return -1; res->s=p->name.s; res->len=p->bsize; trim(res); return 0; }
/*! \brief * Prepend own uri to Path header */ int add_path(struct sip_msg* _msg, char* _a, char* _b) { str user = {0,0}; int ret; path_param_t param = PATH_PARAM_NONE; struct via_body *via; if (path_obb.use_outbound != NULL && path_obb.use_outbound(_msg)) { if (path_obb.encode_flow_token(&user, _msg->rcv) != 0) { LM_ERR("encoding outbound flow-token\n"); return -1; } /* Only include ;ob parameter if this is the first-hop (that means only one Via:) */ if (parse_via_header(_msg, 2, &via) < 0) param = PATH_PARAM_OB; } ret = prepend_path(_msg, &user, param); if (user.s != NULL) pkg_free(user.s); return ret; }
int select_via_params(str* res, select_t* s, struct sip_msg* msg) { struct via_body *p = NULL; struct via_param *q; // it's not neccessary to test if (s->n > 1) if ((s->params[1].type == SEL_PARAM_STR) && (parse_via_header(msg, 1, &p)<0)) return -1; else if (parse_via_header(msg, s->params[1].v.i, &p)<0) return -1; if (!p) return -1; for (q = p->param_lst;q;q=q->next) { if ((q->name.len==s->params[s->n-1].v.s.len) && !strncasecmp(q->name.s, s->params[s->n-1].v.s.s,q->name.len)) { RETURN0_res(q->value); } } return 1; }