[asterisk-commits] rizzo: branch rizzo/astobj2 r72799 - /team/rizzo/astobj2/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jun 30 16:25:28 CDT 2007


Author: rizzo
Date: Sat Jun 30 16:25:27 2007
New Revision: 72799

URL: http://svn.digium.com/view/asterisk?view=rev&rev=72799
Log:
more merging from trunk up to svn 61152 (some changes were already
present in my version)


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=72799&r1=72798&r2=72799
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Sat Jun 30 16:25:27 2007
@@ -1459,7 +1459,6 @@
 static int hangup_sip2cause(int cause);
 static const char *hangup_cause2sip(int cause);
 static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *sin, const int intended_method);
-static void free_old_route(struct sip_route *route);
 static void list_route(struct sip_route *route);
 static void build_route(struct sip_pvt *p, struct sip_request *req, int backwards);
 static enum check_auth_result register_verify(struct sip_pvt *p, struct sockaddr_in *sin,
@@ -1567,6 +1566,7 @@
 static int sip_dtmfmode(struct ast_channel *chan, void *data);
 static int sip_addheader(struct ast_channel *chan, void *data);
 static int sip_reload(int fd, int argc, char *argv[]);
+static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen);
 
 /*--- Debugging 
 	Functions for enabling debug per IP or fully, or enabling history logging for
@@ -1730,6 +1730,7 @@
 	.bridge = ast_rtp_bridge,	/* XXX chan unlocked ? */
 	.early_bridge = ast_rtp_early_bridge,
 	.send_text = sip_sendtext,	/* called with chan locked */
+	.func_channel_read = acf_channel_read,
 };
 
 static const struct ast_channel_tech sip_tech_info = {
@@ -4384,8 +4385,7 @@
 		sip_pvt_unlock(i);
 		/* Don't hold a sip pvt lock while we allocate a channel */
 
-		tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, "SIP/%s-%08x", my_name, (int)(long) i);
-
+		tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "SIP/%s-%08x", my_name, (int)(long) i);
 	}
 	if (!tmp) {
 		ast_log(LOG_WARNING, "Unable to allocate AST channel structure for SIP channel\n");
@@ -5886,15 +5886,15 @@
 					ast_log(LOG_DEBUG, "Transcoding JBIG: %d\n",x);
 				if (x == 1)
 					peert38capability |= T38FAX_TRANSCODING_JBIG;
-			} else if ((sscanf(a, "T38FaxRateManagement:%s", s) == 1)) {
+			} else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) {
 				found = 1;
 				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "RateMangement: %s\n", s);
+					ast_log(LOG_DEBUG, "RateManagement: %s\n", s);
 				if (!strcasecmp(s, "localTCF"))
 					peert38capability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
 				else if (!strcasecmp(s, "transferredTCF"))
 					peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
-			} else if ((sscanf(a, "T38FaxUdpEC:%s", s) == 1)) {
+			} else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) {
 				found = 1;
 				if (option_debug > 2)
 					ast_log(LOG_DEBUG, "UDP EC: %s\n", s);
@@ -6611,6 +6611,7 @@
 	respprep(&resp, p, msg, req);
 	append_date(&resp);
 	add_header(&resp, "Unsupported", unsupported);
+	add_header_contentLength(&resp, 0);
 	return send_response(p, &resp, XMIT_UNRELIABLE, 0);
 }
 
@@ -6858,7 +6859,7 @@
 	}
 	
 	if (!p->sessionid) {
-		p->sessionid = getpid();
+		p->sessionid = (int)ast_random();
 		p->sessionversion = p->sessionid;
 	} else
 		p->sessionversion++;
@@ -7026,7 +7027,7 @@
 
 	/* Set RTP Session ID and version */
 	if (!p->sessionid) {
-		p->sessionid = getpid();
+		p->sessionid = (int)ast_random();
 		p->sessionversion = p->sessionid;
 	} else
 		p->sessionversion++;
@@ -8050,7 +8051,7 @@
 		r->regstate = REG_STATE_UNREGISTERED;
 		res=transmit_register(r, NULL, NULL);
 	}
-	manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelDriver: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
+	manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
 	return 0;
 }
 
@@ -11318,7 +11319,7 @@
 	char host[80];
 	char tmpdat[256];
 	struct tm tm;
-
+	int counter = 0;
 
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
@@ -11334,7 +11335,9 @@
 		}
 		ast_cli(fd, FORMAT, host, iterator->username, iterator->refresh, regstate2str(iterator->regstate), tmpdat);
 		ASTOBJ_UNLOCK(iterator);
+		counter++;
 	} while(0));
+	ast_cli(fd, "%d SIP registrations.\n", counter);
 	return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -13186,7 +13189,7 @@
 			r->regstate = REG_STATE_UNREGISTERED;
 			transmit_register(r, NULL, NULL);
 		}
