static int w_registered(struct sip_msg* _m, char* _d, char* _uri) { str uri = {0}; if(_uri!=NULL && (fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0 || uri.len<=0)) { LM_ERR("invalid uri parameter\n"); return -1; } return registered(_m, (udomain_t*)_d, (uri.len>0)?&uri:NULL); }
static int w_xavp_params_explode(sip_msg_t *msg, char *pparams, char *pxname) { str sparams; str sxname; if(fixup_get_svalue(msg, (gparam_t*)pparams, &sparams)!=0) { LM_ERR("cannot get the params\n"); return -1; } if(fixup_get_svalue(msg, (gparam_t*)pxname, &sxname)!=0) { LM_ERR("cannot get the xavp name\n"); return -1; } if(xavp_params_explode(&sparams, &sxname)<0) return -1; return 1; }
static int w_send_data(sip_msg_t *msg, char *suri, char *sdata) { str uri; str data; if (fixup_get_svalue(msg, (gparam_t*)suri, &uri)) { LM_ERR("cannot get the destination parameter\n"); return -1; } if (fixup_get_svalue(msg, (gparam_t*)sdata, &data)) { LM_ERR("cannot get the destination parameter\n"); return -1; } if(corex_send_data(&uri, NULL, &data) < 0) return -1; return 1; }
static int w_sd_journal_send_xavp(struct sip_msg* msg, char* xname, char* foo) { str sxname; if(fixup_get_svalue(msg, (gparam_t*)xname, &sxname)!=0) { LM_ERR("unable to get xname parameter\n"); return -1; } return k_sd_journal_send_xavp(&sxname); }
/* * Check if the parameter contains alphanumeric characters or are part of * the second parameter */ int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se) { str tval = {0, 0}; str eset = {0, 0}; int i; int j; int found; if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) { LM_ERR("cannot get tval parameter value\n"); return -1; } if(fixup_get_svalue(msg, (gparam_t*)_se, &eset)!=0) { LM_ERR("cannot get eset parameter value\n"); return -1; } if(tval.len<=0) return -2; i = 0; for(; i<tval.len; i++) { if( !((tval.s[i]>='0' && tval.s[i]<='9') || (tval.s[i]>='A' && tval.s[i]<='Z') || (tval.s[i]>='z' && tval.s[i]<='z')) ) { if(eset.len<=0) { return -3; } found = 0; for(j=0; j<eset.len; j++) { if(tval.s[i]==eset.s[j]) { found = 1; break; } } if(found==0) { return -3; } } } return 1; }
/** * wrapper for update_watchers_status to use in config */ static int w_pres_update_watchers(struct sip_msg *msg, char *puri, char *pevent) { str pres_uri; str event; if(fixup_get_svalue(msg, (gparam_p)puri, &pres_uri)!=0) { LM_ERR("invalid uri parameter"); return -1; } if(fixup_get_svalue(msg, (gparam_p)pevent, &event)!=0) { LM_ERR("invalid uri parameter"); return -1; } return ki_pres_update_watchers(msg, &pres_uri, &event); }
int w_rls_update_subs(struct sip_msg *msg, char *puri, char *pevent) { str uri; str event; if (fixup_get_svalue(msg, (gparam_p)puri, &uri) != 0) { LM_ERR("invalid uri parameter\n"); return -1; } if (fixup_get_svalue(msg, (gparam_p)pevent, &event) != 0) { LM_ERR("invalid event parameter\n"); return -1; } return ki_rls_update_subs(msg, &uri, &event); }
static int w_evapi_async_relay(sip_msg_t *msg, char *evdata, char *p2) { str sdata; unsigned int tindex; unsigned int tlabel; tm_cell_t *t = 0; if(evdata==0) { LM_ERR("invalid parameters\n"); return -1; } if(tmb.t_suspend==NULL) { LM_ERR("evapi async relay is disabled - tm module not loaded\n"); return -1; } t = tmb.t_gett(); if (t==NULL || t==T_UNDEFINED) { if(tmb.t_newtran(msg)<0) { LM_ERR("cannot create the transaction\n"); return -1; } t = tmb.t_gett(); if (t==NULL || t==T_UNDEFINED) { LM_ERR("cannot lookup the transaction\n"); return -1; } } if(tmb.t_suspend(msg, &tindex, &tlabel)<0) { LM_ERR("failed to suspend request processing\n"); return -1; } LM_DBG("transaction suspended [%u:%u]\n", tindex, tlabel); if(fixup_get_svalue(msg, (gparam_t*)evdata, &sdata)!=0) { LM_ERR("unable to get data\n"); return -1; } if(sdata.s==NULL || sdata.len == 0) { LM_ERR("invalid data parameter\n"); return -1; } if(evapi_relay(&sdata)<0) { LM_ERR("failed to relay event: %.*s\n", sdata.len, sdata.s); return -2; } return 1; }
static int w_dlg_bridge(struct sip_msg *msg, char *from, char *to, char *op) { str sf = {0,0}; str st = {0,0}; str so = {0,0}; if(from==0 || to==0 || op==0) { LM_ERR("invalid parameters\n"); return -1; } if(fixup_get_svalue(msg, (gparam_p)from, &sf)!=0) { LM_ERR("unable to get From\n"); return -1; } if(sf.s==NULL || sf.len == 0) { LM_ERR("invalid From parameter\n"); return -1; } if(fixup_get_svalue(msg, (gparam_p)to, &st)!=0) { LM_ERR("unable to get To\n"); return -1; } if(st.s==NULL || st.len == 0) { LM_ERR("invalid To parameter\n"); return -1; } if(fixup_get_svalue(msg, (gparam_p)op, &so)!=0) { LM_ERR("unable to get OP\n"); return -1; } if(dlg_bridge(&sf, &st, &so, NULL)!=0) return -1; return 1; }
static int w_http_set_tls_client_key(sip_msg_t* msg, char* sk, char*foo) { str _tls_client_key; if(fixup_get_svalue(msg, (gparam_t*)sk, &_tls_client_key)!=0) { LM_ERR("unable to get method value\n"); return -1; } return set_query_param(&ah_params.tls_client_key, _tls_client_key); }
static int w_rest_init_client_tls(struct sip_msg *msg, char *gp_tls_dom) { str tls_client_dom; if (fixup_get_svalue(msg, (gparam_p)gp_tls_dom, &tls_client_dom) != 0) { LM_ERR("cannot retrieve header field value\n"); return -1; } return rest_init_client_tls(msg, &tls_client_dom); }
static int w_rest_append_hf(struct sip_msg *msg, char *gp_hfv) { str hfv; if (fixup_get_svalue(msg, (gparam_p)gp_hfv, &hfv) != 0) { LM_ERR("cannot retrieve header field value\n"); return -1; } return rest_append_hf_method(msg, &hfv); }
static int w_xavp_rm(sip_msg_t *msg, char *prname, char *p2) { str rname; if(fixup_get_svalue(msg, (gparam_t*)prname, &rname)<0) { LM_ERR("failed to get root xavp name\n"); return -1; } return ki_xavp_rm(msg, &rname); }
int pv_fetch_contacts(sip_msg_t* msg, char* table, char* uri, char* profile) { str u = STR_NULL; if(fixup_get_svalue(msg, (gparam_t*)uri, &u)!=0 || u.len<=0) { LM_ERR("invalid uri parameter\n"); return -1; } return pv_fetch_contacts_helper(msg, (udomain_t*)table, &u, (str*)profile); }
int w_rls_handle_subscribe1(struct sip_msg* msg, char* watcher_uri, char *p2) { str wuri; if (fixup_get_svalue(msg, (gparam_p)watcher_uri, &wuri) != 0) { LM_ERR("invalid uri parameter\n"); return -1; } return ki_rls_handle_subscribe_uri(msg, &wuri); }
static int w_ht_iterator_start(struct sip_msg* msg, char* iname, char* hname) { str siname; str shname; if(fixup_get_svalue(msg, (gparam_t*)iname, &siname)<0 || siname.len<=0) { LM_ERR("cannot get iterator name\n"); return -1; } if(fixup_get_svalue(msg, (gparam_t*)hname, &shname)<0 || shname.len<=0) { LM_ERR("cannot get hash table name\n"); return -1; } if(ht_iterator_start(&siname, &shname)<0) return -1; return 1; }
static int w_http_set_tls_ca_path(sip_msg_t* msg, char* cp, char*foo) { str _tls_ca_path; if(fixup_get_svalue(msg, (gparam_t*)cp, &_tls_ca_path)!=0) { LM_ERR("unable to get method value\n"); return -1; } return set_query_param(&ah_params.tls_ca_path, _tls_ca_path); }
static int w_xavp_params_implode(sip_msg_t *msg, char *pxname, char *pvname) { str sxname; if(fixup_get_svalue(msg, (gparam_t*)pxname, &sxname)!=0) { LM_ERR("cannot get the xavp name\n"); return -1; } return ki_xavp_params_implode(msg, &sxname, (str*)pvname); }
static int w_unregister(struct sip_msg* _m, char* _d, char* _uri) { str uri = {0}; if(fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0 || uri.len<=0) { LM_ERR("invalid uri parameter\n"); return -1; } return unregister(_m, (udomain_t*)_d, &uri, NULL); }
/** * xavp to script variable */ static int w_xavp_to_var(sip_msg_t *msg, char *s1) { str xname = STR_NULL; if(fixup_get_svalue(msg, (gparam_t*)s1, &xname)<0) { LM_ERR("failed to get the xavp name\n"); return -1; } return pv_xavp_to_var(&xname); }
/*! \brief * Wrapper to save(location) */ static int w_save3(struct sip_msg* _m, char* _d, char* _cflags, char* _uri) { str uri; if(fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0 || uri.len<=0) { LM_ERR("invalid uri parameter\n"); return -1; } return save(_m, (udomain_t*)_d, ((int)(unsigned long)_cflags), &uri); }
static int w_evapi_set_tag(sip_msg_t* msg, char* ptag, char* p2) { str stag; if(fixup_get_svalue(msg, (gparam_t*)ptag, &stag)!=0) { LM_ERR("no tag name\n"); return -1; } if(evapi_set_tag(msg, &stag)<0) return -1; return 1; }
int cmd_check_addr(struct sip_msg *msg, char *param_cluster, char *param_ip, char *param_addr_type) { int cluster_id; str ip_str; str addr_type_str; static str bin_addr_t = str_init("bin"); static str sip_addr_t = str_init("sip"); enum node_addr_type check_type; if (fixup_get_ivalue(msg, (gparam_p)param_cluster, &cluster_id) < 0) { LM_ERR("Failed to fetch cluster id parameter\n"); return -1; } if (fixup_get_svalue(msg, (gparam_p)param_ip, &ip_str) < 0) { LM_ERR("Failed to fetch ip parameter\n"); return -1; } if (param_addr_type && fixup_get_svalue(msg, (gparam_p)param_addr_type, &addr_type_str) < 0) { LM_ERR("Failed to fetch address type parameter\n"); return -1; } if (param_addr_type) { if (!str_strcasecmp(&addr_type_str, &bin_addr_t)) check_type = NODE_BIN_ADDR; else if (!str_strcasecmp(&addr_type_str, &sip_addr_t)) check_type = NODE_SIP_ADDR; else { LM_ERR("Bad address type, should be 'bin' or 'sip'\n"); return -1; } } else check_type = NODE_SIP_ADDR; if (clusterer_check_addr(cluster_id, &ip_str, check_type) == 0) return -1; else return 1; }
static int w_http_async_get(sip_msg_t *msg, char *query, char* rt) { str sdata; cfg_action_t *act; str rn; int ri; if(msg==NULL) return -1; if(fixup_get_svalue(msg, (gparam_t*)query, &sdata)!=0) { LM_ERR("unable to get data\n"); return -1; } if(sdata.s==NULL || sdata.len == 0) { LM_ERR("invalid data parameter\n"); return -1; } if(fixup_get_svalue(msg, (gparam_t*)rt, &rn)!=0) { LM_ERR("no route block name\n"); return -1; } ri = route_get(&main_rt, rn.s); if(ri<0) { LM_ERR("unable to find route block [%.*s]\n", rn.len, rn.s); return -1; } act = main_rt.rlist[ri]; if(act==NULL) { LM_ERR("empty action lists in route block [%.*s]\n", rn.len, rn.s); return -1; } return async_send_query(msg, &sdata, NULL, act); }
/* * Authorize digest credentials */ static inline int authorize(struct sip_msg *_msg, gparam_t *_realm, gparam_t *_uri_user, hdr_types_t _hftype) { str srealm = STR_NULL; str suser = STR_NULL; /* get pre_auth domain from _realm param (if exists) */ if(_realm) { if(fixup_get_svalue(_msg, _realm, &srealm)<0) { LM_ERR("failed to get realm value\n"); return -5; } } if(_uri_user) { if(fixup_get_svalue(_msg, _uri_user, &suser)<0) { LM_ERR("cannot get uri user value\n"); return AUTH_ERROR; } } return ki_authorize(_msg, &srealm, &suser, _hftype); }
static int w_geoip_match(sip_msg_t* msg, char* target, char* pvname) { str tomatch = STR_NULL; str pvclass = STR_NULL; if(msg==NULL) { LM_ERR("received null msg\n"); return -1; } if(fixup_get_svalue(msg, (gparam_t*)target, &tomatch)<0) { LM_ERR("cannot get the address\n"); return -1; } if(fixup_get_svalue(msg, (gparam_t*)pvname, &pvclass)<0) { LM_ERR("cannot get the pv class\n"); return -1; } return geoip_match(msg, &tomatch, &pvclass); }
static int w_alias_db_lookup(struct sip_msg* _msg, char* _table, char* _str2) { str table_s; if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) { LM_ERR("invalid table parameter\n"); return -1; } return alias_db_lookup(_msg, table_s); }
static int w_basic_round_op(struct sip_msg *msg, char *number, char *result, double (*round_func)(double)) { str n; if (fixup_get_svalue(msg, (gparam_p)number, &n) != 0) { LM_ERR("Invalid number pseudo variable!\n"); return -1; } return basic_round_op(msg, &n, (pv_spec_p)result, round_func); }
static int w_mq_pv_free(struct sip_msg* msg, char* mq, char* str2) { str q; if(fixup_get_svalue(msg, (gparam_t*)mq, &q)<0) { LM_ERR("cannot get the queue\n"); return -1; } mq_pv_free(&q); return 1; }
static int w_cfg_lock_wrapper(struct sip_msg *msg, gparam_p key, int mode) { str s; if(key==NULL) { return -1; } if(fixup_get_svalue(msg, key, &s)!=0) { LM_ERR("cannot get first parameter\n"); return -1; } return cfg_lock_helper(&s, mode); }