int w_drop_acc_2(struct sip_msg* msg, char* type_p, char* flags_p) { unsigned long long type=0; /* if not set, we reset all flags for the type of accounting requested */ unsigned long long flags=ALL_ACC_FLAGS; unsigned long long flag_mask; acc_type_param_t* acc_param; acc_ctx_t* acc_ctx=try_fetch_ctx(); str in; if (acc_ctx == NULL) { LM_ERR("do_accounting() not used! This function resets flags in " "do_accounting()!\n"); return -1; } if (type_p != NULL) { acc_param = (acc_type_param_t *)type_p; if (acc_param->t == DO_ACC_PARAM_TYPE_VALUE) { type = acc_param->u.ival; } else { if (pv_printf_s(msg, acc_param->u.pval, &in) < 0) { LM_ERR("failed to fetch type value!\n"); return -1; } if ((type=do_acc_parse(&in, do_acc_type_parser)) == DO_ACC_ERR) { LM_ERR("Invalid expression <%.*s> for acc type!\n", in.len, in.s); return -1; } } } if (flags_p != NULL) { flags= *(unsigned long long*)flags_p; } flag_mask = type * flags; /* reset all flags */ if (flag_mask == 0) { /* * we use this flag in order make the difference between * 0 value (do_accounting never called, callbacks never registered) and * ACC_FLAGS_RESET (do_accounting called, callbacks registered, flag value * changing during script execution) */ acc_ctx->flags = ACC_FLAGS_RESET; } else { reset_flags(acc_ctx->flags, flag_mask); } return 1; }
static int rtpproxy_stream2_f(struct sip_msg *msg, char *str1, int count, int stream2uac) { str pname; if (str1 == NULL || pv_printf_s(msg, (pv_elem_p)str1, &pname) != 0) return -1; return rtpproxy_stream(msg, &pname, count, stream2uac); }
static int sql_query_async(struct sip_msg *msg, char *dbl, char *query) { str sq; if(pv_printf_s(msg, (pv_elem_t*)query, &sq)!=0) { LM_ERR("cannot print the sql query\n"); return -1; } return sql_do_query_async((sql_con_t*)dbl, &sq); }
static int w_add_rr_param(struct sip_msg *msg, char *key, char *foo) { str s; if (pv_printf_s(msg, (pv_elem_t*)key, &s)<0) { LM_ERR("failed to print the format\n"); return -1; } return ((add_rr_param( msg, &s)==0)?1:-1); }
static int w_load_balance(struct sip_msg *req, char *grp, char *rl, char *al) { int ret; int grp_no; struct lb_grp_param *lbgp = (struct lb_grp_param *)grp; pv_value_t val; struct lb_res_str_list *lb_rl; struct lb_res_parse *lbp; pv_elem_t *model; str dest; if (lbgp->grp_pv) { if (pv_get_spec_value( req, (pv_spec_p)lbgp->grp_pv, &val)!=0) { LM_ERR("failed to get PV value\n"); return -1; } if ( (val.flags&PV_VAL_INT)==0 ) { LM_ERR("PV vals is not integer\n"); return -1; } grp_no = val.ri; } else { grp_no = lbgp->grp_no; } lbp = (struct lb_res_parse *)rl; if (lbp->type & RES_ELEM) { model = (pv_elem_p)lbp->param; if (pv_printf_s(req, model, &dest) || dest.len <= 0) { LM_ERR("cannot create resource string\n"); return -1; } lb_rl = parse_resources_list(dest.s, 0); if (!lb_rl) { LM_ERR("cannot create resource list\n"); return -1; } } else lb_rl = (struct lb_res_str_list *)lbp->param; lock_start_read( ref_lock ); /* do lb */ ret = do_load_balance(req, grp_no, lb_rl, (unsigned int)(long)al, *curr_data); lock_stop_read( ref_lock ); if (lbp->type & RES_ELEM) pkg_free(lb_rl); if (ret<0) return ret; return 1; }
int pv_set_ht_cell(struct sip_msg* msg, pv_param_t *param, int op, pv_value_t *val) { str htname; int_str isval; ht_pv_t *hpv; hpv = (ht_pv_t*)param->pvn.u.dname; if(hpv->ht==NULL) hpv->ht = ht_get_table(&hpv->htname); if(hpv->ht==NULL) return -1; if(pv_printf_s(msg, hpv->pve, &htname)!=0) { LM_ERR("cannot get $ht name\n"); return -1; } LM_DBG("set value for $ht(%.*s=>%.*s)\n", hpv->htname.len, hpv->htname.s, htname.len, htname.s); if((val==NULL) || (val->flags&PV_VAL_NULL)) { /* delete it */ if (hpv->ht->dmqreplicate>0 && ht_dmq_replicate_action(HT_DMQ_DEL_CELL, &hpv->htname, &htname, 0, NULL, 0)!=0) { LM_ERR("dmq relication failed\n"); } ht_del_cell(hpv->ht, &htname); return 0; } if(val->flags&PV_TYPE_INT) { isval.n = val->ri; if (hpv->ht->dmqreplicate>0 && ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname, &htname, 0, &isval, 1)!=0) { LM_ERR("dmq relication failed\n"); } if(ht_set_cell(hpv->ht, &htname, 0, &isval, 1)!=0) { LM_ERR("cannot set $ht(%.*s)\n", htname.len, htname.s); return -1; } } else { isval.s = val->rs; if (hpv->ht->dmqreplicate>0 && ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname, &htname, AVP_VAL_STR, &isval, 1)!=0) { LM_ERR("dmq relication failed\n"); } if(ht_set_cell(hpv->ht, &htname, AVP_VAL_STR, &isval, 1)!=0) { LM_ERR("cannot set $ht(%.*s)\n", htname.len, htname.s); return -1; } } return 0; }
int ldap_filter_url_encode( struct sip_msg* _msg, pv_elem_t* _filter_component, pv_spec_t* _dst_avp_spec) { str filter_component_str, esc_str; int dst_avp_name; unsigned short dst_avp_type; /* * variable substitution for _filter_component */ if (_filter_component) { if (pv_printf_s(_msg, _filter_component, &filter_component_str) != 0) { LM_ERR("pv_printf_s failed\n"); return -1; } } else { LM_ERR("empty first argument\n"); return -1; } /* * get dst AVP name (dst_avp_name) */ if (pv_get_avp_name(_msg, &(_dst_avp_spec->pvp), &dst_avp_name, &dst_avp_type) != 0) { LM_ERR("error getting dst AVP name\n"); return -1; } /* * apply LDAP filter escaping rules */ esc_str.s = esc_buf; esc_str.len = ESC_BUF_SIZE; if (ldap_rfc4515_escape(&filter_component_str, &esc_str, 1) != 0) { LM_ERR("ldap_rfc4515_escape() failed\n"); return -1; } /* * add dst AVP */ if (add_avp(dst_avp_type|AVP_VAL_STR, dst_avp_name, (int_str)esc_str) != 0) { LM_ERR("failed to add new AVP\n"); return -1; } return 1; }
static int w_update_stat(struct sip_msg *msg, char *stat_p, char *n) { struct stat_param *sp = (struct stat_param *)stat_p; pv_value_t pv_val; stat_var *stat; if (sp->type==STAT_PARAM_TYPE_STAT) { /* we have the statistic */ update_stat( sp->u.stat, (long)n); return 1; } if (sp->type==STAT_PARAM_TYPE_PVAR) { /* take name from PVAR */ if (pv_get_spec_value(msg, sp->u.pvar, &pv_val)!=0 || (pv_val.flags & PV_VAL_STR)==0 ) { LM_ERR("failed to get pv string value\n"); return -1; } } else if (sp->type==STAT_PARAM_TYPE_FMT) { /* take name from FMT */ if (pv_printf_s( msg, sp->u.format, &(pv_val.rs) )!=0 ) { LM_ERR("failed to get format string value\n"); return -1; } } else if (sp->type==STAT_PARAM_TYPE_NAME) { /* take name from STRING */ pv_val.rs = *sp->u.name; } LM_DBG("needed statistic is <%.*s>\n", pv_val.rs.len, pv_val.rs.s); /* name is in pv_val.rs -> look for it */ stat = get_stat( &(pv_val.rs) ); if ( stat==NULL ) { /* stats not found -> create it */ LM_DBG("creating dynamic statistic <%.*s>\n", pv_val.rs.len, pv_val.rs.s); if (register_dynamic_stat( &(pv_val.rs), &stat )!=0) { LM_ERR("failed to create dynamic statistic <%.*s>\n", pv_val.rs.len, pv_val.rs.s); return -1; } if (sp->type==STAT_PARAM_TYPE_NAME) { sp->u.stat = stat; sp->type=STAT_PARAM_TYPE_STAT; } } /* statistic exists ! */ update_stat( stat, (long)n); return 1; }
inline static int w_t_replicate(struct sip_msg *p_msg, char *dst, char *flags) { str dest; if(((pv_elem_p)dst)->spec.getf!=NULL) { if(pv_printf_s(p_msg, (pv_elem_p)dst, &dest)!=0 || dest.len <=0) return -1; } else { dest = ((pv_elem_p)dst)->text; } return t_replicate( p_msg, &dest, (int)(long)flags); }
int sql_do_xquery(struct sip_msg *msg, sql_con_t *con, pv_elem_t *query, pv_elem_t *res) { str sv, xavp; if(msg==NULL || query==NULL || res==NULL) { LM_ERR("bad parameters\n"); return -1; } if(pv_printf_s(msg, query, &sv)!=0) { LM_ERR("cannot print the sql query\n"); return -1; } if(pv_printf_s(msg, res, &xavp)!=0) { LM_ERR("cannot print the result parameter\n"); return -1; } return sql_exec_xquery(msg, con, &sv, &xavp); }
int w_drop_acc_2(struct sip_msg* msg, char* type_p, char* flags_p) { unsigned long long type=0; /* if not set, we reset all flags for the type of accounting requested */ unsigned long long flags=ALL_ACC_FLAGS; unsigned long long flag_mask; unsigned long long *context_flags_p=try_fetch_flags(); acc_type_param_t* acc_param; str in; if (context_flags_p == NULL) { LM_ERR("do_accounting() not used! This function resets flags in " "do_accounting()!\n"); return -1; } if (type_p != NULL) { acc_param = (acc_type_param_t *)type_p; if (acc_param->t == DO_ACC_PARAM_TYPE_VALUE) { type = acc_param->u.ival; } else { if (pv_printf_s(msg, acc_param->u.pval, &in) < 0) { LM_ERR("failed to fetch type value!\n"); return -1; } if ((type=do_acc_parse(&in, do_acc_type_parser)) < 0) { LM_ERR("Invalid expression <%.*s> for acc type!\n", in.len, in.s); return -1; } } } if (flags_p != NULL) { flags= *(unsigned long long*)flags_p; } flag_mask = type * flags; /* reset all flags */ if (flag_mask == 0) { *context_flags_p = 0; } else { reset_flags(*context_flags_p, flag_mask); } return 1; }
inline static int w_pv_t_reply(struct sip_msg *msg, char* code, char* text) { str code_s; unsigned int code_i; if(((pv_elem_p)code)->spec.getf!=NULL) { if(pv_printf_s(msg, (pv_elem_p)code, &code_s)!=0) return -1; if(str2int(&code_s, &code_i)!=0 || code_i<100 || code_i>699) return -1; } else { code_i = ((pv_elem_p)code)->spec.pvp.pvn.u.isname.name.n; } if(((pv_elem_p)text)->spec.getf!=NULL) { if(pv_printf_s(msg, (pv_elem_p)text, &code_s)!=0 || code_s.len <=0) return -1; } else { code_s = ((pv_elem_p)text)->text; } return w_t_reply(msg, (char*)(unsigned long)code_i, (char*)&code_s); }
/** * rewrites the request URI of msg by calculating a rule, using * crc32 for hashing. The request URI is used to determine tree node * the given _tree is the used routing tree * * @param msg the current SIP message * @param _tree the routing tree to be used (string or pseudo-variable * @param _domain the requested routing domain * * @return 1 on success, -1 on failure */ int tree_route_uri(struct sip_msg * msg, char * _tree, char * _domain) { struct rewrite_data * rd = NULL; pv_elem_t *model; str carrier_name; int index; str ruser; str ruri; if (!_tree) { LM_ERR("bad parameters\n"); return -1; } if (parse_sip_msg_uri(msg) < 0) { return -1; } /* Retrieve carrier name from parameter */ model = (pv_elem_t*)_tree; if (pv_printf_s(msg, model, &carrier_name)<0) { LM_ERR("cannot print the format\n"); return -1; } if ((index = find_tree(carrier_name)) < 0) LM_WARN("could not find carrier %.*s\n", carrier_name.len, carrier_name.s); else LM_DBG("tree %.*s has id %i\n", carrier_name.len, carrier_name.s, index); ruser.s = msg->parsed_uri.user.s; ruser.len = msg->parsed_uri.user.len; ruri.s = msg->parsed_uri.user.s; ruri.len = msg->parsed_uri.user.len; do { rd = get_data(); } while (rd == NULL); if (index < 0) { if (fallback_default) { LM_NOTICE("invalid tree id %i specified, use default tree\n", index); index = rd->default_carrier_index; } else { LM_ERR("invalid tree id %i specified and fallback deactivated\n", index); release_data(rd); return -1; } } release_data(rd); return carrier_rewrite_msg(index, (int)(long)_domain, &ruri, msg, &ruser, shs_call_id, alg_crc32); }
static int w_evaluate_rpn(struct sip_msg *msg, char *exp, char *result) { pv_elem_p exp_fmt = (pv_elem_p)exp; str s; if (pv_printf_s(msg, exp_fmt, &s) != 0) { LM_ERR("Failed to print the pv format string!\n"); return -1; } LM_DBG("Evaluating expression: %.*s\n", s.len, s.s); return evaluate_exp(msg, &s, (pv_spec_p)result, 1); }
static int w_replace_to(struct sip_msg* msg, char* p1, char* p2) { str uri_s; str dsp_s; str *uri = NULL; str *dsp = NULL; if (p2==NULL) { p2 = p1; p1 = NULL; dsp = NULL; } /* p1 display , p2 uri */ if( p1!=NULL ) { if(pv_printf_s( msg, (pv_elem_p)p1, &dsp_s)!=0) return -1; dsp = &dsp_s; } /* compute the URI string; if empty string -> make it NULL */ if (pv_printf_s( msg, (pv_elem_p)p2, &uri_s)!=0) return -1; uri = uri_s.len?&uri_s:NULL; /* parse TO hdr */ if ( msg->to==0 && (parse_headers(msg,HDR_TO_F,0)!=0 || msg->to==0) ) { LM_ERR("failed to parse TO hdr\n"); return -1; } LM_DBG("dsp=%p (len=%d) , uri=%p (len=%d)\n",dsp,dsp?dsp->len:0,uri,uri?uri->len:0); return (replace_uri(msg, dsp, uri, msg->to, &rr_to_param, &restore_to_avp, 0)==0)?1:-1; }
int h350_sipuri_lookup(struct sip_msg* _msg, pv_elem_t* _sip_uri) { str sip_uri, sip_uri_escaped; int ld_result_count; static char sip_uri_escaped_buf[SIP_URI_ESCAPED_MAX_LEN]; /* * get sip_uri */ if (pv_printf_s(_msg, _sip_uri, &sip_uri) != 0) { LM_ERR("pv_printf_s failed\n"); return E_H350_INTERNAL; } /* * ldap filter escape sip_uri */ sip_uri_escaped.s = sip_uri_escaped_buf; sip_uri_escaped.len = SIP_URI_ESCAPED_MAX_LEN - 1; if (ldap_api.ldap_rfc4515_escape(&sip_uri, &sip_uri_escaped, 0)) { LM_ERR("ldap_rfc4515_escape failed\n"); return E_H350_INTERNAL; } /* * do ldap search */ if (ldap_api.ldap_params_search(&ld_result_count, h350_ldap_session.s, h350_base_dn.s, h350_search_scope_int, NULL, H350_SIPURI_LOOKUP_LDAP_FILTER, sip_uri_escaped.s) != 0) { LM_ERR("ldap search failed\n"); return E_H350_INTERNAL; } if (ld_result_count < 1) { return E_H350_NO_SUCCESS; } return ld_result_count; }
int acc_get_param_value(struct sip_msg *rq, struct acc_param *param) { if(param->elem!=NULL) { if(pv_printf_s(rq, param->elem, ¶m->reason)==-1) { LM_ERR("Can't get value for %.*s\n", param->reason.len, param->reason.s); return -1; } if(acc_parse_code(param->reason.s, param)<0) { LM_ERR("Can't parse code\n"); return -1; } } return 0; }
int w_replace_from(struct sip_msg* msg, char* p1, char* p2) { str uri_s; str dsp_s; str *uri = NULL; str *dsp = NULL; if (p2==NULL) { p2 = p1; p1 = NULL; dsp = NULL; } /* p1 display , p2 uri */ if ( p1!=NULL ) { if(pv_printf_s( msg, (pv_elem_p)p1, &dsp_s)!=0) return -1; dsp = &dsp_s; } /* compute the URI string; if empty string -> make it NULL */ if (pv_printf_s( msg, (pv_elem_p)p2, &uri_s)!=0) return -1; uri = uri_s.len?&uri_s:NULL; if (parse_from_header(msg)<0 ) { LM_ERR("failed to find/parse FROM hdr\n"); return -1; } LM_DBG("dsp=%p (len=%d) , uri=%p (len=%d)\n",dsp,dsp?dsp->len:0,uri,uri?uri->len:0); return (replace_uri(msg, dsp, uri, msg->from, &rr_from_param, &restore_from_avp, 1)==0)?1:-1; }
int w_store_dlg_value(struct sip_msg *msg, char *name, char *val) { struct dlg_cell *dlg; pv_elem_t *pve = (pv_elem_t *)val; str val_s; if ( (dlg=get_current_dialog())==NULL ) return -1; if ( pve==NULL || pv_printf_s(msg, pve, &val_s)!=0 || val_s.len == 0 || val_s.s == NULL) { LM_WARN("cannot get string for value\n"); return -1; } return (store_dlg_value( dlg, (str*)name, &val_s)==0)?1:-1; }
/** * Get the carrier id from multiparam_t structure. * * @param mp carrier id as integer, pseudo-variable or AVP name of carrier * @param _msg SIP message * @return carrier id on success, -1 otherwise * */ int mp2carrier_id(struct sip_msg * _msg, struct multiparam_t *mp) { int carrier_id; struct usr_avp *avp; int_str avp_val; str tmp; /* TODO combine the redundant parts of the logic */ switch (mp->type) { case MP_INT: return mp->u.n; break; case MP_AVP: avp = search_first_avp(mp->u.a.flags, mp->u.a.name, &avp_val, 0); if (!avp) { LM_ERR("cannot find AVP '%d'\n", mp->u.a.name); return -1; } if ((avp->flags&AVP_VAL_STR)==0) { return avp_val.n; } else { carrier_id = find_tree(avp_val.s); if (carrier_id < 0) { LM_WARN("could not find carrier tree '%.*s'\n", avp_val.s.len, avp_val.s.s); /* might be using fallback later... */ } return carrier_id; } break; case MP_PVE: /* retrieve carrier name from parameter */ if (pv_printf_s(_msg, mp->u.p, &tmp)<0) { LM_ERR("cannot print the carrier\n"); return -1; } carrier_id = find_tree(tmp); if (carrier_id < 0) { LM_WARN("could not find carrier tree '%.*s'\n", tmp.len, tmp.s); /* might be using fallback later... */ } return carrier_id; default: LM_ERR("invalid carrier type\n"); return -1; } }
static int w_assert_identity(struct sip_msg* _m, char* _d, char* _preferred_uri) { pv_elem_t *model; str identity; if(_preferred_uri == NULL) { LM_ERR("error - bad parameters\n"); return -1; } model = (pv_elem_t*)_preferred_uri; if (pv_printf_s(_m, model, &identity)<0) { LM_ERR("error - cannot print the format\n"); return -1; } return assert_identity( _m, (udomain_t*)_d, identity); }
/** * Get the domain id from multiparam_t structure. * * @param _msg SIP message * @param mp carrier id as integer, pseudo-variable or AVP name of carrier * @return carrier id on success, -1 otherwise * */ int mp2domain_id(struct sip_msg * _msg, struct multiparam_t *mp) { int domain_id; struct usr_avp *avp; int_str avp_val; str tmp; /* TODO combine the redundant parts of the logic */ switch (mp->type) { case MP_INT: return mp->u.n; break; case MP_AVP: avp = search_first_avp(mp->u.a.flags, mp->u.a.name, &avp_val, 0); if (!avp) { LM_ERR("cannot find AVP '%d'\n", mp->u.a.name); return -1; } if ((avp->flags&AVP_VAL_STR)==0) { return avp_val.n; } else { domain_id = add_domain(&avp_val.s); if (domain_id < 0) { LM_ERR("could not find domain '%.*s'\n", avp_val.s.len, avp_val.s.s); return -1; } return domain_id; } break; case MP_PVE: /* retrieve domain name from parameter */ if (pv_printf_s(_msg, mp->u.p, &tmp)<0) { LM_ERR("cannot print the domain\n"); return -1; } domain_id = add_domain(&tmp); if (domain_id < 0) { LM_ERR("could not find domain '%.*s'\n", tmp.len, tmp.s); return -1; } return domain_id; default: LM_ERR("invalid domain type\n"); return -1; } }
/** * 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; }
/** * wrapper for record_route(msg, params) */ static int w_record_route_advertised_address(struct sip_msg *msg, char *addr, char *bar) { str s; if (msg->msg_flags & FL_RR_ADDED) { LM_ERR("Double attempt to record-route\n"); return -1; } if (pv_printf_s(msg, (pv_elem_t*)addr, &s) < 0) { LM_ERR("failed to print the format\n"); return -1; } if ( record_route_advertised_address( msg, &s ) < 0) return -1; msg->msg_flags |= FL_RR_ADDED; return 1; }
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; }
static int w_is_in_profile(struct sip_msg *msg, char *profile, char *value) { pv_elem_t *pve; str val_s; pve = (pv_elem_t *) value; if (pve != NULL && ((struct dlg_profile_table*) profile)->has_value) { if (pv_printf_s(msg, pve, &val_s) != 0 || val_s.len == 0 || val_s.s == NULL) { LM_WARN("cannot get string for value\n"); return -1; } return is_dlg_in_profile(msg, (struct dlg_profile_table*) profile, &val_s); } else { return is_dlg_in_profile(msg, (struct dlg_profile_table*) profile, NULL); } }
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; }
int pv_get_ht_add(struct sip_msg *msg, pv_param_t *param, pv_value_t *res, int val) { str htname; ht_cell_t *htc=NULL; ht_pv_t *hpv; hpv = (ht_pv_t*)param->pvn.u.dname; if(hpv->ht==NULL) { hpv->ht = ht_get_table(&hpv->htname); if(hpv->ht==NULL) return pv_get_null(msg, param, res); } if(pv_printf_s(msg, hpv->pve, &htname)!=0) { LM_ERR("cannot get $ht name\n"); return -1; } htc = ht_cell_value_add(hpv->ht, &htname, val, 1, _htc_local); if(htc==NULL) { return pv_get_null(msg, param, res); } if(_htc_local!=htc) { ht_cell_pkg_free(_htc_local); _htc_local=htc; } if(htc->flags&AVP_VAL_STR) return pv_get_null(msg, param, res); /* integer */ if (hpv->ht->dmqreplicate>0) { if (ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname, &htname, 0, &htc->value, 1)!=0) { LM_ERR("dmq relication failed\n"); } } return pv_get_sintval(msg, param, res, htc->value.n); }
static int w_get_dlg_info(struct sip_msg *msg, char *attr, char *attr_val, char *key, char *key_val) { struct dlg_cell *dlg; pv_elem_t *pve = (pv_elem_t *)key_val; pv_spec_t *dst = (pv_spec_t *)attr_val; pv_value_t val; str val_s; int n; if ( pve==NULL || pv_printf_s(msg, pve, &val_s)!=0 || val_s.len == 0 || val_s.s == NULL) { LM_WARN("cannot get string for value\n"); return -1; } dlg = get_dlg_by_val( (str*)key, &val_s); if (dlg==NULL) { /* nothing found */ LM_DBG("no dialog found\n"); return -1; } /* dlg found - NOTE you have a ref! */ LM_DBG("dialog found, fetching variable\n"); if (fetch_dlg_value( dlg, (str*)attr, &val.rs, 0) ) { LM_DBG("failed to fetch dialog value <%.*s>\n", ((str*)attr)->len, ((str*)attr)->s); n = -1 ; } else { val.flags = PV_VAL_STR; n = (dst->setf( msg, &dst->pvp, 0, &val )==0)?1:-1; } unref_dlg(dlg, 1); return n; }
/** * get dynamic name profile size */ static int w_get_profile_size3(struct sip_msg *msg, char *profile, char *value, char *result) { pv_elem_t *pve; str val_s; pv_spec_t *sp_dest; unsigned int size; pv_value_t val; if(result!=NULL) { pve = (pv_elem_t *)value; sp_dest = (pv_spec_t *)result; } else { pve = NULL; sp_dest = (pv_spec_t *)value; } if ( pve!=NULL && ((struct dlg_profile_table*)profile)->has_value) { if ( pv_printf_s(msg, pve, &val_s)!=0 || val_s.len == 0 || val_s.s == NULL) { LM_WARN("cannot get string for value\n"); return -1; } size = get_profile_size( (struct dlg_profile_table*)profile, &val_s ); } else { size = get_profile_size( (struct dlg_profile_table*)profile, NULL ); } memset(&val, 0, sizeof(pv_value_t)); val.flags = PV_VAL_INT|PV_TYPE_INT; val.ri = (int)size; if(sp_dest->setf(msg, &sp_dest->pvp, (int)EQ_T, &val)<0) { LM_ERR("setting profile PV failed\n"); return -1; } return 1; }