[svn-commits] kmoore: branch kmoore/pjsip_path_support r403157 - in /team/kmoore/pjsip_path...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Nov 25 22:05:00 CST 2013


Author: kmoore
Date: Mon Nov 25 22:04:59 2013
New Revision: 403157

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403157
Log:
Fix merge conflict

Added:
    team/kmoore/pjsip_path_support/include/asterisk/stasis_app_device_state.h
      - copied unchanged from r403135, trunk/include/asterisk/stasis_app_device_state.h
    team/kmoore/pjsip_path_support/res/ari/resource_device_states.c
      - copied unchanged from r403135, trunk/res/ari/resource_device_states.c
    team/kmoore/pjsip_path_support/res/ari/resource_device_states.h
      - copied unchanged from r403135, trunk/res/ari/resource_device_states.h
    team/kmoore/pjsip_path_support/res/res_ari_device_states.c
      - copied unchanged from r403135, trunk/res/res_ari_device_states.c
    team/kmoore/pjsip_path_support/res/res_stasis_device_state.c
      - copied unchanged from r403135, trunk/res/res_stasis_device_state.c
    team/kmoore/pjsip_path_support/res/res_stasis_device_state.exports.in
      - copied unchanged from r403135, trunk/res/res_stasis_device_state.exports.in
    team/kmoore/pjsip_path_support/rest-api/api-docs/deviceStates.json
      - copied unchanged from r403135, trunk/rest-api/api-docs/deviceStates.json
Modified:
    team/kmoore/pjsip_path_support/   (props changed)
    team/kmoore/pjsip_path_support/include/asterisk/acl.h
    team/kmoore/pjsip_path_support/include/asterisk/devicestate.h
    team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h
    team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_pubsub.h
    team/kmoore/pjsip_path_support/include/asterisk/sorcery.h
    team/kmoore/pjsip_path_support/include/asterisk/stasis_app.h
    team/kmoore/pjsip_path_support/include/asterisk/strings.h
    team/kmoore/pjsip_path_support/include/asterisk/utils.h
    team/kmoore/pjsip_path_support/main/acl.c
    team/kmoore/pjsip_path_support/main/devicestate.c
    team/kmoore/pjsip_path_support/main/sorcery.c
    team/kmoore/pjsip_path_support/main/utils.c
    team/kmoore/pjsip_path_support/res/ari.make
    team/kmoore/pjsip_path_support/res/ari/ari_model_validators.c
    team/kmoore/pjsip_path_support/res/ari/ari_model_validators.h
    team/kmoore/pjsip_path_support/res/ari/resource_applications.h
    team/kmoore/pjsip_path_support/res/res_pjsip.c
    team/kmoore/pjsip_path_support/res/res_pjsip.exports.in
    team/kmoore/pjsip_path_support/res/res_pjsip/config_auth.c
    team/kmoore/pjsip_path_support/res/res_pjsip/config_transport.c
    team/kmoore/pjsip_path_support/res/res_pjsip/include/res_pjsip_private.h
    team/kmoore/pjsip_path_support/res/res_pjsip/location.c
    team/kmoore/pjsip_path_support/res/res_pjsip/pjsip_configuration.c
    team/kmoore/pjsip_path_support/res/res_pjsip_endpoint_identifier_ip.c
    team/kmoore/pjsip_path_support/res/res_pjsip_exten_state.c
    team/kmoore/pjsip_path_support/res/res_pjsip_mwi.c
    team/kmoore/pjsip_path_support/res/res_pjsip_outbound_registration.c
    team/kmoore/pjsip_path_support/res/res_pjsip_pubsub.c
    team/kmoore/pjsip_path_support/res/res_pjsip_registrar.c
    team/kmoore/pjsip_path_support/res/res_stasis.c
    team/kmoore/pjsip_path_support/res/stasis/app.c
    team/kmoore/pjsip_path_support/res/stasis/app.h
    team/kmoore/pjsip_path_support/rest-api-templates/ari.make.mustache
    team/kmoore/pjsip_path_support/rest-api/api-docs/applications.json
    team/kmoore/pjsip_path_support/rest-api/api-docs/events.json
    team/kmoore/pjsip_path_support/rest-api/resources.json

Propchange: team/kmoore/pjsip_path_support/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/kmoore/pjsip_path_support/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Mon Nov 25 22:04:59 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402993,403016,403022,403069,403082,403094,403117,403119
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402993,403016,403022,403069,403082,403094,403117,403119,403131,403134

