mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
res_pjsip: Fix infinite recursion when loading transports from realtime
Attempting to load a transport from realtime was forcing asterisk into an infinite recursion loop. The first thing transport_apply did was to do a sorcery retrieve by id for an existing transport of the same name. For files, this just returns the previous object from res_sorcery_config's internal container, if any. For realtime, the res_sourcery_realtime driver looks in the database and finds the existing row but now it has to rehydrate it into a sorcery object which means calling... transport_apply. And so it goes. The main issue with loading from realtime (apart from the loop) was that transport stores structures and pointers directly in the ast_sip_transport structure instead of the separate ast_transport_state structure. This patch separates those items into the ast_sip_transport_state structure. The pattern is roughly the same as res_pjsip_outbound_registration. Although all current usages of ast_sip_transport and ast_sip_transport_state were modified to use the new ast_sip_get_transport_state API, the original items are left in ast_sip_transport and kept updated to maintain ABI compatability for third-party modules. They are marked as deprecated and noted that they're now in ast_sip_transport_state. ASTERISK-25606 #close Reported-by: Martin Moučka Change-Id: Ic7a836ea8e786e8def51fe3f8cce855ea54f5f19
This commit is contained in:
@@ -54,34 +54,59 @@ struct pjsip_tpfactory;
|
||||
struct pjsip_tls_setting;
|
||||
struct pjsip_tpselector;
|
||||
|
||||
/*! \brief Maximum number of ciphers supported for a TLS transport */
|
||||
#define SIP_TLS_MAX_CIPHERS 64
|
||||
|
||||
/*!
|
||||
* \brief Structure for SIP transport information
|
||||
*/
|
||||
struct ast_sip_transport_state {
|
||||
/*! \brief Transport itself */
|
||||
struct pjsip_transport *transport;
|
||||
|
||||
/*! \brief Transport factory */
|
||||
struct pjsip_tpfactory *factory;
|
||||
/*!
|
||||
* Transport id
|
||||
* \since 13.8.0
|
||||
*/
|
||||
char *id;
|
||||
/*!
|
||||
* Transport type
|
||||
* \since 13.8.0
|
||||
*/
|
||||
enum ast_transport type;
|
||||
/*!
|
||||
* Address and port to bind to
|
||||
* \since 13.8.0
|
||||
*/
|
||||
pj_sockaddr host;
|
||||
/*!
|
||||
* TLS settings
|
||||
* \since 13.8.0
|
||||
*/
|
||||
pjsip_tls_setting tls;
|
||||
/*!
|
||||
* Configured TLS ciphers
|
||||
* \since 13.8.0
|
||||
*/
|
||||
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS];
|
||||
/*!
|
||||
* Optional local network information, used for NAT purposes
|
||||
* \since 13.8.0
|
||||
*/
|
||||
struct ast_ha *localnet;
|
||||
/*!
|
||||
* DNS manager for refreshing the external address
|
||||
* \since 13.8.0
|
||||
*/
|
||||
struct ast_dnsmgr_entry *external_address_refresher;
|
||||
/*!
|
||||
* Optional external address information
|
||||
* \since 13.8.0
|
||||
*/
|
||||
struct ast_sockaddr external_address;
|
||||
};
|
||||
|
||||
#define SIP_SORCERY_DOMAIN_ALIAS_TYPE "domain_alias"
|
||||
|
||||
/*!
|
||||
* Details about a SIP domain alias
|
||||
*/
|
||||
struct ast_sip_domain_alias {
|
||||
/*! Sorcery object details */
|
||||
SORCERY_OBJECT(details);
|
||||
AST_DECLARE_STRING_FIELDS(
|
||||
/*! Domain to be aliased to */
|
||||
AST_STRING_FIELD(domain);
|
||||
);
|
||||
};
|
||||
|
||||
/*! \brief Maximum number of ciphers supported for a TLS transport */
|
||||
#define SIP_TLS_MAX_CIPHERS 64
|
||||
|
||||
/*
|
||||
* \brief Transport to bind to
|
||||
*/
|
||||
@@ -108,23 +133,51 @@ struct ast_sip_transport {
|
||||
);
|
||||
/*! Type of transport */
|
||||
enum ast_transport type;
|
||||
/*! Address and port to bind to */
|
||||
/*!
|
||||
* \deprecated Moved to ast_sip_transport_state
|
||||
* \version 13.8.0 deprecated
|
||||
* Address and port to bind to
|
||||
*/
|
||||
pj_sockaddr host;
|
||||
/*! Number of simultaneous asynchronous operations */
|
||||
unsigned int async_operations;
|
||||
/*! Optional external port for signaling */
|
||||
unsigned int external_signaling_port;
|
||||
/*! TLS settings */
|
||||
/*!
|
||||
* \deprecated Moved to ast_sip_transport_state
|
||||
* \version 13.7.1 deprecated
|
||||
* TLS settings
|
||||
*/
|
||||
pjsip_tls_setting tls;
|
||||
/*! Configured TLS ciphers */
|
||||
/*!
|
||||
* \deprecated Moved to ast_sip_transport_state
|
||||
* \version 13.7.1 deprecated
|
||||
* Configured TLS ciphers
|
||||
*/
|
||||
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS];
|
||||
/*! Optional local network information, used for NAT purposes */
|
||||
/*!
|
||||
* \deprecated Moved to ast_sip_transport_state
|
||||
* \version 13.7.1 deprecated
|
||||
* Optional local network information, used for NAT purposes
|
||||
*/
|
||||
struct ast_ha *localnet;
|
||||
/*! DNS manager for refreshing the external address */
|
||||
/*!
|
||||
* \deprecated Moved to ast_sip_transport_state
|
||||
* \version 13.7.1 deprecated
|
||||
* DNS manager for refreshing the external address
|
||||
*/
|
||||
struct ast_dnsmgr_entry *external_address_refresher;
|
||||
/*! Optional external address information */
|
||||
/*!
|
||||
* \deprecated Moved to ast_sip_transport_state
|
||||
* \version 13.7.1 deprecated
|
||||
* Optional external address information
|
||||
*/
|
||||
struct ast_sockaddr external_address;
|
||||
/*! Transport state information */
|
||||
/*!
|
||||
* \deprecated
|
||||
* \version 13.7.1 deprecated
|
||||
* Transport state information
|
||||
*/
|
||||
struct ast_sip_transport_state *state;
|
||||
/*! QOS DSCP TOS bits */
|
||||
unsigned int tos;
|
||||
@@ -134,6 +187,20 @@ struct ast_sip_transport {
|
||||
int write_timeout;
|
||||
};
|
||||
|
||||
#define SIP_SORCERY_DOMAIN_ALIAS_TYPE "domain_alias"
|
||||
|
||||
/*!
|
||||
* Details about a SIP domain alias
|
||||
*/
|
||||
struct ast_sip_domain_alias {
|
||||
/*! Sorcery object details */
|
||||
SORCERY_OBJECT(details);
|
||||
AST_DECLARE_STRING_FIELDS(
|
||||
/*! Domain to be aliased to */
|
||||
AST_STRING_FIELD(domain);
|
||||
);
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Structure for SIP nat hook information
|
||||
*/
|
||||
@@ -2172,4 +2239,25 @@ const char *ast_sip_get_host_ip_string(int af);
|
||||
*/
|
||||
long ast_sip_threadpool_queue_size(void);
|
||||
|
||||
/*!
|
||||
* \brief Retrieve transport state
|
||||
* \since 13.7.1
|
||||
*
|
||||
* @param transport_id
|
||||
* @returns transport_state
|
||||
*
|
||||
* \note ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object
|
||||
*/
|
||||
struct ast_sip_transport_state *ast_sip_get_transport_state(const char *transport_id);
|
||||
|
||||
/*!
|
||||
* \brief Retrieves all transport states
|
||||
* \since 13.7.1
|
||||
*
|
||||
* @returns ao2_container
|
||||
*
|
||||
* \note ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object
|
||||
*/
|
||||
struct ao2_container *ast_sip_get_transport_states(void);
|
||||
|
||||
#endif /* _RES_PJSIP_H */
|
||||
|
Reference in New Issue
Block a user