[svn-commits] mmichelson: branch mmichelson/sip_endpoint_reorg r395546 - in /team/mmichelso...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 26 13:40:48 CDT 2013


Author: mmichelson
Date: Fri Jul 26 13:40:46 2013
New Revision: 395546

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395546
Log:
Un-anonymize the structs within an ast_sip_endpoint (except media).

This allows to easily create initialization/destruction functions for the various types,
should they be required. This in turn allows for some string parameters to be moved from
the top-level endpoint structure to places where they belong.

Media will be handled in its own commit since it is a pretty large changeset.


Modified:
    team/mmichelson/sip_endpoint_reorg/include/asterisk/res_sip.h
    team/mmichelson/sip_endpoint_reorg/res/res_sip/sip_configuration.c
    team/mmichelson/sip_endpoint_reorg/res/res_sip_mwi.c
    team/mmichelson/sip_endpoint_reorg/res/res_sip_one_touch_record_info.c

Modified: team/mmichelson/sip_endpoint_reorg/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_endpoint_reorg/include/asterisk/res_sip.h?view=diff&rev=395546&r1=395545&r2=395546
==============================================================================
--- team/mmichelson/sip_endpoint_reorg/include/asterisk/res_sip.h (original)
+++ team/mmichelson/sip_endpoint_reorg/include/asterisk/res_sip.h Fri Jul 26 13:40:46 2013
@@ -317,6 +317,99 @@
 };
 
 /*!
+ * \brief Session timers options
+ */
+struct ast_sip_timer_options {
+	/*! Minimum session expiration period, in seconds */
+	unsigned int min_se;
+	/*! Session expiration period, in seconds */
+	unsigned int sess_expires;
+};
+
+/*!
+ * \brief Endpoint configuration for SIP extensions.
+ *
+ * SIP extensions, in this case refers to features
+ * indicated in Supported or Required headers.
+ */
+struct ast_sip_endpoint_extensions {
+	/*! Enabled SIP extensions */
+	unsigned int flags;
+	/*! Timer options */
+	struct ast_sip_timer_options timer;
+};
+
+struct ast_sip_mwi_configuration {
+	AST_DECLARE_STRING_FIELDS(
+		/*! Configured voicemail boxes for this endpoint. Used for MWI */
+		AST_STRING_FIELD(mailboxes);
+		/*! Username to use when sending MWI NOTIFYs to this endpoint */
+		AST_STRING_FIELD(fromuser);
+	);
+	/* Should mailbox states be combined into a single notification? */
+	unsigned int aggregate;
+};
+
+struct ast_sip_endpoint_subscription_configuration {
+	/*! Indicates if endpoint is allowed to initiate subscriptions */
+	unsigned int allow;
+	/*! The minimum allowed expiration for subscriptions from endpoint */
+	unsigned int minexpiry;
+	/*! Message waiting configuration */
+	struct ast_sip_mwi_configuration mwi;
+};
+
+struct ast_sip_endpoint_nat_configuration {
+	/*! Whether to force using the source IP address/port for sending responses */
+	unsigned int force_rport;
+	/*! Whether to rewrite the Contact header with the source IP address/port or not */
+	unsigned int rewrite_contact;
+};
+
+struct ast_sip_endpoint_id_configuration {
+	struct ast_party_id self;
+	/*! Do we accept identification information from this endpoint */
+	unsigned int trust_inbound;
+	/*! Do we send private identification information to this endpoint? */
+	unsigned int trust_outbound;
+	/*! Do we send P-Asserted-Identity headers to this endpoint? */
+	unsigned int send_pai;
+	/*! Do we send Remote-Party-ID headers to this endpoint? */
+	unsigned int send_rpid;
+	/*! Do we add Diversion headers to applicable outgoing requests/responses? */
+	unsigned int send_diversion;
+	/*! When performing connected line update, which method should be used */
+	enum ast_sip_session_refresh_method refresh_method;
+};
+
+struct ast_sip_endpoint_pickup_configuration {
+	/*! Call group */
+	ast_group_t callgroup;
+	/*! Pickup group */
+	ast_group_t pickupgroup;
+	/*! Named call group */
+	struct ast_namedgroups *named_callgroups;
+	/*! Named pickup group */
+	struct ast_namedgroups *named_pickupgroups;
+};
+
+struct ast_sip_info_recording_configuration {
+	AST_DECLARE_STRING_FIELDS(
+		/*! Feature to enact when one-touch recording INFO with Record: On is received */
+		AST_STRING_FIELD(onfeature);
+		/*! Feature to enact when one-touch recording INFO with Record: Off is received */
+		AST_STRING_FIELD(offfeature);
+	);
+	/*! Is one-touch recording permitted? */
+	unsigned int enabled;
+};
+
+struct ast_sip_endpoint_info_configuration {
+	/*! Configuration for one-touch recording */
+	struct ast_sip_info_recording_configuration recording;
+};
+
+/*!
  * \brief An entity with which Asterisk communicates
  */
 struct ast_sip_endpoint {
@@ -334,18 +427,12 @@
 		AST_STRING_FIELD(mohsuggest);
 		/*! Optional external media address to use in SDP */
 		AST_STRING_FIELD(external_media_address);
-		/*! Configured voicemail boxes for this endpoint. Used for MWI */
-		AST_STRING_FIELD(mailboxes);
 		/*! Configured RTP engine for this endpoint. */
 		AST_STRING_FIELD(rtp_engine);
 		/*! Configured tone zone for this endpoint. */
 		AST_STRING_FIELD(zone);
 		/*! Configured language for this endpoint. */
 		AST_STRING_FIELD(language);
-		/*! Feature to enact when one-touch recording INFO with Record: On is received */
-		AST_STRING_FIELD(recordonfeature);
-		/*! Feature to enact when one-touch recording INFO with Record: Off is received */
-		AST_STRING_FIELD(recordofffeature);
 		/*! SDP origin username */
 		AST_STRING_FIELD(sdpowner);
 		/*! SDP session name */
@@ -354,20 +441,9 @@
 		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);
 	);
