[asterisk-commits] branch oej/codecnegotiation r20843 - in /team/oej/codecnegotiation: ./ channe...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Apr 17 00:03:50 MST 2006


Author: oej
Date: Mon Apr 17 02:03:42 2006
New Revision: 20843

URL: http://svn.digium.com/view/asterisk?rev=20843&view=rev
Log:
Reset, resolve, go!
- Japanese food is good for you :-)

Modified:
    team/oej/codecnegotiation/   (props changed)
    team/oej/codecnegotiation/channels/chan_sip.c
    team/oej/codecnegotiation/channels/chan_skinny.c
    team/oej/codecnegotiation/res/res_features.c

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

Propchange: team/oej/codecnegotiation/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr 17 02:03:42 2006
@@ -1,1 +1,1 @@
-/trunk:1-20721
+/trunk:1-20842

Modified: team/oej/codecnegotiation/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/channels/chan_sip.c?rev=20843&r1=20842&r2=20843&view=diff
==============================================================================
--- team/oej/codecnegotiation/channels/chan_sip.c (original)
+++ team/oej/codecnegotiation/channels/chan_sip.c Mon Apr 17 02:03:42 2006
@@ -1129,6 +1129,22 @@
 	return "";
 }
 
+/*! \brief Initialize the initital request packet in the pvt structure.
+ 	This packet is used for creating replies and future requests in
+	a dialog */
+void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
+{
+	if (p->initreq.headers) {
+		ast_log(LOG_WARNING, "Initializing already initialized SIP dialog??? %s\n", p->callid);
+		return;
+	}
+	/* Use this as the basis */
+	copy_request(&p->initreq, req);
+	parse_request(&p->initreq);
+	if (ast_test_flag(req, SIP_PKT_DEBUG))
+		ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
+}
+
 
 /*! \brief returns true if 'name' (with optional trailing whitespace)
  * matches the sip method 'id'.
@@ -3384,6 +3400,12 @@
 	char totag[128];
 	char fromtag[128];
 	const char *callid = get_header(req, "Call-ID");
+	const char *from = get_header(req, "From");
+	const char *to = get_header(req, "To");
+	const char *cseq = get_header(req, "Cseq");
+
+	if (!callid || !to || !from || !cseq)		/* Call-ID, to, from and Cseq are required by RFC 3261. (Max-forwards and via too - ignored now) */
+		return NULL;	/* Invalid packet */
 
 	if (pedanticsipchecking) {
 		/* In principle Call-ID's uniquely identify a call, but with a forking SIP proxy
@@ -3566,7 +3588,9 @@
 	return t; 
 }
 
-/*! \brief Parse a SIP message */
+/*! \brief Parse a SIP message 
+	\note this function is used both on incoming and outgoing packets
+*/
 static void parse_request(struct sip_request *req)
 {
 	/* Divide fields by NULL's */
@@ -4862,10 +4886,7 @@
 		append_history(p, "ReInv", "Re-invite sent");
 	add_sdp(&req, p);
 	/* Use this as the basis */
-	copy_request(&p->initreq, &req);
-	parse_request(&p->initreq);
-	if (sip_debug_test_pvt(p))
-		ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
+	initialize_initreq(p, &req);
 	p->lastinvite = p->ocseq;
 	ast_set_flag(&p->flags[0], SIP_OUTGOING);
 	return send_request(p, &req, 1, p->ocseq);
@@ -5199,13 +5220,8 @@
 		add_blank_header(&req);
 	}
 
-	if (!p->initreq.headers) {
-		/* Use this as the basis */
-		copy_request(&p->initreq, &req);
-		parse_request(&p->initreq);
-		if (sip_debug_test_pvt(p))
-			ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
-	}
+	if (!p->initreq.headers)
+		initialize_initreq(p, &req);
 	p->lastinvite = p->ocseq;
 	return send_request(p, &req, init ? 2 : 1, p->ocseq);
 }
@@ -5408,29 +5424,16 @@
 	add_header_contentLength(&req, strlen(tmp));
 	add_line(&req, tmp);
 