Propchange: team/kmoore/pjsip_path_support/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Nov 25 22:04:59 2013
@@ -1,1 +1,1 @@
-/trunk:1-403121
+/trunk:1-403156

Modified: team/kmoore/pjsip_path_support/include/asterisk/acl.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/acl.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/acl.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/acl.h Mon Nov 25 22:04:59 2013
@@ -133,6 +133,13 @@
  * \return The head of the HA list
  */
 struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error);
+
+/*!
+ * \brief Convert HAs to a comma separated string value
+ * \param ha the starting ha head
+ * \param buf string buffer to convert data to
+ */
+void ast_ha_join(const struct ast_ha *ha, struct ast_str **buf);
 
 /*!
  * \brief Add a rule to an ACL struct

Modified: team/kmoore/pjsip_path_support/include/asterisk/devicestate.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/devicestate.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/devicestate.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/devicestate.h Mon Nov 25 22:04:59 2013
@@ -325,6 +325,15 @@
 struct stasis_message_type *ast_device_state_message_type(void);
 
 /*!
+ * \brief Clear the device from the stasis cache.
+ * \param The device to clear
+ * \retval 0 if successful
+ * \retval -1 nothing to clear
+ * \since 12
+ */
+int ast_device_state_clear_cache(const char *device);
+
+/*!
  * \brief Initialize the device state core
  * \retval 0 Success
  * \retval -1 Failure

Modified: team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h Mon Nov 25 22:04:59 2013
@@ -1581,6 +1581,156 @@
 #define ast_sip_mod_data_set(pool, mod_data, id, key, val)		\
 	mod_data[id] = ast_sip_dict_set(pool, mod_data[id], key, val)
 
+/*!
+ * \brief Function pointer for contact callbacks.
+ */
+typedef int (*on_contact_t)(const struct ast_sip_aor *aor,
+			    const struct ast_sip_contact *contact,
+			    int last, void *arg);
+
+/*!
+ * \brief For every contact on an AOR call the given 'on_contact' handler.
+ *
+ * \param aor the aor containing a list of contacts to iterate
+ * \param on_contact callback on each contact on an AOR
+ * \param arg user data passed to handler
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_for_each_contact(const struct ast_sip_aor *aor,
+			     on_contact_t on_contact, void *arg);
+
+/*!
+ * \brief Handler used to convert a contact to a string.
+ *
+ * \param aor the aor containing a list of contacts to iterate
+ * \param contact the contact to convert
+ * \param last is this the last contact
+ * \param arg user data passed to handler
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_contact_to_str(const struct ast_sip_aor *aor,
+			   const struct ast_sip_contact *contact,
+			   int last, void *arg);
+
+/*!
+ * \brief For every aor in the comma separated aors string call the
+ *        given 'on_aor' handler.
+ *
+ * \param aors a comma separated list of aors
+ * \param on_aor callback for each aor
+ * \param arg user data passed to handler
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg);
+
+/*!
+ * \brief For every auth in the array call the given 'on_auth' handler.
+ *
+ * \param array an array of auths
+ * \param on_auth callback for each auth
+ * \param arg user data passed to handler
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_for_each_auth(const struct ast_sip_auth_array *array,
+			  ao2_callback_fn on_auth, void *arg);
+
+/*!
+ * \brief Converts the given auth type to a string
+ *
+ * \param type the auth type to convert
+ * \retval a string representative of the auth type
+ */
+const char *ast_sip_auth_type_to_str(enum ast_sip_auth_type type);
+
+/*!
+ * \brief Converts an auths array to a string of comma separated values
+ *
+ * \param auths an auth array
+ * \param buf the string buffer to write the object data
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_auths_to_str(const struct ast_sip_auth_array *auths, char **buf);
+
+/*
+ * \brief AMI variable container
+ */
+struct ast_sip_ami {
+	/*! Manager session */
+	struct mansession *s;
+	/*! Manager message */
+	const struct message *m;
+	/*! user specified argument data */
+	void *arg;
+};
+
+/*!
+ * \brief Creates a string to store AMI event data in.
+ *
+ * \param event the event to set
+ * \param ami AMI session and message container
+ * \retval an initialized ast_str or NULL on error.
+ */
+struct ast_str *ast_sip_create_ami_event(const char *event,
+					 struct ast_sip_ami *ami);
+
+/*!
+ * \brief An entity responsible formatting endpoint information.
+ */
+struct ast_sip_endpoint_formatter {
+	/*!
+	 * \brief Callback used to format endpoint information over AMI.
+	 */
+	int (*format_ami)(const struct ast_sip_endpoint *endpoint,
+			  struct ast_sip_ami *ami);
+	AST_RWLIST_ENTRY(ast_sip_endpoint_formatter) next;
+};
+
+/*!
+ * \brief Register an endpoint formatter.
+ *
+ * \param obj the formatter to register
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);
+
+/*!
+ * \brief Unregister an endpoint formatter.
+ *
+ * \param obj the formatter to unregister
+ */
+void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj);
+
+/*!
+ * \brief Converts a sorcery object to a string of object properties.
+ *
+ * \param obj the sorcery object to convert
+ * \param str the string buffer to write the object data
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf);
+
+/*!
+ * \brief Formats the endpoint and sends over AMI.
+ *
+ * \param endpoint the endpoint to format and send
+ * \param endpoint ami AMI variable container
+ * \param count the number of formatters operated on
+ * \retval 0 Success, otherwise non-zero on error
+ */
+int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint,
+				struct ast_sip_ami *ami, int *count);
+
+/*!
+ * \brief Format auth details for AMI.
+ *
+ * \param auths an auth array
+ * \param ami ami variable container
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_format_auths_ami(const struct ast_sip_auth_array *auths,
+			     struct ast_sip_ami *ami);
+
 enum ast_sip_supplement_priority {
 	/*! Top priority. Supplements with this priority are those that need to run before any others */
 	AST_SIP_SESSION_SUPPLEMENT_PRIORITY_FIRST = 0,

