diff options
-rw-r--r-- | apps/app_directory.c | 6 | ||||
-rw-r--r-- | apps/app_macro.c | 5 | ||||
-rw-r--r-- | apps/app_voicemail.c | 10 | ||||
-rw-r--r-- | cdr/cdr_odbc.c | 1 | ||||
-rw-r--r-- | channels/Makefile | 6 | ||||
-rw-r--r-- | channels/chan_iax2.c | 45 | ||||
-rw-r--r-- | channels/chan_misdn.c | 63 | ||||
-rw-r--r-- | channels/chan_sip.c | 20 | ||||
-rw-r--r-- | channels/misdn/Makefile | 3 | ||||
-rw-r--r-- | channels/misdn/chan_misdn_config.h | 4 | ||||
-rw-r--r-- | channels/misdn/isdn_lib.c | 24 | ||||
-rw-r--r-- | channels/misdn/isdn_lib.h | 5 | ||||
-rw-r--r-- | channels/misdn_config.c | 3 | ||||
-rw-r--r-- | res/res_odbc.c | 11 |
14 files changed, 159 insertions, 47 deletions
diff --git a/apps/app_directory.c b/apps/app_directory.c index 9caefc030..2b1d4e967 100644 --- a/apps/app_directory.c +++ b/apps/app_directory.c @@ -94,7 +94,7 @@ static void retrieve_file(char *dir) int res; int fd=-1; size_t fdlen = 0; - void *fdm=NULL; + void *fdm = MAP_FAILED; SQLHSTMT stmt; char sql[256]; char fmt[80]=""; @@ -161,7 +161,7 @@ static void retrieve_file(char *dir) if (fd > -1) fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); } - if (fdm) { + if (fdm != MAP_FAILED) { memset(fdm, 0, fdlen); res = SQLGetData(stmt, x + 1, SQL_BINARY, fdm, fdlen, &colsize); if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { @@ -174,7 +174,7 @@ static void retrieve_file(char *dir) } while (0); } else ast_log(LOG_WARNING, "Failed to obtain database object for '%s'!\n", odbc_database); - if (fdm) + if (fdm != MAP_FAILED) munmap(fdm, fdlen); if (fd > -1) close(fd); diff --git a/apps/app_macro.c b/apps/app_macro.c index 425836278..45e7d70ab 100644 --- a/apps/app_macro.c +++ b/apps/app_macro.c @@ -61,6 +61,11 @@ static char *descrip = "will be returned at the location of the Goto.\n" "If ${MACRO_OFFSET} is set at termination, Macro will attempt to continue\n" "at priority MACRO_OFFSET + N + 1 if such a step exists, and N + 1 otherwise.\n" +"Extensions: While a macro is being executed, it becomes the current context.\n" +" This means that if a hangup occurs, for instance, that the macro\n" +" will be searched for an 'h' extension, NOT the context from which\n" +" the macro was called. So, make sure to define all appropriate\n" +" extensions in your macro! (you can use 'catch' in AEL) \n" "WARNING: Because of the way Macro is implemented (it executes the priorities\n" " contained within it via sub-engine), and a fixed per-thread\n" " memory stack allowance, macros are limited to 7 levels\n" diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 23cf6bd4b..bd6e8b8d6 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -836,7 +836,7 @@ static int retrieve_file(char *dir, int msgnum) int res; int fd=-1; size_t fdlen = 0; - void *fdm=NULL; + void *fdm = MAP_FAILED; SQLSMALLINT colcount=0; SQLHSTMT stmt; char sql[PATH_MAX]; @@ -944,7 +944,7 @@ static int retrieve_file(char *dir, int msgnum) } /* Read out in small chunks */ for (offset = 0; offset < colsize; offset += CHUNKSIZE) { - if ((fdm = mmap(NULL, CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)) == (void *)-1) { + if ((fdm = mmap(NULL, CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset)) == MAP_FAILED) { ast_log(LOG_WARNING, "Could not mmap the output file: %s (%d)\n", strerror(errno), errno); SQLFreeHandle(SQL_HANDLE_STMT, stmt); goto yuck; @@ -1207,7 +1207,7 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms int x = 0; int res; int fd = -1; - void *fdm=NULL; + void *fdm = MAP_FAILED; size_t fdlen = -1; SQLHSTMT stmt; SQLINTEGER len; @@ -1262,7 +1262,7 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms lseek(fd, 0, SEEK_SET); printf("Length is %d\n", fdlen); fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED,fd, 0); - if (!fdm) { + if (fdm == MAP_FAILED) { ast_log(LOG_WARNING, "Memory map failed!\n"); goto yuck; } @@ -1319,7 +1319,7 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms yuck: if (cfg) ast_config_destroy(cfg); - if (fdm) + if (fdm != MAP_FAILED) munmap(fdm, fdlen); if (fd > -1) close(fd); diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c index 7a50bf21d..294738bfb 100644 --- a/cdr/cdr_odbc.c +++ b/cdr/cdr_odbc.c @@ -383,7 +383,6 @@ static int odbc_do_query(void) if ((ODBC_res != SQL_SUCCESS) && (ODBC_res != SQL_SUCCESS_WITH_INFO)) { if (option_verbose > 10) ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: Error in Query %d\n", ODBC_res); - SQLGetDiagRec(SQL_HANDLE_DBC, ODBC_con, 1, (unsigned char *)ODBC_stat, &ODBC_err, (unsigned char *)ODBC_msg, 100, &ODBC_mlen); SQLFreeHandle(SQL_HANDLE_STMT, ODBC_stmt); odbc_disconnect(); return -1; diff --git a/channels/Makefile b/channels/Makefile index 1e09688cd..3a2ad6871 100644 --- a/channels/Makefile +++ b/channels/Makefile @@ -88,6 +88,10 @@ ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/mISDNuser/mISDNlib.h),) CFLAGS+=-Imisdn endif +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/mISDNdsp.h),) + CFLAGS+=-DMISDN_1_2 +endif + CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/alsa/asoundlib.h),) @@ -243,7 +247,7 @@ chan_h323.so: chan_h323.o h323/libchanh323.a endif misdn/chan_misdn_lib.a: - make -C misdn + make CROSS_COMPILE_TARGET=$(CROSS_COMPILE_TARGET) -C misdn chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a $(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index b9d536aab..c8c4221df 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -176,6 +176,7 @@ static int max_reg_expire; static int timingfd = -1; /* Timing file descriptor */ static struct ast_netsock_list *netsock; +static struct ast_netsock_list *outsock; /*!< used if sourceaddress specified and bindaddr == INADDR_ANY */ static int defaultsockfd = -1; static int usecnt; @@ -8225,20 +8226,40 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr) if (res == 0) { /* ip address valid. */ sin.sin_port = htons(port); - sock = ast_netsock_find(netsock, &sin); + if (!(sock = ast_netsock_find(netsock, &sin))) + sock = ast_netsock_find(outsock, &sin); if (sock) { sockfd = ast_netsock_sockfd(sock); nonlocal = 0; + } else { + unsigned int orig_saddr = sin.sin_addr.s_addr; + /* INADDR_ANY matches anyway! */ + sin.sin_addr.s_addr = INADDR_ANY; + if (ast_netsock_find(netsock, &sin)) { + sin.sin_addr.s_addr = orig_saddr; + sock = ast_netsock_bind(outsock, io, srcaddr, port, tos, socket_read, NULL); + if (sock) { + sockfd = ast_netsock_sockfd(sock); + ast_netsock_unref(sock); + nonlocal = 0; + } else { + nonlocal = 2; + } + } } } } peer->sockfd = sockfd; - if (nonlocal) { + if (nonlocal == 1) { ast_log(LOG_WARNING, "Non-local or unbound address specified (%s) in sourceaddress for '%s', reverting to default\n", srcaddr, peer->name); return -1; + } else if (nonlocal == 2) { + ast_log(LOG_WARNING, "Unable to bind to sourceaddress '%s' for '%s', reverting to default\n", + srcaddr, peer->name); + return -1; } else { ast_log(LOG_DEBUG, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name); return 0; @@ -8942,7 +8963,16 @@ static int set_config(char *config_file, int reload) ast_netsock_unref(ns); } } - + if (reload) { + ast_netsock_release(outsock); + outsock = ast_netsock_list_alloc(); + if (!outsock) { + ast_log(LOG_ERROR, "Could not allocate outsock list.\n"); + return -1; + } + ast_netsock_init(outsock); + } + if (min_reg_expire > max_reg_expire) { ast_log(LOG_WARNING, "Minimum registration interval of %d is more than maximum of %d, resetting minimum to %d\n", min_reg_expire, max_reg_expire, max_reg_expire); @@ -9665,6 +9695,7 @@ static int __unload_module(void) pthread_join(netthreadid, NULL); } ast_netsock_release(netsock); + ast_netsock_release(outsock); for (x=0;x<IAX_MAX_CALLS;x++) if (iaxs[x]) iax2_destroy(x); @@ -9743,6 +9774,13 @@ int load_module(void) } ast_netsock_init(netsock); + outsock = ast_netsock_list_alloc(); + if (!outsock) { + ast_log(LOG_ERROR, "Could not allocate outsock list.\n"); + return -1; + } + ast_netsock_init(outsock); + ast_mutex_init(&iaxq.lock); ast_mutex_init(&userl.lock); ast_mutex_init(&peerl.lock); @@ -9773,6 +9811,7 @@ int load_module(void) } else { ast_log(LOG_ERROR, "Unable to start network thread\n"); ast_netsock_release(netsock); + ast_netsock_release(outsock); } ast_mutex_lock(®_lock); diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index 4d29fd33c..48c8063e6 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -283,9 +283,6 @@ static int tracing = 0 ; static int usecnt=0; -static char **misdn_key_vector=NULL; -static int misdn_key_vector_size=0; - /* Only alaw and mulaw is allowed for now */ static int prefformat = AST_FORMAT_ALAW ; /* AST_FORMAT_SLINEAR ; AST_FORMAT_ULAW | */ @@ -325,7 +322,11 @@ static int misdn_facility_exec(struct ast_channel *chan, void *data); int chan_misdn_jb_empty(struct misdn_bchannel *bc, char *buf, int len); +#ifdef MISDN_1_2 +static int update_pipeline_config(struct misdn_bchannel *bc); +#else static int update_ec_config(struct misdn_bchannel *bc); +#endif /*************** Helpers *****************/ @@ -773,7 +774,11 @@ static void print_bc_info (int fd, struct chan_list* help, struct misdn_bchannel " --> activated: %d\n" " --> state: %s\n" " --> capability: %s\n" +#ifdef MISDN_1_2 + " --> pipeline: %s\n" +#else " --> echo_cancel: %d\n" +#endif " --> notone : rx %d tx:%d\n" " --> bc_hold: %d\n", help->ast->name, @@ -786,7 +791,11 @@ static void print_bc_info (int fd, struct chan_list* help, struct misdn_bchannel bc->active, bc_state2str(bc->bc_state), bearer2str(bc->capability), +#ifdef MISDN_1_2 + bc->pipeline, +#else bc->ec_enable, +#endif help->norxtone,help->notxtone, bc->holded @@ -1005,7 +1014,11 @@ static int misdn_toggle_echocancel (int fd, int argc, char *argv[]) tmp->toggle_ec=tmp->toggle_ec?0:1; if (tmp->toggle_ec) { +#ifdef MISDN_1_2 + update_pipeline_config(tmp->bc); +#else update_ec_config(tmp->bc); +#endif manager_ec_enable(tmp->bc); } else { manager_ec_disable(tmp->bc); @@ -1404,9 +1417,25 @@ void debug_numplan(int port, int numplan, char *type) } } +#ifdef MISDN_1_2 +static int update_pipeline_config(struct misdn_bchannel *bc) +{ + int ec; + misdn_cfg_get(bc->port, MISDN_CFG_PIPELINE, bc->pipeline, sizeof(bc->pipeline)); + if (*bc->pipeline) + return 0; + + misdn_cfg_get(bc->port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int)); + if (ec == 1) + snprintf(bc->pipeline, sizeof(bc->pipeline) - 1, "mg2ec"); + else if (ec > 1) + snprintf(bc->pipeline, sizeof(bc->pipeline) - 1, "mg2ec(deftaps=%d)", ec); + return 0; +} +#else static int update_ec_config(struct misdn_bchannel *bc) { int ec; @@ -1423,7 +1452,7 @@ static int update_ec_config(struct misdn_bchannel *bc) return 0; } - +#endif static int read_config(struct chan_list *ch, int orig) { @@ -1493,7 +1522,11 @@ static int read_config(struct chan_list *ch, int orig) { ast_copy_string (ast->context,ch->context,sizeof(ast->context)); +#ifdef MISDN_1_2 + update_pipeline_config(bc); +#else update_ec_config(bc); +#endif { int eb3; @@ -1721,9 +1754,15 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout) int bridging; misdn_cfg_get( 0, MISDN_GEN_BRIDGING, &bridging, sizeof(int)); if (bridging && ch->other_ch) { - chan_misdn_log(0, port, "Disabling EC on both Sides\n"); +#ifdef MISDN_1_2 + chan_misdn_log(0, port, "Disabling EC (aka Pipeline) on both Sides\n"); + *ch->bc->pipeline=0; + *ch->other_ch->bc->pipeline=0; +#else + chan_misdn_log(0, port, "Disabling EC on both Sides\n"); ch->bc->ec_enable=0; ch->other_ch->bc->ec_enable=0; +#endif } r=misdn_lib_send_event( newbc, EVENT_SETUP ); @@ -3863,7 +3902,8 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) if (ch->ast) { ch->ast->hangupcause=bc->cause; - ast_queue_control(ch->ast, AST_CONTROL_BUSY); + if (bc->cause == 17) + ast_queue_control(ch->ast, AST_CONTROL_BUSY); } ch->need_busy=0; break; @@ -4563,15 +4603,22 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data) if (neglect) { chan_misdn_log(1, ch->bc->port, " --> disabled\n"); +#ifdef MISDN_1_2 + *ch->bc->pipeline=0; +#else ch->bc->ec_enable=0; - +#endif } else { +#ifdef MISDN_1_2 + update_pipeline_config(ch->bc); +#else ch->bc->ec_enable=1; ch->bc->orig=ch->orginator; tok++; - if (tok) { + if (*tok) { ch->bc->ec_deftaps=atoi(tok); } +#endif } break; diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 3906e9fd2..0e968fd05 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -11405,16 +11405,16 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc /* ignore means "don't do anything with it" but still have to respond appropriately */ ignore=1; - } - - e = ast_skip_blanks(e); - if (sscanf(e, "%d %n", &respid, &len) != 1) { - ast_log(LOG_WARNING, "Invalid response: '%s'\n", e); - } else { - /* More SIP ridiculousness, we have to ignore bogus contacts in 100 etc responses */ - if ((respid == 200) || ((respid >= 300) && (respid <= 399))) - extract_uri(p, req); - handle_response(p, respid, e + len, req, ignore, seqno); + } else if (e) { + e = ast_skip_blanks(e); + if (sscanf(e, "%d %n", &respid, &len) != 1) { + ast_log(LOG_WARNING, "Invalid response: '%s'\n", e); + } else { + /* More SIP ridiculousness, we have to ignore bogus contacts in 100 etc responses */ + if ((respid == 200) || ((respid >= 300) && (respid <= 399))) + extract_uri(p, req); + handle_response(p, respid, e + len, req, ignore, seqno); + } } return 0; } diff --git a/channels/misdn/Makefile b/channels/misdn/Makefile index 1374e75e3..8b03cc3ed 100644 --- a/channels/misdn/Makefile +++ b/channels/misdn/Makefile @@ -9,6 +9,9 @@ CFLAGS = -pipe -c -Wall -ggdb ifeq ($(shell uname -m),x86_64) CFLAGS += -fPIC endif +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/mISDNdsp.h),) +CFLAGS+=-DMISDN_1_2 +endif SOURCES = isdn_lib.c isdn_msg_parser.c OBJDIR = . OBJS = isdn_lib.o isdn_msg_parser.o fac.o diff --git a/channels/misdn/chan_misdn_config.h b/channels/misdn/chan_misdn_config.h index 31751aa80..78d34750f 100644 --- a/channels/misdn/chan_misdn_config.h +++ b/channels/misdn/chan_misdn_config.h @@ -52,7 +52,9 @@ enum misdn_cfg_elements { MISDN_CFG_EARLY_BCONNECT, /* int (bool) */ MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */ MISDN_CFG_ECHOCANCEL, /* int */ - MISDN_CFG_ECHOCANCELWHENBRIDGED, /* int (bool) */ +#ifdef MISDN_1_2 + MISDN_CFG_PIPELINE, /* char[] */ +#endif MISDN_CFG_NEED_MORE_INFOS, /* bool */ MISDN_CFG_NTTIMEOUT, /* bool */ MISDN_CFG_JITTERBUFFER, /* int */ diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c index c1ddd551a..73ee20096 100644 --- a/channels/misdn/isdn_lib.c +++ b/channels/misdn/isdn_lib.c @@ -573,14 +573,17 @@ void empty_bc(struct misdn_bchannel *bc) bc->active = 0; bc->early_bconnect = 1; - + +#ifdef MISDN_1_2 + *bc->pipeline = 0; +#else bc->ec_enable = 0; bc->ec_deftaps = 128; - bc->ec_whenbridged = 0; #ifdef EC_TRAIN bc->ec_training = 1; #endif +#endif bc->orig=0; @@ -4240,16 +4243,21 @@ void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone) void manager_ec_enable(struct misdn_bchannel *bc) { - int ec_arr[2]; - struct misdn_stack *stack=get_stack_by_bc(bc); cb_log(4, stack?stack->port:0,"ec_enable\n"); if (!misdn_cap_is_speech(bc->capability)) { cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n"); - return; + } else { + +#ifdef MISDN_1_2 + if (*bc->pipeline) { + cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline); + manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1); } +#else + int ec_arr[2]; if (bc->ec_enable) { cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d training:%d\n",bc->ec_deftaps, bc->ec_training); @@ -4276,6 +4284,8 @@ void manager_ec_enable(struct misdn_bchannel *bc) manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr)); } +#endif + } } @@ -4291,10 +4301,14 @@ void manager_ec_disable(struct misdn_bchannel *bc) return; } +#ifdef MISDN_1_2 + manager_ph_control_block(bc, PIPELINE_CFG, "", 0); +#else if ( ! bc->ec_enable) { cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n"); manager_ph_control(bc, ECHOCAN_OFF, 0); } +#endif } struct misdn_stack* get_misdn_stack() { diff --git a/channels/misdn/isdn_lib.h b/channels/misdn/isdn_lib.h index 5179c50dd..4b687c3b6 100644 --- a/channels/misdn/isdn_lib.h +++ b/channels/misdn/isdn_lib.h @@ -354,10 +354,13 @@ struct misdn_bchannel { /** list stuf **/ +#ifdef MISDN_1_2 + char pipeline[128]; +#else int ec_enable; int ec_deftaps; - int ec_whenbridged; int ec_training; +#endif #ifdef WITH_BEROEC beroec_t *ec; diff --git a/channels/misdn_config.c b/channels/misdn_config.c index 966006e80..64dc8835d 100644 --- a/channels/misdn_config.c +++ b/channels/misdn_config.c @@ -113,6 +113,9 @@ static const struct misdn_cfg_spec port_spec[] = { { "early_bconnect", MISDN_CFG_EARLY_BCONNECT, MISDN_CTYPE_BOOL, "yes", NONE }, { "incoming_early_audio", MISDN_CFG_INCOMING_EARLY_AUDIO, MISDN_CTYPE_BOOL, "no", NONE }, { "echocancel", MISDN_CFG_ECHOCANCEL, MISDN_CTYPE_BOOLINT, "0", 128 }, +#ifdef MISDN_1_2 + { "pipeline", MISDN_CFG_PIPELINE, MISDN_CTYPE_STR, NO_DEFAULT, NONE }, +#endif { "need_more_infos", MISDN_CFG_NEED_MORE_INFOS, MISDN_CTYPE_BOOL, "0", NONE }, { "nttimeout", MISDN_CFG_NTTIMEOUT, MISDN_CTYPE_BOOL, "no", NONE }, { "jitterbuffer", MISDN_CFG_JITTERBUFFER, MISDN_CTYPE_INT, "4000", NONE }, diff --git a/res/res_odbc.c b/res/res_odbc.c index 92cd1ccfb..87b34c08b 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -251,7 +251,6 @@ static int load_odbc_config(void) char *cat, *dsn, *username, *password; int enabled; int connect = 0; - char *env_var; odbc_obj *obj; @@ -260,16 +259,10 @@ static int load_odbc_config(void) for (cat = ast_category_browse(config, NULL); cat; cat=ast_category_browse(config, cat)) { if (!strcmp(cat, "ENV")) { for (v = ast_variable_browse(config, cat); v; v = v->next) { - env_var = malloc(strlen(v->name) + strlen(v->value) + 2); - if (env_var) { - sprintf(env_var, "%s=%s", v->name, v->value); - ast_log(LOG_NOTICE, "Adding ENV var: %s=%s\n", v->name, v->value); - putenv(env_var); - free(env_var); - } + setenv(v->name, v->value, 1); } - cat = ast_category_browse(config, cat); + cat = ast_category_browse(config, cat); } dsn = username = password = NULL; |