Module: kamailio
Branch: master
Commit: 132c9d03a458c1c8371dfe5bfe07d996e4407cb2
URL:
https://github.com/kamailio/kamailio/commit/132c9d03a458c1c8371dfe5bfe07d99…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-12-21T14:31:08+01:00
registrar: allow taking expires value from xavp_cfg expires field
---
Modified: src/modules/registrar/sip_msg.c
---
Diff:
https://github.com/kamailio/kamailio/commit/132c9d03a458c1c8371dfe5bfe07d99…
Patch:
https://github.com/kamailio/kamailio/commit/132c9d03a458c1c8371dfe5bfe07d99…
---
diff --git a/src/modules/registrar/sip_msg.c b/src/modules/registrar/sip_msg.c
index 2b43dd7611..905e3d6b9d 100644
--- a/src/modules/registrar/sip_msg.c
+++ b/src/modules/registrar/sip_msg.c
@@ -246,27 +246,36 @@ contact_t* get_next_contact(contact_t* _c)
void calc_contact_expires(struct sip_msg* _m, param_t* _ep, int* _e, int novariation)
{
int range = 0;
+ sr_xavp_t *vavp = NULL;
+ str xename = str_init("expires");
- if (!_ep || !_ep->body.len) {
- *_e = get_expires_hf(_m);
+ if (reg_xavp_cfg.s != NULL) {
+ vavp = xavp_get_child_with_ival(®_xavp_cfg, &xename);
+ }
- if ( *_e < 0 ) {
- *_e = cfg_get(registrar, registrar_cfg, default_expires);
- range = cfg_get(registrar, registrar_cfg, default_expires_range);
- } else {
- range = cfg_get(registrar, registrar_cfg, expires_range);
- }
+ if (vavp != NULL && vavp->val.v.i >= 0) {
+ *_e = vavp->val.v.i;
} else {
- if (str2int(&_ep->body, (unsigned int*)_e) < 0) {
- *_e = cfg_get(registrar, registrar_cfg, default_expires);
- range = cfg_get(registrar, registrar_cfg, default_expires_range);
+ if (!_ep || !_ep->body.len) {
+ *_e = get_expires_hf(_m);
+
+ if ( *_e < 0 ) {
+ *_e = cfg_get(registrar, registrar_cfg, default_expires);
+ range = cfg_get(registrar, registrar_cfg, default_expires_range);
+ } else {
+ range = cfg_get(registrar, registrar_cfg, expires_range);
+ }
} else {
- range = cfg_get(registrar, registrar_cfg, expires_range);
+ if (str2int(&_ep->body, (unsigned int*)_e) < 0) {
+ *_e = cfg_get(registrar, registrar_cfg, default_expires);
+ range = cfg_get(registrar, registrar_cfg, default_expires_range);
+ } else {
+ range = cfg_get(registrar, registrar_cfg, expires_range);
+ }
}
}
- if ( *_e != 0 )
- {
+ if ( *_e != 0 ) {
if (*_e < cfg_get(registrar, registrar_cfg, min_expires)) {
if(reg_min_expires_mode) {
rerrno = R_LOW_EXP;