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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 7 12:04:36 CST 2009


Author: mmichelson
Date: Mon Dec  7 12:04:35 2009
New Revision: 233470

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=233470
Log:
Stuff.

Now we will not register the SIP CC agent if XML support
is not available. In addition, if a peer is defined with a "native"
cc_agent_policy, it will be changed to "never" and a warning will
be emitted explaining why. Also, al CC ESC code will not be compiled
if XML support is non-existent.

A user may still set a SIP caller's agent policy to "native" using
the CALLCOMPLETION dialplan function. However, when it comes time
to attempt creation of the agent during a call, the CC engine will
be unable to since the SIP CC agent was not registered. The result
will be that the CC transaction will be immediately torn down. In other
words, things will work fine.


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=233470&r1=233469&r2=233470
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Mon Dec  7 12:04:35 2009
@@ -1959,12 +1959,14 @@
 	const esc_publish_callback remove_handler;
 };
 
+#ifdef HAVE_XML
 static int cc_esc_publish_handler(struct sip_pvt *pvt, struct sip_request *req, struct event_state_compositor *esc, struct sip_esc_entry *esc_entry);
 
 static const struct sip_esc_publish_callbacks cc_esc_publish_callbacks = {
 	.initial_handler = cc_esc_publish_handler,
 	.modify_handler = cc_esc_publish_handler,
 };
+#endif
 
 /*!
  * \brief The Event State Compositors
@@ -1984,11 +1986,14 @@
 	const struct sip_esc_publish_callbacks *callbacks;
 	struct ao2_container *compositor;
 } event_state_compositors [] = {
+#ifdef HAVE_XML
 	{CALL_COMPLETION, "call-completion", &cc_esc_publish_callbacks},
+#endif
 };
 
 static const int ESC_MAX_BUCKETS = 37;
 
+#ifdef HAVE_XML
 /* I don't actually know if I'll need to do anything here yet,
  * but this helps to fit the skeleton that I've designed for
  * PUBLISH support
@@ -1997,52 +2002,6 @@
 {
 	/* XXX STUB */
 	return;
-}
-
-static void esc_entry_destructor(void *obj)
-{
-	struct sip_esc_entry *esc_entry = obj;
-	if (esc_entry->sched_id > -1) {
-		AST_SCHED_DEL(sched, esc_entry->sched_id);
-	}
-	if (!strcasecmp(esc_entry->event, "call-completion")) {
-		cc_esc_destructor(esc_entry);
-	}
-}
-
-static int esc_hash_fn(const void *obj, const int flags)
-{
-	const struct sip_esc_entry *entry = obj;
-	return ast_str_hash(entry->entity_tag);
-}
-
-static int esc_cmp_fn(void *obj, void *arg, int flags)
-{
-	struct sip_esc_entry *entry1 = obj;
-	struct sip_esc_entry *entry2 = arg;
-
-	return (!strcmp(entry1->entity_tag, entry2->entity_tag)) ? (CMP_MATCH | CMP_STOP) : 0;
-}
-
-static struct event_state_compositor *get_esc(const char * const event_package) {
-	int i;
-	for (i = 0; i < ARRAY_LEN(event_state_compositors); i++) {
-		if (!strcasecmp(event_package, event_state_compositors[i].name)) {
-			return &event_state_compositors[i];
-		}
-	}
-	return NULL;
-}
-
-static struct sip_esc_entry *get_esc_entry(const char * entity_tag, struct event_state_compositor *esc) {
-	struct sip_esc_entry *entry;
-	struct sip_esc_entry finder;
-
-	ast_copy_string(finder.entity_tag, entity_tag, sizeof(finder.entity_tag));
-
-	entry = ao2_find(esc->compositor, &finder, OBJ_POINTER);
-
-	return entry;
 }
 
 static int cc_esc_init(struct sip_esc_entry *sip_esc_entry, struct sip_request *req)
@@ -2066,6 +2025,55 @@
 
 	return 0;
 }
