#include #include #include #include #include "../../sr_module.h" #include "../../items.h" MODULE_VERSION static int goto_url_f(struct sip_msg*, char*, char*); static int fixup_goto_url(void** param, int param_no); static int mod_init(void); struct fis_param { int ops; /* operation flags */ int opd; /* operand flags */ xl_spec_t sval; /* values int or str */ }; struct fis_param* cnam_parse_pvar(char *s, int flags); static cmd_export_t cmds[] = { {"goto_url", goto_url_f, 2, fixup_goto_url, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE}, {0,0,0,0,0} }; /* static param_export_t mod_params[] = { {0,0,0} }; */ struct module_exports exports = { "cnam", cmds, 0, 0, mod_init, 0, 0, 0, }; static int mod_init(void) { LOG(L_INFO, "cnam - initializing\n"); return 0; } static int goto_url_f(struct sip_msg* msg, char* _s1, char* _s2) { CURL* handle = curl_easy_init(); if(handle == NULL) { LOG(L_ERR, "Could not init CURL!\n"); } else { CURLcode code = curl_easy_setopt(handle, CURLOPT_URL, _s1); if(code == CURLE_OK) { // we're fine } else { LOG(L_ERR, "Could not connect to host!\n"); } } return 0; } static int fixup_goto_url(void** param, int param_no) { struct fis_param *ap; xl_elem_t *model; char* s; s = (char*)(*param); if(param_no == 1) { ap = cnam_parse_pvar(s, XL_THROW_ERROR|XL_DISABLE_MULTI|XL_DISABLE_COLORS); if(ap == 0) { LOG(L_ERR, "ERROR: cnam: fixup_goto_url: unable to get pvar in param\n"); return E_OUT_OF_MEM; } if(ap->sval.type != XL_AVP) { LOG(L_ERR, "ERROR: cnam: fixup_goto_url: bad avp name <%s>\n", (char* )* param); return E_UNSPEC; } * param = (void* ) ap; } else if(param_no == 2) { if(* param) { if(xl_parse_format((char* )(* param), &model, XL_DISABLE_COLORS) < 0) { LOG(L_ERR, "ERROR: cnam: fixup_goto_url: wrong format[%s]\n", (char* )(* param)); return E_UNSPEC; } * param = (void* )model; } else { LOG(L_ERR, "ERROR: cnam: fixup_goto_url: null format\n"); return E_UNSPEC; } } return 0; }