-	if (!p->initreq.headers) { /* Use this as the basis */
-		copy_request(&p->initreq, &req);
-		parse_request(&p->initreq);
-		if (sip_debug_test_pvt(p))
-			ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
-		determine_firstline_parts(&p->initreq);
-	}
-
+	if (!p->initreq.headers) 
+		initialize_initreq(p, &req);
 	return send_request(p, &req, 1, p->ocseq);
 }
 
 /*! \brief Transmit SIP request */
 static int transmit_sip_request(struct sip_pvt *p,struct sip_request *req)
 {
-	if (!p->initreq.headers) {
-		/* Use this as the basis */
-		copy_request(&p->initreq, req);
-		parse_request(&p->initreq);
-		if (sip_debug_test_pvt(p))
-			ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
-		determine_firstline_parts(&p->initreq);
-	}
-
+	if (!p->initreq.headers) 
+		initialize_initreq(p, req);
 	return send_request(p, req, 0, p->ocseq);
 }
 
@@ -5452,14 +5455,9 @@
 	add_header_contentLength(&req, strlen(tmp));
 	add_line(&req, tmp);
 
-	if (!p->initreq.headers) {
-		/* Use this as the basis */
-		copy_request(&p->initreq, &req);
-		parse_request(&p->initreq);
-		if (sip_debug_test_pvt(p))
-			ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
-		determine_firstline_parts(&p->initreq);
-	}
+	
+	if (!p->initreq.headers)
+		initialize_initreq(p, &req);
 
 	return send_request(p, &req, 1, p->ocseq);
 }
@@ -5735,12 +5733,10 @@
 	add_header(&req, "Event", "registration");
 	add_header_contentLength(&req, 0);
 	add_blank_header(&req);
-	copy_request(&p->initreq, &req);
-	parse_request(&p->initreq);
-	if (sip_debug_test_pvt(p)) {
+
+	initialize_initreq(p, &req);
+	if (sip_debug_test_pvt(p))
 		ast_verbose("REGISTER %d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
-	}
-	determine_firstline_parts(&p->initreq);
 	r->regstate = auth ? REG_STATE_AUTHSENT : REG_STATE_REGSENT;
 	r->regattempts++;	/* Another attempt */
 	if (option_debug > 3)
@@ -11723,18 +11719,18 @@
 			ast_log(LOG_WARNING, "Recv error: %s\n", strerror(errno));
 		return 1;
 	}
-	if (res == sizeof(req.data)) {
+	if (option_debug && res == sizeof(req.data))
 		ast_log(LOG_DEBUG, "Received packet exceeds buffer. Data is possibly lost\n");
-	}
+
 	req.data[res] = '\0';
 	req.len = res;
-	if(sip_debug_test_addr(&sin))
+	if(sip_debug_test_addr(&sin))	/* Set the debug flag early on packet level */
 		ast_set_flag(&req, SIP_PKT_DEBUG);
 	if (pedanticsipchecking)
 		req.len = lws2sws(req.data, req.len);	/* Fix multiline headers */
