#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <string.h>
#include <errno.h>
#include <netinet/ip.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <zlib.h>
#include <sys/signal.h>
#include <pthread.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/frame.h"
#include "asterisk/cli.h"
#include "asterisk/lock.h"
#include "asterisk/md5.h"
#include "asterisk/dundi.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/utils.h"
#include "asterisk/crypto.h"
#include "asterisk/astdb.h"
#include "asterisk/acl.h"
#include "asterisk/aes.h"
#include "dundi-parser.h"
Include dependency graph for pbx_dundi.c:

Go to the source code of this file.
Data Structures | |
| struct | dundi_hint_metadata |
| struct | dundi_mapping |
| struct | dundi_packet |
| struct | dundi_peer |
| struct | dundi_precache_queue |
| struct | dundi_query_state |
| struct | dundi_request |
| struct | dundi_transaction |
| struct | permission |
Defines | |
| #define | DUNDI_FLAG_INTERNAL_NOPARTIAL (1 << 17) |
| #define | DUNDI_MODEL_INBOUND (1 << 0) |
| #define | DUNDI_MODEL_OUTBOUND (1 << 1) |
| #define | DUNDI_MODEL_SYMMETRIC (DUNDI_MODEL_INBOUND | DUNDI_MODEL_OUTBOUND) |
| #define | DUNDI_SECRET_TIME DUNDI_DEFAULT_CACHE_TIME |
| #define | DUNDI_TIMING_HISTORY 10 |
| #define | FLAG_DEAD (1 << 1) |
| #define | FLAG_ENCRYPT (1 << 4) |
| #define | FLAG_FINAL (1 << 2) |
| #define | FLAG_ISQUAL (1 << 3) |
| #define | FLAG_ISREG (1 << 0) |
| #define | FLAG_SENDFULLKEY (1 << 5) |
| #define | FLAG_STOREHIST (1 << 6) |
| #define | FORMAT "%-12.12s %-12.12s %02d:%02d:%02d\n" |
| #define | FORMAT "%-12.12s %-7d %-12.12s %-10.10s %-5.5s %-25.25s\n" |
| #define | FORMAT "%-15s %-15s %-15s %-3.3d %-3.3d\n" |
| #define | FORMAT "%-16.16s:%5d %-5.5d %-5.5d %-3.3d %-3.3d %-3.3d\n" |
| #define | FORMAT "%-20.20s %-15.15s %s %-10.10s %-8.8s %-15.15s\n" |
| #define | FORMAT2 "%-12.12s %-12.12s %-10.10s\n" |
| #define | FORMAT2 "%-12.12s %-7.7s %-12.12s %-10.10s %-5.5s %-25.25s\n" |
| #define | FORMAT2 "%-15s %-15s %-15s %-3.3s %-3.3s\n" |
| #define | FORMAT2 "%-22.22s %-5.5s %-5.5s %-3.3s %-3.3s %-3.3s\n" |
| #define | FORMAT2 "%-20.20s %-15.15s %-10.10s %-8.8s %-15.15s\n" |
| #define | KEY_IN 1 |
| #define | KEY_OUT 0 |
| #define | MAX_OPTS 128 |
| #define | MAX_PACKET_SIZE 8192 |
| #define | MAX_RESULTS 64 |
Functions | |
| static void | abort_request (struct dundi_request *dr) |
| static int | ack_trans (struct dundi_transaction *trans, int iseqno) |
| static void | append_permission (struct permissionlist *permlist, char *s, int allow) |
| static int | append_transaction (struct dundi_request *dr, struct dundi_peer *p, int ttl, dundi_eid *avoid[]) |
| static void | apply_peer (struct dundi_transaction *trans, struct dundi_peer *p) |
| static | AST_LIST_HEAD_NOLOCK_STATIC (alltrans, dundi_transaction) |
| static | AST_LIST_HEAD_NOLOCK_STATIC (requests, dundi_request) |
| static | AST_LIST_HEAD_NOLOCK_STATIC (mappings, dundi_mapping) |
| static | AST_LIST_HEAD_STATIC (pcq, dundi_precache_queue) |
| static | AST_LIST_HEAD_STATIC (peers, dundi_peer) |
| AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,"Distributed Universal Number Discovery (DUNDi)",.load=load_module,.unload=unload_module,.reload=reload,) | |
| static unsigned long | avoid_crc32 (dundi_eid *avoid[]) |
| static void | build_iv (unsigned char *iv) |
| static void | build_mapping (char *name, char *value) |
| static void | build_peer (dundi_eid *eid, struct ast_variable *v, int *globalpcmode) |
| static void | build_secret (char *secret, int seclen) |
| static void | build_transactions (struct dundi_request *dr, int ttl, int order, int *foundcache, int *skipped, int blockempty, int nocache, int modeselect, dundi_eid *skip, dundi_eid *avoid[], int directs[]) |
| static int | cache_lookup (struct dundi_request *req, dundi_eid *peer_eid, unsigned long crc32, int *lowexpiration) |
| static int | cache_lookup_internal (time_t now, struct dundi_request *req, char *key, char *eid_str_full, int *lowexpiration) |
| static int | cache_save (dundi_eid *eidpeer, struct dundi_request *req, int start, int unaffected, int expiration, int push) |
| static int | cache_save_hint (dundi_eid *eidpeer, struct dundi_request *req, struct dundi_hint *hint, int expiration) |
| static void | cancel_request (struct dundi_request *dr) |
| static int | check_key (struct dundi_peer *peer, unsigned char *newkey, unsigned char *newsig, unsigned long keycrc32) |
| static void | check_password (void) |
| static int | check_request (struct dundi_request *dr) |
| static char * | complete_peer_4 (const char *line, const char *word, int pos, int state) |
| static char * | complete_peer_helper (const char *line, const char *word, int pos, int state, int rpos) |
| static struct dundi_transaction * | create_transaction (struct dundi_peer *p) |
| static int | decrypt_memcpy (unsigned char *dst, unsigned char *src, int len, unsigned char *iv, aes_decrypt_ctx *dcx) |
| static void | deep_copy_peer (struct dundi_peer *peer_dst, const struct dundi_peer *peer_src) |
| static void | destroy_map (struct dundi_mapping *map) |
| static void | destroy_packet (struct dundi_packet *pack, int needfree) |
| static void | destroy_packets (struct packetlist *p) |
| static void | destroy_peer (struct dundi_peer *peer) |
| static void | destroy_permissions (struct permissionlist *permlist) |
| static void | destroy_trans (struct dundi_transaction *trans, int fromtimeout) |
| static int | discover_transactions (struct dundi_request *dr) |
| static int | do_autokill (const void *data) |
| static int | do_qualify (const void *data) |
| static int | do_register (const void *data) |
| static int | do_register_expire (const void *data) |
| static int | dundi_ack (struct dundi_transaction *trans, int final) |
| static int | dundi_answer_entity (struct dundi_transaction *trans, struct dundi_ies *ies, char *ccontext) |
| static int | dundi_answer_query (struct dundi_transaction *trans, struct dundi_ies *ies, char *ccontext) |
| static int | dundi_canmatch (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data) |
| static void | dundi_debug_output (const char *data) |
| static struct dundi_hdr * | dundi_decrypt (struct dundi_transaction *trans, unsigned char *dst, int *dstlen, struct dundi_hdr *ohdr, struct dundi_encblock *src, int srclen) |
| static int | dundi_discover (struct dundi_transaction *trans) |
| static int | dundi_do_debug (int fd, int argc, char *argv[]) |
| static int | dundi_do_lookup (int fd, int argc, char *argv[]) |
| static int | dundi_do_precache (int fd, int argc, char *argv[]) |
| static int | dundi_do_query (int fd, int argc, char *argv[]) |
| static int | dundi_do_store_history (int fd, int argc, char *argv[]) |
| static int | dundi_encrypt (struct dundi_transaction *trans, struct dundi_packet *pack) |
| static void | dundi_error_output (const char *data) |
| static int | dundi_exec (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data) |
| static int | dundi_exists (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data) |
| static int | dundi_flush (int fd, int argc, char *argv[]) |
| static int | dundi_helper (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *data, int flag) |
| static void | dundi_ie_append_eid_appropriately (struct dundi_ie_data *ied, char *context, dundi_eid *eid, dundi_eid *us) |
| int | dundi_lookup (struct dundi_result *result, int maxret, struct ast_channel *chan, const char *dcontext, const char *number, int cbypass) |
| Lookup the given number in the given dundi context (or e164 if unspecified) using the given callerid (if specified) and return up to maxret results in the array specified. returns the number of results found or -1 on a hangup of teh channel. | |
| static int | dundi_lookup_internal (struct dundi_result *result, int maxret, struct ast_channel *chan, const char *dcontext, const char *number, int ttl, int blockempty, struct dundi_hint_metadata *md, int *expiration, int cybpass, int modeselect, dundi_eid *skip, dundi_eid *avoid[], int direct[]) |
| static int | dundi_lookup_local (struct dundi_result *dr, struct dundi_mapping *map, char *called_number, dundi_eid *us_eid, int anscnt, struct dundi_hint_metadata *hmd) |
| static void * | dundi_lookup_thread (void *data) |
| static int | dundi_matchmore (struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data) |
| static int | dundi_no_debug (int fd, int argc, char *argv[]) |
| static int | dundi_no_store_history (int fd, int argc, char *argv[]) |
| int | dundi_precache (const char *context, const char *number) |
| Pre-cache to push upstream peers. | |
| static void | dundi_precache_full (void) |
| static int | dundi_precache_internal (const char *context, const char *number, int ttl, dundi_eid *avoids[]) |
| static void * | dundi_precache_thread (void *data) |
| static int | dundi_prop_precache (struct dundi_transaction *trans, struct dundi_ies *ies, char *ccontext) |
| static int | dundi_query (struct dundi_transaction *trans) |
| int | dundi_query_eid (struct dundi_entity_info *dei, const char *dcontext, dundi_eid eid) |
| Retrieve information on a specific EID. | |
| static int | dundi_query_eid_internal (struct dundi_entity_info *dei, const char *dcontext, dundi_eid *eid, struct dundi_hint_metadata *hmd, int ttl, int blockempty, dundi_eid *avoid[]) |
| static void * | dundi_query_thread (void *data) |
| static void | dundi_reject (struct dundi_hdr *h, struct sockaddr_in *sin) |
| static int | dundi_rexmit (const void *data) |
| static int | dundi_send (struct dundi_transaction *trans, int cmdresp, int flags, int final, struct dundi_ie_data *ied) |
| static int | dundi_show_entityid (int fd, int argc, char *argv[]) |
| static int | dundi_show_mappings (int fd, int argc, char *argv[]) |
| static int | dundi_show_peer (int fd, int argc, char *argv[]) |
| static int | dundi_show_peers (int fd, int argc, char *argv[]) |
| static int | dundi_show_precache (int fd, int argc, char *argv[]) |
| static int | dundi_show_requests (int fd, int argc, char *argv[]) |
| static int | dundi_show_trans (int fd, int argc, char *argv[]) |
| static int | dundi_xmit (struct dundi_packet *pack) |
| static int | dundifunc_read (struct ast_channel *chan, char *cmd, char *num, char *buf, size_t len) |
| static int | encrypt_memcpy (unsigned char *dst, unsigned char *src, int len, unsigned char *iv, aes_encrypt_ctx *ecx) |
| static struct dundi_peer * | find_peer (dundi_eid *eid) |
| static struct dundi_transaction * | find_transaction (struct dundi_hdr *hdr, struct sockaddr_in *sin) |
| static int | get_trans_id (void) |
| static int | handle_command_response (struct dundi_transaction *trans, struct dundi_hdr *hdr, int datalen, int encrypted) |
| static int | handle_frame (struct dundi_hdr *h, struct sockaddr_in *sin, int datalen) |
| static int | has_permission (struct permissionlist *permlist, char *cont) |
| static int | load_module (void) |
| static void | load_password (void) |
| static void | mark_mappings (void) |
| static void | mark_peers (void) |
| static char * | model2str (int model) |
| static void * | network_thread (void *ignore) |
| static int | optimize_transactions (struct dundi_request *dr, int order) |
| static void | populate_addr (struct dundi_peer *peer, dundi_eid *eid) |
| static int | precache_trans (struct dundi_transaction *trans, struct dundi_mapping *maps, int mapcount, int *minexp, int *foundanswers) |
| static int | precache_transactions (struct dundi_request *dr, struct dundi_mapping *maps, int mapcount, int *expiration, int *foundanswers) |
| static void * | process_precache (void *ign) |
| static void | prune_mappings (void) |
| static void | prune_peers (void) |
| static void | qualify_peer (struct dundi_peer *peer, int schedonly) |
| static int | query_transactions (struct dundi_request *dr) |
| static int | register_request (struct dundi_request *dr, struct dundi_request **pending) |
| static int | reload (void) |
| static void | reschedule_precache (const char *number, const char *context, int expiration) |
| static int | rescomp (const void *a, const void *b) |
| static void | reset_global_eid (void) |
| static int | reset_transaction (struct dundi_transaction *trans) |
| static void | save_secret (const char *newkey, const char *oldkey) |
| static int | set_config (char *config_file, struct sockaddr_in *sin) |
| static int | socket_read (int *id, int fd, short events, void *cbdata) |
| static void | sort_results (struct dundi_result *results, int count) |
| static int | start_network_thread (void) |
| static int | str2tech (char *str) |
| static char * | tech2str (int tech) |
| static int | unload_module (void) |
| static void | unregister_request (struct dundi_request *dr) |
| static int | update_key (struct dundi_peer *peer) |
Variables | |
| static struct dundi_peer * | any_peer |
| Wildcard peer. | |
| static int | authdebug = 0 |
| static struct ast_cli_entry | cli_dundi [] |
| static char | country [80] |
| static char | cursecret [80] |
| static char | debug_usage [] |
| static int | default_expiration = 60 |
| static char | dept [80] |
| static int | dundi_cache_time = DUNDI_DEFAULT_CACHE_TIME |
| static struct ast_custom_function | dundi_function |
| static int | dundi_key_ttl = DUNDI_DEFAULT_KEY_EXPIRE |
| static int | dundi_shutdown = 0 |
| static struct ast_switch | dundi_switch |
| static int | dundi_ttl = DUNDI_DEFAULT_TTL |
| static int | dundidebug = 0 |
| static char | email [80] |
| static dundi_eid | empty_eid = { { 0, 0, 0, 0, 0, 0 } } |
| static char | flush_usage [] |
| static int | global_autokilltimeout = 0 |
| static dundi_eid | global_eid |
| static int | global_storehistory = 0 |
| static struct io_context * | io |
| static char | ipaddr [80] |
| static char | locality [80] |
| static char | lookup_usage [] |
| static int | netsocket = -1 |
| static pthread_t | netthreadid = AST_PTHREADT_NULL |
| static char | no_debug_usage [] |
| static char | no_store_history_usage [] |
| static char | org [80] |
| static char | phone [80] |
| static char | precache_usage [] |
| static pthread_t | precachethreadid = AST_PTHREADT_NULL |
| static char | query_usage [] |
| static time_t | rotatetime |
| static struct sched_context * | sched |
| static char | secretpath [80] |
| static char | show_entityid_usage [] |
| static char | show_mappings_usage [] |
| static char | show_peer_usage [] |
| static char | show_peers_usage [] |
| static char | show_precache_usage [] |
| static char | show_requests_usage [] |
| static char | show_trans_usage [] |
| static char | stateprov [80] |
| static char | store_history_usage [] |
| static int | tos = 0 |
Definition in file pbx_dundi.c.
| #define DUNDI_FLAG_INTERNAL_NOPARTIAL (1 << 17) |
| #define DUNDI_MODEL_INBOUND (1 << 0) |
Definition at line 83 of file pbx_dundi.c.
Referenced by dundi_show_peer(), handle_command_response(), and model2str().
| #define DUNDI_MODEL_OUTBOUND (1 << 1) |
Definition at line 84 of file pbx_dundi.c.
Referenced by build_transactions(), dundi_show_peer(), model2str(), and set_config().
| #define DUNDI_MODEL_SYMMETRIC (DUNDI_MODEL_INBOUND | DUNDI_MODEL_OUTBOUND) |
| #define DUNDI_SECRET_TIME DUNDI_DEFAULT_CACHE_TIME |
| #define DUNDI_TIMING_HISTORY 10 |
Keep times of last 10 lookups
Definition at line 88 of file pbx_dundi.c.
Referenced by destroy_trans(), dundi_flush(), and dundi_show_peer().
| #define FLAG_DEAD (1 << 1) |
Transaction is dead
Definition at line 91 of file pbx_dundi.c.
Referenced by dundi_lookup_thread(), dundi_precache_thread(), dundi_query_thread(), and precache_transactions().
| #define FLAG_ENCRYPT (1 << 4) |
Transaction is encrypted wiht ECX/DCX
Definition at line 94 of file pbx_dundi.c.
Referenced by apply_peer(), dundi_send(), and handle_command_response().
| #define FLAG_FINAL (1 << 2) |
Transaction has final message sent
Definition at line 92 of file pbx_dundi.c.
Referenced by dundi_send(), handle_frame(), and reset_transaction().
| #define FLAG_ISQUAL (1 << 3) |
Transaction is a qualification
Definition at line 93 of file pbx_dundi.c.
Referenced by destroy_trans(), dundi_rexmit(), and qualify_peer().
| #define FLAG_ISREG (1 << 0) |
Transaction is register request
Definition at line 90 of file pbx_dundi.c.
Referenced by destroy_trans(), and do_register().
| #define FLAG_SENDFULLKEY (1 << 5) |
Send full key on transaction
Definition at line 95 of file pbx_dundi.c.
Referenced by create_transaction(), and dundi_encrypt().
| #define FLAG_STOREHIST (1 << 6) |
Record historic performance
Definition at line 96 of file pbx_dundi.c.
Referenced by create_transaction(), and destroy_trans().
| #define FORMAT "%-12.12s %-12.12s %02d:%02d:%02d\n" |
| #define FORMAT "%-12.12s %-7d %-12.12s %-10.10s %-5.5s %-25.25s\n" |
| #define FORMAT "%-15s %-15s %-15s %-3.3d %-3.3d\n" |
| #define FORMAT "%-16.16s:%5d %-5.5d %-5.5d %-3.3d %-3.3d %-3.3d\n" |
| #define FORMAT "%-20.20s %-15.15s %s %-10.10s %-8.8s %-15.15s\n" |
| #define FORMAT2 "%-12.12s %-12.12s %-10.10s\n" |
| #define FORMAT2 "%-12.12s %-7.7s %-12.12s %-10.10s %-5.5s %-25.25s\n" |
| #define FORMAT2 "%-15s %-15s %-15s %-3.3s %-3.3s\n" |
| #define FORMAT2 "%-22.22s %-5.5s %-5.5s %-3.3s %-3.3s %-3.3s\n" |
| #define FORMAT2 "%-20.20s %-15.15s %-10.10s %-8.8s %-15.15s\n" |
| #define KEY_IN 1 |
Definition at line 107 of file pbx_dundi.c.
| #define KEY_OUT 0 |
Definition at line 106 of file pbx_dundi.c.
| #define MAX_OPTS 128 |
| #define MAX_PACKET_SIZE 8192 |
| #define MAX_RESULTS 64 |
Definition at line 79 of file pbx_dundi.c.
Referenced by dundi_do_lookup(), dundi_exec(), dundi_helper(), dundi_lookup_thread(), dundi_precache_internal(), dundi_prop_precache(), dundifunc_read(), and precache_trans().
| static void abort_request | ( | struct dundi_request * | dr | ) | [static] |
Definition at line 3364 of file pbx_dundi.c.
References AST_LIST_FIRST, AST_LIST_LOCK, AST_LIST_UNLOCK, destroy_trans(), dr, and peers.
Referenced by dundi_lookup_internal().
03365 { 03366 struct dundi_transaction *trans; 03367 03368 AST_LIST_LOCK(&peers); 03369 while ((trans = AST_LIST_FIRST(&dr->trans))) { 03370 /* This will remove the transaction from the list */ 03371 destroy_trans(trans, 0); 03372 } 03373 AST_LIST_UNLOCK(&peers); 03374 }
| static int ack_trans | ( | struct dundi_transaction * | trans, | |
| int | iseqno | |||
| ) | [static] |
Definition at line 1974 of file pbx_dundi.c.
References AST_LIST_EMPTY, AST_LIST_INSERT_HEAD, AST_LIST_TRAVERSE, ast_log(), AST_SCHED_DEL, dundi_transaction::autokillid, destroy_packet(), destroy_packets(), LOG_WARNING, and sched.
Referenced by handle_frame().
01975 { 01976 struct dundi_packet *pack; 01977 01978 /* Ack transmitted packet corresponding to iseqno */ 01979 AST_LIST_TRAVERSE(&trans->packets, pack, list) { 01980 if ((pack->h->oseqno + 1) % 255 == iseqno) { 01981 destroy_packet(pack, 0); 01982 if (!AST_LIST_EMPTY(&trans->lasttrans)) { 01983 ast_log(LOG_WARNING, "Whoa, there was still a last trans?\n"); 01984 destroy_packets(&trans->lasttrans); 01985 } 01986 AST_LIST_INSERT_HEAD(&trans->lasttrans, pack, list); 01987 AST_SCHED_DEL(sched, trans->autokillid); 01988 return 1; 01989 } 01990 } 01991 01992 return 0; 01993 }
| static void append_permission | ( | struct permissionlist * | permlist, | |
| char * | s, | |||
| int | allow | |||
| ) | [static] |
Definition at line 3948 of file pbx_dundi.c.
References ast_calloc, and AST_LIST_INSERT_TAIL.
03949 { 03950 struct permission *perm; 03951 03952 if (!(perm = ast_calloc(1, sizeof(*perm) + strlen(s) + 1))) 03953 return; 03954 03955 strcpy(perm->name, s); 03956 perm->allow = allow; 03957 03958 AST_LIST_INSERT_TAIL(permlist, perm, list); 03959 }
| static int append_transaction | ( | struct dundi_request * | dr, | |
| struct dundi_peer * | p, | |||
| int | ttl, | |||
| dundi_eid * | avoid[] | |||
| ) | [static] |
Definition at line 3321 of file pbx_dundi.c.
References dundi_peer::addr, AST_LIST_INSERT_HEAD, ast_log(), ast_strlen_zero(), create_transaction(), dr, dundi_eid_to_str(), DUNDI_MAX_STACK, dundi_peer::eid, dundi_transaction::eidcount, dundi_transaction::eids, LOG_DEBUG, and dundi_transaction::ttl.
Referenced by build_transactions().
03322 { 03323 struct dundi_transaction *trans; 03324 int x; 03325 char eid_str[20]; 03326 char eid_str2[20]; 03327 03328 /* Ignore if not registered */ 03329 if (!p->addr.sin_addr.s_addr) 03330 return 0; 03331 if (p->maxms && ((p->lastms < 0) || (p->lastms >= p->maxms))) 03332 return 0; 03333 if (ast_strlen_zero(dr->number)) 03334 ast_log(LOG_DEBUG, "Will query peer '%s' for '%s' (context '%s')\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext); 03335 else 03336 ast_log(LOG_DEBUG, "Will query peer '%s' for '%s@%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext); 03337 trans = create_transaction(p); 03338 if (!trans) 03339 return -1; 03340 trans->parent = dr; 03341 trans->ttl = ttl; 03342 for (x = 0; avoid[x] && (x < DUNDI_MAX_STACK); x++) 03343 trans->eids[x] = *avoid[x]; 03344 trans->eidcount = x; 03345 AST_LIST_INSERT_HEAD(&dr->trans, trans, parentlist); 03346 03347 return 0; 03348 }
| static void apply_peer | ( | struct dundi_transaction * | trans, | |
| struct dundi_peer * | p | |||
| ) | [static] |
Definition at line 1251 of file pbx_dundi.c.
References dundi_peer::addr, dundi_transaction::addr, ast_set_flag, ast_strlen_zero(), dundi_transaction::autokilltimeout, DUNDI_DEFAULT_RETRANS_TIMER, dundi_peer::eid, FLAG_ENCRYPT, dundi_transaction::retranstimer, dundi_transaction::them_eid, and dundi_transaction::us_eid.
Referenced by create_transaction().
01252 { 01253 if (!trans->addr.sin_addr.s_addr) 01254 memcpy(&trans->addr, &p->addr, sizeof(trans->addr)); 01255 trans->us_eid = p->us_eid; 01256 trans->them_eid = p->eid; 01257 /* Enable encryption if appropriate */ 01258 if (!ast_strlen_zero(p->inkey)) 01259 ast_set_flag(trans, FLAG_ENCRYPT); 01260 if (p->maxms) { 01261 trans->autokilltimeout = p->maxms; 01262 trans->retranstimer = DUNDI_DEFAULT_RETRANS_TIMER; 01263 if (p->lastms > 1) { 01264 trans->retranstimer = p->lastms * 2; 01265 /* Keep it from being silly */ 01266 if (trans->retranstimer < 150) 01267 trans->retranstimer = 150; 01268 } 01269 if (trans->retranstimer > DUNDI_DEFAULT_RETRANS_TIMER) 01270 trans->retranstimer = DUNDI_DEFAULT_RETRANS_TIMER; 01271 } else 01272 trans->autokilltimeout = global_autokilltimeout; 01273 }
| static AST_LIST_HEAD_NOLOCK_STATIC | ( | alltrans | , | |
| dundi_transaction | ||||
| ) | [static] |
| static AST_LIST_HEAD_NOLOCK_STATIC | ( | requests | , | |
| dundi_request | ||||
| ) | [static] |
| static AST_LIST_HEAD_NOLOCK_STATIC | ( | mappings | , | |
| dundi_mapping | ||||
| ) | [static] |
| static AST_LIST_HEAD_STATIC | ( | pcq | , | |
| dundi_precache_queue | ||||
| ) | [static] |
| static AST_LIST_HEAD_STATIC | ( | peers | , | |
| dundi_peer | ||||
| ) | [static] |
| AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
| AST_MODFLAG_DEFAULT | , | |||
| "Distributed Universal Number Discovery (DUNDi)" | , | |||
| . | load = load_module, |
|||
| . | unload = unload_module, |
|||
| . | reload = reload | |||
| ) |
| static unsigned long avoid_crc32 | ( | dundi_eid * | avoid[] | ) | [static] |
Definition at line 3485 of file pbx_dundi.c.
References dundi_request::crc32.
Referenced by dundi_lookup_internal().
03486 { 03487 /* Idea is that we're calculating a checksum which is independent of 03488 the order that the EID's are listed in */ 03489 unsigned long acrc32 = 0; 03490 int x; 03491 for (x=0;avoid[x];x++) { 03492 /* Order doesn't matter */ 03493 if (avoid[x+1]) { 03494 acrc32 ^= crc32(0L, (unsigned char *)avoid[x], sizeof(dundi_eid)); 03495 } 03496 } 03497 return acrc32; 03498 }
| static void build_iv | ( | unsigned char * | iv | ) | [static] |
Definition at line 501 of file pbx_dundi.c.
References ast_random().
Referenced by build_secret(), dundi_encrypt(), and update_key().
00502 { 00503 /* XXX Would be nice to be more random XXX */ 00504 unsigned int *fluffy; 00505 int x; 00506 fluffy = (unsigned int *)(iv); 00507 for (x=0;x<4;x++) 00508 fluffy[x] = ast_random(); 00509 }
| static void build_mapping | ( | char * | name, | |
| char * | value | |||
| ) | [static] |
Definition at line 3963 of file pbx_dundi.c.
References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_TRAVERSE, ast_log(), ast_strdupa, ast_strlen_zero(), DUNDI_FLAG_COMMERCIAL, DUNDI_FLAG_INTERNAL_NOPARTIAL, DUNDI_FLAG_MOBILE, DUNDI_FLAG_NOCOMUNSOLICIT, DUNDI_FLAG_NOUNSOLICITED, DUNDI_FLAG_RESIDENTIAL, LOG_WARNING, map, MAX_OPTS, str2tech(), and t.
Referenced by set_config().
03964 { 03965 char *t, *fields[MAX_OPTS]; 03966 struct dundi_mapping *map; 03967 int x; 03968 int y; 03969 03970 t = ast_strdupa(value); 03971 03972 AST_LIST_TRAVERSE(&mappings, map, list) { 03973 /* Find a double match */ 03974 if (!strcasecmp(map->dcontext, name) && 03975 (!strncasecmp(map->lcontext, value, strlen(map->lcontext)) && 03976 (!value[strlen(map->lcontext)] || 03977 (value[strlen(map->lcontext)] == ',')))) 03978 break; 03979 } 03980 if (!map) { 03981 if (!(map = ast_calloc(1, sizeof(*map)))) 03982 return; 03983 AST_LIST_INSERT_HEAD(&mappings, map, list); 03984 map->dead = 1; 03985 } 03986 map->options = 0; 03987 memset(fields, 0, sizeof(fields)); 03988 x = 0; 03989 while (t && x < MAX_OPTS) { 03990 fields[x++] = t; 03991 t = strchr(t, ','); 03992 if (t) { 03993 *t = '\0'; 03994 t++; 03995 } 03996 } /* Russell was here, arrrr! */ 03997 if ((x == 1) && ast_strlen_zero(fields[0])) { 03998 /* Placeholder mapping */ 03999 ast_copy_string(map->dcontext, name, sizeof(