static int sipt_get_screening(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) { str body; body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len); if(body.s == NULL) { LM_INFO("No ISUP Message Found"); return -1; } if(body.s[0] != ISUP_IAM) { LM_DBG("message not an IAM\n"); return -1; } LM_DBG("about to get screening\n"); pv_get_sintval(msg, param, res, isup_get_screening((unsigned char*)body.s, body.len)); return 0; }
static int sipt_get_charge_indicator(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) { str body; body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len); if(body.s == NULL) { LM_INFO("No ISUP Message Found"); return -1; } if(body.s[0] != ISUP_COT && body.s[0] != ISUP_ACM) { LM_DBG("message not a COT or ACM\n"); return -1; } LM_DBG("about to get charge indicator\n"); pv_get_sintval(msg, param, res, isup_get_charging_indicator((unsigned char*)body.s, body.len)); return 0; }
/* returns the value of the requested SDP line */ int select_sdp_line(str* res, select_t* sel, struct sip_msg* msg) { int len; char *buf; char *buf_end, *line_end; char line; if (msg == NULL) { if (res!=NULL) return -1; if (sel->n < 5) return -1; if (sel->params[4].type != SEL_PARAM_STR) { LM_ERR("wrong parameter type"); return -1; } if ((sel->params[4].v.s.len < 1) || (sel->params[4].v.s.len > 2) || ((sel->params[4].v.s.len == 2) && (sel->params[4].v.s.s[1] != '=')) ) { LM_ERR("wrong sdp line format: %.*s\n", sel->params[4].v.s.len, sel->params[4].v.s.s); return -1; } return 0; } /* try to get the body part with application/sdp */ if (!(buf = get_body_part(msg, TYPE_APPLICATION, SUBTYPE_SDP, &len)) ) return -1; buf_end = buf + len; line = *(sel->params[4].v.s.s); while (buf < buf_end) { if (*buf == line) { /* the requested SDP line is found, return its value */ buf++; if ((buf >= buf_end) || (*buf != '=')) { LM_ERR("wrong SDP line format\n"); return -1; } buf++; line_end = buf; while ((line_end < buf_end) && (*line_end != '\n')) line_end++; if (line_end >= buf_end) { LM_ERR("wrong SDP line format\n"); return -1; } line_end--; if (*line_end == '\r') line_end--; if (line_end < buf) { LM_ERR("wrong SDP line format\n"); return -1; } res->s = buf; res->len = line_end - buf + 1; return 0; } while ((buf < buf_end) && (*buf != '\n')) buf++; buf++; } return -1; }
static int sipt_destination2(struct sip_msg *msg, char *_destination, char *_hops, char * _nai, char * _terminator) { str * str_hops = (str*)_hops; unsigned int hops = 0; str2int(str_hops, &hops); str * nai = (str*)_nai; unsigned int int_nai = 0; str2int(nai, &int_nai); str * terminator = (str*)_terminator; unsigned int int_terminator = 0; /* if the str2int later fail */ str2int(terminator, &int_terminator); str * destination = (str*)_destination; struct sdp_mangler mangle; // update forwarded iam str body; body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len); if(body.s == NULL) { LM_INFO("No ISUP Message Found"); return -1; } str sdp; sdp.s = get_body_part(msg, TYPE_APPLICATION, SUBTYPE_SDP, &sdp.len); unsigned char newbuf[1024]; memset(newbuf, 0, 1024); if (body.s==0) { LM_ERR("failed to get the message body\n"); return -1; } body.len = msg->len -(int)(body.s-msg->buf); if (body.len==0) { LM_DBG("message body has zero length\n"); return -1; } if(body.s[0] != ISUP_IAM) { LM_DBG("message not an IAM\n"); return -1; } mangle.msg = msg; mangle.body_offset = (int)(body.s - msg->buf); char * digits = calloc(1,destination->len+2); memcpy(digits, destination->s, destination->len); if (int_terminator) { digits[destination->len] = '#'; } int res = isup_update_destination(&mangle, digits, hops, int_nai, (unsigned char*)body.s, body.len); free(digits); if(res < 0) { LM_DBG("error updating IAM\n"); return -1; } return 1; }