-	if (ast_test_flag(&req, SIP_PKT_DEBUG)) {
+	if (ast_test_flag(&req, SIP_PKT_DEBUG))
 		ast_verbose("\n<-- SIP read from %s:%d: \n%s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), req.data);
-	}
+
 	parse_request(&req);
 	req.method = find_sip_method(req.rlPart1);
 	if (ast_test_flag(&req, SIP_PKT_DEBUG)) {
@@ -11758,7 +11754,8 @@
 		/* Go ahead and lock the owner if it has one -- we may need it */
 		/* becaues this is deadlock-prone, we need to try and unlock if failed */
 		if (p->owner && ast_channel_trylock(p->owner)) {
-			ast_log(LOG_DEBUG, "Failed to grab lock, trying again...\n");
+			if (option_debug)
+				ast_log(LOG_DEBUG, "Failed to grab lock, trying again...\n");
 			ast_mutex_unlock(&p->lock);
 			ast_mutex_unlock(&netlock);
 			/* Sleep infintismly short amount of time */
@@ -11766,17 +11763,21 @@
 			goto retrylock;
 		}
 		p->recv = sin;
-		if (recordhistory) /* This is a response, note what it was for */
+		if (recordhistory) /* This is a request or response, note what it was for */
 			append_history(p, "Rx", "%s / %s / %s", req.data, get_header(&req, "CSeq"), req.rlPart2);
 		nounlock = 0;
 		if (handle_request(p, &req, &sin, &recount, &nounlock) == -1) {
 			/* Request failed */
-			ast_log(LOG_DEBUG, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
+			if (option_debug)
+				ast_log(LOG_DEBUG, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
 		}
 		
 		if (p->owner && !nounlock)
 			ast_channel_unlock(p->owner);
 		ast_mutex_unlock(&p->lock);
+	} else {
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Invalid SIP message - rejected , bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
 	}
 	ast_mutex_unlock(&netlock);
 	if (recount)

Modified: team/oej/codecnegotiation/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/channels/chan_skinny.c?rev=20843&r1=20842&r2=20843&view=diff
==============================================================================
--- team/oej/codecnegotiation/channels/chan_skinny.c (original)
+++ team/oej/codecnegotiation/channels/chan_skinny.c Mon Apr 17 02:03:42 2006
@@ -121,10 +121,10 @@
  * Protocol Messages *
  *********************/
 /* message types */
-#define	KEEP_ALIVE_MESSAGE 0x0000
+#define KEEP_ALIVE_MESSAGE 0x0000
 /* no additional struct */
 
-#define	REGISTER_MESSAGE 0x0001
+#define REGISTER_MESSAGE 0x0001
 typedef struct register_message {
 	char name[16];
 	int userId;
@@ -150,7 +150,7 @@
 #define OFFHOOK_MESSAGE 0x0006
 #define ONHOOK_MESSAGE 0x0007
 
-#define	CAPABILITIES_RES_MESSAGE 0x0010
+#define CAPABILITIES_RES_MESSAGE 0x0010
 typedef struct station_capabilities {
 	int codec;
 	int frames;
@@ -170,30 +170,30 @@
 	int speedDialNumber;
 } speed_dial_stat_req_message;
 
-#define	LINE_STATE_REQ_MESSAGE 0x000B
+#define LINE_STATE_REQ_MESSAGE 0x000B
 typedef struct line_state_req_message {
 	int lineNumber;
 } line_state_req_message;
 
-#define	TIME_DATE_REQ_MESSAGE 0x000D
-#define	VERSION_REQ_MESSAGE 0x000F
+#define TIME_DATE_REQ_MESSAGE 0x000D
 #define BUTTON_TEMPLATE_REQ_MESSAGE 0x000E
+#define VERSION_REQ_MESSAGE 0x000F
 #define SERVER_REQUEST_MESSAGE 0x0012
 #define ALARM_MESSAGE 0x0020
 
-#define OPEN_RECIEVE_CHANNEL_ACK_MESSAGE 0x0022
-typedef struct open_recieve_channel_ack_message {
+#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022
+typedef struct open_receive_channel_ack_message {
 	int status;
 	char ipAddr[4];
 	int port;
 	int passThruId;
-} open_recieve_channel_ack_message;
-
-#define	SOFT_KEY_SET_REQ_MESSAGE 0x0025
+} open_receive_channel_ack_message;
+
+#define SOFT_KEY_SET_REQ_MESSAGE 0x0025
 #define UNREGISTER_MESSAGE 0x0027
-#define	SOFT_KEY_TEMPLATE_REQ_MESSAGE 0x0028
-
-#define	REGISTER_ACK_MESSAGE 0x0081
+#define SOFT_KEY_TEMPLATE_REQ_MESSAGE 0x0028
+
+#define REGISTER_ACK_MESSAGE 0x0081
 typedef struct register_ack_message {
 	int keepAlive;
 	char dateTemplate[6];
@@ -202,7 +202,7 @@
 	char res2[4];
 } register_ack_message;
 
-#define	START_TONE_MESSAGE 0x0082
+#define START_TONE_MESSAGE 0x0082
 typedef struct start_tone_message {
 	int tone;
 } start_tone_message;
@@ -290,31 +290,6 @@
 	int milliseconds;
 	int timestamp;
 } definetimedate_message;
-
-#define DISPLAYTEXT_MESSAGE 0x0099
-typedef struct displaytext_message {
-	char text[40];
-} displaytext_message;
-
-#define CLEAR_DISPLAY_MESSAGE 0x009A
-
-#define	REGISTER_REJ_MESSAGE 0x009D
-typedef struct register_rej_message {
-	char errMsg[33];
-} register_rej_message;
-
-#define CAPABILITIES_REQ_MESSAGE 0x009B
-
-#define SERVER_RES_MESSAGE 0x009E
-typedef struct server_identifier {
-	char serverName[48];
-} server_identifier;
-
-typedef struct server_res_message {
-	server_identifier server[5];
-	int serverListenPort[5];
-	int serverIpAddr[5];
-} server_res_message;
 
 #define BUTTON_TEMPLATE_RES_MESSAGE 0x0097
 
@@ -477,30 +452,54 @@
 	button_definition definition[42];
 } button_template_res_message;
 
-#define	VERSION_RES_MESSAGE 0x0098
+#define VERSION_RES_MESSAGE 0x0098
 typedef struct version_res_message {
 	char version[16];
 } version_res_message;
 
-#define	KEEP_ALIVE_ACK_MESSAGE 0x0100
-
-#define OPEN_RECIEVE_CHANNEL_MESSAGE 0x0105
-typedef struct open_recieve_channel_message {
+#define DISPLAYTEXT_MESSAGE 0x0099
+typedef struct displaytext_message {
+	char text[40];
+} displaytext_message;
+
+#define CLEAR_DISPLAY_MESSAGE 0x009A
+#define CAPABILITIES_REQ_MESSAGE 0x009B
+
+#define REGISTER_REJ_MESSAGE 0x009D
+typedef struct register_rej_message {
+	char errMsg[33];
+} register_rej_message;
+
+#define SERVER_RES_MESSAGE 0x009E
+typedef struct server_identifier {
+	char serverName[48];
+} server_identifier;
+
+typedef struct server_res_message {
+	server_identifier server[5];
+	int serverListenPort[5];
+	int serverIpAddr[5];
+} server_res_message;
+
+#define KEEP_ALIVE_ACK_MESSAGE 0x0100
+
+#define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105
+typedef struct open_receive_channel_message {
 	int conferenceId;
 	int partyId;
 	int packets;
 	int capability;
 	int echo;
 	int bitrate;
-} open_recieve_channel_message;
-
-#define CLOSE_RECIEVE_CHANNEL_MESSAGE 0x0106
-typedef struct close_recieve_channel_message {
+} open_receive_channel_message;
+
+#define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106
+typedef struct close_receive_channel_message {
 	int conferenceId;
 	int partyId;
-} close_recieve_channel_message;
-
-#define	SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
+} close_receive_channel_message;
+
+#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
 
 typedef struct soft_key_template_definition {
 	char softKeyLabel[16];
@@ -535,7 +534,7 @@
 	soft_key_template_definition softKeyTemplateDefinition[32];
 } soft_key_template;
 
-#define	SOFT_KEY_SET_RES_MESSAGE 0x0109
+#define SOFT_KEY_SET_RES_MESSAGE 0x0109
 static const char *soft_key_set_hack = {
 	"\x01\x02\x05\x03\x09\x0a\x0b\x10\x11\x12\x04\x0e\x0d\x00\x00\x00"
 	"\x2d\x01\x2e\x01\x31\x01\x2f\x01\x35\x01\x36\x01\x37\x01\x3c\x01"
@@ -660,9 +659,9 @@
 		call_info_message callinfo;
 		start_media_transmission_message startmedia;
 		stop_media_transmission_message stopmedia;
-		open_recieve_channel_message openrecievechannel;
-		open_recieve_channel_ack_message openrecievechannelack;
-		close_recieve_channel_message closerecievechannel;
+		open_receive_channel_message openreceivechannel;
+		open_receive_channel_ack_message openreceivechannelack;
+		close_receive_channel_message closereceivechannel;
 		display_notify_message displaynotify;
 		dialed_number_message dialednumber;
 	} data;
@@ -1056,10 +1055,10 @@
 		req->data.activatecallplane.lineInstance = 0;
 		transmit_response(s, req);
 		memset(req, 0, memsize);
-		req->len = htolel(sizeof(close_recieve_channel_message)+4);
-		req->e = htolel(CLOSE_RECIEVE_CHANNEL_MESSAGE);
-		req->data.closerecievechannel.conferenceId = 0;
-		req->data.closerecievechannel.partyId = 0;
+		req->len = htolel(sizeof(close_receive_channel_message)+4);
+		req->e = htolel(CLOSE_RECEIVE_CHANNEL_MESSAGE);
+		req->data.closereceivechannel.conferenceId = 0;
+		req->data.closereceivechannel.partyId = 0;
 		transmit_response(s, req);
 		memset(req, 0, memsize);
 		req->len = htolel(sizeof(stop_media_transmission_message)+4);
@@ -1106,19 +1105,19 @@
 	skinny_req *req;
 	struct skinny_line *l = s->device->lines;
 
-	req = req_alloc(sizeof(struct open_recieve_channel_message));
+	req = req_alloc(sizeof(struct open_receive_channel_message));
 	if (!req) {
 		ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
 		return;
 	}
-	req->len = htolel(sizeof(struct open_recieve_channel_message));
-	req->e = htolel(OPEN_RECIEVE_CHANNEL_MESSAGE);
-	req->data.openrecievechannel.conferenceId = 0;
-	req->data.openrecievechannel.partyId = 0;
-	req->data.openrecievechannel.packets = htolel(20);
-	req->data.openrecievechannel.capability = htolel(convert_cap(l->capability));
-	req->data.openrecievechannel.echo = 0;
-	req->data.openrecievechannel.bitrate = 0;
+	req->len = htolel(sizeof(struct open_receive_channel_message));
+	req->e = htolel(OPEN_RECEIVE_CHANNEL_MESSAGE);
+	req->data.openreceivechannel.conferenceId = 0;
+	req->data.openreceivechannel.partyId = 0;
+	req->data.openreceivechannel.packets = htolel(20);
+	req->data.openreceivechannel.capability = htolel(convert_cap(l->capability));
+	req->data.openreceivechannel.echo = 0;
+	req->data.openreceivechannel.bitrate = 0;
 	transmit_response(s, req);
 }
 
@@ -2397,43 +2396,43 @@
 			   and dirty redial, feeding the frames we last got into the queue
 			   function */
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Redial(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Redial(%d)\n", stimulusInstance);
 			}
 			break;
 		case STIMULUS_SPEEDDIAL:
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: SpeedDial(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: SpeedDial(%d)\n", stimulusInstance);
 			}
 			break;
 		case STIMULUS_HOLD:
 			/* start moh? set RTP to 0.0.0.0? */
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Hold(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Hold(%d)\n", stimulusInstance);
 			}
 			break;
 		case STIMULUS_TRANSFER:
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Transfer(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Transfer(%d)\n", stimulusInstance);
 			}
 			transmit_tone(s, SKINNY_DIALTONE);
 			/* XXX figure out how to transfer */
 			break;
 		case STIMULUS_CONFERENCE:
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Transfer(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Transfer(%d)\n", stimulusInstance);
 			}
 			transmit_tone(s, SKINNY_DIALTONE);
 			/* XXX determine the best way to pull off a conference.  Meetme? */
 			break;
 		case STIMULUS_VOICEMAIL:
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Voicemail(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Voicemail(%d)\n", stimulusInstance);
 			}
 			/* XXX Find and dial voicemail extension */
 			break;
 		case STIMULUS_CALLPARK:
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Park Call(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Park Call(%d)\n", stimulusInstance);
 			}
 			/* XXX Park the call */
 			break;
@@ -2460,18 +2459,18 @@
 		case STIMULUS_FORWARDNOANSWER:
 			/* Gonna be fun, not */
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Forward (%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Forward (%d)\n", stimulusInstance);
 			}
 			break;
 		case STIMULUS_DISPLAY:
 			/* Not sure what this is */
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Display(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Display(%d)\n", stimulusInstance);
 			}
 			break;
 		case STIMULUS_LINE:
 			if (skinnydebug) {
-				ast_verbose("Recieved Stimulus: Line(%d)\n", stimulusInstance);
+				ast_verbose("Received Stimulus: Line(%d)\n", stimulusInstance);
 			}
 			sub = find_subchannel_by_line(s->device->lines);
 			/* turn the speaker on */
@@ -2496,7 +2495,7 @@
 		break;
 	case SERVER_REQUEST_MESSAGE:
 		if (skinnydebug) {
-			ast_verbose("Recieved Server Request\n");
+			ast_verbose("Received Server Request\n");
 		}
 		memset(req, 0, SKINNY_MAX_PACKET);
 		req->len = htolel(sizeof(server_res_message)+4);
@@ -2566,7 +2565,7 @@
 		break;
 	case SOFT_KEY_TEMPLATE_REQ_MESSAGE:
 		if (skinnydebug) {
-			ast_verbose("Recieved SoftKey Template Request\n");
+			ast_verbose("Received SoftKey Template Request\n");
 		}
 		memset(req, 0, SKINNY_MAX_PACKET);
 		req->len = htolel(sizeof(soft_key_template)+4);
@@ -2775,18 +2774,18 @@
 			}
 		}
 		break;
