#include <asterisk/channel.h>
Go to the source code of this file.
Functions | |
int | ast_get_enum (struct ast_channel *chan, const char *number, char *location, int maxloc, char *technology, int maxtech) |
int | ast_enum_init (void) |
int | ast_enum_reload (void) |
|
Definition at line 314 of file enum.c. References ast_destroy(), ast_load(), ast_mutex_lock, ast_mutex_unlock, ast_variable_browse(), free, s, and TOPLEV. Referenced by ast_enum_reload(), and main().
00315 { 00316 struct ast_config *cfg; 00317 struct enum_search *s, *sl; 00318 struct ast_variable *v; 00319 00320 /* Destroy existing list */ 00321 ast_mutex_lock(&enumlock); 00322 s = toplevs; 00323 while(s) { 00324 sl = s; 00325 s = s->next; 00326 free(sl); 00327 } 00328 toplevs = NULL; 00329 cfg = ast_load("enum.conf"); 00330 if (cfg) { 00331 sl = NULL; 00332 v = ast_variable_browse(cfg, "general"); 00333 while(v) { 00334 if (!strcasecmp(v->name, "search")) { 00335 s = enum_newtoplev(v->value); 00336 if (s) { 00337 if (sl) 00338 sl->next = s; 00339 else 00340 toplevs = s; 00341 sl = s; 00342 } 00343 } 00344 v = v->next; 00345 } 00346 ast_destroy(cfg); 00347 } else { 00348 toplevs = enum_newtoplev(TOPLEV); 00349 } 00350 enumver++; 00351 ast_mutex_unlock(&enumlock); 00352 return 0; 00353 } |
|
Definition at line 355 of file enum.c. References ast_enum_init(). Referenced by ast_module_reload().
00356 { 00357 return ast_enum_init(); 00358 } |
|
Definition at line 246 of file enum.c. References ast_autoservice_start(), ast_autoservice_stop(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_search_dns(), enum_context::dst, enum_context::dstlen, LOG_DEBUG, enum_context::naptrinput, s, enum_context::tech, and enum_context::techlen.
00247 { 00248 struct enum_context context; 00249 char tmp[259 + 80]; 00250 char naptrinput[80] = "+"; 00251 int pos = strlen(number) - 1; 00252 int newpos = 0; 00253 int ret = -1; 00254 struct enum_search *s = NULL; 00255 int version = -1; 00256 00257 strncat(naptrinput, number, sizeof(naptrinput) - 2); 00258 00259 context.naptrinput = naptrinput; 00260 context.dst = dst; 00261 context.dstlen = dstlen; 00262 context.tech = tech; 00263 context.techlen = techlen; 00264 00265 if (pos > 128) 00266 pos = 128; 00267 while(pos >= 0) { 00268 tmp[newpos++] = number[pos--]; 00269 tmp[newpos++] = '.'; 00270 } 00271 00272 if (chan && ast_autoservice_start(chan) < 0) 00273 return -1; 00274 00275 for(;;) { 00276 ast_mutex_lock(&enumlock); 00277 if (version != enumver) { 00278 /* Ooh, a reload... */ 00279 s = toplevs; 00280 version = enumver; 00281 } else { 00282 s = s->next; 00283 } 00284 if (s) { 00285 strcpy(tmp + newpos, s->toplev); 00286 } 00287 ast_mutex_unlock(&enumlock); 00288 if (!s) 00289 break; 00290 ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback); 00291 if (ret > 0) 00292 break; 00293 } 00294 if (ret < 0) { 00295 ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno)); 00296 ret = 0; 00297 } 00298 if (chan) 00299 ret |= ast_autoservice_stop(chan); 00300 return ret; 00301 } |