int gzc_prepare_msg(sip_msg_t *msg) { if (parse_msg(msg->buf, msg->len, msg)!=0) { LM_DBG("outbuf buffer parsing failed!"); return 1; } if(msg->first_line.type==SIP_REQUEST) { if(!IS_SIP(msg) && !IS_HTTP(msg)) { LM_DBG("non sip or http request\n"); return 1; } } else if(msg->first_line.type==SIP_REPLY) { if(!IS_SIP_REPLY(msg) && !IS_HTTP_REPLY(msg)) { LM_DBG("non sip or http response\n"); return 1; } } else { LM_DBG("non sip or http message\n"); return 1; } if (parse_headers(msg, HDR_EOH_F, 0)==-1) { LM_DBG("parsing headers failed"); return 2; } return 0; }
static int dlg_cseq_prepare_msg(sip_msg_t *msg) { LM_DBG("prepare msg for cseq update operations\n"); if(msg->first_line.type==SIP_REQUEST) { if(!IS_SIP(msg)) { LM_DBG("non sip request message\n"); return 1; } } else if(msg->first_line.type==SIP_REPLY) { if(!IS_SIP_REPLY(msg)) { LM_DBG("non sip reply message\n"); return 1; } } else { LM_DBG("non sip message\n"); return 1; } if((!msg->cseq && (parse_headers(msg,HDR_CSEQ_F,0)<0 || !msg->cseq)) || !msg->cseq->parsed){ LM_DBG("parsing cseq header failed\n"); return 2; } if(msg->first_line.type==SIP_REPLY) { /* reply to local transaction -- nothing to do */ if (parse_headers(msg, HDR_VIA2_F, 0)==-1 || (msg->via2==0) || (msg->via2->error!=PARSE_OK)) { if(get_cseq(msg)->method_id != METHOD_CANCEL) { LM_DBG("no second via in this message \n"); return 3; } } } if(parse_from_header(msg)<0) { LM_ERR("cannot parse FROM header\n"); return 3; } if(parse_to_header(msg)<0 || msg->to==NULL) { LM_ERR("cannot parse TO header\n"); return 3; } if(get_to(msg)==NULL) { LM_ERR("cannot get TO header\n"); return 3; } return 0; }
void log_prefix_set(sip_msg_t *msg) { if(log_prefix_pvs == NULL) return; if(msg==NULL || !(IS_SIP(msg) || IS_SIP_REPLY(msg))) { log_prefix_val = NULL; return; } log_prefix_str.s = log_prefix_buf; log_prefix_str.len = LOG_PREFIX_SIZE; if(pv_printf(msg, log_prefix_pvs, log_prefix_str.s, &log_prefix_str.len)<0) return; if(log_prefix_str.len<=0) return; log_prefix_val = &log_prefix_str; }
int registered4(struct sip_msg* _m, udomain_t* _d, str* _uri, int match_flag, int match_action_flag) { str uri, aor; urecord_t* r; ucontact_t* ptr; int res; str match_callid = {0,0}; str match_received = {0,0}; str match_contact = {0,0}; sr_xavp_t *vavp = NULL; if(_uri!=NULL) { uri = *_uri; } else { if(IS_SIP_REPLY(_m)) { if (parse_to_header(_m) < 0) { LM_ERR("failed to prepare the message\n"); return -1; } uri = get_to(_m)->uri; } else { if (_m->new_uri.s) uri = _m->new_uri; else uri = _m->first_line.u.request.uri; } } if (extract_aor(&uri, &aor, NULL) < 0) { LM_ERR("failed to extract address of record\n"); return -1; } ul.lock_udomain(_d, &aor); res = ul.get_urecord(_d, &aor, &r); if (res < 0) { ul.unlock_udomain(_d, &aor); LM_ERR("failed to query usrloc\n"); return -1; } if (res == 0) { LM_DBG("searching with match flags (%d,%d)\n", match_flag, match_action_flag); if(reg_xavp_cfg.s!=NULL) { if((match_flag & 1) && (vavp = xavp_get_child_with_sval(®_xavp_cfg, &match_callid_name)) != NULL && vavp->val.v.s.len > 0) { match_callid = vavp->val.v.s; LM_DBG("matching with callid %.*s\n", match_callid.len, match_callid.s); } if((match_flag & 2) && (vavp = xavp_get_child_with_sval(®_xavp_cfg, &match_received_name)) != NULL && vavp->val.v.s.len > 0) { match_received = vavp->val.v.s; LM_DBG("matching with received %.*s\n", match_received.len, match_received.s); } if((match_flag & 4) && (vavp = xavp_get_child_with_sval(®_xavp_cfg, &match_contact_name)) != NULL && vavp->val.v.s.len > 0) { match_contact = vavp->val.v.s; LM_DBG("matching with contact %.*s\n", match_contact.len, match_contact.s); } } for (ptr = r->contacts; ptr; ptr = ptr->next) { if(!VALID_CONTACT(ptr, act_time)) continue; if (match_callid.s && /* optionally enforce tighter matching w/ Call-ID */ match_callid.len > 0 && (match_callid.len != ptr->callid.len || memcmp(match_callid.s, ptr->callid.s, match_callid.len))) continue; if (match_received.s && /* optionally enforce tighter matching w/ ip:port */ match_received.len > 0 && (match_received.len != ptr->received.len || memcmp(match_received.s, ptr->received.s, match_received.len))) continue; if (match_contact.s && /* optionally enforce tighter matching w/ Contact */ match_contact.len > 0 && (match_contact.len != ptr->c.len || memcmp(match_contact.s, ptr->c.s, match_contact.len))) continue; if(!(match_action_flag & 2)) { xavp_rcd_helper(ptr); } if((ptr->xavp!=NULL) && (match_action_flag & 1)) { sr_xavp_t *xavp = xavp_clone_level_nodata(ptr->xavp); if(xavp_add(xavp, NULL)<0) { LM_ERR("error adding xavp for %.*s after successful match\n", aor.len, ZSW(aor.s)); xavp_destroy_list(&xavp); } } ul.release_urecord(r); ul.unlock_udomain(_d, &aor); LM_DBG("'%.*s' found in usrloc\n", aor.len, ZSW(aor.s)); return 1; } } ul.unlock_udomain(_d, &aor); LM_DBG("'%.*s' not found in usrloc\n", aor.len, ZSW(aor.s)); return -1; }