-	case OPEN_RECIEVE_CHANNEL_ACK_MESSAGE:
+	case OPEN_RECEIVE_CHANNEL_ACK_MESSAGE:
 		if (skinnydebug) {
-			ast_verbose("Recieved Open Recieve Channel Ack\n");
-		}
-		status = letohl(req->data.openrecievechannelack.status);
+			ast_verbose("Received Open Receive Channel Ack\n");
+		}
+		status = letohl(req->data.openreceivechannelack.status);
 		if (status) {
-			ast_log(LOG_ERROR, "Open Recieve Channel Failure\n");
+			ast_log(LOG_ERROR, "Open Receive Channel Failure\n");
 			break;
 		}
 		/* ENDIAN */
-		memcpy(addr, req->data.openrecievechannelack.ipAddr, sizeof(addr));
-		port = htolel(req->data.openrecievechannelack.port);
+		memcpy(addr, req->data.openreceivechannelack.ipAddr, sizeof(addr));
+		port = htolel(req->data.openreceivechannelack.port);
 		sin.sin_family = AF_INET;
 		/* I smell endian problems */
 		memcpy(&sin.sin_addr, addr, sizeof(sin.sin_addr));

Modified: team/oej/codecnegotiation/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/oej/codecnegotiation/res/res_features.c?rev=20843&r1=20842&r2=20843&view=diff
==============================================================================
--- team/oej/codecnegotiation/res/res_features.c (original)
+++ team/oej/codecnegotiation/res/res_features.c Mon Apr 17 02:03:42 2006
@@ -138,7 +138,7 @@
 
 static struct parkeduser *parkinglot;
 
