[svn-commits] mmichelson: branch mmichelson/sip_options r394234 - in /team/mmichelson/sip_o...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 12 16:13:02 CDT 2013


Author: mmichelson
Date: Fri Jul 12 16:13:00 2013
New Revision: 394234

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394234
Log:
Add "fromuser" option for endpoints.


Modified:
    team/mmichelson/sip_options/include/asterisk/res_sip.h
    team/mmichelson/sip_options/res/res_sip.c
    team/mmichelson/sip_options/res/res_sip/sip_configuration.c

Modified: team/mmichelson/sip_options/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/include/asterisk/res_sip.h?view=diff&rev=394234&r1=394233&r2=394234
==============================================================================
--- team/mmichelson/sip_options/include/asterisk/res_sip.h (original)
+++ team/mmichelson/sip_options/include/asterisk/res_sip.h Fri Jul 12 16:13:00 2013
@@ -343,6 +343,8 @@
 		AST_STRING_FIELD(sdpsession);
 		/*! Default username to place in From header */
 		AST_STRING_FIELD(fromuser);
+		/*! Domain to place in From header */
+		AST_STRING_FIELD(fromdomain);
 		/*! Username to use when sending MWI NOTIFYs to this endpoint */
 		AST_STRING_FIELD(mwi_from);
 	);

Modified: team/mmichelson/sip_options/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip.c?view=diff&rev=394234&r1=394233&r2=394234
==============================================================================
--- team/mmichelson/sip_options/res/res_sip.c (original)
+++ team/mmichelson/sip_options/res/res_sip.c Fri Jul 12 16:13:00 2013
@@ -473,6 +473,9 @@
 				<configOption name="mwifromuser">
 					<synopsis>Username to use in From header for unsolicited MWI NOTIFYs to this endpoint.</synopsis>
 				</configOption>
+				<configOption name="fromdomain">
+					<synopsis>Domain to user in From header for requests to this endpoint.</synopsis>
+				</configOption>
 			</configObject>
 			<configObject name="auth">
 				<synopsis>Authentication type</synopsis>
@@ -994,7 +997,7 @@
 	return ast_pjsip_endpoint;
 }
 
-static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *user, const pj_str_t *target, pjsip_tpselector *selector)
+static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *user, const char *domain, const pj_str_t *target, pjsip_tpselector *selector)
 {
 	pj_str_t tmp, local_addr;
 	pjsip_uri *uri;
@@ -1037,6 +1040,18 @@
 	/* If the host is IPv6 turn the transport into an IPv6 version */
 	if (pj_strchr(&sip_uri->host, ':') && type < PJSIP_TRANSPORT_START_OTHER) {
 		type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6);
+	}
+
+	if (!ast_strlen_zero(domain)) {
+		from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
+		from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
+				"<%s:%s@%s%s%s>",
+				(pjsip_transport_get_flag_from_type(type) & PJSIP_TRANSPORT_SECURE) ? "sips" : "sip",
+				user,
+				domain,
+				(type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
+				(type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
+		return 0;
 	}
 
 	/* Get the local bound address for the transport that will be used when communicating with the provided URI */
@@ -1129,7 +1144,7 @@
 		return NULL;
 	}
 
-	if (sip_dialog_create_from(dlg->pool, &local_uri, endpoint->fromuser, &remote_uri, &selector)) {
+	if (sip_dialog_create_from(dlg->pool, &local_uri, endpoint->fromuser, endpoint->fromdomain, &remote_uri, &selector)) {
 		pjsip_dlg_terminate(dlg);
 		return NULL;
 	}
@@ -1256,7 +1271,8 @@
 		return -1;
 	}
 
-	if (sip_dialog_create_from(pool, &from, endpoint ? endpoint->fromuser : NULL, &remote_uri, &selector)) {
+	if (sip_dialog_create_from(pool, &from, endpoint ? endpoint->fromuser : NULL,
+				endpoint ? endpoint->fromdomain : NULL, &remote_uri, &selector)) {
 		ast_log(LOG_ERROR, "Unable to create From header for %.*s request to endpoint %s\n",
 				(int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
 		pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);

Modified: team/mmichelson/sip_options/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_options/res/res_sip/sip_configuration.c?view=diff&rev=394234&r1=394233&r2=394234
==============================================================================
--- team/mmichelson/sip_options/res/res_sip/sip_configuration.c (original)
+++ team/mmichelson/sip_options/res/res_sip/sip_configuration.c Fri Jul 12 16:13:00 2013
@@ -674,6 +674,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subminexpiry", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, subminexpiry));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subminexpirey", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, subminexpiry));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fromuser", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromuser));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "fromdomain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromdomain));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwifromuser", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, mwi_from));
 
 	if (ast_sip_initialize_sorcery_transport(sip_sorcery)) {




More information about the svn-commits mailing list