From 093edc657cad2f4570d6fa81978b2640171ccc54 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Tue, 7 May 2024 15:17:13 +0200 Subject: [PATCH] Add option to disable automatic registration Use "manual_register=yes" in registration block of pjsip.conf to disable automatic registration. Then registration must be triggered by AMI interface. --- res/res_pjsip_outbound_registration.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c index a1cd19373e..6a3cf79449 100644 --- a/res/res_pjsip_outbound_registration.c +++ b/res/res_pjsip_outbound_registration.c @@ -209,6 +209,9 @@ Enables advertising SIP Outbound support (RFC5626) for outbound REGISTER requests. + + Perform registration only upon request over AMI interface. + @@ -368,6 +371,8 @@ struct sip_outbound_registration { unsigned int support_path; /*! \brief Whether Outbound support is enabled */ unsigned int support_outbound; + /*! \brief Do not trigger registration automatically. */ + unsigned int manual_register; }; /*! \brief Outbound registration client state information (persists for lifetime of regc) */ @@ -2019,7 +2024,8 @@ static int sip_outbound_registration_apply(const struct ast_sorcery *sorcery, vo return -1; } - if (ast_sip_push_task(new_state->client_state->serializer, + if (!applied->manual_register && + ast_sip_push_task(new_state->client_state->serializer, sip_outbound_registration_perform, ao2_bump(new_state))) { ast_log(LOG_ERROR, "Failed to perform outbound registration on '%s'\n", ast_sorcery_object_get_id(new_state->registration)); @@ -2805,6 +2811,7 @@ static int load_module(void) ast_sorcery_object_field_register_custom(ast_sip_get_sorcery(), "registration", "security_mechanisms", "", security_mechanisms_handler, security_mechanism_to_str, NULL, 0, 0); ast_sorcery_object_field_register(ast_sip_get_sorcery(), "registration", "line", "no", OPT_BOOL_T, 1, FLDSET(struct sip_outbound_registration, line)); ast_sorcery_object_field_register(ast_sip_get_sorcery(), "registration", "endpoint", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct sip_outbound_registration, endpoint)); + ast_sorcery_object_field_register(ast_sip_get_sorcery(), "registration", "manual_register", "no", OPT_BOOL_T, 1, FLDSET(struct sip_outbound_registration, manual_register)); /* * Register sorcery observers.