| 68 | |
| 69 | |
| 70 | int aaa_prot_bind(str* aaa_url, aaa_prot* prot) { |
| 71 | |
| 72 | aaa_prot_config pc; |
| 73 | char *module_name; |
| 74 | aaa_bind_api_f bind_f; |
| 75 | |
| 76 | if (!aaa_url || !prot) { |
| 77 | |
| 78 | LM_ERR("null argument\n"); |
| 79 | return -1; |
| 80 | } |
| 81 | |
| 82 | if (aaa_parse_url(aaa_url, &pc)) { |
| 83 | LM_ERR("parse url error\n"); |
| 84 | return -1; |
| 85 | } |
| 86 | |
| 87 | module_name = (char*) pkg_malloc(pc.prot_name->len + 4 + 1); |
| 88 | |
| 89 | if (!module_name) { |
| 90 | LM_ERR("no pkg memory left\n"); |
| 91 | return -1; |
| 92 | } |
| 93 | |
| 94 | sprintf(module_name, "aaa_%.*s", pc.prot_name->len,pc.prot_name->s); |
| 95 | |
| 96 | bind_f = (aaa_bind_api_f) find_mod_export(module_name, |
| 97 | "aaa_bind_api", 0); |
| 98 | |
| 99 | if (bind_f) { |
| 100 | LM_DBG("using aaa bind api for %s\n", module_name); |
| 101 | |
| 102 | if (bind_f(prot)) { |
| 103 | pkg_free(module_name); |
| 104 | return -1; |
| 105 | } |
| 106 | } else { |
| 107 | LM_ERR("<%s> has no bind api function\n", module_name); |
| 108 | pkg_free(module_name); |
| 109 | return -1; |
| 110 | } |
| 111 | |
| 112 | pkg_free(module_name); |
| 113 | return 0; |
| 114 | } |
no test coverage detected