-	/*! Configuration for extensions (i.e. Supported and Required headers) */
-	struct {
-		/*! Enabled SIP extensions */
-		unsigned int flags;
-		struct {
-			/*! Minimum session expiration period, in seconds */
-			unsigned int min_se;
-			/*! Session expiration period, in seconds */
-			unsigned int sess_expires;
-		} timer;
-	} extensions;
+	/*! Configuration for extensions */
+	struct ast_sip_endpoint_extensions extensions;
 	/*! Configuration relating to media */
 	struct {
 		/*! RTP media configuration */
@@ -413,55 +489,12 @@
 		/*! Priority for video streams */
 		unsigned int cos_video;
 	} media;
-	struct {
-		/*! Indicates if endpoint is allowed to initiate subscriptions */
-		unsigned int allow;
-		/*! The minimum allowed expiration for subscriptions from endpoint */
-		unsigned int minexpiry;
-		struct {
-			/*! Should unsolicited MWI be aggregated into a single NOTIFY? */
-			unsigned int aggregate;
-		} mwi;
-	} subscription;
-	struct {
-		/*! Whether to force using the source IP address/port for sending responses */
-		unsigned int force_rport;
-		/*! Whether to rewrite the Contact header with the source IP address/port or not */
-		unsigned int rewrite_contact;
-	} nat;
-	struct {
-		struct ast_party_id self;
-		/*! Do we accept identification information from this endpoint */
-		unsigned int trust_inbound;
-		/*! Do we send private identification information to this endpoint? */
-		unsigned int trust_outbound;
-		/*! Do we send P-Asserted-Identity headers to this endpoint? */
-		unsigned int send_pai;
-		/*! Do we send Remote-Party-ID headers to this endpoint? */
-		unsigned int send_rpid;
-		/*! Do we add Diversion headers to applicable outgoing requests/responses? */
-		unsigned int send_diversion;
-		/*! When performing connected line update, which method should be used */
-		enum ast_sip_session_refresh_method refresh_method;
-	} id;
-	struct {
-		/*! Call group */
-		ast_group_t callgroup;
-		/*! Pickup group */
-		ast_group_t pickupgroup;
-		/*! Named call group */
-		struct ast_namedgroups *named_callgroups;
-		/*! Named pickup group */
-		struct ast_namedgroups *named_pickupgroups;
-	} pickup;
+	struct ast_sip_endpoint_subscription_configuration subscription;
+	struct ast_sip_endpoint_nat_configuration nat;
+	struct ast_sip_endpoint_id_configuration id;
 	/*! Configuration options for INFO packages */
