[asterisk-commits] oej: branch oej/videocaps r65054 - in /team/oej/videocaps: ./ apps/ channels/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri May 18 06:06:07 MST 2007


Author: oej
Date: Fri May 18 08:06:05 2007
New Revision: 65054

URL: http://svn.digium.com/view/asterisk?view=rev&rev=65054
Log:
Reset automerge, resolve conflict, live happily forever after

Added:
    team/oej/videocaps/main/adsistub.c
      - copied unchanged from r65006, trunk/main/adsistub.c
Removed:
    team/oej/videocaps/contrib/scripts/astxs
Modified:
    team/oej/videocaps/   (props changed)
    team/oej/videocaps/CHANGES
    team/oej/videocaps/README
    team/oej/videocaps/acinclude.m4
    team/oej/videocaps/apps/app_dial.c
    team/oej/videocaps/apps/app_queue.c
    team/oej/videocaps/apps/app_voicemail.c
    team/oej/videocaps/channels/chan_alsa.c
    team/oej/videocaps/channels/chan_local.c
    team/oej/videocaps/channels/chan_misdn.c
    team/oej/videocaps/channels/chan_sip.c
    team/oej/videocaps/channels/chan_zap.c
    team/oej/videocaps/channels/misdn/chan_misdn_config.h
    team/oej/videocaps/channels/misdn/ie.c
    team/oej/videocaps/channels/misdn/isdn_lib.c
    team/oej/videocaps/channels/misdn/isdn_lib.h
    team/oej/videocaps/channels/misdn/isdn_lib_intern.h
    team/oej/videocaps/channels/misdn/isdn_msg_parser.c
    team/oej/videocaps/channels/misdn_config.c
    team/oej/videocaps/codecs/codec_speex.c
    team/oej/videocaps/configs/manager.conf.sample
    team/oej/videocaps/configs/queues.conf.sample
    team/oej/videocaps/configs/sip.conf.sample
    team/oej/videocaps/configs/zapata.conf.sample
    team/oej/videocaps/configure
    team/oej/videocaps/funcs/func_enum.c
    team/oej/videocaps/include/asterisk/adsi.h
    team/oej/videocaps/include/asterisk/enum.h
    team/oej/videocaps/include/asterisk/linkedlists.h
    team/oej/videocaps/main/Makefile
    team/oej/videocaps/main/app.c
    team/oej/videocaps/main/cdr.c
    team/oej/videocaps/main/channel.c
    team/oej/videocaps/main/devicestate.c
    team/oej/videocaps/main/dial.c
    team/oej/videocaps/main/enum.c
    team/oej/videocaps/main/event.c
    team/oej/videocaps/main/manager.c
    team/oej/videocaps/main/pbx.c
    team/oej/videocaps/pbx/pbx_dundi.c
    team/oej/videocaps/res/res_adsi.c
    team/oej/videocaps/res/res_features.c

Propchange: team/oej/videocaps/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/videocaps/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/oej/videocaps/
            ('svnmerge-blocked' removed)

Propchange: team/oej/videocaps/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri May 18 08:06:05 2007
@@ -1,1 +1,1 @@
-/trunk:1-64185
+/trunk:1-65038

Modified: team/oej/videocaps/CHANGES
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/CHANGES?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/CHANGES (original)
+++ team/oej/videocaps/CHANGES Fri May 18 08:06:05 2007
@@ -76,6 +76,13 @@
   * Added two new dialplan functions, DUNDIQUERY and DUNDIRESULT.  These
      functions will allow you to initiate a DUNDi query from the dialplan,
      find out how many results there are, and access each one.
+
+ENUM changes
+------------
+  * Added two new dialplan functions, ENUMQUERY and ENUMRESULT.  These
+     functions will allow you to initiate an ENUM lookup from the dialplan,
+     and Asterisk will cache the results.  ENUMRESULT can be used to access
+	 the results without doing multiple DNS queries.
 
 Voicemail Changes
 -----------------

Modified: team/oej/videocaps/README
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/README?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/README (original)
+++ team/oej/videocaps/README Fri May 18 08:06:05 2007
@@ -84,18 +84,28 @@
 
   So let's proceed:
 
-1) Read the README files.
-   There are more README files than this one in the doc/ directory.
-   Start with doc/00README.1st
-   You may also want to check the configuration files that contain
-   examples and reference guides. They are all in the configs/
-   directory.
-
-2) Run "make"
+1) Read this README file.
+
+  There are more documents than this one in the doc/ directory.
+You may also want to check the configuration files that contain
+examples and reference guides. They are all in the configs/
+directory.
+
+2) Run "./configure"
+
+  Execute the configure script to guess values for system-dependent
+variables used during compilation.
+
+3) Run "make menuselect" [optional]
+
+  This is needed if you want to select the modules that will be
+compiled and to check modules dependencies.
+
+4) Run "make"
 
   Assuming the build completes successfully:
 
-3) Run "make install"
+5) Run "make install"
 
   Each time you update or checkout from the repository, you are strongly
 encouraged to ensure all previous object files are removed to avoid internal 
@@ -106,7 +116,7 @@
   If this is your first time working with Asterisk, you may wish to install
 the sample PBX, with demonstration extensions, etc.  If so, run:
 
-4) "make samples"
+6) "make samples"
 
   Doing so will overwrite any existing config files you have.
 

Modified: team/oej/videocaps/acinclude.m4
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/acinclude.m4?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/acinclude.m4 (original)
+++ team/oej/videocaps/acinclude.m4 Fri May 18 08:06:05 2007
@@ -77,7 +77,7 @@
 	AC_MSG_CHECKING([for $2 in $3])
 	saved_cppflags="${CPPFLAGS}"
 	if test "x${$1_DIR}" != "x"; then
-	    $1_INCLUDE= "-I${$1_DIR}/include"
+	    $1_INCLUDE="-I${$1_DIR}/include"
 	fi
 	CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
 

Modified: team/oej/videocaps/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/apps/app_dial.c?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/apps/app_dial.c (original)
+++ team/oej/videocaps/apps/app_dial.c Fri May 18 08:06:05 2007
@@ -1191,7 +1191,7 @@
 	int to;	/* timeout */
 	struct cause_args num = { chan, 0, 0, 0 };
 	int cause;
