Module: sip-router Branch: master Commit: 32951506dff11df32c03230c1548553838140574 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=32951506...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon May 13 10:35:35 2013 +0200
msrp: cache in a local variable if tls module is loaded
- avoid looping at runtime through the list of modules
---
modules/msrp/msrp_cmap.c | 5 +++-- modules/msrp/msrp_mod.c | 3 +++ modules/msrp/msrp_vars.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/modules/msrp/msrp_cmap.c b/modules/msrp/msrp_cmap.c index 5ae3b0c..0ae14a6 100644 --- a/modules/msrp/msrp_cmap.c +++ b/modules/msrp/msrp_cmap.c @@ -43,6 +43,7 @@ static sruid_t _msrp_sruid;
extern int msrp_auth_min_expires; extern int msrp_auth_max_expires; +extern int msrp_tls_module_loaded; extern str msrp_use_path_addr;
/** @@ -211,8 +212,8 @@ int msrp_cmap_save(msrp_frame_t *mf) hid = msrp_get_hashid(&_msrp_sruid.uid); idx = msrp_get_slot(hid, _msrp_cmap_head->mapsize);
- srcaddr.s = sbuf;; - if (module_loaded("tls")) + srcaddr.s = sbuf; + if (msrp_tls_module_loaded) { memcpy(srcaddr.s, "msrps://", 8); srcaddr.s+=8; diff --git a/modules/msrp/msrp_mod.c b/modules/msrp/msrp_mod.c index edc4666..4b85ffe 100644 --- a/modules/msrp/msrp_mod.c +++ b/modules/msrp/msrp_mod.c @@ -69,6 +69,7 @@ int msrp_auth_min_expires = 60; int msrp_auth_max_expires = 3600; int msrp_timer_interval = 60; str msrp_use_path_addr = { 0 }; +int msrp_tls_module_loaded = 0;
static int msrp_frame_received(void *data); sip_msg_t *msrp_fake_sipmsg(msrp_frame_t *mf); @@ -172,6 +173,8 @@ static int mod_init(void) LM_WARN(""tls" module is not loaded. TLS is mandatory for" " MSRP Relays. To comply with RFC 4976 you must use" " TLS.\n"); + } else { + msrp_tls_module_loaded = 1; }
return 0; diff --git a/modules/msrp/msrp_vars.c b/modules/msrp/msrp_vars.c index 673b20d..7e135e5 100644 --- a/modules/msrp/msrp_vars.c +++ b/modules/msrp/msrp_vars.c @@ -36,6 +36,8 @@ #include "msrp_parser.h" #include "msrp_vars.h"
+extern int msrp_tls_module_loaded; + /** * */ @@ -274,7 +276,7 @@ int pv_get_msrp(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) return pv_get_null(msg, param, res); s.s = pv_get_buffer(); p = s.s; - if (module_loaded("tls")) + if (msrp_tls_module_loaded) { memcpy(p, "msrps://", 8); p+=8;