Modified: team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_pubsub.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_pubsub.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_pubsub.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_pubsub.h Mon Nov 25 22:04:59 2013
@@ -252,7 +252,7 @@
 	 * during this callback. The handler MUST, however, begin the destruction
 	 * process for the subscription during this callback.
 	 */
-   void (*subscription_shutdown)(struct ast_sip_subscription *subscription);
+	void (*subscription_shutdown)(struct ast_sip_subscription *subscription);
 
 	/*!
 	 * \brief Called when a SUBSCRIBE arrives in order to create a new subscription
@@ -366,6 +366,16 @@
 	 * \retval non-zero Failure
 	 */
 	int (*refresh_subscription)(struct ast_sip_subscription *sub);
+
+	/*!
+	 * \brief Converts the subscriber to AMI
+	 *
+	 * This is a subscriber callback.
+	 *
+	 * \param sub The subscription
+	 * \param buf The string to write AMI data
+	 */
+	void (*to_ami)(struct ast_sip_subscription *sub, struct ast_str **buf);
 	AST_LIST_ENTRY(ast_sip_subscription_handler) next;
 };
 

Modified: team/kmoore/pjsip_path_support/include/asterisk/sorcery.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/sorcery.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/sorcery.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/sorcery.h Mon Nov 25 22:04:59 2013
@@ -102,6 +102,9 @@
 /*! \brief Maximum size of an object type */
 #define MAX_OBJECT_TYPE 64
 
+/*! \brief Maximum length of an object field name */
+#define MAX_OBJECT_FIELD 128
+
 /*!
  * \brief Retrieval flags
  */

Modified: team/kmoore/pjsip_path_support/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/stasis_app.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/stasis_app.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/stasis_app.h Mon Nov 25 22:04:59 2013
@@ -111,6 +111,18 @@
  */
 int stasis_app_send(const char *app_name, struct ast_json *message);
 
+/*! \brief Forward declare app */
+struct stasis_app;
+
+/*!
+ * \brief Retrieve an application's name
+ *
+ * \param app An application
+ *
+ * \return The name of the application.
+ */
+const char *stasis_app_name(const struct stasis_app *app);
+
 /*!
  * \brief Return the JSON representation of a Stasis application.
  *
@@ -120,6 +132,102 @@
  * \return \c NULL on error.
  */
 struct ast_json *stasis_app_to_json(const char *app_name);