-	char numsubst[AST_MAX_EXTENSION];
+	char numsubst[256];
 	char cidname[AST_MAX_EXTENSION];
 
 	struct ast_bridge_config config;

Modified: team/oej/videocaps/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/apps/app_queue.c?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/apps/app_queue.c (original)
+++ team/oej/videocaps/apps/app_queue.c Fri May 18 08:06:05 2007
@@ -134,6 +134,7 @@
 "This application will return to the dialplan if the queue does not exist, or\n"
 "any of the join options cause the caller to not enter the queue.\n"
 "The option string may contain zero or more of the following characters:\n"
+"      'c' -- continue in the dialplan if the callee hangs up.\n"
 "      'd' -- data-quality (modem) call (minimum delay).\n"
 "      'h' -- allow callee to hang up by pressing *.\n"
 "      'H' -- allow caller to hang up by pressing *.\n"
@@ -158,7 +159,7 @@
 "seconds, checked between each queues.conf 'timeout' and 'retry' cycle.\n"
 "  This application sets the following channel variable upon completion:\n"
 "      QUEUESTATUS    The status of the call as a text string, one of\n"
-"             TIMEOUT | FULL | JOINEMPTY | LEAVEEMPTY | JOINUNAVAIL | LEAVEUNAVAIL\n";
+"             TIMEOUT | FULL | JOINEMPTY | LEAVEEMPTY | JOINUNAVAIL | LEAVEUNAVAIL | CONTINUE\n";
 
 static char *app_aqm = "AddQueueMember" ;
 static char *app_aqm_synopsis = "Dynamically adds queue members" ;
@@ -264,6 +265,7 @@
 	QUEUE_JOINUNAVAIL = 4,
 	QUEUE_LEAVEUNAVAIL = 5,
 	QUEUE_FULL = 6,
+	QUEUE_CONTINUE = 7,
 };
 
 const struct {
@@ -277,6 +279,7 @@
 	{ QUEUE_JOINUNAVAIL, "JOINUNAVAIL" },
 	{ QUEUE_LEAVEUNAVAIL, "LEAVEUNAVAIL" },
 	{ QUEUE_FULL, "FULL" },
+	{ QUEUE_CONTINUE, "CONTINUE" },
 };
 
 /*! \brief We define a custom "local user" structure because we
@@ -856,7 +859,9 @@
 		ast_log(LOG_DEBUG, "%s=%s for queue '%s'\n", param, val, q->name);
 	} else if (!strcasecmp(param, "announce-round-seconds")) {
 		q->roundingseconds = atoi(val);
-		if (q->roundingseconds>60 || q->roundingseconds<0) {
+		/* Rounding to any other values just doesn't make sense... */
+		if (!(q->roundingseconds == 0 || q->roundingseconds == 1 || q->roundingseconds == 5 || q->roundingseconds == 10
+			|| q->roundingseconds == 15 || q->roundingseconds == 20 || q->roundingseconds == 30)) {
 			if (linenum >= 0) {
 				ast_log(LOG_WARNING, "'%s' isn't a valid value for %s "
 					"using 0 instead for queue '%s' at line %d of queues.conf\n",
@@ -3411,6 +3416,7 @@
 	const char *user_priority;
 	const char *max_penalty_str;
 	int prio;
+	int qcontinue = 0;
 	int max_penalty;
 	enum queue_result reason = QUEUE_UNKNOWN;
 	/* whether to exit Queue application after the timeout hits */
@@ -3484,6 +3490,9 @@
 	if (args.options && (strchr(args.options, 'r')))
 		ringing = 1;
 
+	if (args.options && (strchr(args.options, 'c')))
+		qcontinue = 1;
+
 	if (option_debug)
 		ast_log(LOG_DEBUG, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n",
 			args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio);
@@ -3578,6 +3587,9 @@
 							ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ABANDON",
 								"%d|%d|%ld", qe.pos, qe.opos,
 								(long) time(NULL) - qe.start);
+						} else if (qcontinue) {
+							reason = QUEUE_CONTINUE;
+							res = 0;
 						}
 					} else if (valid_exit(&qe, res)) {
 						ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d|%d|%ld", 
@@ -4695,6 +4707,7 @@
 	res |= ast_custom_function_unregister(&queuemembercount_function);
 	res |= ast_custom_function_unregister(&queuememberlist_function);
 	res |= ast_custom_function_unregister(&queuewaitingcount_function);
+	ast_devstate_del(statechange_queue, NULL);
 
 	ast_module_user_hangup_all();
 

Modified: team/oej/videocaps/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/apps/app_voicemail.c?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/apps/app_voicemail.c (original)
+++ team/oej/videocaps/apps/app_voicemail.c Fri May 18 08:06:05 2007
@@ -41,7 +41,6 @@
  */
 
 /*** MODULEINFO
-	<depend>res_adsi</depend>
  ***/
 
 /*** MAKEOPTS
@@ -4814,7 +4813,7 @@
 
 	/* Add authentication user if present */
 	if (!ast_strlen_zero(authuser))
-		ast_build_string(&t, &left, "/%s", authuser);
+		ast_build_string(&t, &left, "/authuser=%s", authuser);
 
 	/* Add flags if present */
 	if (!ast_strlen_zero(imapflags))
@@ -6767,7 +6766,7 @@
 			}
 			break;
 		case '4':
