[svn-commits] oej: branch oej/gin-register-bnc-1.8 r426076 - in /team/oej/gin-register-bnc-...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Oct 21 04:29:08 CDT 2014


Author: oej
Date: Tue Oct 21 04:28:55 2014
New Revision: 426076

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=426076
Log:
Coding in the deep, blindly

Modified:
    team/oej/gin-register-bnc-1.8/channels/chan_sip.c
    team/oej/gin-register-bnc-1.8/channels/sip/config_parser.c
    team/oej/gin-register-bnc-1.8/channels/sip/include/sip.h

Modified: team/oej/gin-register-bnc-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/gin-register-bnc-1.8/channels/chan_sip.c?view=diff&rev=426076&r1=426075&r2=426076
==============================================================================
--- team/oej/gin-register-bnc-1.8/channels/chan_sip.c (original)
+++ team/oej/gin-register-bnc-1.8/channels/chan_sip.c Tue Oct 21 04:28:55 2014
@@ -1532,6 +1532,7 @@
 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_param(struct sip_pvt *p, const char *param);
 
 /*------Request handling functions */
 static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct ast_sockaddr *addr, int *recount, int *nounlock);
@@ -12328,16 +12329,33 @@
 /*! \brief Build contact header - the contact header we send out */
 static void build_contact(struct sip_pvt *p)
 {
+	build_contact_param(p, NULL);
+}
+
+/*! \brief Build contact header and add contact URI parameter.
+	URI parameter needs to start with ";" and be separated by ";"'s */
+static void build_contact_param(struct sip_pvt *p, const char *param)
+{
 	char tmp[SIPBUFSIZE];
+	char params[SIPBUFSIZE];
 	char *user = ast_uri_encode(p->exten, tmp, sizeof(tmp), 0);
 
-	if (p->socket.type == SIP_TRANSPORT_UDP) {
-		ast_string_field_build(p, our_contact, "<sip:%s%s%s>", user,
-			ast_strlen_zero(user) ? "" : "@", ast_sockaddr_stringify_remote(&p->ourip));
+	params[0] = '\0';
+	if(ast_strlen_zero(param)) {
+		if (p->socket.type != SIP_TRANSPORT_UDP) {
+			snprintf(params, sizeof(params), ";transport=%s", get_transport(p->socket.type));
+		}
 	} else {
-		ast_string_field_build(p, our_contact, "<sip:%s%s%s;transport=%s>", user,
+		if (p->socket.type != SIP_TRANSPORT_UDP) {
+			snprintf(params, sizeof(params), ";transport=%s%s", get_transport(p->socket.type), param);
+		} else {
+			snprintf(params, sizeof(params), ";%s", param);
+		}
+	}
+
+	ast_string_field_build(p, our_contact, "<sip:%s%s%s%s>", user,
 			ast_strlen_zero(user) ? "" : "@", ast_sockaddr_stringify_remote(&p->ourip),
-			get_transport(p->socket.type));
+			params);
 	}
 }
 
@@ -13830,7 +13848,9 @@
 		}
 		/* Save extension in packet */
 		if (!ast_strlen_zero(r->callback)) {
-			ast_string_field_set(p, exten, r->callback);
+			if (!r->bnc) {
+				ast_string_field_set(p, exten, r->callback);
+			}
 		}
 
 		/* Set transport and port so the correct contact is built */
@@ -13846,7 +13866,11 @@
 		  internal network so we can register through nat
 		 */
 		ast_sip_ouraddrfor(&p->sa, &p->ourip, p);
-		build_contact(p);
+		if (r->bnc) {
+			build_contact_param(p, ";bnc");
+		} else {
+			build_contact(p);
+		}
 	}
 
 	/* set up a timeout */
@@ -13927,6 +13951,13 @@
 	snprintf(tmp, sizeof(tmp), "%d", r->expiry);
 	add_header(&req, "Expires", tmp);
 	add_header(&req, "Contact", p->our_contact);
+
+	if (r->bnc) {
+		/* RFC 6140 headers required */
+		add_header(&req, "Supported", "path");
+		add_header(&req, "Require", "gin");
+		add_header(&req, "Proxy-Require", "gin");
+	}
 
 	initialize_initreq(p, &req);
 	if (sip_debug_test_pvt(p)) {

Modified: team/oej/gin-register-bnc-1.8/channels/sip/config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/gin-register-bnc-1.8/channels/sip/config_parser.c?view=diff&rev=426076&r1=426075&r2=426076
==============================================================================
--- team/oej/gin-register-bnc-1.8/channels/sip/config_parser.c (original)
+++ team/oej/gin-register-bnc-1.8/channels/sip/config_parser.c Tue Oct 21 04:28:55 2014
@@ -250,6 +250,10 @@
 			portnum = STANDARD_SIP_PORT;
 		}
 	}
+	reg->bnc = FALSE;
+	if (!strncasecmp(host2.extension, "-bnc-", 5)) {
+		reg->bnc = TRUE;
+	}
 
 	/* copy into sip_registry object */
 	ast_string_field_set(reg, callback, ast_strip_quoted(S_OR(host2.extension, "s"), "\"", "\""));

Modified: team/oej/gin-register-bnc-1.8/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/gin-register-bnc-1.8/channels/sip/include/sip.h?view=diff&rev=426076&r1=426075&r2=426076
==============================================================================
--- team/oej/gin-register-bnc-1.8/channels/sip/include/sip.h (original)
+++ team/oej/gin-register-bnc-1.8/channels/sip/include/sip.h Tue Oct 21 04:28:55 2014
@@ -1326,6 +1326,7 @@
 	int regattempts;        /*!< Number of attempts (since the last success) */
 	int timeout;            /*!< sched id of sip_reg_timeout */
 	int refresh;            /*!< How often to refresh */
+	int bnc;		/*!< Bulk number contact (RFC 6140) */
 	struct sip_pvt *call;   /*!< create a sip_pvt structure for each outbound "registration dialog" in progress */
 	enum sipregistrystate regstate; /*!< Registration state (see above) */
 	struct timeval regtime;         /*!< Last successful registration time */




More information about the svn-commits mailing list