-	struct {
-		/*! Configuration for one-touch recording */
-		struct {
-			/*! Is one-touch recording permitted? */
-			unsigned int enabled;
-		} recording;
-	} info;
+	struct ast_sip_endpoint_info_configuration info;
+	struct ast_sip_endpoint_pickup_configuration pickup;
 	/*! Domain to which this endpoint belongs */
 	struct ast_sip_domain *domain;
 	/*! Address of record for incoming registrations */

Modified: team/mmichelson/sip_endpoint_reorg/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_endpoint_reorg/res/res_sip/sip_configuration.c?view=diff&rev=395546&r1=395545&r2=395546
==============================================================================
--- team/mmichelson/sip_endpoint_reorg/res/res_sip/sip_configuration.c (original)
+++ team/mmichelson/sip_endpoint_reorg/res/res_sip/sip_configuration.c Fri Jul 26 13:40:46 2013
@@ -650,7 +650,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_pai", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_pai));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_rpid", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_rpid));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_diversion", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.send_diversion));
-	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, mailboxes));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mailboxes", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.mailboxes));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "aggregate_mwi", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.mwi.aggregate));
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "media_encryption", "no", media_encryption_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "use_avpf", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.rtp.use_avpf));
@@ -664,8 +664,8 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtpengine", "asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, rtp_engine));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tonezone", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, zone));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "language", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, language));
-	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "recordonfeature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, recordonfeature));
-	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "recordofffeature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, recordofffeature));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "recordonfeature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.onfeature));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "recordofffeature", "automixmon", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, info.recording.offfeature));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allowtransfer", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allowtransfer));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdpowner", "-", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, sdpowner));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdpsession", "Asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, sdpsession));
@@ -678,7 +678,7 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "subminexpirey", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, subscription.minexpiry));
 	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));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwifromuser", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.fromuser));
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtlsverify", "", dtls_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtlsrekey", "", dtls_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtlscertfile", "", dtls_handler, NULL, 0, 0);
@@ -752,6 +752,16 @@
 	return 0;
 }
 
+static void subscription_configuration_destroy(struct ast_sip_endpoint_subscription_configuration *subscription)
+{
+	ast_string_field_free_memory(&subscription->mwi);
+}
+
+static void info_configuration_destroy(struct ast_sip_endpoint_info_configuration *info)
+{
+	ast_string_field_free_memory(&info->recording);
+}
+
 static void endpoint_destructor(void* obj)
 {
 	struct ast_sip_endpoint *endpoint = obj;
@@ -761,6 +771,8 @@
 	if (endpoint->media.codecs) {
 		ast_format_cap_destroy(endpoint->media.codecs);
 	}
+	subscription_configuration_destroy(&endpoint->subscription);
+	info_configuration_destroy(&endpoint->info);
 	ast_sip_auth_array_destroy(&endpoint->inbound_auths);
 	ast_sip_auth_array_destroy(&endpoint->outbound_auths);
 	ast_party_id_free(&endpoint->id.self);
@@ -769,6 +781,16 @@
 	ao2_cleanup(endpoint->persistent);
 }
 
