[asterisk-commits] jrose: trunk r410029 - in /trunk: ./ contrib/ast-db-manage/config/versions/ i...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 6 13:05:07 CST 2014
Author: jrose
Date: Thu Mar 6 13:04:58 2014
New Revision: 410029
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410029
Log:
pjsip configuration: Make transport TOS values consistent with endpoints
Transport TOS values were interpreted as DSCP values without being documented
as such. Endpoint TOS values (tos_audio/tos_video) behaved normally as TOS
values have historically. This patch makes the transport TOS values behave as
TOS values and makes all TOS values readable as string values (e.g. AF11).
In addition, alembic scripts have been updated to use the proper field types
for all TOS/COS values.
(issue ASTERISK-23235)
Reported by: George Joseph
Review: https://reviewboard.asterisk.org/r/3304/
........
Merged revisions 410028 from http://svn.asterisk.org/svn/asterisk/branches/12
Added:
trunk/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py
- copied unchanged from r410028, branches/12/contrib/ast-db-manage/config/versions/4c573e7135bd_fix_tos_field_types.py
Modified:
trunk/ (props changed)
trunk/UPGRADE.txt
trunk/include/asterisk/acl.h
trunk/main/acl.c
trunk/res/res_pjsip/config_transport.c
trunk/res/res_pjsip/pjsip_configuration.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE.txt?view=diff&rev=410029&r1=410028&r2=410029
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Thu Mar 6 13:04:58 2014
@@ -26,6 +26,13 @@
REGISTER requests for each contact that is registered. If using realtime for
PJSIP contacts, this means that the schema has been updated to add a user_agent
column. An alembic revision has been added to facilitate this update.
+
+Realtime Configuration:
+ - PJSIP endpoint columns 'tos_audio' and 'tos_video' have been changed from yes/no
+ enumerators to string values. 'cos_audio' and 'cos_video' have been changed from
+ yes/no enumerators to integer values. PJSIP transport column 'tos' has been
+ changed from a yes/no enumerator to a string value. 'cos' has been changed from
+ a yes/no enumerator to an integer value.
From 12.0.0 to 12.1.0:
* The sound_place_into_conference sound used in Confbridge is now deprecated
Modified: trunk/include/asterisk/acl.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/acl.h?view=diff&rev=410029&r1=410028&r2=410029
==============================================================================
--- trunk/include/asterisk/acl.h (original)
+++ trunk/include/asterisk/acl.h Thu Mar 6 13:04:58 2014
@@ -358,6 +358,17 @@
const char *ast_tos2str(unsigned int tos);
/*!
+ * \brief Convert a TOS value into its string representation
+ * and create a dynamically allocated copy
+ *
+ * \param tos The TOS value to look up
+ * \param buf pointer to character pointer where string will be duplicated to
+ *
+ * \note The string allocated at buf must be free'd
+ */
+void ast_tos2str_buf(unsigned int tos, char **buf);
+
+/*!
* \brief Retrieve a named ACL
*
* \details
Modified: trunk/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/acl.c?view=diff&rev=410029&r1=410028&r2=410029
==============================================================================
--- trunk/main/acl.c (original)
+++ trunk/main/acl.c Thu Mar 6 13:04:58 2014
@@ -894,6 +894,12 @@
return "unknown";
}
+void ast_tos2str_buf(unsigned int tos, char **buf)
+{
+ const char *tos_string = ast_tos2str(tos);
+ *buf = ast_strdup(tos_string);
+}
+
int ast_get_ip(struct ast_sockaddr *addr, const char *hostname)
{
return ast_get_ip_or_srv(addr, hostname, NULL);
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=410029&r1=410028&r2=410029
==============================================================================
--- trunk/res/res_pjsip/config_transport.c (original)
+++ trunk/res/res_pjsip/config_transport.c Thu Mar 6 13:04:58 2014
@@ -121,9 +121,11 @@
static void set_qos(struct ast_sip_transport *transport, pj_qos_params *qos)
{
+ int tos_as_dscp = transport->tos >> 2;
+
if (transport->tos) {
qos->flags |= PJ_QOS_PARAM_HAS_DSCP;
- qos->dscp_val = transport->tos;
+ qos->dscp_val = tos_as_dscp;
}
if (transport->cos) {
qos->flags |= PJ_QOS_PARAM_HAS_SO_PRIO;
@@ -445,6 +447,39 @@
ast_ha_join(transport->localnet, &str);
*buf = ast_strdup(ast_str_buffer(str));
+ return 0;
+}
+
+/*! \brief Custom handler for TOS setting */
+static int transport_tos_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+{
+ struct ast_sip_transport *transport = obj;
+ unsigned int value;
+
+ if (ast_str2tos(var->value, &value)) {
+ ast_log(LOG_ERROR, "Error configuring transport '%s' - Could not "
+ "interpret 'tos' value '%s'\n",
+ ast_sorcery_object_get_id(transport), var->value);
+ return -1;
+ }
+
+ if (value % 4) {
+ value = value >> 2;
+ value = value << 2;
+ ast_log(LOG_WARNING,
+ "transport '%s' - 'tos' value '%s' uses bits that are "
+ "discarded when converted to DSCP. Using equivalent %d instead.\n",
+ ast_sorcery_object_get_id(transport), var->value, value);
+ }
+
+ transport->tos = value;
+ return 0;
+}
+
+static int tos_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_transport *transport = obj;
+ ast_tos2str_buf(transport->tos, buf);
return 0;
}
@@ -581,7 +616,7 @@
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_custom(sorcery, "transport", "tos", "0", transport_tos_handler, tos_to_str, 0, 0);
ast_sorcery_object_field_register(sorcery, "transport", "cos", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, cos));
ast_sip_register_endpoint_formatter(&endpoint_transport_formatter);
Modified: trunk/res/res_pjsip/pjsip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/pjsip_configuration.c?view=diff&rev=410029&r1=410028&r2=410029
==============================================================================
--- trunk/res/res_pjsip/pjsip_configuration.c (original)
+++ trunk/res/res_pjsip/pjsip_configuration.c Thu Mar 6 13:04:58 2014
@@ -755,6 +755,45 @@
*buf = ast_strdup(ast_t38_ec_modes_map[
endpoint->media.t38.error_correction]);
}
+ return 0;
+}
+
+static int tos_handler(const struct aco_option *opt,
+ struct ast_variable *var, void *obj)
+{
+ struct ast_sip_endpoint *endpoint = obj;
+ unsigned int value;
+
+ if (ast_str2tos(var->value, &value)) {
+ ast_log(LOG_ERROR, "Error configuring endpoint '%s' - Could not "
+ "interpret '%s' value '%s'\n",
+ ast_sorcery_object_get_id(endpoint), var->name, var->value);
+ return -1;
+ }
+
+ if (!strcmp(var->name, "tos_audio")) {
+ endpoint->media.tos_audio = value;
+ } else if (!strcmp(var->name, "tos_video")) {
+ endpoint->media.tos_video = value;
+ } else {
+ /* If we reach this point, someone called the tos_handler when they shouldn't have. */
+ ast_assert(0);
+ return -1;
+ }
+ return 0;
+}
+
+static int tos_audio_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_endpoint *endpoint = obj;
+ ast_tos2str_buf(endpoint->media.tos_audio, buf);
+ return 0;
+}
+
+static int tos_video_to_str(const void *obj, const intptr_t *args, char **buf)
+{
+ const struct ast_sip_endpoint *endpoint = obj;
+ ast_tos2str_buf(endpoint->media.tos_video, buf);
return 0;
}
@@ -1586,8 +1625,8 @@
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_transfer", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allowtransfer));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdp_owner", "-", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.sdpowner));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "sdp_session", "Asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.sdpsession));
- ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tos_audio", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.tos_audio));
- ast_sorcery_object_field_register(sip_sorcery, "endpoint", "tos_video", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.tos_video));
+ ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "tos_audio", "0", tos_handler, tos_audio_to_str, 0, 0);
+ ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "tos_video", "0", tos_handler, tos_video_to_str, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_audio", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.cos_audio));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "cos_video", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.cos_video));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_subscribe", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, subscription.allow));
More information about the asterisk-commits
mailing list