[Asterisk-cvs] asterisk/channels chan_sip.c,1.551,1.552

markster at lists.digium.com markster at lists.digium.com
Sun Nov 7 19:33:40 CST 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv10657/channels

Modified Files:
	chan_sip.c 
Log Message:
Allow client code to be set from snom phone if "useclientcode=yes" in friend


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.551
retrieving revision 1.552
diff -u -d -r1.551 -r1.552
--- chan_sip.c	7 Nov 2004 18:44:33 -0000	1.551
+++ chan_sip.c	8 Nov 2004 00:35:23 -0000	1.552
@@ -262,6 +262,7 @@
 	int canreinvite;			/* Do we support reinvite */
 	int ringing;				/* Have sent 180 ringing */
 	int progress;				/* Have sent 183 message progress */
+	int useclientcode;			/* Trust X-ClientCode info message */
 	int tag;				/* Another random number */
 	int nat;				/* Whether to try to support NAT */
 	int sessionid;				/* SDP Session ID */
@@ -392,6 +393,7 @@
 	int outUse;
 	int outgoinglimit;
 	int promiscredir;
+	int useclientcode;
 	int trustrpid;
 	int progressinband;
 	struct ast_ha *ha;
@@ -436,6 +438,7 @@
 	int promiscredir;
 	int dtmfmode;
 	int trustrpid;
+	int useclientcode;
 	int progressinband;
 	struct sockaddr_in addr;
 	struct in_addr mask;
@@ -5295,6 +5298,7 @@
 		p->ospauth = user->ospauth;
 #endif
 		p->trustrpid = user->trustrpid;
+		p->useclientcode = user->useclientcode;
 		p->progressinband = user->progressinband;
 		/* replace callerid if rpid found, and not restricted */
 		if(!ast_strlen_zero(rpid_num) && p->trustrpid) {
@@ -5373,6 +5377,7 @@
 			/* Take the peer */
 			p->nat = peer->nat;
 			p->trustrpid = peer->trustrpid;
+			p->useclientcode = peer->useclientcode;
 			p->progressinband = peer->progressinband;
 			/* replace callerid if rpid found, and not restricted */
 			if(!ast_strlen_zero(rpid_num) && p->trustrpid) {
@@ -6061,6 +6066,18 @@
 			p->needdestroy = 1;
 		}
 		return;
+	} else if ((c = get_header(req, "X-ClientCode"))) {
+		/* Client code (from SNOM phone) */
+		if (p->useclientcode) {
+			if (p->owner && p->owner->cdr)
+				ast_cdr_setaccount(p->owner, c);
+			if (p->owner && ast_bridged_channel(p->owner) && ast_bridged_channel(p->owner)->cdr)
+				ast_cdr_setaccount(ast_bridged_channel(p->owner), c);
+			transmit_response(p, "200 OK", req);
+		} else {
+			transmit_response(p, "403 Unauthorized", req);
+		}
+		return;
 	}
 	/* Other type of INFO message, not really understood by Asterisk */
 	/* if (get_msg_text(buf, sizeof(buf), req)) { */
@@ -8170,6 +8187,8 @@
 				user->callingpres = atoi(v->value);
 			} else if (!strcasecmp(v->name, "trustrpid")) {
 				user->trustrpid = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "useclientcode")) {
+				user->useclientcode = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "progressinband")) {
 				user->progressinband = ast_true(v->value);
 #ifdef OSP_SUPPORT
@@ -8432,6 +8451,8 @@
 					ast_log(LOG_WARNING, "Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", peer->name, v->lineno);
 					peer->maxms = 0;
 				}
+			} else if (!strcasecmp(v->name, "useclientcode")) {
+				peer->useclientcode = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "trustrpid")) {
 				peer->trustrpid = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "progressinband")) {




More information about the svn-commits mailing list