-AST_MUTEX_DEFINE_STATIC(parking_lock);	/* protects all static variables above */
+AST_MUTEX_DEFINE_STATIC(parking_lock);	/*!< protects all static variables above */
 
 static pthread_t parking_thread;
 
@@ -159,10 +159,10 @@
 	struct ast_channel *peer;
 };
 
-/* store context, priority and extension */
-static void set_c_e_p(struct ast_channel *chan, const char *ctx, const char *ext, int pri)
-{
-	ast_copy_string(chan->context, ctx, sizeof(chan->context));
+/*! \brief store context, priority and extension */
+static void set_c_e_p(struct ast_channel *chan, const char *context, const char *ext, int pri)
+{
+	ast_copy_string(chan->context, context, sizeof(chan->context));
 	ast_copy_string(chan->exten, ext, sizeof(chan->exten));
 	chan->priority = pri;
 }
@@ -220,7 +220,7 @@
 	ast_bridge_call(tobj->peer, tobj->chan, &tobj->bconfig);
 	ast_hangup(tobj->chan);
 	ast_hangup(tobj->peer);
-	bzero(tobj, sizeof(*tobj)); /* XXX for safety */
+	bzero(tobj, sizeof(*tobj)); /*! \todo XXX for safety */
 	free(tobj);
 	return NULL;
 }
