[svn-commits] mmichelson: branch group/CCSS r236793 - /team/group/CCSS/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 29 13:17:09 CST 2009


Author: mmichelson
Date: Tue Dec 29 13:17:07 2009
New Revision: 236793

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=236793
Log:
Add a new parameter to initreqprep to provide an explicit request URI.

When sending CC-related NOTIFY and PUBLISH requests, we need to set the
request URI to a specific value that the other end is expecting, rather than
any other settings on the sip_pvt. This new change allows for such a URI
to be passed in.

For now, all callers of initreqprep are setting this parameter NULL. My next
set of changes should include their usage of the parameter.


Modified:
    team/group/CCSS/channels/chan_sip.c

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=236793&r1=236792&r2=236793
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Tue Dec 29 13:17:07 2009
@@ -3238,7 +3238,7 @@
 static void initialize_initreq(struct sip_pvt *p, struct sip_request *req);
 static int init_req(struct sip_request *req, int sipmethod, const char *recip);
 static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, int seqno, int newbranch);
-static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod);
+static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, const char * const explicit_uri);
 static int init_resp(struct sip_request *resp, const char *msg);
 static inline int resp_needs_contact(const char *msg, enum sipmethod method);
 static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg, const struct sip_request *req);
@@ -12271,7 +12271,7 @@
 }
 
 /*! \brief Initiate new SIP request to peer/user */
-static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod)
+static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, const char * const explicit_uri)
 {
 	struct ast_str *invite = ast_str_alloca(256);
 	char from[256];
@@ -12356,25 +12356,30 @@
 	else
 		snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=%s", n, l, d, p->tag);
 
-	/* If we're calling a registered SIP peer, use the fullcontact to dial to the peer */
-	if (!ast_strlen_zero(p->fullcontact)) {
-		/* If we have full contact, trust it */
-		ast_str_append(&invite, 0, "%s", p->fullcontact);
+
+	if (!ast_strlen_zero(explicit_uri)) {
+		ast_str_set(&invite, 0, "%s", explicit_uri);
 	} else {
-		/* Otherwise, use the username while waiting for registration */
-		ast_str_append(&invite, 0, "sip:");
-		if (!ast_strlen_zero(p->username)) {
-			n = p->username;
-			if (sip_cfg.pedanticsipchecking) {
-				ast_uri_encode(n, tmp_n, sizeof(tmp_n), 0);
-				n = tmp_n;
+		/* If we're calling a registered SIP peer, use the fullcontact to dial to the peer */
+		if (!ast_strlen_zero(p->fullcontact)) {
+			/* If we have full contact, trust it */
+			ast_str_append(&invite, 0, "%s", p->fullcontact);
+		} else {
+			/* Otherwise, use the username while waiting for registration */
+			ast_str_append(&invite, 0, "sip:");
+			if (!ast_strlen_zero(p->username)) {
+				n = p->username;
+				if (sip_cfg.pedanticsipchecking) {
+					ast_uri_encode(n, tmp_n, sizeof(tmp_n), 0);
+					n = tmp_n;
+				}
+				ast_str_append(&invite, 0, "%s@", n);
 			}
-			ast_str_append(&invite, 0, "%s@", n);
-		}
-		ast_str_append(&invite, 0, "%s", p->tohost);
-		if (p->portinuri)
-			ast_str_append(&invite, 0, ":%d", ntohs(p->sa.sin_port));
-		ast_str_append(&invite, 0, "%s", urioptions);
+			ast_str_append(&invite, 0, "%s", p->tohost);
+			if (p->portinuri)
+				ast_str_append(&invite, 0, ":%d", ntohs(p->sa.sin_port));
+			ast_str_append(&invite, 0, "%s", urioptions);
+		}
 	}
 
 	/* If custom URI options have been provided, append them */
@@ -12483,7 +12488,7 @@
 	pvt->branch = ast_random();
 	build_via(pvt);
 
-	initreqprep(&req, pvt, SIP_PUBLISH);
+	initreqprep(&req, pvt, SIP_PUBLISH, NULL);
 
 	ast_set_flag(&pvt->flags[0], SIP_OUTGOING);
 
@@ -12533,7 +12538,7 @@
 		build_via(p);
 	}
 	if (init > 1)
-		initreqprep(&req, p, sipmethod);
+		initreqprep(&req, p, sipmethod, NULL);
 	else
 		/* If init=1, we should not generate a new branch. If it's 0, we need a new branch. */
 		reqprep(&req, p, sipmethod, 0, init ? 0 : 1);
@@ -13050,7 +13055,7 @@
 	int ourport = ntohs(p->ourip.sin_port);
 	const char *exten = S_OR(vmexten, default_vmexten);
 
-	initreqprep(&req, p, SIP_NOTIFY);
+	initreqprep(&req, p, SIP_NOTIFY, NULL);
 	add_header(&req, "Event", "message-summary");
 	add_header(&req, "Content-Type", default_notifymime);
 	ast_str_append(&out, 0, "Messages-Waiting: %s\r\n", newmsgs ? "yes" : "no");




More information about the svn-commits mailing list