1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
https://issues.asterisk.org/jira/browse/ASTERISK-26518
commit 500470607eae4144b44ed4f188cfff437d56f0e7
Author: Alex Hermann <alex@hexla.nl>
Date: Fri Jan 20 11:09:01 2017 +0100
pjsip: Restore multihomed module
Since the automatic dual stack commit, the multihome module has become
part of the pjsip core module. This caused a circular dependency loop
preventing the pjsip module from loading. By putting the logic back into
its own module, things can be loaded again.
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index dd4a619d2a..6e9523d76b 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -4317,6 +4317,5 @@ static int unload_pjsip(void *data)
if (ast_pjsip_endpoint && serializer_pool[0]) {
ast_res_pjsip_cleanup_options_handling();
- ast_res_pjsip_cleanup_message_ip_updater();
ast_sip_destroy_distributor();
ast_res_pjsip_destroy_configuration();
ast_sip_destroy_system();
@@ -4488,11 +4487,6 @@ static int load_module(void)
ast_res_pjsip_init_options_handling(0);
- if (ast_res_pjsip_init_message_ip_updater()) {
- ast_log(LOG_ERROR, "Failed to initialize message IP updating. Aborting load\n");
- goto error;
- }
-
ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));
AST_TEST_REGISTER(xml_sanitization_end_null);
diff --git a/res/res_pjsip/pjsip_message_ip_updater.c b/res/res_pjsip_multihomed.c
similarity index 94%
rename from res/res_pjsip/pjsip_message_ip_updater.c
rename to res/res_pjsip_multihomed.c
index 7671ad0a75..3a29255973 100644
--- a/res/res_pjsip/pjsip_message_ip_updater.c
+++ b/res/res_pjsip_multihomed.c
@@ -16,6 +16,12 @@
* at the top of the source tree.
*/
+/*** MODULEINFO
+ <depend>pjproject</depend>
+ <depend>res_pjsip</depend>
+ <support_level>core</support_level>
+ ***/
+
#include "asterisk.h"
#include <pjsip.h>
@@ -23,7 +29,8 @@
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
-#include "include/res_pjsip_private.h"
+#include "res_pjsip/include/res_pjsip_private.h"
+#include "asterisk/module.h"
#define MOD_DATA_RESTRICTIONS "restrictions"
@@ -273,31 +280,41 @@ static pj_status_t multihomed_on_tx_message(pjsip_tx_data *tdata)
return PJ_SUCCESS;
}
-void ast_res_pjsip_cleanup_message_ip_updater(void)
+static int unload_module(void)
{
ast_sip_unregister_service(&multihomed_module);
ast_sip_unregister_supplement(&multihomed_supplement);
ast_sip_session_unregister_supplement(&multihomed_session_supplement);
+ return 0;
}
-int ast_res_pjsip_init_message_ip_updater(void)
+static int load_module(void)
{
+ CHECK_PJSIP_MODULE_LOADED();
+
if (ast_sip_session_register_supplement(&multihomed_session_supplement)) {
ast_log(LOG_ERROR, "Could not register multihomed session supplement for outgoing requests\n");
- return -1;
+ return AST_MODULE_LOAD_FAILURE;
}
if (ast_sip_register_supplement(&multihomed_supplement)) {
ast_log(LOG_ERROR, "Could not register multihomed supplement for outgoing requests\n");
- ast_res_pjsip_cleanup_message_ip_updater();
- return -1;
+ unload_module();
+ return AST_MODULE_LOAD_FAILURE;
}
if (ast_sip_register_service(&multihomed_module)) {
ast_log(LOG_ERROR, "Could not register multihomed module for incoming and outgoing requests\n");
- ast_res_pjsip_cleanup_message_ip_updater();
- return -1;
+ unload_module();
+ return AST_MODULE_LOAD_FAILURE;
}
- return 0;
+ return AST_MODULE_LOAD_SUCCESS;
}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Multihomed Routing Support",
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .load_pri = AST_MODPRI_CHANNEL_DEPEND,
+);
|