+#endif
+
+static void esc_entry_destructor(void *obj)
+{
+	struct sip_esc_entry *esc_entry = obj;
+	if (esc_entry->sched_id > -1) {
+		AST_SCHED_DEL(sched, esc_entry->sched_id);
+	}
+#ifdef HAVE_XML
+	if (!strcasecmp(esc_entry->event, "call-completion")) {
+		cc_esc_destructor(esc_entry);
+	}
+#endif
+}
+
+static int esc_hash_fn(const void *obj, const int flags)
+{
+	const struct sip_esc_entry *entry = obj;
+	return ast_str_hash(entry->entity_tag);
+}
+
+static int esc_cmp_fn(void *obj, void *arg, int flags)
+{
+	struct sip_esc_entry *entry1 = obj;
+	struct sip_esc_entry *entry2 = arg;
+
+	return (!strcmp(entry1->entity_tag, entry2->entity_tag)) ? (CMP_MATCH | CMP_STOP) : 0;
+}
+
+static struct event_state_compositor *get_esc(const char * const event_package) {
+	int i;
+	for (i = 0; i < ARRAY_LEN(event_state_compositors); i++) {
+		if (!strcasecmp(event_package, event_state_compositors[i].name)) {
+			return &event_state_compositors[i];
+		}
+	}
+	return NULL;
+}
+
+static struct sip_esc_entry *get_esc_entry(const char * entity_tag, struct event_state_compositor *esc) {
+	struct sip_esc_entry *entry;
+	struct sip_esc_entry finder;
+
+	ast_copy_string(finder.entity_tag, entity_tag, sizeof(finder.entity_tag));
+
+	entry = ao2_find(esc->compositor, &finder, OBJ_POINTER);
+
+	return entry;
+}
 
 static int publish_expire(const void *data)
 {
@@ -2095,7 +2103,6 @@
 static struct sip_esc_entry *create_esc_entry(struct event_state_compositor *esc, struct sip_request *req, const int expires)
 {
 	struct sip_esc_entry *esc_entry;
-	int res = -1;
 	int expires_ms;
 
 	if (!(esc_entry = ao2_alloc(sizeof(*esc_entry), esc_entry_destructor))) {
@@ -2105,9 +2112,11 @@
 	esc_entry->event = esc->name;
 
 	switch (esc->event) {
+#ifdef HAVE_XML
 	case CALL_COMPLETION:
-		res = cc_esc_init(esc_entry, req);
+		cc_esc_init(esc_entry, req);
 		break;
+#endif
 	default:
 		break;
 	}
@@ -23323,6 +23332,7 @@
 	return SIP_PUBLISH_UNKNOWN;
 }
 
+#ifdef HAVE_XML
 static int pidf_validate_tuple(struct ast_xml_node *tuple_node)
 {
 	const char *id;
@@ -23556,6 +23566,8 @@
 	ast_xml_close(pidf_doc);
 	return 0;
 }
+
+#endif /* HAVE_XML */
 
 static int handle_sip_publish_initial(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const int expires)
 {
@@ -26735,6 +26747,11 @@
 		}
 	}
 
+	if (!can_parse_xml && (ast_get_cc_agent_policy(peer->cc_params) == AST_CC_AGENT_NATIVE)) {
+		ast_log(LOG_WARNING, "Peer %s has a cc_agent_policy of 'native' but required libxml2 dependency is not installed. Changing policy to 'never'\n", peer->name);
+		ast_set_cc_agent_policy(peer->cc_params, AST_CC_AGENT_NEVER);
+	}
+
 	if (!peer->default_outbound_transport) {
 		/* Set default set of transports */
 		peer->transports = default_transports;
@@ -28482,8 +28499,13 @@
 	if (sip_epa_register(&cc_epa_static_data)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	if (ast_cc_agent_register(&sip_cc_agent_callbacks)) {
-		return AST_MODULE_LOAD_DECLINE;
+	if (can_parse_xml) {
+		/* SIP CC agents require the ability to parse XML PIDF bodies
+		 * in incoming PUBLISH requests
+		 */
+		if (ast_cc_agent_register(&sip_cc_agent_callbacks)) {
+			return AST_MODULE_LOAD_DECLINE;
+		}
 	}
 	if (ast_cc_monitor_register(&sip_cc_monitor_callbacks)) {
 		return AST_MODULE_LOAD_DECLINE;




More information about the svn-commits mailing list