@@ -408,8 +408,9 @@
  * if the file name is non-empty, try to play it.
  * Return 0 if success, -1 if error, digit if interrupted by a digit.
  * If digits == "" then we can simply check for non-zero.
- *
- * XXX there are probably many replicas of this function in the source tree,
+ */
+/*
+ *! \todo XXX there are probably many replicas of this function in the source tree,
  * that should be merged.
  */
 static int stream_and_wait(struct ast_channel *chan, const char *file, const char *language, const char *digits)
@@ -596,7 +597,7 @@
 		} else {
 			ast_log(LOG_WARNING, "Unable to park call %s\n", transferee->name);
 		}
-		/* XXX Maybe we should have another message here instead of invalid extension XXX */
+		/*! \todo XXX Maybe we should have another message here instead of invalid extension XXX */
 	} else if (ast_exists_extension(transferee, transferer_real_context, xferto, 1, transferer->cid.cid_num)) {
 		pbx_builtin_setvar_helper(peer, "BLINDTRANSFER", chan->name);
 		pbx_builtin_setvar_helper(chan, "BLINDTRANSFER", peer->name);
@@ -642,13 +643,12 @@
 	struct ast_bridge_config bconfig;
 	const char *transferer_real_context;
 	char xferto[256],dialstr[265];
-	char *cid_num;
-	char *cid_name;
 	int res;
 	struct ast_frame *f = NULL;
 	struct ast_bridge_thread_obj *tobj;
 
-	ast_log(LOG_DEBUG, "Executing Attended Transfer %s, %s (sense=%d) XXX\n", chan->name, peer->name, sense);
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
 	set_peers(&transferer, &transferee, peer, chan, sense);
         transferer_real_context = real_ctx(transferer, transferee);
 	/* Start autoservice on chan while we talk to the originator */
@@ -666,18 +666,37 @@
 
 	/* this is specific of atxfer */
 	res = ast_app_dtget(transferer, transferer_real_context, xferto, sizeof(xferto), 100, transferdigittimeout);
-	if (!res) {
+        if (res < 0) {  /* hangup, would be 0 for invalid and 1 for valid */
+                finishup(transferee);
+                return res;
+        }
+	if (res == 0) {
 		ast_log(LOG_WARNING, "Did not read data.\n");
+		finishup(transferee);
 		if (stream_and_wait(transferer, "beeperr", transferer->language, ""))
 			return -1;
-	} else {
-		cid_num = transferer->cid.cid_num;
-		cid_name = transferer->cid.cid_name;
-		if (ast_exists_extension(transferer, transferer_real_context,xferto, 1, cid_num)) {
+		return FEATURE_RETURN_SUCCESS;
+	}
+	/* valid extension, res == 1 */
+	{
+		if (!ast_exists_extension(transferer, transferer_real_context,xferto, 1, transferer->cid.cid_num)) {
+			ast_log(LOG_WARNING, "Extension %s does not exist in context %s\n",xferto,transferer_real_context);
+			finishup(transferee);
+			if (stream_and_wait(transferer, "beeperr", transferer->language, ""))
+				return -1;
+		} else {
 			snprintf(dialstr, sizeof(dialstr), "%s@%s/n", xferto, transferer_real_context);
-			newchan = ast_feature_request_and_dial(transferer, "Local", ast_channel_best_codec(transferer), dialstr, 15000, &outstate, cid_num, cid_name);
+			newchan = ast_feature_request_and_dial(transferer, "Local", ast_channel_best_codec(transferer), dialstr, 15000, &outstate, transferer->cid.cid_num, transferer->cid.cid_name);
 			ast_indicate(transferer, -1);
-			if (newchan) {
+			if (!newchan) {
+				finishup(transferee);
+				/* any reason besides user requested cancel and busy triggers the failed sound */
+				if (outstate != AST_CONTROL_UNHOLD && outstate != AST_CONTROL_BUSY &&
+						stream_and_wait(transferer, xferfailsound, transferer->language, ""))
+					return -1;
+				return FEATURE_RETURN_SUCCESS;
+			}
+			{
 				res = ast_channel_make_compatible(transferer, newchan);
 				if (res < 0) {
 					ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", transferer->name, newchan->name);
@@ -760,19 +779,7 @@
 				}
 				return -1;
 				
-			} else {
-				finishup(transferee);
-				/* any reason besides user requested cancel and busy triggers the failed sound */
-				if (outstate != AST_CONTROL_UNHOLD && outstate != AST_CONTROL_BUSY &&
-						stream_and_wait(transferer, xferfailsound, transferer->language, ""))
-					return -1;
-				return FEATURE_RETURN_SUCCESS;
 			}
-		} else {
-			ast_log(LOG_WARNING, "Extension %s does not exist in context %s\n",xferto,transferer_real_context);
-			finishup(transferee);
-			if (stream_and_wait(transferer, "beeperr", transferer->language, ""))
-				return -1;
 		}
 	}
 	finishup(transferee);
@@ -878,7 +885,7 @@
 		return -2;
 	}
 	
-	return FEATURE_RETURN_SUCCESS;	/* XXX should probably return res */
+	return FEATURE_RETURN_SUCCESS;	/*! \todo XXX should probably return res */
 }
 
 static void unmap_features(void)
@@ -916,7 +923,8 @@
 		ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL);	
 	else
 		ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL);	
