From eafb8f148e91e50c18a911093faa00077cc54e6e Mon Sep 17 00:00:00 2001 From: George Joseph Date: Wed, 6 Nov 2024 10:31:08 -0700 Subject: [PATCH] res_pjsip: Move tenantid to end of ast_sip_endpoint The tenantid field was originally added to the ast_sip_endpoint structure at the end of the AST_DECLARE_STRING_FIELDS block. This caused everything after it in the structure to move down in memory and break ABI compatibility. It's now at the end of the structure as an AST_STRING_FIELD_EXTENDED. Given the number of string fields in the structure now, the initial string field allocation was also increased from 64 to 128 bytes. Resolves: #982 --- include/asterisk/res_pjsip.h | 4 ++-- res/res_pjsip/pjsip_configuration.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h index 044d66d228..f83cbe82cf 100644 --- a/include/asterisk/res_pjsip.h +++ b/include/asterisk/res_pjsip.h @@ -977,8 +977,6 @@ struct ast_sip_endpoint { AST_STRING_FIELD(incoming_mwi_mailbox); /*! STIR/SHAKEN profile to use */ AST_STRING_FIELD(stir_shaken_profile); - /*! Tenant ID for the endpoint */ - AST_STRING_FIELD(tenantid); ); /*! Configuration for extensions */ struct ast_sip_endpoint_extensions extensions; @@ -1062,6 +1060,8 @@ struct ast_sip_endpoint { enum ast_sip_100rel_mode rel100; /*! Send Advice-of-Charge messages */ unsigned int send_aoc; + /*! Tenant ID for the endpoint */ + AST_STRING_FIELD_EXTENDED(tenantid); }; /*! URI parameter for symmetric transport */ diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index 9dbc8337ad..8b24f29ae5 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -2453,7 +2453,7 @@ void *ast_sip_endpoint_alloc(const char *name) if (!endpoint) { return NULL; } - if (ast_string_field_init(endpoint, 64)) { + if (ast_string_field_init(endpoint, 128)) { ao2_cleanup(endpoint); return NULL; } @@ -2467,6 +2467,10 @@ void *ast_sip_endpoint_alloc(const char *name) ao2_cleanup(endpoint); return NULL; } + if (ast_string_field_init_extended(endpoint, tenantid)) { + ao2_cleanup(endpoint); + return NULL; + } if (!(endpoint->media.codecs = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) { ao2_cleanup(endpoint); -- 2.47.2