+
+/*!
+ * \brief Event source information and callbacks.
+ */
+struct stasis_app_event_source {
+	/*! \brief The scheme to match against on [un]subscribes */
+	const char *scheme;
+
+	/*!
+	 * \brief Find an event source data object by the given id/name.
+	 *
+	 * \param app Application
+	 * \param id A unique identifier to search on
+	 *
+	 * \return The data object associated with the id/name.
+	 */
+	void *(*find)(const struct stasis_app *app, const char *id);
+
+	/*!
+	 * \brief Subscribe an application to an event source.
+	 *
+	 * \param app Application
+	 * \param obj an event source data object
+	 *
+	 * \return 0 on success, failure code otherwise
+	 */
+	int (*subscribe)(struct stasis_app *app, void *obj);
+
+	/*!
+	 * \brief Cancel the subscription an app has to an event source.
+	 *
+	 * \param app Application
+	 * \param id a previously subscribed object id
+	 *
+	 * \return 0 on success, failure code otherwise
+	 */
+	int (*unsubscribe)(struct stasis_app *app, const char *id);
+
+	/*!
+	 * \brief Find an event source by the given id/name.
+	 *
+	 * \param app Application
+	 * \param id A unique identifier to check
+	 *
+	 * \return true if id is subscribed, false otherwise.
+	 */
+	int (*is_subscribed)(struct stasis_app *app, const char *id);
+
+	/*!
+	 * \brief Convert event source data to json
+	 *
+	 * \param app Application
+	 * \param id json object to fill
+	 */
+	void (*to_json)(const struct stasis_app *app, struct ast_json *json);
+
+	/*! Next item in the list */
+	AST_LIST_ENTRY(stasis_app_event_source) next;
+};
+
+/*!
+ * \brief Register an application event source.
+ *
+ * \param obj the event source to register
+ */
+void stasis_app_register_event_source(struct stasis_app_event_source *obj);
+
+/*!
+ * \brief Register core event sources.
+ */
+void stasis_app_register_event_sources(void);
+
+/*!
+ * \brief Checks to see if the given object is a core event source
+ *
+ * \note core event sources are currently only endpoint, bridge, and channel.
+ *
+ * \param obj event source object to check
+ *
+ * \return non-zero if core event source, otherwise 0 (false)
+
+ */
+int stasis_app_is_core_event_source(struct stasis_app_event_source *obj);
+
+/*!
+ * \brief Unregister an application event source.
+ *
+ * \param obj the event source to unregister
+ */
+void stasis_app_unregister_event_source(struct stasis_app_event_source *obj);
+
+/*!
+ * \brief Unregister core event sources.
+ */
+void stasis_app_unregister_event_sources(void);
+
 
 /*! \brief Return code for stasis_app_[un]subscribe */
 enum stasis_app_subscribe_res {

Modified: team/kmoore/pjsip_path_support/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/strings.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/strings.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/strings.h Mon Nov 25 22:04:59 2013
@@ -332,7 +332,23 @@
 int attribute_pure ast_false(const char *val);
 
 /*
- *  \brief Join an array of strings into a single string.
+ * \brief Join an array of strings into a single string.
+ * \param s the resulting string buffer
+ * \param len the length of the result buffer, s
+ * \param w an array of strings to join.
+ * \param size the number of elements to join
+ * \param delim delimiter between elements
+ *
+ * This function will join all of the strings in the array 'w' into a single
+ * string.  It will also place 'delim' in the result buffer in between each
+ * string from 'w'.
+ * \since 12
+*/
+void ast_join_delim(char *s, size_t len, const char * const w[],
+		    unsigned int size, char delim);
+
+/*
+ * \brief Join an array of strings into a single string.
  * \param s the resulting string buffer
  * \param len the length of the result buffer, s
  * \param w an array of strings to join.
@@ -341,7 +357,33 @@
  * string.  It will also place a space in the result buffer in between each
  * string from 'w'.
 */
-void ast_join(char *s, size_t len, const char * const w[]);
+#define ast_join(s, len, w) ast_join_delim(s, len, w, -1, ' ')
+
+/*
+ * \brief Attempts to convert the given string to camel case using
+ *        the specified delimiter.
+ *
+ * note - returned string needs to be freed
+ *
+ * \param s the string to convert
+ * \param delim delimiter to parse out
+ *
+ * \retval The string converted to "CamelCase"
+ * \since 12
+*/
+char *ast_to_camel_case_delim(const char *s, const char *delim);
+
+/*
+ * \brief Attempts to convert the given string to camel case using
+ *        an underscore as the specified delimiter.
+ *
+ * note - returned string needs to be freed
+ *
+ * \param s the string to convert
+ *
+ * \retval The string converted to "CamelCase"
+*/
+#define ast_to_camel_case(s) ast_to_camel_case_delim(s, "_")
 
 /*
   \brief Parse a time (integer) string.

Modified: team/kmoore/pjsip_path_support/include/asterisk/utils.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/utils.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/utils.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/utils.h Mon Nov 25 22:04:59 2013
@@ -755,6 +755,24 @@
 
 #define ARRAY_LEN(a) (size_t) (sizeof(a) / sizeof(0[a]))
 
+/*!
+ * \brief Checks to see if value is within the given bounds
+ *
+ * \param v the value to check
+ * \param min minimum lower bound (inclusive)
+ * \param max maximum upper bound (inclusive)
+ * \return 0 if value out of bounds, otherwise true (non-zero)
+ */
+#define IN_BOUNDS(v, min, max) ((v) >= (min)) && ((v) <= (max))
+
+/*!
+ * \brief Checks to see if value is within the bounds of the given array
+ *
+ * \param v the value to check
+ * \param a the array to bound check
+ * \return 0 if value out of bounds, otherwise true (non-zero)
+ */
+#define ARRAY_IN_BOUNDS(v, a) IN_BOUNDS(v, 0, ARRAY_LEN(a) - 1)
 
 /* Definition for Digest authorization */
 struct ast_http_digest {

Modified: team/kmoore/pjsip_path_support/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/acl.c?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/main/acl.c (original)
+++ team/kmoore/pjsip_path_support/main/acl.c Mon Nov 25 22:04:59 2013
@@ -662,6 +662,19 @@
 	}
 
 	return ret;
+}
+
+void ast_ha_join(const struct ast_ha *ha, struct ast_str **buf)
+{
+	for (; ha; ha = ha->next) {
+		const char *addr = ast_strdupa(ast_sockaddr_stringify_addr(&ha->addr));
+		ast_str_append(buf, 0, "%s%s/%s",
+			       ha->sense == AST_SENSE_ALLOW ? "!" : "",
+			       addr, ast_sockaddr_stringify_addr(&ha->netmask));
+		if (ha->next) {
+			ast_str_append(buf, 0, ",");
+		}
+	}
 }
 
 enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose)

