]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Expanding PJSIP endpoint ID and relevant resource length to 255 characters
authorsungtae kim <pchero21@gmail.com>
Fri, 22 Sep 2023 17:32:43 +0000 (02:32 +0900)
committersungtae kim <pchero21@gmail.com>
Fri, 20 Oct 2023 12:18:50 +0000 (12:18 +0000)
This commit introduces an extension to the endpoint and relevant
resource sizes for PJSIP, transitioning from its current 40-character
constraint to a more versatile 255-character capacity. This enhancement
significantly overcomes limitations related to domain qualification and
practical usage, ultimately delivering improved functionality. In
addition, it includes adjustments to accommodate the expanded realm size
within the ARI, specifically enhancing the maximum realm length.

Resolves: #345

UserNote: With this update, the PJSIP realm lengths have been extended
to support up to 255 characters.

UpgradeNote: As part of this update, the maximum allowable length
for PJSIP endpoints and relevant resources has been increased from
40 to 255 characters. To take advantage of this enhancement, it is
recommended to run the necessary procedures (e.g., Alembic) to
update your schemas.

contrib/ast-db-manage/config/versions/dac2b4c328b8_incease_pjsip_id_length.py [new file with mode: 0644]
include/asterisk/res_pjsip.h
res/ari/internal.h
res/res_pjsip/pjsip_distributor.c
res/res_pjsip_authenticator_digest.c
res/res_pjsip_endpoint_identifier_user.c

