/* Radius implementation for the init_prot callback For Radius, initialization consists of: - the url is parsed and a configuration structure is obtained - the rest field from the configuration structure is, for the radius module, a string for the path of the radius configuration file - obtain the connection handle - initialize the dictionary For Radius, the aaa_conn is actually the rc_handle resulted by reading the Radius configuration file. */ aaa_conn* rad_init_prot(str* aaa_url) { rc_handle *rh; aaa_prot_config cfg; if (!aaa_url) { LM_ERR("null aaa url \n"); return NULL; } if (aaa_parse_url(aaa_url, &cfg)) { LM_ERR("aaa parse url error\n"); return NULL; } if (!(rh = rc_read_config((char*)(cfg.rest)))) { LM_ERR("failed to open radius config file: %s\n", (char*)(cfg.rest)); return NULL; } if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary"))) { LM_ERR("failed to read radius dictionary\n"); return NULL; } return rh; }
int aaa_prot_bind(str* aaa_url, aaa_prot* prot) { aaa_prot_config pc; char *module_name; aaa_bind_api_f bind_f; if (!aaa_url || !prot) { LM_ERR("null argument\n"); return -1; } if (aaa_parse_url(aaa_url, &pc)) { LM_ERR("parse url error\n"); return -1; } module_name = (char*) pkg_malloc(pc.prot_name->len + 4 + 1); if (!module_name) { LM_ERR("no pkg memory left\n"); return -1; } sprintf(module_name, "aaa_%.*s", pc.prot_name->len,pc.prot_name->s); bind_f = (aaa_bind_api_f) find_mod_export(module_name, "aaa_bind_api", 0, 0); if (bind_f) { LM_DBG("using aaa bind api for %s\n", module_name); if (bind_f(prot)) { pkg_free(module_name); return -1; } } else { LM_ERR("<%s> has no bind api function\n", module_name); pkg_free(module_name); return -1; } pkg_free(module_name); return 0; }