[asterisk-commits] oej: branch oej/pekoe-tonic-displayname-in-register-1.8 r386097 - /team/oej/p...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 19 03:49:56 CDT 2013


Author: oej
Date: Fri Apr 19 03:49:50 2013
New Revision: 386097

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386097
Log:
Just a quick Friday hack to show the Tonic crew that I may be old, but still know my stuff.

Now let's check Kamailio.

Modified:
    team/oej/pekoe-tonic-displayname-in-register-1.8/channels/chan_sip.c

Modified: team/oej/pekoe-tonic-displayname-in-register-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pekoe-tonic-displayname-in-register-1.8/channels/chan_sip.c?view=diff&rev=386097&r1=386096&r2=386097
==============================================================================
--- team/oej/pekoe-tonic-displayname-in-register-1.8/channels/chan_sip.c (original)
+++ team/oej/pekoe-tonic-displayname-in-register-1.8/channels/chan_sip.c Fri Apr 19 03:49:50 2013
@@ -1538,7 +1538,7 @@
 static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, const struct sip_request *orig, const char *field);
 static void set_destination(struct sip_pvt *p, char *uri);
 static void append_date(struct sip_request *req);
-static void build_contact(struct sip_pvt *p);
+static void build_contact(struct sip_pvt *p, int displayname);
 
 /*------Request handling functions */
 static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, int *recount, int *nounlock);
@@ -12424,16 +12424,21 @@
 }
 
 /*! \brief Build contact header - the contact header we send out */
-static void build_contact(struct sip_pvt *p)
+static void build_contact(struct sip_pvt *p, int displayname)
 {
 	char tmp[SIPBUFSIZE];
 	char *user = ast_uri_encode(p->exten, tmp, sizeof(tmp), 0);
+	char display[SIPBUFSIZE] = "";
+
+	if (displayname && strlen(ast_config_AST_SYSTEM_NAME) > 0) {
+		snprintf(display, sizeof(display), "\"%s\" ", ast_config_AST_SYSTEM_NAME);
+	}
 
 	if (p->socket.type == SIP_TRANSPORT_UDP) {
-		ast_string_field_build(p, our_contact, "<sip:%s%s%s>", user,
+		ast_string_field_build(p, our_contact, "%s<sip:%s%s%s>", display, user,
 			ast_strlen_zero(user) ? "" : "@", ast_sockaddr_stringify_remote(&p->ourip));
 	} else {
-		ast_string_field_build(p, our_contact, "<sip:%s%s%s;transport=%s>", user,
+		ast_string_field_build(p, our_contact, "%s<sip:%s%s%s;transport=%s>", display, user,
 			ast_strlen_zero(user) ? "" : "@", ast_sockaddr_stringify_remote(&p->ourip),
 			get_transport(p->socket.type));
 	}
@@ -12599,7 +12604,7 @@
 	add_header(req, "From", from);
 	add_header(req, "To", to);
 	ast_string_field_set(p, exten, l);
-	build_contact(p);
+	build_contact(p, FALSE);
 	add_header(req, "Contact", p->our_contact);
 	add_header(req, "Call-ID", p->callid);
 	add_header(req, "CSeq", tmp_n);
@@ -13012,7 +13017,7 @@
 	set_socket_transport(&mwi->call->socket, mwi->transport);
 	mwi->call->socket.port = htons(mwi->portno);
 	ast_sip_ouraddrfor(&mwi->call->sa, &mwi->call->ourip, mwi->call);
-	build_contact(mwi->call);
+	build_contact(mwi->call, FALSE);
 	build_via(mwi->call);
 
 	/* Change the dialog callid. */
@@ -13892,7 +13897,7 @@
 		  internal network so we can register through nat
 		 */
 		ast_sip_ouraddrfor(&p->sa, &p->ourip, p);
-		build_contact(p);
+		build_contact(p, TRUE);
 	}
 
 	/* set up a timeout */
@@ -15378,7 +15383,7 @@
 	}
 
 	ast_string_field_set(p, exten, name);
-	build_contact(p);
+	build_contact(p, FALSE);
 	if (req->ignore) {
 		/* Expires is a special case, where we only want to load the peer if this isn't a deregistration attempt */
 		const char *expires = get_header(req, "Expires");
@@ -16783,7 +16788,7 @@
 			*t = '\0';
 
 		if (ast_strlen_zero(p->our_contact))
-			build_contact(p);
+			build_contact(p, FALSE);
 	}
 
 	of = get_in_brackets(of);
@@ -22651,7 +22656,7 @@
 
 	/* must go through authentication before getting here */
 	gotdest = get_destination(p, req, NULL);
-	build_contact(p);
+	build_contact(p, FALSE);
 
 	if (ast_strlen_zero(p->context))
 		ast_string_field_set(p, context, sip_cfg.default_context);
@@ -23369,7 +23374,7 @@
 		}
 		gotdest = get_destination(p, NULL, &cc_recall_core_id);	/* Get destination right away */
 		extract_uri(p, req);			/* Get the Contact URI */
-		build_contact(p);			/* Build our contact header */
+		build_contact(p, FALSE);			/* Build our contact header */
 
 		if (p->rtp) {
 			ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_DTMF, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
@@ -25386,7 +25391,7 @@
 	/* Get full contact header - this needs to be used as a request URI in NOTIFY's */
 	parse_ok_contact(p, req);
 
-	build_contact(p);
+	build_contact(p, FALSE);
 	if (gotdest != SIP_GET_DEST_EXTEN_FOUND) {
 		if (gotdest == SIP_GET_DEST_INVALID_URI) {
 			transmit_response(p, "416 Unsupported URI scheme", req);




More information about the asterisk-commits mailing list