diff --git a/contrib/ast-db-manage/config/versions/dac2b4c328b8_incease_pjsip_id_length.py b/contrib/ast-db-manage/config/versions/dac2b4c328b8_incease_pjsip_id_length.py
new file mode 100644 (file)
index 0000000..4d8b161
--- /dev/null
@@ -0,0 +1,83 @@
+"""increase pjsip id length
+
+Revision ID: dac2b4c328b8
+Revises: f5b0e7427449
+Create Date: 2023-09-23 02:15:24.270526
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'dac2b4c328b8'
+down_revision = 'f5b0e7427449'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    op.alter_column('ps_aors', 'id', type_=sa.String(255))
+    op.alter_column('ps_aors', 'outbound_proxy', type_=sa.String(255))
+
+    op.alter_column('ps_auths', 'id', type_=sa.String(255))
+    op.alter_column('ps_auths', 'realm', type_=sa.String(255))
+
+    op.alter_column('ps_contacts', 'outbound_proxy', type_=sa.String(255))
+    op.alter_column('ps_contacts', 'endpoint', type_=sa.String(255))
+
+    op.alter_column('ps_domain_aliases', 'id', type_=sa.String(255))
+    op.alter_column('ps_domain_aliases', 'domain', type_=sa.String(255))
+
+    op.alter_column('ps_endpoint_id_ips', 'id', type_=sa.String(255))
+    op.alter_column('ps_endpoint_id_ips', 'endpoint', type_=sa.String(255))
+
+    op.alter_column('ps_endpoints', 'id', type_=sa.String(255))
+    op.alter_column('ps_endpoints', 'aors', type_=sa.String(2048))
+    op.alter_column('ps_endpoints', 'auth', type_=sa.String(255))
+    op.alter_column('ps_endpoints', 'outbound_auth', type_=sa.String(255))
+    op.alter_column('ps_endpoints', 'outbound_proxy', type_=sa.String(255))
+
+    op.alter_column('ps_inbound_publications', 'id', type_=sa.String(255))
+    op.alter_column('ps_inbound_publications', 'endpoint', type_=sa.String(255))
+
+    op.alter_column('ps_outbound_publishes', 'id', type_=sa.String(255))
+    op.alter_column('ps_outbound_publishes', 'outbound_auth', type_=sa.String(255))
+
+    op.alter_column('ps_registrations', 'id', type_=sa.String(255))
+    op.alter_column('ps_registrations', 'outbound_auth', type_=sa.String(255))
+    op.alter_column('ps_registrations', 'outbound_proxy', type_=sa.String(255))
+    op.alter_column('ps_registrations', 'endpoint', type_=sa.String(255))
+
+
+def downgrade():
+    op.alter_column('ps_aors', 'id', type_=sa.String(40))
+    op.alter_column('ps_aors', 'outbound_proxy', type_=sa.String(40))
+
+    op.alter_column('ps_auths', 'id', type_=sa.String(40))
+    op.alter_column('ps_auths', 'realm', type_=sa.String(40))
+
+    op.alter_column('ps_contacts', 'outbound_proxy', type_=sa.String(40))
+    op.alter_column('ps_contacts', 'endpoint', type_=sa.String(40))
+
+    op.alter_column('ps_domain_aliases', 'id', type_=sa.String(40))
+    op.alter_column('ps_domain_aliases', 'domain', type_=sa.String(40))
+
+    op.alter_column('ps_endpoint_id_ips', 'id', type_=sa.String(40))
+    op.alter_column('ps_endpoint_id_ips', 'endpoint', type_=sa.String(40))
+
+    op.alter_column('ps_endpoints', 'id', type_=sa.String(40))
+    op.alter_column('ps_endpoints', 'aors', type_=sa.String(200))
+    op.alter_column('ps_endpoints', 'auth', type_=sa.String(40))
+    op.alter_column('ps_endpoints', 'outbound_auth', type_=sa.String(40))
+    op.alter_column('ps_endpoints', 'outbound_proxy', type_=sa.String(40))
+
+    op.alter_column('ps_inbound_publications', 'id', type_=sa.String(40))
+    op.alter_column('ps_inbound_publications', 'endpoint', type_=sa.String(40))
+
+    op.alter_column('ps_outbound_publishes', 'id', type_=sa.String(40))
+    op.alter_column('ps_outbound_publishes', 'outbound_auth', type_=sa.String(40))
+
+    op.alter_column('ps_registrations', 'id', type_=sa.String(40))
+    op.alter_column('ps_registrations', 'outbound_auth', type_=sa.String(40))
+    op.alter_column('ps_registrations', 'outbound_proxy', type_=sa.String(40))
+    op.alter_column('ps_registrations', 'endpoint', type_=sa.String(40))
+
index cf95aafda4f5eb00f8b51e7a6812a54241399dd8..0f68a9bbcbab95460d7a4cc64256dcf0fedefed8 100644 (file)
@@ -87,6 +87,8 @@
 #define AST_STIR_SHAKEN_RESPONSE_STR_UNSUPPORTED_CREDENTIAL "Unsupported Credential"
 #define AST_STIR_SHAKEN_RESPONSE_STR_INVALID_IDENTITY_HEADER "Invalid Identity Header"
 
+#define AST_SIP_AUTH_MAX_REALM_LENGTH 255      /* From the auth/realm realtime column size */
+
 /* ":12345" */
 #define COLON_PORT_STRLEN 6
 /*
index 610e9160cebc72a2cb9d0decba8367d9b86eadba..564e547c19bbba7176f24a412f8b5afea38c1fb4 100644 (file)
@@ -59,7 +59,7 @@ struct ast_ari_conf {
 };
 
 /*! Max length for auth_realm field */
-#define ARI_AUTH_REALM_LEN 80
+#define ARI_AUTH_REALM_LEN 256
 
 /*! \brief Global configuration options for ARI. */
 struct ast_ari_conf_general {
index 092e012a773b102bf4945f6ba2b6e6964e11b8fc..909f99a8f98cc624e1e9b754b6653977be0328f7 100644 (file)
@@ -41,9 +41,6 @@ static pjsip_module distributor_mod = {
 
 struct ast_sched_context *prune_context;
 
-/* From the auth/realm realtime column size */
-#define MAX_REALM_LENGTH 40
-
 #define DEFAULT_SUSPECTS_BUCKETS 53
 
 static struct ao2_container *unidentified_requests;
@@ -613,7 +610,7 @@ static AO2_GLOBAL_OBJ_STATIC(artificial_auth);
 
 static int create_artificial_auth(void)
 {
-       char default_realm[MAX_REALM_LENGTH + 1];
+       char default_realm[AST_SIP_AUTH_MAX_REALM_LENGTH + 1];
        struct ast_sip_auth *fake_auth;
 
        ast_sip_get_default_realm(default_realm, sizeof(default_realm));
@@ -1164,7 +1161,7 @@ static int clean_task(const void *data)
 
 static void global_loaded(const char *object_type)
 {
-       char default_realm[MAX_REALM_LENGTH + 1];
+       char default_realm[AST_SIP_AUTH_MAX_REALM_LENGTH + 1];
        struct ast_sip_auth *fake_auth;
        char *identifier_order;
 
index 2cdbe6eff5866193894523980bbf84bd908300b2..0b9424e0b3479b83a32a457dd1e3bf881a025914 100644 (file)
@@ -32,9 +32,7 @@
        <support_level>core</support_level>
  ***/
 
-/* From the auth/realm realtime column size */
-#define MAX_REALM_LENGTH 40
-static char default_realm[MAX_REALM_LENGTH + 1];
+static char default_realm[AST_SIP_AUTH_MAX_REALM_LENGTH + 1];
 
 AO2_GLOBAL_OBJ_STATIC(entity_id);
 
index 481cd3b3fcfb80327413123193cc2bee1ce1d0fb..bc3f0902a42b456d1803e34908a158e9c3badfa9 100644 (file)
@@ -164,7 +164,7 @@ static struct ast_sip_endpoint *username_identify(pjsip_rx_data *rdata)
 
 static struct ast_sip_endpoint *auth_username_identify(pjsip_rx_data *rdata)
 {
-       char username[USERNAME_LEN + 1], realm[DOMAIN_NAME_LEN + 1];
+       char username[USERNAME_LEN + 1], realm[AST_SIP_AUTH_MAX_REALM_LENGTH + 1];
        struct ast_sip_endpoint *endpoint;
        pjsip_authorization_hdr *auth_header = NULL;