-			if (vms.curmsg) {
+			if (vms.curmsg > 0) {
 				vms.curmsg--;
 				cmd = play_message(chan, vmu, &vms);
 			} else {

Modified: team/oej/videocaps/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_alsa.c?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/channels/chan_alsa.c (original)
+++ team/oej/videocaps/channels/chan_alsa.c Fri May 18 08:06:05 2007
@@ -758,6 +758,7 @@
 			res = 2;
 			break;
 		case AST_CONTROL_RINGING:
+		case AST_CONTROL_PROGRESS:
 			break;
 		case -1:
 			res = -1;

Modified: team/oej/videocaps/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_local.c?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/channels/chan_local.c (original)
+++ team/oej/videocaps/channels/chan_local.c Fri May 18 08:06:05 2007
@@ -594,10 +594,22 @@
 {
 	struct ast_channel *tmp = NULL, *tmp2 = NULL;
 	int randnum = ast_random() & 0xffff, fmt = 0;
+	const char *t;
+	int ama;
 
 	/* Allocate two new Asterisk channels */
-	if (!(tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, 0, "Local/%s@%s-%04x,1", p->exten, p->context, randnum)) 
-			|| !(tmp2 = ast_channel_alloc(1, AST_STATE_RING, 0, 0, "", p->exten, p->context, 0, "Local/%s@%s-%04x,2", p->exten, p->context, randnum))) {
+	/* safe accountcode */
+	if (p->owner && p->owner->accountcode)
+		t = p->owner->accountcode;
+	else
+		t = "";
+
+	if (p->owner)
+		ama = p->owner->amaflags;
+	else
+		ama = 0;
+	if (!(tmp = ast_channel_alloc(1, state, 0, 0, t, p->exten, p->context, ama, "Local/%s@%s-%04x,1", p->exten, p->context, randnum)) 
+			|| !(tmp2 = ast_channel_alloc(1, AST_STATE_RING, 0, 0, t, p->exten, p->context, ama, "Local/%s@%s-%04x,2", p->exten, p->context, randnum))) {
 		if (tmp)
 			ast_channel_free(tmp);
 		if (tmp2)

Modified: team/oej/videocaps/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_misdn.c?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/channels/chan_misdn.c (original)
+++ team/oej/videocaps/channels/chan_misdn.c Fri May 18 08:06:05 2007
@@ -117,6 +117,7 @@
 	MISDN_NOTHING=0,	/*!< at beginning */
 	MISDN_WAITING4DIGS, /*!<  when waiting for infos */
 	MISDN_EXTCANTMATCH, /*!<  when asterisk couldnt match our ext */
+	MISDN_INCOMING_SETUP, /*!<  for incoming setups*/
 	MISDN_DIALING, /*!<  when pbx_start */
 	MISDN_PROGRESS, /*!<  we got a progress */
 	MISDN_PROCEEDING, /*!<  we got a progress */
@@ -156,7 +157,8 @@
 	int need_busy;
 	
 	int originator;
-
+	int noautorespond_on_setup;
+	
 	int norxtone;
 	int notxtone; 
 
@@ -335,6 +337,7 @@
 static int stop_bc_tones(struct chan_list *cl);
 static void release_chan(struct misdn_bchannel *bc);
 
+static int misdn_check_l2l1(struct ast_channel *chan, void *data);
 static int misdn_set_opt_exec(struct ast_channel *chan, void *data);
 static int misdn_facility_exec(struct ast_channel *chan, void *data);
 
@@ -986,6 +989,7 @@
 	{MISDN_NOTHING,"NOTHING"}, /* at beginning */
 	{MISDN_WAITING4DIGS,"WAITING4DIGS"}, /*  when waiting for infos */
 	{MISDN_EXTCANTMATCH,"EXTCANTMATCH"}, /*  when asterisk couldnt match our ext */
+	{MISDN_INCOMING_SETUP,"INCOMING SETUP"}, /*  when pbx_start */
 	{MISDN_DIALING,"DIALING"}, /*  when pbx_start */
 	{MISDN_PROGRESS,"PROGRESS"}, /*  when pbx_start */
 	{MISDN_PROCEEDING,"PROCEEDING"}, /*  when pbx_start */
@@ -1121,8 +1125,8 @@
 			print_bc_info(fd, help, bc);
 		} else {
 			if (help->state == MISDN_HOLDED) {
-				chan_misdn_log(2, 0, "ITS A HOLDED BC:\n");
-				chan_misdn_log(2,0," --> l3_id: %x\n"
+				ast_cli(fd, "ITS A HOLDED BC:\n");
+				ast_cli(fd, " --> l3_id: %x\n"
 						" --> dad:%s oad:%s\n"
 						" --> hold_port: %d\n"
 						" --> hold_channel: %d\n"
@@ -1747,6 +1751,8 @@
 	misdn_cfg_get( port, MISDN_CFG_NEED_MORE_INFOS, &bc->need_more_infos, sizeof(int));
 	misdn_cfg_get( port, MISDN_CFG_NTTIMEOUT, &ch->nttimeout, sizeof(int));
 	
+	misdn_cfg_get( port, MISDN_CFG_NOAUTORESPOND_ON_SETUP, &ch->noautorespond_on_setup, sizeof(int));
+	
 	misdn_cfg_get( port, MISDN_CFG_FAR_ALERTING, &ch->far_alerting, sizeof(int));
 
 	misdn_cfg_get( port, MISDN_CFG_ALLOWED_BEARERS, &ch->allowed_bearers, BUFFERSIZE);
@@ -1994,8 +2000,7 @@
 	}
 	
 	port=newbc->port;
-	strncpy(newbc->dad,ext,sizeof( newbc->dad));
-	strncpy(ast->exten,ext,sizeof(ast->exten));
+
 
 	int exceed;
 	if ((exceed=add_out_calls(port))) {
@@ -2012,10 +2017,18 @@
 	chan_misdn_log(3, port, " --> * adding2newbc ext %s\n",ast->exten);
 	if (ast->exten) {
 		int l = sizeof(newbc->dad);
-		strncpy(newbc->dad,ast->exten, l);
+		strncpy(ast->exten,ext,sizeof(ast->exten));
+
+		strncpy(newbc->dad,ext,l);
+
 		newbc->dad[l-1] = 0;
 	}
-	newbc->rad[0]=0;
+
+	if (ast->cid.cid_rdnis)  
+		strcpy(newbc->rad, ast->cid.cid_rdnis);
+	else 
+		newbc->rad[0]=0;
+
 	chan_misdn_log(3, port, " --> * adding2newbc callerid %s\n",ast->cid.cid_num);
 	if (ast_strlen_zero(newbc->oad) && ast->cid.cid_num ) {
 
@@ -2025,7 +2038,7 @@
 			newbc->oad[l-1] = 0;
 		}
 	}
-	
+
 	{
 		struct chan_list *ch=MISDN_ASTERISK_TECH_PVT(ast);
 		if (!ch) { ast_verbose("No chan_list in misdn_call\n"); return -1;}
@@ -2054,11 +2067,11 @@
 		misdn_cfg_get( 0, MISDN_GEN_BRIDGING, &bridging, sizeof(int));
 		if (bridging && ch->other_ch) {
 #ifdef MISDN_1_2
-			chan_misdn_log(0, port, "Disabling EC (aka Pipeline) on both Sides\n");
+			chan_misdn_log(1, 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");
+			chan_misdn_log(1, port, "Disabling EC on both Sides\n");
 			ch->bc->ec_enable=0;
 			ch->other_ch->bc->ec_enable=0;
 #endif
@@ -2330,12 +2343,8 @@
 		chan_misdn_log(1, p->bc->port, " --> * IND :\tcongestion pid:%d\n",p->bc?p->bc->pid:-1);
 
 		p->bc->out_cause=42;
-		if (p->state != MISDN_CONNECTED) {
-			start_bc_tones(p);
-			misdn_lib_send_event( p->bc, EVENT_RELEASE);
-		} else {
-			misdn_lib_send_event( p->bc, EVENT_DISCONNECT);
-		}
+		start_bc_tones(p);
+		misdn_lib_send_event( p->bc, EVENT_DISCONNECT);
 
 		if (p->bc->nt) {
 			hanguptone_indicate(p);
@@ -2438,6 +2447,7 @@
 		chan_misdn_log(2, bc->port, " --> state:%s\n", misdn_get_ch_state(p));
 		
 		switch (p->state) {
+		case MISDN_INCOMING_SETUP:
 		case MISDN_CALLING:
 			p->state=MISDN_CLEANING;
 			misdn_lib_send_event( bc, EVENT_RELEASE_COMPLETE);
@@ -2614,7 +2624,8 @@
 		chan_misdn_log(1,0,"misdn_read called without ast->pvt\n");
 		return NULL;
 	}
-	if (!tmp->bc) {
+
+	if (!tmp->bc && !(tmp->state==MISDN_HOLDED)) {
 		chan_misdn_log(1,0,"misdn_read called without bc\n");
 		return NULL;
 	}
@@ -2705,7 +2716,18 @@
 
 	if ( !frame->samples ) {
 		chan_misdn_log(4, ch->bc->port, "misdn_write: zero write\n");
-		return 0;
+		
+		if (!strcmp(frame->src,"ast_prod")) {
+			chan_misdn_log(1, ch->bc->port, "misdn_write: state (%s) prodded.\n", misdn_get_ch_state(ch));
+
+			if (ch->ts) {
+				chan_misdn_log(4,ch->bc->port,"Starting Playtones\n");
+				misdn_lib_tone_generator_start(ch->bc);
+			}
+			return 0;
+		}
+
+		return -1;
 	}
 
 	if ( ! ch->bc->addr ) {
@@ -2889,9 +2911,8 @@
 	if (ts) {
 		cl->notxtone=0;
 		cl->norxtone=0;
+		/* This prods us in misdn_write */
 		ast_playtones_start(ast,0, ts->data, 0);
-		chan_misdn_log(4,cl->bc->port,"Starting Playtones\n");
-		misdn_lib_tone_generator_start(cl->bc);
 	}
 
 	return 0;
@@ -2971,6 +2992,7 @@
 	char *tokb=NULL, *p=NULL;
 	int channel=0, port=0;
 	struct misdn_bchannel *newbc = NULL;
+	int dec=0;
 	
 	struct chan_list *cl=init_chan_list(ORG_AST);
 	
@@ -2999,23 +3021,27 @@
 		else {
 			port = atoi(port_str);
 		}
-		
-		
 	} else {
 		ast_log(LOG_WARNING, " --> ! IND : CALL dad:%s WITHOUT PORT/Group, check extension.conf\n",ext);
 		return NULL;
 	}
 
+	if (misdn_cfg_is_group_method(group, METHOD_STANDARD_DEC)) {
+		chan_misdn_log(4, port, " --> STARTING STANDARDDEC...\n");
+		dec=1;
+	}
+
 	if (!ast_strlen_zero(group)) {
 	
 		char cfg_group[BUFFERSIZE+1];
 		struct robin_list *rr = NULL;
 
 		if (misdn_cfg_is_group_method(group, METHOD_ROUND_ROBIN)) {
-			chan_misdn_log(4, port, " --> STARTING ROUND ROBIN...");
+			chan_misdn_log(4, port, " --> STARTING ROUND ROBIN...\n");
 			rr = get_robin_position(group);
 		}
 		
+			
 		if (rr) {
 			int robin_channel = rr->channel;
 			int port_start;
@@ -3057,7 +3083,7 @@
 						
 						
 						if ( port_up>0 )	{
-							newbc = misdn_lib_get_free_bc(port, robin_channel,0);
+							newbc = misdn_lib_get_free_bc(port, robin_channel,0, 0);
 							if (newbc) {
 								chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
 								if (port_up)
@@ -3071,11 +3097,7 @@
 				}
 			} while (!newbc && robin_channel != rr->channel);
 			
-			if (!newbc)
-				chan_misdn_log(-1, port, " Failed! No free channel in group %d!", group);
-		}
-		
-		else {		
+		} else {		
 			for (port=misdn_cfg_get_next_port(0); port > 0;
 				 port=misdn_cfg_get_next_port(port)) {
 				
@@ -3091,7 +3113,7 @@
 					chan_misdn_log(4, port, "portup:%d\n", port_up);
 					
 					if ( port_up>0 ) {
-						newbc = misdn_lib_get_free_bc(port, 0, 0);
+						newbc = misdn_lib_get_free_bc(port, 0, 0, dec);
 						if (newbc)
 							break;
 					}
@@ -3099,16 +3121,26 @@
 			}
 		}
 		
-	} else {
+		/* Group dial failed ?*/
+		if (!newbc) {
+			ast_log(LOG_WARNING, 
+					"Could not Dial out on group '%s'.\n"
+					"\tEither the L2 and L1 on all of these ports where DOWN (see 'show application misdn_check_l2l1')\n"
+					"\tOr there was no free channel on none of the ports\n\n"
+					, group);
+			return NULL;
+		}
+	} else { /* 'Normal' Port dial * Port dial */
 		if (channel)
 			chan_misdn_log(1, port," --> preselected_channel: %d\n",channel);
-		newbc = misdn_lib_get_free_bc(port, channel, 0);
-	}
-	
-	if (!newbc) {
-		chan_misdn_log(-1, 0, "Could not create channel on port:%d with extensions:%s\n",port,ext);
-		return NULL;
-	}
+		newbc = misdn_lib_get_free_bc(port, channel, 0, dec);
+
+		if (!newbc) {
+			ast_log(LOG_WARNING, "Could not create channel on port:%d with extensions:%s\n",port,ext);
+			return NULL;
+		}
+	}
+	
 
 	/* create ast_channel and link all the objects together */
 	cl->bc=newbc;
@@ -3532,23 +3564,22 @@
   
 	ch->state=MISDN_DIALING;
 
-	if (bc->nt) {
-		int ret; 
-		ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
-	} else {
-		int ret;
-		if ( misdn_lib_is_ptp(bc->port)) {
+	if (!ch->noautorespond_on_setup) {
+		if (bc->nt) {
+			int ret; 
 			ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
 		} else {
-			ret = misdn_lib_send_event(bc, EVENT_PROCEEDING );
-		}
-	}
-
-	if ( !bc->nt && (ch->originator==ORG_MISDN) && !ch->incoming_early_audio ) 
-		chan_misdn_log(1,bc->port, " --> incoming_early_audio off\n");
-	 else  
-		dialtone_indicate(ch);
-  
+			int ret;
+			if ( misdn_lib_is_ptp(bc->port)) {
+				ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
+			} else {
+				ret = misdn_lib_send_event(bc, EVENT_PROCEEDING );
+			}
+		}
+	} else {
+		ch->state = MISDN_INCOMING_SETUP;
+	}
+
 	chan_misdn_log(1, bc->port, "* Starting Ast ctx:%s dad:%s oad:%s with 's' extension\n", ast->context, ast->exten, ast->cid.cid_num);
   
 	strncpy(ast->exten,"s", 2);
@@ -3660,6 +3691,21 @@
 	if (tmp && (atoi(tmp) == 1)) {
 		bc->sending_complete=1;
 	}
+	
+	tmp=pbx_builtin_getvar_helper(chan,"MISDN_USERUSER");
+	if (tmp) {
+		ast_log(LOG_NOTICE, "MISDN_USERUSER: %s\n", tmp);
+		strcpy(bc->uu, tmp);
+		bc->uulen=strlen(bc->uu);
+	}
+
+	tmp=pbx_builtin_getvar_helper(chan,"MISDN_KEYPAD");
+	if (tmp) {
+		strncpy(bc->keypad,tmp,sizeof(bc->keypad));
+		bc->keypad[sizeof(bc->keypad)-1]=0;
+	}
+	
+	
 }
 
 void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
@@ -3678,6 +3724,13 @@
 		sprintf(tmp,"%d",bc->urate);
 		pbx_builtin_setvar_helper(chan,"MISDN_URATE",tmp);
 	}
+
+	if (bc->uulen) {
+		pbx_builtin_setvar_helper(chan,"MISDN_USERUSER",bc->uu);
+	}
+
+	if (bc->keypad[0]) 
+		pbx_builtin_setvar_helper(chan,"MISDN_KEYPAD",bc->keypad);
 }
 
 int add_in_calls(int port)
@@ -3850,7 +3903,9 @@
 		if ( stop_tone ) {
 			stop_indicate(ch);
 		}
-		
+	
+		if (!ch->ast) break;
+
 		if (ch->state == MISDN_WAITING4DIGS ) {
 			/*  Ok, incomplete Setup, waiting till extension exists */
 
@@ -4088,8 +4143,12 @@
 		
 		/* Check for Pickup Request first */
 		if (!strcmp(chan->exten, ast_pickup_ext())) {
-			int ret;/** Sending SETUP_ACK**/
-			ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
+			if (!ch->noautorespond_on_setup) {
+				int ret;/** Sending SETUP_ACK**/
+				ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
+			} else {
+				ch->state = MISDN_INCOMING_SETUP;
+			}
 			if (ast_pickup_call(chan)) {
 				hangup_chan(ch);
 			} else {
@@ -4147,14 +4206,20 @@
 		}
 		
 		if (!ch->overlap_dial && ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
-			ch->state=MISDN_DIALING;
 			
-			if (bc->nt || (bc->need_more_infos && misdn_lib_is_ptp(bc->port)) ) {
-				int ret; 
-				ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
+			if (!ch->noautorespond_on_setup) {
+				ch->state=MISDN_DIALING;
+
+				if (!bc->sending_complete &&
+						(bc->nt || (bc->need_more_infos && misdn_lib_is_ptp(bc->port)))) {
+					int ret; 
+					ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
+				} else {
+					int ret;
+					ret= misdn_lib_send_event(bc, EVENT_PROCEEDING );
+				}
 			} else {
-				int ret;
-				ret= misdn_lib_send_event(bc, EVENT_PROCEEDING );
+				ch->state = MISDN_INCOMING_SETUP;
 			}
 	
 			if (pbx_start_chan(ch)<0) {
@@ -4184,7 +4249,6 @@
 				}
 
 			} else {
-
 				int ret= misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
 				if (ret == -ENOCHAN) {
 					ast_log(LOG_WARNING,"Channel was catched, before we could Acknowledge\n");
@@ -4195,6 +4259,8 @@
 				/** ADD IGNOREPAT **/
 				
 				int stop_tone, dad_len;
+				ch->state=MISDN_WAITING4DIGS;
+
 				misdn_cfg_get( 0, MISDN_GEN_STOP_TONE, &stop_tone, sizeof(int));
 
 				dad_len = ast_strlen_zero(bc->dad);
@@ -4202,9 +4268,9 @@
 				if ( !dad_len && stop_tone )
 					stop_indicate(ch);
 				else
-					dialtone_indicate(ch);
+					if (bc->nt) 
+						dialtone_indicate(ch);
 				
-				ch->state=MISDN_WAITING4DIGS;
 				
 				if (ch->overlap_dial && !dad_len) {
 					ast_mutex_lock(&ch->overlap_tv_lock);
@@ -4367,7 +4433,8 @@
 
 			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;
@@ -4381,6 +4448,8 @@
 			cb_log(1,bc->port," --> found holded ch\n");
 			misdn_transfer_bc(ch, holded_ch) ;
 		}
+
+		bc->need_disconnect=0;
 		
 		stop_bc_tones(ch);
 		hangup_chan(ch);
@@ -4397,8 +4466,9 @@
 	
 	case EVENT_RELEASE:
 		{
-			bc->out_cause=16;
-			
+			bc->need_disconnect=0;
+			bc->need_release=0;
+
 			hangup_chan(ch);
 			release_chan(bc);
 		
@@ -4408,11 +4478,17 @@
 		break;
 	case EVENT_RELEASE_COMPLETE:
 	{
+		bc->need_disconnect=0;
+		bc->need_release=0;
+		bc->need_release_complete=0;
+
 		stop_bc_tones(ch);
 		hangup_chan(ch);
-		release_chan(bc);
+
 		if(ch)	
 			ch->state=MISDN_CLEANING;
+
+		release_chan(bc);
 	}
 	break;
 	case EVENT_BCHAN_ERROR:
@@ -4581,7 +4657,11 @@
 	/***************************/
 	case EVENT_RETRIEVE:
 	{
-		ch=find_holded_l3(cl_te, bc->l3_id,1);
+		if (!ch) {
+			chan_misdn_log(4, bc->port, " --> no CH, searching in holded");
+			ch=find_holded_l3(cl_te, bc->l3_id,1);
+		}
+
 		if (!ch) {
 			ast_log(LOG_WARNING, "Found no Holded channel, cannot Retrieve\n");
 			misdn_lib_send_event(bc, EVENT_RETRIEVE_REJECT);
@@ -4731,6 +4811,7 @@
 	/* ast_unregister_application("misdn_crypt"); */
 	ast_unregister_application("misdn_set_opt");
 	ast_unregister_application("misdn_facility");
+	ast_unregister_application("misdn_check_l2l1");
   
 	ast_channel_unregister(&misdn_tech);
 
@@ -4857,6 +4938,24 @@
 		);
 
 
+	ast_register_application("misdn_check_l2l1", misdn_check_l2l1, "misdn_check_l2l1",
+				 "misdn_check_l2l1(<port>||g:<groupname>,timeout)"
+				 "Checks if the L2 and L1 are up on either the given <port> or\n"
+				 "on the ports in the group with <groupname>\n"
+				 "If the L1/L2 are down, check_l2l1 gets up the L1/L2 and waits\n"
+				 "for <timeout> seconds that this happens. Otherwise, nothing happens\n"
+				 "\n"
+				 "This application, ensures the L1/L2 state of the Ports in a group\n"
+				 "it is intended to make the pmp_l1_check option redundant and to\n"
+				 "fix a buggy switch config from your provider\n"
+				 "\n"
+				 "a sample dialplan would look like:\n\n"
+				 "exten => _X.,1,misdn_check_l2l1(g:out|2)\n"
+				 "exten => _X.,n,dial(mISDN/g:out/${EXTEN})\n"
+				 "\n"
+		);
+
+
 	misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
 
 	/* start the l1 watchers */
@@ -4932,6 +5031,86 @@
 	
 }
 
+static int misdn_check_l2l1(struct ast_channel *chan, void *data)
+{
+	if (strcasecmp(chan->tech->type,"mISDN")) {
+		ast_log(LOG_WARNING, "misdn_check_l2l1 makes only sense with chan_misdn channels!\n");
+		return -1;
+	}
+
+	AST_DECLARE_APP_ARGS(args,
+			AST_APP_ARG(grouppar);
+			AST_APP_ARG(timeout);
+	);
+
+	if (ast_strlen_zero((char *)data)) {
+		ast_log(LOG_WARNING, "misdn_check_l2l1 Requires arguments\n");
+		return -1;
+	}
+
+	AST_STANDARD_APP_ARGS(args, data);
+
+	if (args.argc != 2) {
+		ast_log(LOG_WARNING, "Wrong argument count\n");
+		return 0;
+	}
+
+	/*ast_log(LOG_NOTICE, "Arguments: group/port '%s' timeout '%s'\n", args.grouppar, args.timeout);*/
+	char group[BUFFERSIZE+1];
+	char *port_str;
+
+	int port=0;
+	int timeout=atoi(args.timeout);
+	int dowait=0;
+
+	port_str=args.grouppar;
+
+	int port_up;
+	if (port_str[0]=='g' && port_str[1]==':' ) {
+		/* We make a group call lets checkout which ports are in my group */
+		port_str += 2;
+		strncpy(group, port_str, BUFFERSIZE);
+		group[BUFFERSIZE-1] = 0;
+		chan_misdn_log(2, 0, "Checking Ports in group: %s\n",group);
+
+		for (	port = misdn_cfg_get_next_port(port); 
+			port > 0;
+			port = misdn_cfg_get_next_port(port)) {
+			
+			chan_misdn_log(2,0,"trying port %d\n",port);
+
+			char cfg_group[BUFFERSIZE+1];
+			misdn_cfg_get(port, MISDN_CFG_GROUPNAME, cfg_group, BUFFERSIZE);
+
+			if (!strcasecmp(cfg_group, group)) {
+				port_up = misdn_lib_port_up(port, 1);
+
+				if (!port_up) {
+					chan_misdn_log(2, 0, " --> port '%d'\n", port);
+					misdn_lib_get_port_up(port);
+					dowait=1;
+				}
+			}
+		}
+
+	} else {
+		port = atoi(port_str);
+		chan_misdn_log(2, 0, "Checking Port: %d\n",port);
+		port_up = misdn_lib_port_up(port, 1);
+		if (!port_up) {
+			misdn_lib_get_port_up(port);
+			dowait=1;
+		}
+
+	}
+
+	if (dowait) {
+		chan_misdn_log(2, 0, "Waiting for '%d' seconds\n",timeout);
+		sleep(timeout);
+	}
+
+	return 0;
+}
 
 static int misdn_set_opt_exec(struct ast_channel *chan, void *data)
 {

Modified: team/oej/videocaps/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_sip.c?view=diff&rev=65054&r1=65053&r2=65054
==============================================================================
--- team/oej/videocaps/channels/chan_sip.c (original)
+++ team/oej/videocaps/channels/chan_sip.c Fri May 18 08:06:05 2007
@@ -155,6 +155,9 @@
 #define TRUE     1
 #endif
 
+#define XMIT_ERROR		-2
+
+#define VIDEO_CODEC_MASK        0x1fc0000 /*!< Video codecs from H.261 thru AST_FORMAT_MAX_VIDEO */
 #ifndef IPTOS_MINCOST
 #define IPTOS_MINCOST           0x02
 #endif
@@ -343,6 +346,8 @@
 	AUTH_NOT_FOUND = -3,	/* returned by register_verify */
 	AUTH_FAKE_AUTH = -4,
 	AUTH_UNKNOWN_DOMAIN = -5,
+	AUTH_PEER_NOT_DYNAMIC = -6,
+	AUTH_ACL_FAILED = -7,
 };
 
 /*! \brief States for outbound registrations (with register= lines in sip.conf */
@@ -523,6 +528,7 @@
 #define DEFAULT_PEDANTIC	FALSE
 #define DEFAULT_AUTOCREATEPEER	FALSE
 #define DEFAULT_QUALIFY		FALSE
+#define DEFAULT_REGEXTENONQUALIFY FALSE
 #define DEFAULT_T1MIN		100		/*!< 100 MS for minimal roundtrip time */
 #define DEFAULT_MAX_FRAMERATE (30)
 #define VIDEO_UPDATE_XML 1
@@ -591,6 +597,7 @@
 static int allow_external_domains;	/*!< Accept calls to external SIP domains? */
 static int global_callevents;		/*!< Whether we send manager events or not */
 static int global_t1min;		/*!< T1 roundtrip time minimum */
+static int global_regextenonqualify;  /*!< Whether to add/remove regexten when qualifying peers */
 static int global_autoframing;          /*!< Turn autoframing on or off. */
 static enum transfermodes global_allowtransfer;	/*!< SIP Refer restriction scheme */
 static struct sip_proxy global_outboundproxy;	/*!< Outbound proxy */
@@ -1364,6 +1371,7 @@
 				int debug);
 static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p);
 static void do_setnat(struct sip_pvt *p, int natflags);
+static void stop_media_flows(struct sip_pvt *p);
 
 /*--- Authentication stuff */
 static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header, int sipmethod, char *digest, int digest_len);
@@ -1794,8 +1802,7 @@
 		return NULL;
 	proxy->force = force;
 	ast_copy_string(proxy->name, name, sizeof(proxy->name));
-	if (!ast_strlen_zero(port))
-		proxy->ip.sin_port = htons(atoi(port));
+	proxy->ip.sin_port = htons((!ast_strlen_zero(port) ? atoi(port) : STANDARD_SIP_PORT));
 	proxy_update(proxy);
 	return proxy;
 }
@@ -1943,7 +1950,7 @@
 			case EHOSTUNREACH: 	/* Host can't be reached */
 			case ENETDOWN: 		/* Inteface down */
 			case ENETUNREACH:	/* Network failure */
-				res = -2;	/* Don't bother with trying to transmit again */
+				res = XMIT_ERROR;	/* Don't bother with trying to transmit again */
 		}
 	}
 	if (res != len)
@@ -2082,11 +2089,10 @@
 		append_history(pkt->owner, "ReTx", "%d %s", reschedule, pkt->data);
 		xmitres = __sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
 		sip_pvt_unlock(pkt->owner);
-		if (xmitres == -2) {
+		if (xmitres == XMIT_ERROR)
 			ast_log(LOG_WARNING, "Network error on retransmit in dialog %s\n", pkt->owner->callid);
-		} else {
+		else 
 			return  reschedule;
-		}
 	} 
 	/* Too many retries */
 	if (pkt->owner && pkt->method != SIP_OPTIONS && xmitres == 0) {
@@ -2096,7 +2102,7 @@
 			ast_log(LOG_WARNING, "Cancelling retransmit of OPTIONs (call id %s) \n", pkt->owner->callid);
 
 	} 
-	if (xmitres == -2) {
+	if (xmitres == XMIT_ERROR) {
 		ast_log(LOG_WARNING, "Transmit error :: Cancelling transmission on Call ID %s\n", pkt->owner->callid);
 		append_history(pkt->owner, "XmitErr", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
 	} else 
@@ -2177,7 +2183,7 @@
 
 	xmitres = __sip_xmit(pkt->owner, pkt->data, pkt->packetlen);	/* Send packet */
 
-	if (xmitres == -2) {	/* Serious network trouble, no need to try again */
+	if (xmitres == XMIT_ERROR) {	/* Serious network trouble, no need to try again */
 		append_history(pkt->owner, "XmitErr", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
 		ast_sched_del(sched, pkt->retransid);	/* No more retransmission */
 		pkt->retransid = -1;
@@ -2506,7 +2512,7 @@
 		*port = "";
 	if (scheme) {
 		int l = strlen(scheme);
-		if (!strncmp(uri, scheme, l))
+		if (!strncasecmp(uri, scheme, l))
 			uri += l;
 		else {
 			ast_log(LOG_NOTICE, "Missing scheme '%s' in '%s'\n", scheme, uri);
@@ -3229,13 +3235,12 @@
 		if (option_debug > 1)
 			ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
 		xmitres = transmit_invite(p, SIP_INVITE, 1, 2);
-		if (xmitres != -2) {
-			p->invitestate = INV_CALLING;
-		
-			/* Initialize auto-congest time */
-			p->initid = ast_sched_add(sched, SIP_TRANS_TIMEOUT, auto_congest, p);
-		} else 
-			res = -1;
+		if (xmitres == XMIT_ERROR)
+			return -1;
+		p->invitestate = INV_CALLING;
+	
+		/* Initialize auto-congest time */
+		p->initid = ast_sched_add(sched, SIP_TRANS_TIMEOUT, auto_congest, p);
 	}
 
 	return res;
@@ -3719,6 +3724,8 @@
 		if (option_debug > 3)
 			ast_log(LOG_DEBUG, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
 	}
+
+	stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
 
 	/* Disconnect */
 	if (p->vad)
@@ -6393,9 +6400,9 @@
 		++h;
 	else {
 		h = uri;
-		if (strncmp(h, "sip:", 4) == 0)
+		if (strncasecmp(h, "sip:", 4) == 0)
 			h += 4;
-		else if (strncmp(h, "sips:", 5) == 0)
+		else if (strncasecmp(h, "sips:", 5) == 0)
 			h += 5;
 	}
 	hn = strcspn(h, ":;>") + 1;
@@ -7541,7 +7548,7 @@
 }
 
 /*! \brief Used for 200 OK and 183 early media 
-	\return Will return -2 for network errors.
+	\return Will return XMIT_ERROR for network errors.
 */
 static int transmit_response_with_sdp(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable)
 {
@@ -8066,7 +8073,7 @@
 
 	ast_copy_string(from, get_header(&p->initreq, "From"), sizeof(from));
 	c = get_in_brackets(from);
-	if (strncmp(c, "sip:", 4)) {
+	if (strncasecmp(c, "sip:", 4)) {
 		ast_log(LOG_WARNING, "Huh?  Not a SIP header (%s)?\n", c);
 		return -1;
 	}
@@ -8075,7 +8082,7 @@
 
 	ast_copy_string(to, get_header(&p->initreq, "To"), sizeof(to));
 	c = get_in_brackets(to);
-	if (strncmp(c, "sip:", 4)) {
+	if (strncasecmp(c, "sip:", 4)) {
 		ast_log(LOG_WARNING, "Huh?  Not a SIP header (%s)?\n", c);
 		return -1;
 	}
@@ -8585,7 +8592,7 @@
 	ast_copy_string(from, of, sizeof(from));
 	of = get_in_brackets(from);
 	ast_string_field_set(p, from, of);
-	if (strncmp(of, "sip:", 4))
+	if (strncasecmp(of, "sip:", 4))
 		ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n");
 	else
 		of += 4;
@@ -8647,7 +8654,7 @@
 }
 
 /*! \brief Transmit generic SIP request 
-	returns -2 if transmit failed with a critical error (don't retry)
+	returns XMIT_ERROR if transmit failed with a critical error (don't retry)
 */
 static int transmit_request(struct sip_pvt *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch)
 {
@@ -8944,7 +8951,7 @@
 
 		destroy_association(peer);
 		
-		register_peer_exten(peer, 0);	/* Add extension from regexten= setting in sip.conf */
+		register_peer_exten(peer, FALSE);	/* Remove extension from regexten= setting in sip.conf */
 		peer->fullcontact[0] = '\0';
 		peer->useragent[0] = '\0';
 		peer->sipoptions = 0;
@@ -9012,7 +9019,7 @@
 		sip_poke_peer(peer);
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s port %d expires %d\n", peer->name, ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry);
-		register_peer_exten(peer, 1);
+		register_peer_exten(peer, TRUE);
 	}
 	
 	/* Save User agent */
@@ -9430,7 +9437,7 @@
 	c = get_in_brackets(tmp);
 	c = remove_uri_parameters(c);
 
-	if (!strncmp(c, "sip:", 4)) {
+	if (!strncasecmp(c, "sip:", 4)) {
 		name = c + 4;
 	} else {
 		name = c;
@@ -9465,6 +9472,7 @@
 		if (peer)
 			unref_peer(peer);
 		peer = NULL;
+		res = AUTH_ACL_FAILED;
 	}
 	if (peer) {
 		/* Set Frame packetization */
@@ -9474,6 +9482,7 @@
 		}
 		if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)) {
 			ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name);
+			res = AUTH_PEER_NOT_DYNAMIC;
 		} else {
 			ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_NAT);
 			transmit_response(p, "100 Trying", req);
@@ -9551,34 +9560,20 @@
 			transmit_response(p, "403 Authentication user name does not match account name", &p->initreq);
 			break;
 		case AUTH_NOT_FOUND:
+		case AUTH_PEER_NOT_DYNAMIC:
+		case AUTH_ACL_FAILED:
 			if (global_alwaysauthreject) {
 				transmit_fake_auth_response(p, &p->initreq, 1);
 			} else {
 				/* URI not found */
-				transmit_response(p, "404 Not found", &p->initreq);
+				if (res == AUTH_UNKNOWN_DOMAIN || res == AUTH_PEER_NOT_DYNAMIC)
+					transmit_response(p, "403 Forbidden", &p->initreq);
+				else
+					transmit_response(p, "404 Not found", &p->initreq);
 			}
 			break;
 		default:
 			break;
-		}
-		if (option_debug > 1) {
-			const char *reason = "";
-
-			switch (res) {
-			case AUTH_SECRET_FAILED:
-				reason = "Bad password";
-				break;
-			case AUTH_USERNAME_MISMATCH:
-				reason = "Bad digest user";
-				break;
-			case AUTH_NOT_FOUND:
-				reason = "Peer not found";
-				break;
-			default:
-				break;
-			}
-			ast_log(LOG_DEBUG, "SIP REGISTER attempt failed for %s : %s\n",
-				peer->name, reason);
 		}
 	}
 	if (peer)
@@ -9631,7 +9626,7 @@
 		return 0;
 
 	exten = get_in_brackets(tmp);
-	if (strncmp(exten, "sip:", 4)) {
+	if (strncasecmp(exten, "sip:", 4)) {

[... 2611 lines stripped ...]


More information about the asterisk-commits mailing list