+static int init_subscription_configuration(struct ast_sip_endpoint_subscription_configuration *subscription)
+{
+	return ast_string_field_init(&subscription->mwi, 64);
+}
+
+static int init_info_configuration(struct ast_sip_endpoint_info_configuration *info)
+{
+	return ast_string_field_init(&info->recording, 32);
+}
+
 void *ast_sip_endpoint_alloc(const char *name)
 {
 	struct ast_sip_endpoint *endpoint = ast_sorcery_generic_alloc(sizeof(*endpoint), endpoint_destructor);
@@ -780,6 +802,14 @@
 		return NULL;
 	}
 	if (!(endpoint->media.codecs = ast_format_cap_alloc_nolock())) {
+		ao2_cleanup(endpoint);
+		return NULL;
+	}
+	if (init_subscription_configuration(&endpoint->subscription)) {
+		ao2_cleanup(endpoint);
+		return NULL;
+	}
+	if (init_info_configuration(&endpoint->info)) {
 		ao2_cleanup(endpoint);
 		return NULL;
 	}

Modified: team/mmichelson/sip_endpoint_reorg/res/res_sip_mwi.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_endpoint_reorg/res/res_sip_mwi.c?view=diff&rev=395546&r1=395545&r2=395546
==============================================================================
--- team/mmichelson/sip_endpoint_reorg/res/res_sip_mwi.c (original)
+++ team/mmichelson/sip_endpoint_reorg/res/res_sip_mwi.c Fri Jul 26 13:40:46 2013
@@ -281,12 +281,12 @@
 		return 0;
 	}
 
-	if (!ast_strlen_zero(endpoint->mwi_from)) {
+	if (!ast_strlen_zero(endpoint->subscription.mwi.fromuser)) {
 		pjsip_fromto_hdr *from = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_FROM, NULL);
 		pjsip_name_addr *from_name_addr = (pjsip_name_addr *) from->uri;
 		pjsip_sip_uri *from_uri = pjsip_uri_get_uri(from_name_addr->uri);
 
-		pj_strdup2(tdata->pool, &from_uri->user, endpoint->mwi_from);
+		pj_strdup2(tdata->pool, &from_uri->user, endpoint->subscription.mwi.fromuser);
 	}
 
 	switch (state) {
@@ -627,7 +627,7 @@
 	char *mailboxes;
 	char *mailbox;
 
-	if (ast_strlen_zero(endpoint->mailboxes)) {
+	if (ast_strlen_zero(endpoint->subscription.mwi.mailboxes)) {
 		return 0;
 	}
 
@@ -638,7 +638,7 @@
 		}
 	}
 
-	mailboxes = ast_strdupa(endpoint->mailboxes);
+	mailboxes = ast_strdupa(endpoint->subscription.mwi.mailboxes);
 	while ((mailbox = strsep(&mailboxes, ","))) {
 		struct mwi_subscription *sub = aggregate_sub ?:
 			mwi_subscription_alloc(endpoint, AST_SIP_SUBSCRIBER, 0, NULL);

Modified: team/mmichelson/sip_endpoint_reorg/res/res_sip_one_touch_record_info.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_endpoint_reorg/res/res_sip_one_touch_record_info.c?view=diff&rev=395546&r1=395545&r2=395546
==============================================================================
--- team/mmichelson/sip_endpoint_reorg/res/res_sip_one_touch_record_info.c (original)
+++ team/mmichelson/sip_endpoint_reorg/res/res_sip_one_touch_record_info.c Fri Jul 26 13:40:46 2013
@@ -62,9 +62,9 @@
 	}
 
 	if (!pj_stricmp2(&record->hvalue, "on")) {
-		feature = session->endpoint->recordonfeature;
+		feature = session->endpoint->info.recording.onfeature;
 	} else if (!pj_stricmp2(&record->hvalue, "off")) {
-		feature = session->endpoint->recordofffeature;
+		feature = session->endpoint->info.recording.offfeature;
 	} else {
 		/* Don't send response because another module may handle this */
 		return 0;




More information about the svn-commits mailing list