-	ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags);
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags);
 
 	for (x=0; x < FEATURES_COUNT; x++) {
 		if ((ast_test_flag(&features, builtin_features[x].feature_mask)) &&
@@ -999,7 +1007,7 @@
 	}
 }
 
-/* XXX this is very similar to the code in channel.c */
+/*! \todo XXX Check - this is very similar to the code in channel.c */
 static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *caller, const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name)
 {
 	int state = 0;
@@ -1253,7 +1261,8 @@
 				   activated, but that's no excuse to keep things going 
 				   indefinitely! */
 				if (backup_config.feature_timer && ((backup_config.feature_timer -= diff) <= 0)) {
-					ast_log(LOG_DEBUG, "Timed out, realtime this time!\n");
+					if (option_debug)
+						ast_log(LOG_DEBUG, "Timed out, realtime this time!\n");
 					config->feature_timer = 0;
 					who = chan;
 					if (f)
@@ -1263,7 +1272,8 @@
 				} else if (config->feature_timer <= 0) {
 					/* Not *really* out of time, just out of time for
 					   digits to come in for features. */
-					ast_log(LOG_DEBUG, "Timed out for feature!\n");
+					if (option_debug)
+						ast_log(LOG_DEBUG, "Timed out for feature!\n");
 					if (!ast_strlen_zero(peer_featurecode)) {
 						ast_dtmf_stream(chan, peer, peer_featurecode, 0);
 						memset(peer_featurecode, 0, sizeof(peer_featurecode));
@@ -1337,8 +1347,9 @@
 				sense = FEATURE_SENSE_PEER;
 				featurecode = peer_featurecode;
 			}
-			/* append the event to featurecode. we rely on the string being zero-filled, and
-			 * not overflowing it. XXX how do we guarantee the latter ?
+			/*! append the event to featurecode. we rely on the string being zero-filled, and
+			 * not overflowing it. 
+			 * \todo XXX how do we guarantee the latter ?
 			 */
 			featurecode[strlen(featurecode)] = f->subclass;
 			config->feature_timer = backup_config.feature_timer;
@@ -1377,7 +1388,8 @@
 					config->firstpass = 0;
 				}
 				config->feature_timer = featuredigittimeout;
-				ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer);
+				if (option_debug)
+					ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer);
 			}
 		}
 		if (f)
