[asterisk-commits] kharwell: trunk r403133 - in /trunk: ./ include/asterisk/ main/ res/ res/res_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Nov 23 11:27:01 CST 2013
Author: kharwell
Date: Sat Nov 23 11:26:57 2013
New Revision: 403133
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403133
Log:
res_pjsip: AMI commands and events.
Created the following AMI commands and corresponding events for res_pjsip:
PJSIPShowEndpoints - Provides a listing of all pjsip endpoints and a few
select attributes on each.
Events:
EndpointList - for each endpoint a few attributes.
EndpointlistComplete - after all endpoints have been listed.
PJSIPShowEndpoint - Provides a detail list of attributes for a specified
endpoint.
Events:
EndpointDetail - attributes on an endpoint.
AorDetail - raised for each AOR on an endpoint.
AuthDetail - raised for each associated inbound and outbound auth
TransportDetail - transport attributes.
IdentifyDetail - attributes for the identify object associated with
the endpoint.
EndpointDetailComplete - last event raised after all detail events.
PJSIPShowRegistrationsInbound - Provides a detail listing of all inbound
registrations.
Events:
InboundRegistrationDetail - inbound registration attributes for each
registration.
InboundRegistrationDetailComplete - raised after all detail records have
been listed.
PJSIPShowRegistrationsOutbound - Provides a detail listing of all outbound
registrations.
Events:
OutboundRegistrationDetail - outbound registration attributes for each
registration.
OutboundRegistrationDetailComplete - raised after all detail records
have been listed.
PJSIPShowSubscriptionsInbound - A detail listing of all inbound subscriptions
and their attributes.
Events:
SubscriptionDetail - on each subscription detailed attributes
SubscriptionDetailComplete - raised after all detail records have
been listed.
PJSIPShowSubscriptionsOutbound - A detail listing of all outboundbound
subscriptions and their attributes.
Events:
SubscriptionDetail - on each subscription detailed attributes
SubscriptionDetailComplete - raised after all detail records have
been listed.
(issue ASTERISK-22609)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2959/
........
Merged revisions 403131 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/include/asterisk/acl.h
trunk/include/asterisk/res_pjsip.h
trunk/include/asterisk/res_pjsip_pubsub.h
trunk/include/asterisk/sorcery.h
trunk/include/asterisk/strings.h
trunk/include/asterisk/utils.h
trunk/main/acl.c
trunk/main/sorcery.c
trunk/main/utils.c
trunk/res/res_pjsip.c
trunk/res/res_pjsip.exports.in
trunk/res/res_pjsip/config_auth.c
trunk/res/res_pjsip/config_transport.c
trunk/res/res_pjsip/include/res_pjsip_private.h
trunk/res/res_pjsip/location.c
trunk/res/res_pjsip/pjsip_configuration.c
trunk/res/res_pjsip_endpoint_identifier_ip.c
trunk/res/res_pjsip_exten_state.c
trunk/res/res_pjsip_mwi.c
trunk/res/res_pjsip_outbound_registration.c
trunk/res/res_pjsip_pubsub.c
trunk/res/res_pjsip_registrar.c
Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Sat Nov 23 11:26:57 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
Modified: trunk/include/asterisk/acl.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/acl.h?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/include/asterisk/acl.h (original)
+++ trunk/include/asterisk/acl.h Sat Nov 23 11:26:57 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: trunk/include/asterisk/res_pjsip.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/res_pjsip.h?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/include/asterisk/res_pjsip.h (original)
+++ trunk/include/asterisk/res_pjsip.h Sat Nov 23 11:26:57 2013
@@ -1559,5 +1559,154 @@
#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);
#endif /* _RES_PJSIP_H */
Modified: trunk/include/asterisk/res_pjsip_pubsub.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/res_pjsip_pubsub.h?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/include/asterisk/res_pjsip_pubsub.h (original)
+++ trunk/include/asterisk/res_pjsip_pubsub.h Sat Nov 23 11:26:57 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: trunk/include/asterisk/sorcery.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/sorcery.h?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/include/asterisk/sorcery.h (original)
+++ trunk/include/asterisk/sorcery.h Sat Nov 23 11:26:57 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: trunk/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/strings.h?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/include/asterisk/strings.h (original)
+++ trunk/include/asterisk/strings.h Sat Nov 23 11:26:57 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: trunk/include/asterisk/utils.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/utils.h?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/include/asterisk/utils.h (original)
+++ trunk/include/asterisk/utils.h Sat Nov 23 11:26:57 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: trunk/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/acl.c?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/main/acl.c (original)
+++ trunk/main/acl.c Sat Nov 23 11:26:57 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: trunk/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/sorcery.c?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/main/sorcery.c (original)
+++ trunk/main/sorcery.c Sat Nov 23 11:26:57 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: trunk/main/utils.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/utils.c?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Sat Nov 23 11:26:57 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: trunk/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip.c?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/res/res_pjsip.c (original)
+++ trunk/res/res_pjsip.c Sat Nov 23 11:26:57 2013
@@ -1021,6 +1021,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>
***/
@@ -1203,6 +1238,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)
@@ -1964,7 +2042,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: trunk/res/res_pjsip.exports.in
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip.exports.in?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/res/res_pjsip.exports.in (original)
+++ trunk/res/res_pjsip.exports.in Sat Nov 23 11:26:57 2013
@@ -1,77 +1,8 @@
{
global:
- LINKER_SYMBOL_PREFIXast_sip_register_service;
- LINKER_SYMBOL_PREFIXast_sip_unregister_service;
- LINKER_SYMBOL_PREFIXast_sip_register_authenticator;
- LINKER_SYMBOL_PREFIXast_sip_unregister_authenticator;
- LINKER_SYMBOL_PREFIXast_sip_register_outbound_authenticator;
- LINKER_SYMBOL_PREFIXast_sip_unregister_outbound_authenticator;
- LINKER_SYMBOL_PREFIXast_sip_register_endpoint_identifier;
- LINKER_SYMBOL_PREFIXast_sip_unregister_endpoint_identifier;
- LINKER_SYMBOL_PREFIXast_sip_create_serializer;
- LINKER_SYMBOL_PREFIXast_sip_push_task;
- LINKER_SYMBOL_PREFIXast_sip_push_task_synchronous;
- LINKER_SYMBOL_PREFIXast_sip_create_request;
- LINKER_SYMBOL_PREFIXast_sip_create_request_with_auth;
- LINKER_SYMBOL_PREFIXast_sip_send_request;
- LINKER_SYMBOL_PREFIXast_sip_requires_authentication;
- LINKER_SYMBOL_PREFIXast_sip_authenticate_request;
- LINKER_SYMBOL_PREFIXast_sip_get_authentication_credentials;
- LINKER_SYMBOL_PREFIXast_sip_check_authentication;
- LINKER_SYMBOL_PREFIXast_sip_create_auth_challenge_response;
- LINKER_SYMBOL_PREFIXast_sip_set_outbound_authentication_credentials;
- LINKER_SYMBOL_PREFIXast_sip_dialog_setup_outbound_authentication;
- LINKER_SYMBOL_PREFIXast_sip_add_digest_to_challenge;
- LINKER_SYMBOL_PREFIXast_sip_identify_endpoint;
- LINKER_SYMBOL_PREFIXast_sip_add_header;
- LINKER_SYMBOL_PREFIXast_sip_add_body;
- LINKER_SYMBOL_PREFIXast_sip_add_body_multipart;
- LINKER_SYMBOL_PREFIXast_sip_append_body;
- LINKER_SYMBOL_PREFIXast_sip_get_pjsip_endpoint;
- LINKER_SYMBOL_PREFIXast_sip_endpoint_alloc;
- LINKER_SYMBOL_PREFIXast_sip_get_endpoints;
+ LINKER_SYMBOL_PREFIXast_sip_*;
LINKER_SYMBOL_PREFIXast_copy_pj_str;
- LINKER_SYMBOL_PREFIXast_sip_get_sorcery;
- LINKER_SYMBOL_PREFIXast_sip_create_dialog_uac;
- LINKER_SYMBOL_PREFIXast_sip_create_dialog_uas;
- LINKER_SYMBOL_PREFIXast_sip_location_retrieve_aor;
- LINKER_SYMBOL_PREFIXast_sip_location_retrieve_first_aor_contact;
- LINKER_SYMBOL_PREFIXast_sip_location_retrieve_contact_from_aor_list;
- LINKER_SYMBOL_PREFIXast_sip_location_retrieve_aor_contacts;
- LINKER_SYMBOL_PREFIXast_sip_location_retrieve_contact;
- LINKER_SYMBOL_PREFIXast_sip_location_add_contact_transport;
- LINKER_SYMBOL_PREFIXast_sip_location_delete_contact_transport;
- LINKER_SYMBOL_PREFIXast_sip_location_retrieve_contact_transport_by_uri;
- LINKER_SYMBOL_PREFIXast_sip_location_retrieve_contact_transport_by_transport;
- LINKER_SYMBOL_PREFIXast_sip_location_add_contact;
- LINKER_SYMBOL_PREFIXast_sip_location_update_contact;
- LINKER_SYMBOL_PREFIXast_sip_location_delete_contact;
LINKER_SYMBOL_PREFIXast_pjsip_rdata_get_endpoint;
- LINKER_SYMBOL_PREFIXast_sip_thread_is_servant;
- LINKER_SYMBOL_PREFIXast_sip_dialog_set_serializer;
- LINKER_SYMBOL_PREFIXast_sip_dialog_set_endpoint;
- LINKER_SYMBOL_PREFIXast_sip_dialog_get_endpoint;
- LINKER_SYMBOL_PREFIXast_sip_retrieve_auths;
- LINKER_SYMBOL_PREFIXast_sip_cleanup_auths;
- LINKER_SYMBOL_PREFIXast_sip_is_content_type;
- LINKER_SYMBOL_PREFIXast_sip_get_artificial_endpoint;
- LINKER_SYMBOL_PREFIXast_sip_get_artificial_auth;
- LINKER_SYMBOL_PREFIXast_sip_report_invalid_endpoint;
- LINKER_SYMBOL_PREFIXast_sip_report_failed_acl;
- LINKER_SYMBOL_PREFIXast_sip_report_auth_failed_challenge_response;
- LINKER_SYMBOL_PREFIXast_sip_report_auth_success;
- LINKER_SYMBOL_PREFIXast_sip_report_auth_challenge_sent;
- LINKER_SYMBOL_PREFIXast_sip_report_req_no_support;
- LINKER_SYMBOL_PREFIXast_sip_report_mem_limit;
- LINKER_SYMBOL_PREFIXast_sip_initialize_global_headers;
- LINKER_SYMBOL_PREFIXast_sip_destroy_global_headers;
- LINKER_SYMBOL_PREFIXast_sip_add_global_request_header;
- LINKER_SYMBOL_PREFIXast_sip_add_global_response_header;
- LINKER_SYMBOL_PREFIXast_sip_initialize_sorcery_global;
- LINKER_SYMBOL_PREFIXast_sip_auth_array_init;
- LINKER_SYMBOL_PREFIXast_sip_auth_array_destroy;
- LINKER_SYMBOL_PREFIXast_sip_dict_get;
- LINKER_SYMBOL_PREFIXast_sip_dict_set;
local:
*;
};
Modified: trunk/res/res_pjsip/config_auth.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/config_auth.c?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/res/res_pjsip/config_auth.c (original)
+++ trunk/res/res_pjsip/config_auth.c Sat Nov 23 11:26:57 2013
@@ -23,6 +23,7 @@
#include "asterisk/res_pjsip.h"
#include "asterisk/logger.h"
#include "asterisk/sorcery.h"
+#include "include/res_pjsip_private.h"
static void auth_destroy(void *obj)
{
@@ -58,6 +59,24 @@
var->value, var->name);
return -1;
}
+ return 0;
+}
+
+static const char *auth_types_map[] = {
+ [AST_SIP_AUTH_TYPE_USER_PASS] = "userpass",
+ [AST_SIP_AUTH_TYPE_MD5] = "md5"
+};
+
+const char *ast_sip_auth_type_to_str(enum ast_sip_auth_type type)
+{
+ return ARRAY_IN_BOUNDS(type, auth_types_map) ?
+ auth_types_map[type] : "";
+}
+
+static int auth_type_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_auth *auth = obj;
+ *buf = ast_strdup(ast_sip_auth_type_to_str(auth->type));
return 0;
}
@@ -98,6 +117,84 @@
return res;
}
+
+int ast_sip_for_each_auth(const struct ast_sip_auth_array *array,
+ ao2_callback_fn on_auth, void *arg)
+{
+ int i;
+
+ if (!array || !array->num) {
+ return 0;
+ }
+
+ for (i = 0; i < array->num; ++i) {
+ RAII_VAR(struct ast_sip_auth *, auth, ast_sorcery_retrieve_by_id(
+ ast_sip_get_sorcery(), SIP_SORCERY_AUTH_TYPE,
+ array->names[i]), ao2_cleanup);
+
+ if (!auth) {
+ continue;
+ }
+
+ if (on_auth(auth, arg, 0)) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int sip_auth_to_ami(const struct ast_sip_auth *auth,
+ struct ast_str **buf)
+{
+ return ast_sip_sorcery_object_to_ami(auth, buf);
+}
+
+static int format_ami_auth_handler(void *obj, void *arg, int flags)
+{
+ const struct ast_sip_auth *auth = obj;
+ struct ast_sip_ami *ami = arg;
+ const struct ast_sip_endpoint *endpoint = ami->arg;
+ RAII_VAR(struct ast_str *, buf,
+ ast_sip_create_ami_event("AuthDetail", ami), ast_free);
+
+ if (!buf) {
+ return -1;
+ }
+
+ if (sip_auth_to_ami(auth, &buf)) {
+ return -1;
+ }
+
+ if (endpoint) {
+ ast_str_append(&buf, 0, "EndpointName: %s\r\n",
+ ast_sorcery_object_get_id(endpoint));
+ }
+
+ astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
+ return 0;
+}
+
+int ast_sip_format_auths_ami(const struct ast_sip_auth_array *auths,
+ struct ast_sip_ami *ami)
+{
+ return ast_sip_for_each_auth(auths, format_ami_auth_handler, ami);
+}
+
+static int format_ami_endpoint_auth(const struct ast_sip_endpoint *endpoint,
+ struct ast_sip_ami *ami)
+{
+ ami->arg = (void *)endpoint;
+ if (ast_sip_format_auths_ami(&endpoint->inbound_auths, ami)) {
+ return -1;
+ }
+
+ return ast_sip_format_auths_ami(&endpoint->outbound_auths, ami);
+}
+
+static struct ast_sip_endpoint_formatter endpoint_auth_formatter = {
+ .format_ami = format_ami_endpoint_auth
+};
/*! \brief Initialize sorcery with auth support */
int ast_sip_initialize_sorcery_auth(struct ast_sorcery *sorcery)
@@ -121,7 +218,8 @@
ast_sorcery_object_field_register(sorcery, SIP_SORCERY_AUTH_TYPE, "nonce_lifetime",
"32", OPT_UINT_T, 0, FLDSET(struct ast_sip_auth, nonce_lifetime));
ast_sorcery_object_field_register_custom(sorcery, SIP_SORCERY_AUTH_TYPE, "auth_type",
- "userpass", auth_type_handler, NULL, 0, 0);
-
- return 0;
-}
+ "userpass", auth_type_handler, auth_type_to_str, 0, 0);
+
+ ast_sip_register_endpoint_formatter(&endpoint_auth_formatter);
+ return 0;
+}
Modified: trunk/res/res_pjsip/config_transport.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/config_transport.c?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/res/res_pjsip/config_transport.c (original)
+++ trunk/res/res_pjsip/config_transport.c Sat Nov 23 11:26:57 2013
@@ -26,6 +26,45 @@
#include "asterisk/astobj2.h"
#include "asterisk/sorcery.h"
#include "asterisk/acl.h"
+#include "include/res_pjsip_private.h"
+
+static int sip_transport_to_ami(const struct ast_sip_transport *transport,
+ struct ast_str **buf)
+{
+ return ast_sip_sorcery_object_to_ami(transport, buf);
+}
+
+static int format_ami_endpoint_transport(const struct ast_sip_endpoint *endpoint,
+ struct ast_sip_ami *ami)
+{
+ RAII_VAR(struct ast_str *, buf,
+ ast_sip_create_ami_event("TransportDetail", ami), ast_free);
+ RAII_VAR(struct ast_sip_transport *,
+ transport, ast_sorcery_retrieve_by_id(
+ ast_sip_get_sorcery(), "transport",
+ endpoint->transport), ao2_cleanup);
+ if (!buf) {
+ return -1;
+ }
+
+ if (!transport) {
+ astman_send_error_va(ami->s, ami->m, "Unable to retrieve "
+ "transport %s\n", endpoint->transport);
+ return -1;
+ }
+
+ sip_transport_to_ami(transport, &buf);
+
+ ast_str_append(&buf, 0, "EndpointName: %s\r\n",
+ ast_sorcery_object_get_id(endpoint));
+
+ astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
+ return 0;
+}
+
+struct ast_sip_endpoint_formatter endpoint_transport_formatter = {
+ .format_ami = format_ami_endpoint_transport
+};
static int destroy_transport_state(void *data)
{
@@ -213,6 +252,25 @@
return 0;
}
+static const char *transport_types[] = {
+ [AST_TRANSPORT_UDP] = "udp",
+ [AST_TRANSPORT_TCP] = "tcp",
+ [AST_TRANSPORT_TLS] = "tls",
+ [AST_TRANSPORT_WS] = "ws",
+ [AST_TRANSPORT_WSS] = "wss"
+};
+
+static int transport_protocol_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_transport *transport = obj;
+
+ if (ARRAY_IN_BOUNDS(transport->type, transport_types)) {
+ *buf = ast_strdup(transport_types[transport->type]);
+ }
+
+ return 0;
+}
+
/*! \brief Custom handler for turning a string bind into a pj_sockaddr */
static int transport_bind_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
{
@@ -220,6 +278,20 @@
pj_str_t buf;
return (pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&buf, var->value), &transport->host) != PJ_SUCCESS) ? -1 : 0;
+}
+
+static int transport_bind_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_transport *transport = obj;
+
+ if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
+ return -1;
+ }
+
+ /* include port as well as brackets if IPv6 */
+ pj_sockaddr_print(&transport->host, *buf, MAX_OBJECT_FIELD, 1 | 2);
+
+ return 0;
}
/*! \brief Custom handler for TLS boolean settings */
@@ -237,6 +309,27 @@
return -1;
}
+ return 0;
+}
+
+static int verify_server_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_transport *transport = obj;
+ *buf = ast_strdup(AST_YESNO(transport->tls.verify_server));
+ return 0;
+}
+
+static int verify_client_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_transport *transport = obj;
+ *buf = ast_strdup(AST_YESNO(transport->tls.verify_client));
+ return 0;
+}
+
+static int require_client_cert_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_transport *transport = obj;
+ *buf = ast_strdup(AST_YESNO(transport->tls.require_client_cert));
return 0;
}
@@ -264,6 +357,24 @@
return 0;
}
+static const char *tls_method_map[] = {
+ [PJSIP_SSL_DEFAULT_METHOD] = "default",
+ [PJSIP_SSL_UNSPECIFIED_METHOD] = "unspecified",
+ [PJSIP_TLSV1_METHOD] = "tlsv1",
+ [PJSIP_SSLV2_METHOD] = "sslv2",
+ [PJSIP_SSLV3_METHOD] = "sslv3",
+ [PJSIP_SSLV23_METHOD] = "sslv23",
+};
+
+static int tls_method_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_transport *transport = obj;
+ if (ARRAY_IN_BOUNDS(transport->tls.method, tls_method_map)) {
+ *buf = ast_strdup(tls_method_map[transport->tls.method]);
+ }
+ return 0;
+}
+
/*! \brief Custom handler for TLS cipher setting */
static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
{
@@ -291,6 +402,27 @@
}
}
+static int transport_tls_cipher_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ RAII_VAR(struct ast_str *, str, ast_str_create(MAX_OBJECT_FIELD), ast_free);
+ const struct ast_sip_transport *transport = obj;
+ int i;
+
+ if (!str) {
+ return -1;
+ }
+
+ for (i = 0; i < transport->tls.ciphers_num; ++i) {
+ ast_str_append(&str, 0, "%s", pj_ssl_cipher_name(transport->ciphers[i]));
+ if (i < transport->tls.ciphers_num - 1) {
+ ast_str_append(&str, 0, ",");
+ }
+ }
+
+ *buf = ast_strdup(ast_str_buffer(str));
+ return 0;
+}
+
/*! \brief Custom handler for localnet setting */
static int transport_localnet_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
{
@@ -304,6 +436,16 @@
return error;
}
+static int localnet_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ RAII_VAR(struct ast_str *, str, ast_str_create(MAX_OBJECT_FIELD), ast_free);
+ const struct ast_sip_transport *transport = obj;
+
+ ast_ha_join(transport->localnet, &str);
+ *buf = ast_strdup(ast_str_buffer(str));
+ return 0;
+}
+
/*! \brief Initialize sorcery with transport support */
int ast_sip_initialize_sorcery_transport(struct ast_sorcery *sorcery)
{
@@ -314,8 +456,8 @@
}
ast_sorcery_object_field_register(sorcery, "transport", "type", "", OPT_NOOP_T, 0, 0);
- ast_sorcery_object_field_register_custom(sorcery, "transport", "protocol", "udp", transport_protocol_handler, NULL, 0, 0);
- ast_sorcery_object_field_register_custom(sorcery, "transport", "bind", "", transport_bind_handler, NULL, 0, 0);
+ ast_sorcery_object_field_register_custom(sorcery, "transport", "protocol", "udp", transport_protocol_handler, transport_protocol_to_str, 0, 0);
+ ast_sorcery_object_field_register_custom(sorcery, "transport", "bind", "", transport_bind_handler, transport_bind_to_str, 0, 0);
ast_sorcery_object_field_register(sorcery, "transport", "async_operations", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, async_operations));
ast_sorcery_object_field_register(sorcery, "transport", "ca_list_file", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, ca_list_file));
ast_sorcery_object_field_register(sorcery, "transport", "cert_file", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, cert_file));
@@ -325,14 +467,15 @@
ast_sorcery_object_field_register(sorcery, "transport", "external_signaling_port", "0", OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct ast_sip_transport, external_signaling_port), 0, 65535);
ast_sorcery_object_field_register(sorcery, "transport", "external_media_address", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, external_media_address));
ast_sorcery_object_field_register(sorcery, "transport", "domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, domain));
- ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_server", "", transport_tls_bool_handler, NULL, 0, 0);
- ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_client", "", transport_tls_bool_handler, NULL, 0, 0);
- ast_sorcery_object_field_register_custom(sorcery, "transport", "require_client_cert", "", transport_tls_bool_handler, NULL, 0, 0);
- ast_sorcery_object_field_register_custom(sorcery, "transport", "method", "", transport_tls_method_handler, NULL, 0, 0);
- ast_sorcery_object_field_register_custom(sorcery, "transport", "cipher", "", transport_tls_cipher_handler, NULL, 0, 0);
- ast_sorcery_object_field_register_custom(sorcery, "transport", "local_net", "", transport_localnet_handler, NULL, 0, 0);
+ ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_server", "", transport_tls_bool_handler, verify_server_to_str, 0, 0);
+ ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_client", "", transport_tls_bool_handler, verify_client_to_str, 0, 0);
+ ast_sorcery_object_field_register_custom(sorcery, "transport", "require_client_cert", "", transport_tls_bool_handler, require_client_cert_to_str, 0, 0);
+ ast_sorcery_object_field_register_custom(sorcery, "transport", "method", "", transport_tls_method_handler, tls_method_to_str, 0, 0);
+ ast_sorcery_object_field_register_custom(sorcery, "transport", "cipher", "", transport_tls_cipher_handler, transport_tls_cipher_to_str, 0, 0);
+ ast_sorcery_object_field_register_custom(sorcery, "transport", "local_net", "", transport_localnet_handler, localnet_to_str, 0, 0);
ast_sorcery_object_field_register(sorcery, "transport", "tos", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, tos));
ast_sorcery_object_field_register(sorcery, "transport", "cos", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, cos));
- return 0;
-}
+ ast_sip_register_endpoint_formatter(&endpoint_transport_formatter);
+ return 0;
+}
Modified: trunk/res/res_pjsip/include/res_pjsip_private.h
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/include/res_pjsip_private.h?view=diff&rev=403133&r1=403132&r2=403133
==============================================================================
--- trunk/res/res_pjsip/include/res_pjsip_private.h (original)
+++ trunk/res/res_pjsip/include/res_pjsip_private.h Sat Nov 23 11:26:57 2013
@@ -8,13 +8,17 @@
#ifndef RES_PJSIP_PRIVATE_H_
#define RES_PJSIP_PRIVATE_H_
+#include "asterisk/module.h"
+#include "asterisk/stasis_channels.h"
+#include "asterisk/stasis_endpoints.h"
+
struct ao2_container;
struct ast_threadpool_options;
/*!
* \brief Initialize the configuration for res_pjsip
*/
-int ast_res_pjsip_initialize_configuration(void);
+int ast_res_pjsip_initialize_configuration(const struct ast_module_info *ast_module_info);
/*!
* \brief Annihilate the configuration objects
@@ -82,4 +86,23 @@
*/
void sip_get_threadpool_options(struct ast_threadpool_options *threadpool_options);
+/*!
+ * \brief Function pointer for channel snapshot callbacks.
+ */
+typedef int (*on_channel_snapshot_t)(
+ const struct ast_channel_snapshot *snapshot, int last, void *arg);
+
+/*!
+ * \brief For every channel snapshot on an endpoint snapshot call the given
+ * 'on_channel_snapshot' handler.
+ *
+ * \param endpoint_snapshot snapshot of an endpoint
+ * \param on_channel_snapshot callback for each channel snapshot
+ * \param arg user data passed to handler
+ * \retval 0 Success, non-zero on failure
+ */
[... 1724 lines stripped ...]
More information about the asterisk-commits
mailing list