-		manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
+		manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
 		break;
 
 	case 479:	/* SER: Not able to process the URI - address is wrong in register*/
@@ -13197,7 +13200,7 @@
 	case 200:	/* 200 OK */
 		r->regstate = REG_STATE_REGISTERED;
 		r->regtime = time(NULL);		/* Reset time of last succesful registration */
-		manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelDriver: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
+		manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
 		r->regattempts = 0;
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Registration successful\n");
@@ -13801,8 +13804,8 @@
 		/* Chan2m: The transferer, chan1m: The transferee */
 	pthread_t th;
 
-	transferee = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "Parking/%s", chan1->name);
-	transferer = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "SIPPeer/%s", chan2->name);
+	transferee = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, chan1->accountcode, chan1->exten, chan1->context, chan1->amaflags, "Parking/%s", chan1->name);
+	transferer = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, chan2->accountcode, chan2->exten, chan2->context, chan2->amaflags, "SIPPeer/%s", chan2->name);
 	if ((!transferer) || (!transferee)) {
 		if (transferee) {
 			transferee->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
@@ -14627,7 +14630,6 @@
 			/* Initialize our tag */	
 
 			make_our_tag(p->tag, sizeof(p->tag));
-
 			/* First invitation - create the channel */
 			c = sip_new(p, AST_STATE_DOWN, S_OR(p->username, NULL));
 			*recount = 1;
@@ -15316,6 +15318,65 @@
 		transmit_response(p, "481 Call Leg Does Not Exist", req);
 		return 0;
 	}
+}
+
+static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
+{
+	struct ast_rtp_quality qos;
+	struct sip_pvt *p = chan->tech_pvt;
+	char *all = "", *parse = ast_strdupa(preparse);
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(param);
+		AST_APP_ARG(type);
+		AST_APP_ARG(field);
+	);
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	/* Sanity check */
+	if (chan->tech != &sip_tech && chan->tech != &sip_tech_info) {
+		ast_log(LOG_ERROR, "Cannot call %s on a non-SIP channel\n", funcname);
+		return 0;
+	}
+
+	if (strcasecmp(args.param, "rtpqos"))
+		return 0;
+
+	memset(buf, 0, buflen);
+	memset(&qos, 0, sizeof(qos));
+
+	if (strcasecmp(args.type, "AUDIO") == 0) {
+		all = ast_rtp_get_quality(p->rtp, &qos);
+	} else if (strcasecmp(args.type, "VIDEO") == 0) {
+		all = ast_rtp_get_quality(p->vrtp, &qos);
+	} else if (strcasecmp(args.type, "TEXT") == 0) {
+		all = ast_rtp_get_quality(p->trtp, &qos);
+	}
+
+	if (strcasecmp(args.field, "local_ssrc") == 0)
+		snprintf(buf, buflen, "%u", qos.local_ssrc);
+	else if (strcasecmp(args.field, "local_lostpackets") == 0)
+		snprintf(buf, buflen, "%u", qos.local_lostpackets);
+	else if (strcasecmp(args.field, "local_jitter") == 0)
+		snprintf(buf, buflen, "%.0lf", qos.local_jitter * 1000.0);
+	else if (strcasecmp(args.field, "local_count") == 0)
+		snprintf(buf, buflen, "%u", qos.local_count);
+	else if (strcasecmp(args.field, "remote_ssrc") == 0)
+		snprintf(buf, buflen, "%u", qos.remote_ssrc);
+	else if (strcasecmp(args.field, "remote_lostpackets") == 0)
+		snprintf(buf, buflen, "%u", qos.remote_lostpackets);
+	else if (strcasecmp(args.field, "remote_jitter") == 0)
+		snprintf(buf, buflen, "%.0lf", qos.remote_jitter * 1000.0);
+	else if (strcasecmp(args.field, "remote_count") == 0)
+		snprintf(buf, buflen, "%u", qos.remote_count);
+	else if (strcasecmp(args.field, "rtt") == 0)
+		snprintf(buf, buflen, "%.0lf", qos.rtt * 1000.0);
+	else if (strcasecmp(args.field, "all") == 0)
+		ast_copy_string(buf, all, buflen);
+	else {
+		ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
+		return -1;
+	}
+	return 0;
 }
 
 /*! \brief Handle incoming BYE request */
@@ -17899,7 +17960,7 @@
 	notify_types = ast_config_load(notify_config);
 
 	/* Done, tell the manager */
-	manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "Channel: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\nUser_Count: %d\r\n\r\n", channelreloadreason2txt(reason), registry_count, peer_count, user_count);
+	manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "ChannelType: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\nUser_Count: %d\r\n\r\n", channelreloadreason2txt(reason), registry_count, peer_count, user_count);
 
 	return 0;
 }




More information about the asterisk-commits mailing list