Modified: team/kmoore/pjsip_path_support/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/devicestate.c?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/main/devicestate.c (original)
+++ team/kmoore/pjsip_path_support/main/devicestate.c Mon Nov 25 22:04:59 2013
@@ -734,6 +734,22 @@
 	return stasis_topic_pool_get_topic(device_state_topic_pool, device);
 }
 
+int ast_device_state_clear_cache(const char *device)
+{
+	RAII_VAR(struct stasis_message *, cached_msg, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+
+	if (!(cached_msg = stasis_cache_get(ast_device_state_cache(),
+					    ast_device_state_message_type(), device))) {
+		/* nothing to clear */
+		return -1;
+	}
+
+	msg = stasis_cache_clear_create(cached_msg);
+	stasis_publish(ast_device_state_topic(device), msg);
+	return 0;
+}
+
 int ast_publish_device_state_full(
 			const char *device,
 			enum ast_device_state state,

Modified: team/kmoore/pjsip_path_support/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/sorcery.c?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/main/sorcery.c (original)
+++ team/kmoore/pjsip_path_support/main/sorcery.c Mon Nov 25 22:04:59 2013
@@ -52,9 +52,6 @@
 /*! \brief Number of buckets for types (should be prime for performance reasons) */
 #define TYPE_BUCKETS 53
 
-/*! \brief Maximum length of an object field name */
-#define MAX_OBJECT_FIELD 128
-
 /*! \brief Thread pool for observers */
 static struct ast_threadpool *threadpool;
 

Modified: team/kmoore/pjsip_path_support/main/utils.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/utils.c?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/main/utils.c (original)
+++ team/kmoore/pjsip_path_support/main/utils.c Mon Nov 25 22:04:59 2013
@@ -1707,7 +1707,7 @@
 	return dataPut;
 }
 
-void ast_join(char *s, size_t len, const char * const w[])
+void ast_join_delim(char *s, size_t len, const char * const w[], unsigned int size, char delim)
 {
 	int x, ofs = 0;
 	const char *src;
@@ -1715,15 +1715,34 @@
 	/* Join words into a string */
 	if (!s)
 		return;
-	for (x = 0; ofs < len && w[x]; x++) {
+	for (x = 0; ofs < len && w[x] && x < size; x++) {
 		if (x > 0)
-			s[ofs++] = ' ';
+			s[ofs++] = delim;
 		for (src = w[x]; *src && ofs < len; src++)
 			s[ofs++] = *src;
 	}
 	if (ofs == len)
 		ofs--;
 	s[ofs] = '\0';
+}
+
+char *ast_to_camel_case_delim(const char *s, const char *delim)
+{
+	char *res = ast_strdup(s);
+	char *front, *back, *buf = res;
+	int size;
+
+	front = strtok_r(buf, delim, &back);
+
+	while (front) {
+		size = strlen(front);
+		*front = toupper(*front);
+		ast_copy_string(buf, front, size + 1);
+		buf += size;
+		front = strtok_r(NULL, delim, &back);
+	}
+
+	return res;
 }
 
 /*

Modified: team/kmoore/pjsip_path_support/res/ari.make
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/ari.make?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/res/ari.make (original)
+++ team/kmoore/pjsip_path_support/res/ari.make Mon Nov 25 22:04:59 2013
@@ -45,6 +45,10 @@
 
 ari/resource_playbacks.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_playbacks)
 
+res_ari_device_states.so: ari/resource_device_states.o
+
+ari/resource_device_states.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_device_states)
+
 res_ari_events.so: ari/resource_events.o
 
 ari/resource_events.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,res_ari_events)

Modified: team/kmoore/pjsip_path_support/res/ari/ari_model_validators.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/ari/ari_model_validators.c?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/res/ari/ari_model_validators.c (original)
+++ team/kmoore/pjsip_path_support/res/ari/ari_model_validators.c Mon Nov 25 22:04:59 2013
@@ -1333,6 +1333,60 @@
 	return ast_ari_validate_playback;
 }
 
+int ast_ari_validate_device_state(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_name = 0;
+	int has_state = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_name = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DeviceState field name failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_state = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DeviceState field state failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI DeviceState has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_name) {
+		ast_log(LOG_ERROR, "ARI DeviceState missing required field name\n");
+		res = 0;
+	}
+
+	if (!has_state) {
+		ast_log(LOG_ERROR, "ARI DeviceState missing required field state\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_device_state_fn(void)
+{
+	return ast_ari_validate_device_state;
+}
+
 int ast_ari_validate_application_replaced(struct ast_json *json)
 {
 	int res = 1;
@@ -2746,6 +2800,85 @@
 	return ast_ari_validate_channel_varset;
 }
 
+int ast_ari_validate_device_state_changed(struct ast_json *json)
+{
+	int res = 1;
+	struct ast_json_iter *iter;
+	int has_type = 0;
+	int has_application = 0;
+	int has_device_state = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_type = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DeviceStateChanged field type failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_application = 1;
+			prop_is_valid = ast_ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DeviceStateChanged field application failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			prop_is_valid = ast_ari_validate_date(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DeviceStateChanged field timestamp failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("device_state", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_device_state = 1;
+			prop_is_valid = ast_ari_validate_device_state(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI DeviceStateChanged field device_state failed validation\n");
+				res = 0;
+			}
+		} else
+		{
+			ast_log(LOG_ERROR,
+				"ARI DeviceStateChanged has undocumented field %s\n",
+				ast_json_object_iter_key(iter));
+			res = 0;
+		}
+	}
+
+	if (!has_type) {
+		ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field type\n");
+		res = 0;
+	}
+
+	if (!has_application) {
+		ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field application\n");
+		res = 0;
+	}
+
+	if (!has_device_state) {
+		ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field device_state\n");
+		res = 0;
+	}
+
+	return res;
+}
+
+ari_validator ast_ari_validate_device_state_changed_fn(void)
+{
+	return ast_ari_validate_device_state_changed;
+}
+
 int ast_ari_validate_endpoint_state_change(struct ast_json *json)
 {
 	int res = 1;
@@ -2887,6 +3020,9 @@
 	if (strcmp("ChannelVarset", discriminator) == 0) {
 		return ast_ari_validate_channel_varset(json);
 	} else
+	if (strcmp("DeviceStateChanged", discriminator) == 0) {
+		return ast_ari_validate_device_state_changed(json);
+	} else
 	if (strcmp("EndpointStateChange", discriminator) == 0) {
 		return ast_ari_validate_endpoint_state_change(json);
 	} else
@@ -3025,6 +3161,9 @@
 	if (strcmp("ChannelVarset", discriminator) == 0) {
 		return ast_ari_validate_channel_varset(json);
 	} else
+	if (strcmp("DeviceStateChanged", discriminator) == 0) {
+		return ast_ari_validate_device_state_changed(json);
+	} else
 	if (strcmp("EndpointStateChange", discriminator) == 0) {
 		return ast_ari_validate_endpoint_state_change(json);
 	} else
@@ -3592,6 +3731,7 @@
 	struct ast_json_iter *iter;
 	int has_bridge_ids = 0;
 	int has_channel_ids = 0;
+	int has_device_names = 0;
 	int has_endpoint_ids = 0;
 	int has_name = 0;
 
@@ -3618,6 +3758,17 @@
 				res = 0;
 			}
 		} else
+		if (strcmp("device_names", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_device_names = 1;
+			prop_is_valid = ast_ari_validate_list(
+				ast_json_object_iter_value(iter),
+				ast_ari_validate_string);
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Application field device_names failed validation\n");
+				res = 0;
+			}
+		} else
 		if (strcmp("endpoint_ids", ast_json_object_iter_key(iter)) == 0) {
 			int prop_is_valid;
 			has_endpoint_ids = 1;
@@ -3657,6 +3808,11 @@
 		res = 0;
 	}
 
+	if (!has_device_names) {
+		ast_log(LOG_ERROR, "ARI Application missing required field device_names\n");
+		res = 0;
+	}
+
 	if (!has_endpoint_ids) {
 		ast_log(LOG_ERROR, "ARI Application missing required field endpoint_ids\n");
 		res = 0;

Modified: team/kmoore/pjsip_path_support/res/ari/ari_model_validators.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/ari/ari_model_validators.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/res/ari/ari_model_validators.h (original)
+++ team/kmoore/pjsip_path_support/res/ari/ari_model_validators.h Mon Nov 25 22:04:59 2013
@@ -481,6 +481,24 @@
 ari_validator ast_ari_validate_playback_fn(void);
 
 /*!
+ * \brief Validator for DeviceState.
+ *
+ * Represents the state of a device.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ast_ari_validate_device_state(struct ast_json *json);
+
+/*!
+ * \brief Function pointer to ast_ari_validate_device_state().
+ *
+ * See \ref ast_ari_model_validators.h for more details.
+ */
+ari_validator ast_ari_validate_device_state_fn(void);
+
+/*!
  * \brief Validator for ApplicationReplaced.
  *
  * Notification that another WebSocket has taken over for an application.
@@ -753,6 +771,24 @@
  * See \ref ast_ari_model_validators.h for more details.
  */
 ari_validator ast_ari_validate_channel_varset_fn(void);
+
+/*!
+ * \brief Validator for DeviceStateChanged.
+ *
+ * Notification that a device state has changed.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ast_ari_validate_device_state_changed(struct ast_json *json);
+
+/*!
+ * \brief Function pointer to ast_ari_validate_device_state_changed().
+ *
+ * See \ref ast_ari_model_validators.h for more details.
+ */
+ari_validator ast_ari_validate_device_state_changed_fn(void);
 
 /*!
  * \brief Validator for EndpointStateChange.
@@ -1052,6 +1088,9 @@
  * - media_uri: string (required)
  * - state: string (required)
  * - target_uri: string (required)
+ * DeviceState
+ * - name: string (required)
+ * - state: string (required)
  * ApplicationReplaced
  * - type: string (required)
  * - application: string (required)
@@ -1143,6 +1182,11 @@
  * - channel: Channel
  * - value: string (required)
  * - variable: string (required)
+ * DeviceStateChanged
+ * - type: string (required)
+ * - application: string (required)
+ * - timestamp: Date
+ * - device_state: DeviceState (required)
  * EndpointStateChange
  * - type: string (required)
  * - application: string (required)
@@ -1187,6 +1231,7 @@
  * Application
  * - bridge_ids: List[string] (required)
  * - channel_ids: List[string] (required)
+ * - device_names: List[string] (required)
  * - endpoint_ids: List[string] (required)
  * - name: string (required)
  */

Modified: team/kmoore/pjsip_path_support/res/ari/resource_applications.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/ari/resource_applications.h?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/res/ari/resource_applications.h (original)
+++ team/kmoore/pjsip_path_support/res/ari/resource_applications.h Mon Nov 25 22:04:59 2013
@@ -67,7 +67,7 @@
 struct ast_ari_applications_subscribe_args {
 	/*! \brief Application's name */
 	const char *application_name;
-	/*! \brief Array of URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource} */
+	/*! \brief Array of URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName} */
 	const char **event_source;
 	/*! \brief Length of event_source array. */
 	size_t event_source_count;
@@ -88,7 +88,7 @@
 struct ast_ari_applications_unsubscribe_args {
 	/*! \brief Application's name */
 	const char *application_name;
-	/*! \brief Array of URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource} */
+	/*! \brief Array of URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, device_state:{deviceName} */
 	const char **event_source;
 	/*! \brief Length of event_source array. */
 	size_t event_source_count;

Modified: team/kmoore/pjsip_path_support/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip.c?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip.c Mon Nov 25 22:04:59 2013
@@ -1030,6 +1030,41 @@
 			<para>Qualify a chan_pjsip endpoint.</para>
 		</description>
 	</manager>
+	<manager name="PJSIPShowEndpoints" language="en_US">
+		<synopsis>
+			Lists PJSIP endpoints.
+		</synopsis>
+		<syntax />
+		<description>
+			<para>
+			Provides a listing of all endpoints.  For each endpoint an <literal>EndpointList</literal> event
+			is raised that contains relevant attributes and status information.  Once all
+			endpoints have been listed an <literal>EndpointListComplete</literal> event is issued.
+                        </para>
+		</description>
+	</manager>
+	<manager name="PJSIPShowEndpoint" language="en_US">
+		<synopsis>
+			Detail listing of an endpoint and its objects.
+		</synopsis>
+		<syntax>
+			<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+			<parameter name="Endpoint" required="true">
+				<para>The endpoint to list.</para>
+			</parameter>
+		</syntax>
+		<description>
+			<para>
+			Provides a detailed listing of options for a given endpoint.  Events are issued
+			showing the configuration and status of the endpoint and associated objects.  These
+			events include <literal>EndpointDetail</literal>, <literal>AorDetail</literal>,
+			<literal>AuthDetail</literal>, <literal>TransportDetail</literal>, and
+			<literal>IdentifyDetail</literal>.  Some events may be listed multiple times if multiple objects are
+			associated (for instance AoRs).  Once all detail events have been raised a final
+			<literal>EndpointDetailComplete</literal> event is issued.
+                        </para>
+		</description>
+	</manager>
  ***/
 
 
@@ -1212,6 +1247,49 @@
 		}
 	}
 	return endpoint;
+}
+
+AST_RWLIST_HEAD_STATIC(endpoint_formatters, ast_sip_endpoint_formatter);
+
+int ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
+{
+	SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
+	AST_RWLIST_INSERT_TAIL(&endpoint_formatters, obj, next);
+	ast_module_ref(ast_module_info->self);
+	return 0;
+}
+
+void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
+{
+	struct ast_sip_endpoint_formatter *i;
+	SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
+	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_formatters, i, next) {
+		if (i == obj) {
+			AST_RWLIST_REMOVE_CURRENT(next);
+			ast_module_unref(ast_module_info->self);
+			break;
+		}
+	}
+	AST_RWLIST_TRAVERSE_SAFE_END;
+}
+
+int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint,
+				struct ast_sip_ami *ami, int *count)
+{
+	int res = 0;
+	struct ast_sip_endpoint_formatter *i;
+	SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
+	*count = 0;
+	AST_RWLIST_TRAVERSE(&endpoint_formatters, i, next) {
+		if (i->format_ami && ((res = i->format_ami(endpoint, ami)) < 0)) {
+			return res;
+		}
+
+		if (!res) {
+			(*count)++;
+		}
+	}
+	return 0;
 }
 
 pjsip_endpoint *ast_sip_get_pjsip_endpoint(void)
@@ -2119,7 +2197,7 @@
 
 	ast_sip_initialize_global_headers();
 
-	if (ast_res_pjsip_initialize_configuration()) {
+	if (ast_res_pjsip_initialize_configuration(ast_module_info)) {
 		ast_log(LOG_ERROR, "Failed to initialize SIP configuration. Aborting load\n");
 		ast_sip_destroy_global_headers();
 		stop_monitor_thread();

Modified: team/kmoore/pjsip_path_support/res/res_pjsip.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip.exports.in?view=diff&rev=403157&r1=403156&r2=403157
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip.exports.in (original)

[... 3513 lines stripped ...]



More information about the svn-commits mailing list