static inline int add_subs_state_hf(dstring_t *buf, watcher_status_t _s, time_t _e) { char* num; int len; str s = STR_NULL; static str timeout = STR_STATIC_INIT("timeout"); static str rejected = STR_STATIC_INIT("rejected"); switch(_s) { case WS_ACTIVE: ; s = watcher_status_names[WS_ACTIVE]; break; case WS_REJECTED: case WS_PENDING_TERMINATED: case WS_TERMINATED: s = watcher_status_names[WS_TERMINATED]; break; case WS_PENDING: s = watcher_status_names[WS_PENDING]; break; } dstr_append_zt(buf, "Subscription-State: "); dstr_append_str(buf, &s); switch(_s) { case WS_PENDING: ; case WS_ACTIVE: dstr_append_zt(buf, ";expires="); num = int2str((unsigned int)_e, &len); dstr_append(buf, num, len); break; case WS_REJECTED: case WS_PENDING_TERMINATED: case WS_TERMINATED: dstr_append_zt(buf, ";reason="); if (_e <= 0) dstr_append_str(buf, &timeout); else dstr_append_str(buf, &rejected); break; } dstr_append_zt(buf, "\r\n"); return 0; }
static void uri_type_to_str(uri_type type, str *s) { static str s_sip = STR_STATIC_INIT("sip"); static str s_sips = STR_STATIC_INIT("sips"); static str s_tel = STR_STATIC_INIT("tel"); static str s_tels = STR_STATIC_INIT("tels"); static str s_null = STR_STATIC_INIT(""); switch (type) { case SIP_URI_T: *s = s_sip; break; case SIPS_URI_T: *s = s_sips; break; case TEL_URI_T: *s = s_tel; break; case TELS_URI_T: *s = s_tels; break; default: *s = s_null; } }
static int publish_presentity(struct sip_msg* _m, struct pdomain* _d, struct presentity* presentity) { event_t *parsed_event = NULL; int event_package = EVENT_OTHER; str callid = STR_STATIC_INIT("???"); int res; if (_m->event) parsed_event = (event_t *)_m->event->parsed; if (parsed_event) event_package = parsed_event->parsed; LOG(L_DBG, "publish_presentity: event_package=%d -1-\n", event_package); switch (event_package) { case EVENT_PRESENCE: res = publish_presence(_m, presentity); break; default: if (_m->callid) callid = _m->callid->body; LOG(L_WARN, "publish_presentity: no handler for event_package=%d" " callid=%.*s\n", event_package, callid.len, ZSW(callid.s)); paerrno = PA_EVENT_UNSUPP; res = -1; } return res; }
static int db_load_domain(domain_t** d, unsigned long flags, str* domain) { int ret; int_str name, val; domain_t* p; str name_s = STR_STATIC_INIT(AVP_DID); if (flags & AVP_TRACK_FROM) { p = &dom_buf[0]; } else { p = &dom_buf[1]; } free_old_domain(p); ret = db_get_did(&p->did, domain); if (ret != 1) return ret; if (load_domain_attrs) { if (db_load_domain_attrs(p) < 0) return -1; } /* Create an attribute containing did of the domain */ name.s = name_s; val.s = p->did; if (add_avp_list(&p->attrs, AVP_CLASS_DOMAIN | AVP_NAME_STR | AVP_VAL_STR, name, val) < 0) return -1; *d = p; return 0; }
static int prepare_winfo_notify(struct retr_buf **dst, struct presentity* _p, struct watcher* _w, pa_notify_cb_param_t *cbd) { str doc = STR_NULL; str content_type = STR_NULL; str headers = STR_NULL; int res = 0; str body = STR_STATIC_INIT(""); uac_req_t uac_r; switch (_w->preferred_mimetype) { case DOC_WINFO: create_winfo_document(_p, _w, &doc, &content_type); DEBUG("winfo document created\n"); break; /* other formats ? */ default: ERR("unknow doctype\n"); return -1; } if (create_headers(_w, &headers, &content_type) < 0) { ERR("Error while adding headers\n"); str_free_content(&doc); str_free_content(&content_type); return -7; } if (!is_str_empty(&doc)) body = doc; /* res = tmb.t_request_within(¬ify, &headers, &body, _w->dialog, 0, 0); */ set_uac_req(&uac_r, ¬ify, &headers, &body, _w->dialog, TMCB_LOCAL_COMPLETED, pa_notify_cb, cbd ); res = tmb.prepare_request_within(&uac_r, dst); if (res < 0) { ERR("Can't send watcherinfo notification (%d)\n", res); } else { _w->document_index++; /* increment index for next document */ } str_free_content(&doc); str_free_content(&headers); str_free_content(&content_type); return res; }
str_t * rls_get_package(rl_subscription_t *s) { static str presence = STR_STATIC_INIT("presence"); str_t *package = NULL; if (!s) return NULL; if (s->type == rls_external_subscription) package = &((s)->u.external.package); else package = s->u.internal.package; if (!package) package = &presence; return package; }
int send_winfo_notify_offline(struct presentity* _p, struct watcher* _w, offline_winfo_t *info, transaction_cb completion_cb, void* cbp) { str doc = STR_NULL; str content_type = STR_NULL; str headers = STR_NULL; str body = STR_STATIC_INIT(""); uac_req_t uac_r; switch (_w->preferred_mimetype) { case DOC_WINFO: create_winfo_document_offline(_p, _w, info, &doc, &content_type); break; /* other formats ? */ default: ERR("send_winfo_notify: unknow doctype\n"); return -1; } if (create_headers(_w, &headers, &content_type) < 0) { ERR("send_winfo_notify(): Error while adding headers\n"); str_free_content(&doc); str_free_content(&content_type); return -7; } if (!is_str_empty(&doc)) body = doc; set_uac_req(&uac_r, ¬ify, &headers, &body, _w->dialog, TMCB_LOCAL_COMPLETED, completion_cb, cbp ); tmb.t_request_within(&uac_r); str_free_content(&doc); str_free_content(&headers); str_free_content(&content_type); _w->document_index++; /* increment index for next document */ if (use_db) db_update_watcher(_p, _w); /* dialog and index have changed */ return 0; }
/* * Check whether peer certificate exists and verify the result * of certificate verification */ static int check_cert(str* res, int* ires, int local, int err, sip_msg_t* msg) { static str succ = STR_STATIC_INIT("1"); static str fail = STR_STATIC_INIT("0"); struct tcp_connection* c; SSL* ssl; X509* cert = 0; c = get_cur_connection(msg); if (!c) return -1; ssl = get_ssl(c); if (!ssl) goto error; if (local) { DBG("Verification of local certificates not supported\n"); goto error; } else { if ((cert = SSL_get_peer_certificate(ssl)) && SSL_get_verify_result(ssl) == err) { *res = succ; if (ires) *ires = 1; } else { *res = fail; if (ires) *ires = 0; } } if (cert) X509_free(cert); tcpconn_put(c); return 0; error: if (cert) X509_free(cert); if (c) tcpconn_put(c); return -1; }
/** * send a SIP MESSAGE message * - to : destination * - from : origin * - contact : contact header * - msg : body of the message * #return : 0 on success or <0 on error */ int xj_send_sip_msg(str *proxy, str *to, str *from, str *msg, int *cbp) { str msg_type = STR_STATIC_INIT("MESSAGE"); char buf[512]; str tfrom; str str_hdr; char buf1[1024]; if( !to || !to->s || to->len <= 0 || !from || !from->s || from->len <= 0 || !msg || !msg->s || msg->len <= 0 || (cbp && *cbp!=0) ) return -1; // from correction tfrom.len = 0; strncpy(buf+tfrom.len, "<sip:", 5); tfrom.len += 5; strncpy(buf+tfrom.len, from->s, from->len); tfrom.len += from->len; buf[tfrom.len++] = '>'; tfrom.s = buf; // building Contact and Content-Type strcpy(buf1,"Content-Type: text/plain"CRLF"Contact: "); str_hdr.len = 24 + CRLF_LEN + 9; strncat(buf1,tfrom.s,tfrom.len); str_hdr.len += tfrom.len; strcat(buf1, CRLF); str_hdr.len += CRLF_LEN; str_hdr.s = buf1; if(cbp) { #ifdef XJ_EXTRA_DEBUG DBG("XJAB:xj_send_sip_msg: uac callback parameter [%p==%d]\n", cbp, *cbp); #endif return tmb.t_request(&msg_type, 0, to, &tfrom, &str_hdr, msg, 0, xj_tuac_callback, (void*)cbp); } else return tmb.t_request(&msg_type, 0, to, &tfrom, &str_hdr, msg, 0, 0, 0); }
/* * Create a new domain structure which will initialy have * one domain name */ static domain_t* new_domain(str* did, str* domain, unsigned int flags) { domain_t* d; int_str name, val; str name_s = STR_STATIC_INIT(AVP_DID); d = (domain_t*)shm_malloc(sizeof(domain_t)); if (!d) goto error; memset(d, 0, sizeof(domain_t)); d->did.s = shm_malloc(did->len); if (!d->did.s) goto error; memcpy(d->did.s, did->s, did->len); d->did.len = did->len; d->domain = (str*)shm_malloc(sizeof(str)); if (!d->domain) goto error; d->domain[0].s = shm_malloc(domain->len); if (!d->domain[0].s) goto error; memcpy(d->domain[0].s, domain->s, domain->len); d->domain[0].len = domain->len; strlower(d->domain); d->flags = (unsigned int*)shm_malloc(sizeof(unsigned int)); if (!d->flags) goto error; d->flags[0] = flags; d->n = 1; /* Create an attribute containing did of the domain */ name.s = name_s; val.s = *did; if (add_avp_list(&d->attrs, AVP_CLASS_DOMAIN | AVP_NAME_STR | AVP_VAL_STR, name, val) < 0) goto error; return d; error: ERR("Unable to create new domain structure\n"); free_domain(d); return 0; }
int prepare_unauthorized_notify(struct retr_buf **dst, struct presentity* _p, struct watcher* _w, pa_notify_cb_param_t *cbd) { str headers = STR_NULL; str body = STR_STATIC_INIT(""); int res; unc_req_t uac_r; /* send notifications to unauthorized (pending) watchers */ if (create_headers(_w, &headers, NULL) < 0) { LOG(L_ERR, "notify_unauthorized_watcher(): Error while adding headers\n"); return -7; } set_uac_req(&uac_r, ¬ify, &headers, &body, _w->dialog, TMCB_LOCAL_COMPLETED, pa_notify_cb, cbd ); res = tmb.prepare_request_within(&uac_r, dst); if (res < 0) { ERR("Can't send NOTIFY (%d) in dlg %.*s, %.*s, %.*s\n", res, FMT_STR(_w->dialog->id.call_id), FMT_STR(_w->dialog->id.rem_tag), FMT_STR(_w->dialog->id.loc_tag)); } str_free_content(&headers); return res; }
/* callback function called once per cfg_group identified by group_name */ static void on_declare(str *group_name, cfg_def_t *definition) { static db_cmd_t* cmd; db_res_t *res; cfg_def_t *def; int ret; str asterisk_s = STR_STATIC_INIT("*"); DBG(MODULE_NAME": on_declare('%.*s')\n", group_name->len, group_name->s); if (connect_db() < 0) return; for (def=definition; def->name; def++) { /* for each definition lookup config tables */ if (exec_transl(group_name, &cmd, &res) < 0) return; ret = find_cfg_var(group_name, def->name, res); db_res_free(res); db_cmd_free(cmd); if (ret > 0) continue; /* not found then try default '*' translations */ if (exec_transl(&asterisk_s, &cmd, &res) < 0) return; find_cfg_var(group_name, def->name, res); db_res_free(res); db_cmd_free(cmd); } }
{"sca.show_appearance", sca_rpc_show_appearance, sca_rpc_show_appearance_doc, 0}, {"sca.seize_appearance", sca_rpc_seize_appearance, sca_rpc_seize_appearance_doc, 0}, {"sca.update_appearance", sca_rpc_update_appearance, sca_rpc_update_appearance_doc, 0}, {"sca.release_appearance", sca_rpc_release_appearance, sca_rpc_release_appearance_doc, 0}, {NULL, NULL, NULL, 0}, }; /* * EXPORTED PARAMETERS */ str outbound_proxy = STR_NULL; str db_url = STR_STATIC_INIT(DEFAULT_DB_URL); str db_subs_table = STR_STATIC_INIT("sca_subscriptions"); str db_state_table = STR_STATIC_INIT("sca_state"); int db_update_interval = 300; int hash_table_size = -1; int call_info_max_expires = 3600; int line_seize_max_expires = 15; int purge_expired_interval = 120; int onhold_bflag = -1; str server_address = STR_NULL; static param_export_t params[] = { {"outbound_proxy", PARAM_STR, &outbound_proxy}, {"db_url", PARAM_STR, &db_url}, {"subs_table", PARAM_STR, &db_subs_table}, {"state_table", PARAM_STR, &db_state_table},
* @file tls_cfg.c * @ingroup tls * Module: @ref tls */ #include "tls_cfg.h" #include "../../core/config.h" #include "../../core/str.h" #include "../../core/ut.h" #include "../../core/pt.h" #include "../../core/mem/shm_mem.h" #include "../../core/dprint.h" struct cfg_group_tls default_tls_cfg = { 0, /* tls_force_run */ STR_STATIC_INIT("TLSv1"), /* method */ STR_NULL, /* server name (sni) */ STR_NULL, /* server id */ 0, /* verify_certificate */ 9, /* verify_depth */ 0, /* require_certificate */ STR_NULL, /* private_key (default value set in fix_tls_cfg) */ STR_NULL, /* ca_list (default value set in fix_tls_cfg) */ STR_NULL, /* crl (default value set in fix_tls_cfg) */ STR_NULL, /* certificate (default value set in fix_tls_cfg) */ STR_NULL, /* cipher_list (default value set in fix_tls_cfg) */ 0, /* session_cache */ STR_STATIC_INIT("kamailio-tls-4.x.y"), /* session_id */ STR_NULL, /* config_file */ 3, /* log (L_DBG)*/ 3, /* debug (L_DBG) */
#include "../../ut.h" #include "../../data_lump.h" #include "../../mod_fix.h" #include "../../script_cb.h" #include "../../mem/mem.h" #include "../../modules/tm/tm_load.h" #include "sl_stats.h" #include "sl_funcs.h" #include "sl.h" MODULE_VERSION static int default_code = 500; static str default_reason = STR_STATIC_INIT("Internal Server Error"); static int sl_bind_tm = 1; static struct tm_binds tmb; static int w_sl_send_reply(struct sip_msg* msg, char* str1, char* str2); static int w_send_reply(struct sip_msg* msg, char* str1, char* str2); static int w_sl_reply_error(struct sip_msg* msg, char* str1, char* str2); static int w_sl_forward_reply0(sip_msg_t* msg, char* str1, char* str2); static int w_sl_forward_reply1(sip_msg_t* msg, char* str1, char* str2); static int w_sl_forward_reply2(sip_msg_t* msg, char* str1, char* str2); static int bind_sl(sl_api_t* api); static int mod_init(void); static int child_init(int rank); static void mod_destroy(); static int fixup_sl_reply(void** param, int param_no);
return -3; } } // end while #endif } // if c!= NULL } // end if else // after parsing still NULL { LOG(L_ERR,"ERROR: decode_contact: Unable to parse Contact header\n"); return -4; } return 1; } static str s_tcp = STR_STATIC_INIT("tcp"); static str s_tls = STR_STATIC_INIT("tls"); static str s_sctp = STR_STATIC_INIT("sctp"); int encode2format (struct sip_msg* msg, str* uri, struct uri_format *format) { int foo; char *string, *pos, *start, *end; struct sip_uri sipUri; int scheme_len; if (uri->s == NULL)
#define XJ_MSG_POOL_SIZE 10 // proxy address #define _PADDR(a) ((a)->aliases->proxy) /** TM bind */ extern struct tm_binds tmb; /** debug info */ int _xj_pid = 0; int main_loop = 1; /** **/ extern char *registrar; static str jab_gw_name = STR_STATIC_INIT("[email protected]"); /** * address correction * alias A~B: flag == 0 => A->B, otherwise B->A */ int xj_address_translation(str *src, str *dst, xj_jalias als, int flag) { char *p, *p0; int i, ll; if(!src || !dst || !src->s || !dst->s ) return -1; if(!als || !als->jdm || !als->jdm->s || als->jdm->len <= 0) goto done;
static int mod_init(void); static int mod_child(int rank); static void destroy(void); MODULE_VERSION /* * Default settings when modparams are used */ static tls_domain_t mod_params = { TLS_DOMAIN_DEF | TLS_DOMAIN_SRV, /* Domain Type */ {}, /* IP address */ 0, /* Port number */ 0, /* SSL ctx */ STR_STATIC_INIT(TLS_CERT_FILE), /* Certificate file */ STR_STATIC_INIT(TLS_PKEY_FILE), /* Private key file */ 0, /* Verify certificate */ 9, /* Verify depth */ STR_STATIC_INIT(TLS_CA_FILE), /* CA file */ 0, /* Require certificate */ {0, }, /* Cipher list */ TLS_USE_TLSv1, /* TLS method */ 0 /* next */ }; /* * Default settings for server domains when using external config file */ tls_domain_t srv_defaults = {
* GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "notify.h" #include "../../ut.h" #include "../../mem/shm_mem.h" #include "dlist.h" #include "udomain.h" str dom = STR_STATIC_INIT("location"); void notify_watchers(struct urecord* _r, ucontact_t *_c, int state) { notify_cb_t* n; n = _r->watchers; while(n) { n->cb(&_r->uid, &_c->c, state, n->data); n = n->next; } } int add_watcher(struct urecord* _r, notcb_t _c, void* _d)
* along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "mod_sanity.h" #include "sanity.h" #include "../../sr_module.h" #include "../../ut.h" #include "../../error.h" MODULE_VERSION #define PROXY_REQUIRE_DEF "" str pr_str = STR_STATIC_INIT(PROXY_REQUIRE_DEF); int default_checks = SANITY_DEFAULT_CHECKS; int uri_checks = SANITY_DEFAULT_URI_CHECKS; strl* proxyrequire_list = NULL; sl_api_t sl; static int mod_init(void); static int sanity_fixup(void** param, int param_no); static int sanity_check(struct sip_msg* _msg, char* _foo, char* _bar); /* * Exported functions */ static cmd_export_t cmds[] = {
int erlang_srdb2_cmd_exec(db_res_t* res, db_cmd_t* cmd) { LM_DBG("erlang_srdb2_cmd_exec %p %p\n",res ,cmd); db_fld_t* fld; ei_x_buff argbuf; int i,cnt; char *pbuf=NULL; static str con=STR_STATIC_INIT("con1"); static str regname=STR_STATIC_INIT("echo_server"); LM_DBG("erlang_srdb2_cmd %p\n",cmd); // for(i = 0, fld = cmd->vals; !DB_FLD_EMPTY(fld) && !DB_FLD_LAST(fld[i]); i++) { // rv |= sb_add(&sql_buf, set_str(&tmpstr, fld[i].name)); // if (!DB_FLD_LAST(fld[i + 1])) rv |= sb_add(&sql_buf, set_str(&tmpstr, ",")); // } ei_x_new(&argbuf); //encode tuple {db_op, table, [cols], [params]} ei_x_encode_tuple_header(&argbuf, 5); switch(cmd->type) { case DB_PUT: ei_x_encode_atom(&argbuf,"insert"); break; case DB_DEL: ei_x_encode_atom(&argbuf,"delete"); break; case DB_GET: ei_x_encode_atom(&argbuf,"select"); break; case DB_UPD: ei_x_encode_atom(&argbuf,"update"); break; case DB_SQL: ei_x_encode_atom(&argbuf,"rawquery"); break; } ei_x_encode_atom_len(&argbuf,cmd->table.s,cmd->table.len); for(i = 0, fld = cmd->result; !DB_FLD_LAST(fld[i]); i++) {} ei_x_encode_list_header(&argbuf, i); for(i = 0, fld = cmd->result; !DB_FLD_LAST(fld[i]); i++) { ei_x_encode_atom(&argbuf,fld[i].name); } ei_x_encode_empty_list(&argbuf); if(cmd->match) { for(i = 0, fld = cmd->match; !DB_FLD_LAST(fld[i]); i++) {} ei_x_encode_list_header(&argbuf, i); for(i = 0, fld = cmd->match; !DB_FLD_LAST(fld[i]); i++) { ei_x_encode_tuple_header(&argbuf, 3); ei_x_encode_atom(&argbuf,fld[i].name); switch(fld[i].op) { case DB_EQ: ei_x_encode_atom(&argbuf,"="); break; case DB_NE: ei_x_encode_atom(&argbuf,"!="); break; case DB_LT: ei_x_encode_atom(&argbuf,"<"); break; case DB_GT: ei_x_encode_atom(&argbuf,">"); break; case DB_LEQ: ei_x_encode_atom(&argbuf,"<="); break; case DB_GEQ: ei_x_encode_atom(&argbuf,">="); break; } ei_x_encode_atom_len(&argbuf,fld[i].v.lstr.s,fld[i].v.lstr.len); } ei_x_encode_empty_list(&argbuf); } else { ei_x_encode_list_header(&argbuf, 0); } if(cmd->vals) { for(i = 0, fld = cmd->vals; !DB_FLD_LAST(fld[i]); i++) {} ei_x_encode_list_header(&argbuf, i); for(i = 0, fld = cmd->result; !DB_FLD_LAST(fld[i]); i++) { ei_x_encode_atom(&argbuf,fld[i].name); } ei_x_encode_empty_list(&argbuf); } else { ei_x_encode_list_header(&argbuf, 0); } i=0; ei_s_print_term(&pbuf, argbuf.buff, &i); LM_DBG("message is pbuf='%s' buf.buffsz=%d buf.index=%d i=%d\n", pbuf, argbuf.buffsz,argbuf.index,i ); free(pbuf);pbuf=NULL; erl_bind.do_erlang_call(&con,®name, &argbuf, NULL); ei_x_free(&argbuf); return 0; };
static int is_peer_verified(struct sip_msg* msg, char* foo, char* foo2); MODULE_VERSION str sr_tls_xavp_cfg = {0, 0}; /* * Default settings when modparams are used */ static tls_domain_t mod_params = { TLS_DOMAIN_DEF | TLS_DOMAIN_SRV, /* Domain Type */ {}, /* IP address */ 0, /* Port number */ 0, /* SSL ctx */ STR_STATIC_INIT(TLS_CERT_FILE), /* Certificate file */ STR_STATIC_INIT(TLS_PKEY_FILE), /* Private key file */ 0, /* Verify certificate */ 9, /* Verify depth */ STR_STATIC_INIT(TLS_CA_FILE), /* CA file */ 0, /* Require certificate */ {0, }, /* Cipher list */ TLS_USE_TLSv1, /* TLS method */ STR_STATIC_INIT(TLS_CRL_FILE), /* Certificate revocation list */ {0, 0}, /* Server name (SNI) */ 0 /* next */ }; /* * Default settings for server domains when using external config file
STR_OP_EQ, STR_OP_NE, STR_OP_LT, STR_OP_GT, STR_OP_LEQ, STR_OP_GEQ, STR_VALUES, STR_FROM, STR_OID, STR_TIMESTAMP, STR_ZT }; static str strings[] = { STR_STATIC_INIT("delete from "), STR_STATIC_INIT("insert into "), STR_STATIC_INIT("update "), STR_STATIC_INIT("select "), STR_STATIC_INIT("replace "), STR_STATIC_INIT(" set "), STR_STATIC_INIT(" where "), STR_STATIC_INIT(" is "), STR_STATIC_INIT(" and "), STR_STATIC_INIT(" or "), STR_STATIC_INIT("?"), STR_STATIC_INIT("="), STR_STATIC_INIT("!="), STR_STATIC_INIT("<"), STR_STATIC_INIT(">"), STR_STATIC_INIT("<="),
} static int sel_fetch_is_empty(str* res, select_t* s, struct sip_msg* msg) { return sel_do_fetch(res, &s->params[2].v.s, -3, msg); } static int sel_fetch_count(str* res, select_t* s, struct sip_msg* msg) { return sel_do_fetch(res, &s->params[2].v.s, -1, msg); } SELECT_F(select_any_nameaddr) SELECT_F(select_any_uri) select_row_t sel_declaration[] = { { NULL, SEL_PARAM_STR, STR_STATIC_INIT(MODULE_NAME2), sel_dbops, SEL_PARAM_EXPECTED}, { sel_dbops, SEL_PARAM_STR, STR_STATIC_INIT("query"), sel_select, CONSUME_NEXT_STR}, { sel_select, SEL_PARAM_STR, STR_STATIC_INIT("is_empty"), sel_select_is_empty}, { sel_select, SEL_PARAM_STR, STR_STATIC_INIT("count"), sel_select_count}, { sel_select, SEL_PARAM_STR, STR_STATIC_INIT("nameaddr"), select_any_nameaddr, NESTED | CONSUME_NEXT_STR}, { sel_select, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_any_uri, NESTED | CONSUME_NEXT_STR}, { sel_select, SEL_PARAM_STR, STR_STATIC_INIT("field"), sel_select_field, CONSUME_NEXT_INT}, { sel_select_field, SEL_PARAM_STR, STR_STATIC_INIT("nameaddr"), select_any_nameaddr, NESTED | CONSUME_NEXT_STR}, { sel_select_field, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_any_uri, NESTED | CONSUME_NEXT_STR}, { sel_select, SEL_PARAM_STR, STR_STATIC_INIT("row"), sel_select_row, CONSUME_NEXT_INT}, { sel_select_row, SEL_PARAM_STR, STR_STATIC_INIT("field"), sel_select_row_field, CONSUME_NEXT_INT}, { sel_select_row_field, SEL_PARAM_STR, STR_STATIC_INIT("nameaddr"), select_any_nameaddr, NESTED | CONSUME_NEXT_STR}, { sel_select_row_field, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_any_uri, NESTED | CONSUME_NEXT_STR},
#define FLAGS_COL "flags" #define DOMATTR_TABLE "domain_attrs" #define DOMATTR_DID "did" #define DOMATTR_NAME "name" #define DOMATTR_TYPE "type" #define DOMATTR_VALUE "value" #define DOMATTR_FLAGS "flags" #define DOMAIN_COL "domain" int db_mode = 1; /* Enable/disable domain cache */ /* * Module parameter variables */ static str db_url = STR_STATIC_INIT(DEFAULT_RODB_URL); str domain_table = STR_STATIC_INIT(DOMAIN_TABLE); /* Name of domain table */ str domain_col = STR_STATIC_INIT(DOMAIN_COL); /* Name of domain column */ str did_col = STR_STATIC_INIT(DID_COL); /* Domain id */ str flags_col = STR_STATIC_INIT(FLAGS_COL); /* Domain flags */ str domattr_table = STR_STATIC_INIT(DOMATTR_TABLE); str domattr_did = STR_STATIC_INIT(DOMATTR_DID); str domattr_name = STR_STATIC_INIT(DOMATTR_NAME); str domattr_type = STR_STATIC_INIT(DOMATTR_TYPE); str domattr_value = STR_STATIC_INIT(DOMATTR_VALUE); str domattr_flags = STR_STATIC_INIT(DOMATTR_FLAGS); int load_domain_attrs = 0; /* Load attributes for each domain by default */
if (!msg && r==0) { ((struct hname_data*) s->params[1].v.p)->oper = hnoGetValue2; } return r; } static int sel_hf_value2_name_param_name(str* res, select_t* s, struct sip_msg* msg) { return sel_hf_value2_name(res, s, msg); } SELECT_F(select_any_nameaddr) SELECT_F(select_any_uri) SELECT_F(select_anyheader_params) select_row_t sel_declaration[] = { { NULL, SEL_PARAM_STR, STR_STATIC_INIT("hf_value"), sel_hf_value, SEL_PARAM_EXPECTED}, { sel_hf_value, SEL_PARAM_STR, STR_NULL, sel_hf_value_name, CONSUME_NEXT_INT | OPTIONAL | FIXUP_CALL}, { sel_hf_value_name, SEL_PARAM_STR, STR_STATIC_INIT("param"), sel_hf_value_name_param_name2, CONSUME_NEXT_STR | FIXUP_CALL}, { sel_hf_value_name, SEL_PARAM_STR, STR_STATIC_INIT("p"), sel_hf_value_name_param_name2, CONSUME_NEXT_STR | FIXUP_CALL}, { sel_hf_value_name, SEL_PARAM_STR, STR_STATIC_INIT("uri"), sel_hf_value_name_uri, FIXUP_CALL}, { sel_hf_value_name, SEL_PARAM_STR, STR_STATIC_INIT("name"), sel_hf_value_name_name, FIXUP_CALL}, { sel_hf_value_name, SEL_PARAM_STR, STR_STATIC_INIT("nameaddr"), select_any_nameaddr, NESTED | CONSUME_NEXT_STR}, /* it duplicates param,p,name,... */ { sel_hf_value_name, SEL_PARAM_STR, STR_STATIC_INIT("params"), select_anyheader_params, NESTED}, { sel_hf_value_name_uri, SEL_PARAM_INT, STR_NULL, select_any_uri, NESTED}, { sel_hf_value_name, SEL_PARAM_STR, STR_NULL, sel_hf_value_name_param_name, FIXUP_CALL}, { NULL, SEL_PARAM_STR, STR_STATIC_INIT("hf_value_exists"), sel_hf_value_exists, CONSUME_NEXT_STR | SEL_PARAM_EXPECTED}, { sel_hf_value_exists, SEL_PARAM_STR, STR_NULL, sel_hf_value_exists_param, FIXUP_CALL},
int send_sip_msg_request(str *to, str *from_user, str *body) { str msg_type = STR_STATIC_INIT("MESSAGE"); str from; str hdrs; int foo; char *p; uac_req_t uac_r; from.s = hdrs.s = 0; from.len = hdrs.len = 0; /* From header */ from.len = 6 /*"<sip:+"*/ + from_user->len/*user*/ + 1/*"@"*/ + domain.len /*host*/ + 1 /*">"*/ ; from.s = (char*)pkg_malloc(from.len); if (!from.s) goto error; p=from.s; append_str(p,"<sip:+",6); append_str(p,from_user->s,from_user->len); *(p++)='@'; append_str(p,domain.s,domain.len); *(p++)='>'; /* hdrs = Contact header + Content-type */ /* length */ hdrs.len = CONTENT_TYPE_HDR_LEN + CRLF_LEN; if (use_contact) hdrs.len += 15 /*"Contact: <sip:+"*/ + from_user->len/*user*/ + 1/*"@"*/ + domain.len/*host*/ + 1 /*">"*/ + CRLF_LEN; hdrs.s = (char*)pkg_malloc(hdrs.len); if (!hdrs.s) goto error; p=hdrs.s; append_str(p,CONTENT_TYPE_HDR,CONTENT_TYPE_HDR_LEN); append_str(p,CRLF,CRLF_LEN); if (use_contact) { append_str(p,"Contact: <sip:+",15); append_str(p,from_user->s,from_user->len); *(p++)='@'; append_str(p,domain.s,domain.len); append_str(p,">"CRLF,1+CRLF_LEN); } /* sending the request */ set_uac_req(&uac_r, &msg_type, /* request type */ &hdrs, /* Additional headers including CRLF */ body, /* Message body */ 0, /* dialog structure */ 0, /* callback flags */ 0, /* Callback function */ 0 /* Callback parameter */ ); foo = tmb.t_request(&uac_r, 0, /* Request-URI */ to, /* To */ &from, /* From */ 0 /* next hop */ ); if (from.s) pkg_free(from.s); if (hdrs.s) pkg_free(hdrs.s); return foo; error: LM_ERR("no free pkg memory!\n"); if (from.s) pkg_free(from.s); if (hdrs.s) pkg_free(hdrs.s); return -1; }
#define USERNAME_COL "auth_username" #define DID_COL "did" #define REALM_COL "realm" #define PASS_COL "ha1" #define PASS_COL_2 "ha1b" #define PLAIN_PASS_COL "password" #define DEFAULT_CRED_LIST "uid" #define FLAGS_COL "flags" /* * Module parameter variables */ static char* db_url = DEFAULT_RODB_URL; str username_column = STR_STATIC_INIT(USERNAME_COL); str did_column = STR_STATIC_INIT(DID_COL); str realm_column = STR_STATIC_INIT(REALM_COL); str pass_column = STR_STATIC_INIT(PASS_COL); str pass_column_2 = STR_STATIC_INIT(PASS_COL_2); str flags_column = STR_STATIC_INIT(FLAGS_COL); str plain_password_column = STR_STATIC_INIT(PLAIN_PASS_COL); int calc_ha1 = 0; int use_did = 0; int check_all = 0; db_ctx_t* auth_db_handle = 0; /* database connection handle */ auth_api_s_t auth_api; str credentials_list = STR_STATIC_INIT(DEFAULT_CRED_LIST);
/* * Module parameter variables */ char* sec_param = 0; /* If the parameter was not used, the secret phrase will be auto-generated */ int nonce_expire = 300; /* Nonce lifetime */ /*int auth_extra_checks = 0; -- in nonce.c */ int protect_contacts = 0; /* Do not include contacts in nonce by default */ str secret1; str secret2; char* sec_rand1 = 0; char* sec_rand2 = 0; str challenge_attr = STR_STATIC_INIT("$digest_challenge"); avp_ident_t challenge_avpid; str proxy_challenge_header = STR_STATIC_INIT("Proxy-Authenticate"); str www_challenge_header = STR_STATIC_INIT("WWW-Authenticate"); struct qp qop = { STR_STATIC_INIT("auth"), QOP_AUTH }; /* * Exported functions */ static cmd_export_t cmds[] = {
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA. 02110-1301 USA */ #include "sca_common.h" #include <assert.h> #include "sca.h" #include "sca_appearance.h" #include "sca_call_info.h" #include "sca_event.h" #include "sca_notify.h" #include "sca_util.h" #include "../../modules/tm/tm_load.h" const str SCA_METHOD_NOTIFY = STR_STATIC_INIT("NOTIFY"); static void sca_notify_reply_cb(struct cell *t, int cb_type, struct tmcb_params *cbp) { struct sip_msg *notify_reply = NULL; str to_aor = STR_NULL; str *contact_uri; if (cbp == NULL) { LM_ERR("Empty parameters passed to NOTIFY callback!\n"); return; } if ((notify_reply = cbp->rpl) == NULL) { LM_ERR("Empty reply passed to NOTIFY callback!\n"); return;