@@ -1528,14 +1540,15 @@
 						free(pt);
 						break;
 					} else {
-						/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
+						/*! \todo XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
 						ast_frfree(f);
 						if (pu->moh_trys < 3 && !chan->generatordata) {
-							ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source.  Restarting.\n");
+							if (option_debug)
+								ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source.  Restarting.\n");
 							ast_moh_start(chan, NULL);
 							pu->moh_trys++;
 						}
-						goto std;	/* XXX Ick: jumping into an else statement??? XXX */
+						goto std;	/*! \todo XXX Ick: jumping into an else statement??? XXX */
 					}
 
 				} /* end for */
@@ -1664,7 +1677,7 @@
 			} else if (parkedplay == 2) {
 				if (!ast_streamfile(chan, courtesytone, chan->language) &&
 						!ast_streamfile(peer, courtesytone, chan->language)) {
-					/* XXX we would like to wait on both! */
+					/*! \todo XXX we would like to wait on both! */
 					res = ast_waitstream(chan, "");
 					if (res >= 0)
 						res = ast_waitstream(peer, "");
@@ -1704,7 +1717,7 @@
 			ast_hangup(peer);
 		return res;
 	} else {
-		/* XXX Play a message XXX */
+		/*! \todo XXX Play a message XXX */
 		if (stream_and_wait(chan, "pbx-invalidpark", chan->language, ""))
 			ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", "pbx-invalidpark", chan->name);
 		if (option_verbose > 2) 
@@ -2028,7 +2041,7 @@
 			char *exten, *party=NULL, *app=NULL, *app_args=NULL; 
 
 			if (!tmp_val) { 
-				/* XXX No memory. We should probably break, but at least we do not
+				/*! \todo XXX No memory. We should probably break, but at least we do not
 				 * insist on this entry or we could be stuck in an
 				 * infinite loop.
 				 */
@@ -2044,7 +2057,7 @@
 			app = strsep(&tmp_val,",");
 			app_args = strsep(&tmp_val,",");
 
-			/* XXX var_name or app_args ? */
+			/*! \todo XXX var_name or app_args ? */
 			if (ast_strlen_zero(app) || ast_strlen_zero(exten) || ast_strlen_zero(party) || ast_strlen_zero(var->name)) {
 				ast_log(LOG_NOTICE, "Please check the feature Mapping Syntax, either extension, name, or app aren't provided %s %s %s %s\n",app,exten,party,var->name);
 				free(tmp_val);
@@ -2097,7 +2110,8 @@
 	/* Remove the old parking extension */
 	if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con)))	{
 		ast_context_remove_extension2(con, old_parking_ext, 1, registrar);
-		ast_log(LOG_DEBUG, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
 	}
 	
 	if (!(con = ast_context_find(parking_con)) && !(con = ast_context_create(NULL, parking_con, registrar))) {



More information about the asterisk-commits mailing list