mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 10:33:13 +00:00
Add separate configuration options for subscription and registration minexpiry and maxexpiry.
This offers more fine-grained control over how long subscriptions last without negatively affecting the expiration range for registrations. Uploaded by: Guenther Kelleter(license #6372) Review: https://reviewboard.asterisk.org/r/2051 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370386 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
8
CHANGES
8
CHANGES
@@ -311,6 +311,14 @@ chan_sip
|
|||||||
|
|
||||||
* Add support for WebSocket transport. This can be configured using 'ws' or 'wss'
|
* Add support for WebSocket transport. This can be configured using 'ws' or 'wss'
|
||||||
as the transport.
|
as the transport.
|
||||||
|
* Add options subminexpiry and submaxexpiry to set limits of subscription
|
||||||
|
timer independently from registration timer settings. The setting of the
|
||||||
|
registration timer limits still is done by options minexpiry, maxexpiry
|
||||||
|
and defaultexpiry. For backwards compatibility the setting of minexpiry
|
||||||
|
and maxexpiry also is used to configure the subscription timer limits if
|
||||||
|
subminexpiry and submaxexpiry are not set in sip.conf.
|
||||||
|
* Set registration timer limits to default values when reloading sip
|
||||||
|
configuration and values are not set by configuration.
|
||||||
|
|
||||||
* When a MESSAGE request is received, the address the request was received from
|
* When a MESSAGE request is received, the address the request was received from
|
||||||
is now saved in the SIP_RECVADDR variable.
|
is now saved in the SIP_RECVADDR variable.
|
||||||
|
@@ -585,6 +585,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
static int min_expiry = DEFAULT_MIN_EXPIRY; /*!< Minimum accepted registration time */
|
static int min_expiry = DEFAULT_MIN_EXPIRY; /*!< Minimum accepted registration time */
|
||||||
static int max_expiry = DEFAULT_MAX_EXPIRY; /*!< Maximum accepted registration time */
|
static int max_expiry = DEFAULT_MAX_EXPIRY; /*!< Maximum accepted registration time */
|
||||||
static int default_expiry = DEFAULT_DEFAULT_EXPIRY;
|
static int default_expiry = DEFAULT_DEFAULT_EXPIRY;
|
||||||
|
static int min_subexpiry = DEFAULT_MIN_EXPIRY; /*!< Minimum accepted subscription time */
|
||||||
|
static int max_subexpiry = DEFAULT_MAX_EXPIRY; /*!< Maximum accepted subscription time */
|
||||||
static int mwi_expiry = DEFAULT_MWI_EXPIRY;
|
static int mwi_expiry = DEFAULT_MWI_EXPIRY;
|
||||||
|
|
||||||
static int unauth_sessions = 0;
|
static int unauth_sessions = 0;
|
||||||
@@ -11546,12 +11548,12 @@ static int transmit_response_with_allow(struct sip_pvt *p, const char *msg, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Append Min-Expires header, content length before transmitting response */
|
/*! \brief Append Min-Expires header, content length before transmitting response */
|
||||||
static int transmit_response_with_minexpires(struct sip_pvt *p, const char *msg, const struct sip_request *req)
|
static int transmit_response_with_minexpires(struct sip_pvt *p, const char *msg, const struct sip_request *req, int minexpires)
|
||||||
{
|
{
|
||||||
struct sip_request resp;
|
struct sip_request resp;
|
||||||
char tmp[32];
|
char tmp[32];
|
||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "%d", min_expiry);
|
snprintf(tmp, sizeof(tmp), "%d", minexpires);
|
||||||
respprep(&resp, p, msg, req);
|
respprep(&resp, p, msg, req);
|
||||||
add_header(&resp, "Min-Expires", tmp);
|
add_header(&resp, "Min-Expires", tmp);
|
||||||
return send_response(p, &resp, XMIT_UNRELIABLE, 0);
|
return send_response(p, &resp, XMIT_UNRELIABLE, 0);
|
||||||
@@ -19678,6 +19680,8 @@ static char *sip_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_
|
|||||||
ast_cli(a->fd, " Reg. min duration %d secs\n", min_expiry);
|
ast_cli(a->fd, " Reg. min duration %d secs\n", min_expiry);
|
||||||
ast_cli(a->fd, " Reg. max duration: %d secs\n", max_expiry);
|
ast_cli(a->fd, " Reg. max duration: %d secs\n", max_expiry);
|
||||||
ast_cli(a->fd, " Reg. default duration: %d secs\n", default_expiry);
|
ast_cli(a->fd, " Reg. default duration: %d secs\n", default_expiry);
|
||||||
|
ast_cli(a->fd, " Sub. min duration %d secs\n", min_subexpiry);
|
||||||
|
ast_cli(a->fd, " Sub. max duration: %d secs\n", max_subexpiry);
|
||||||
ast_cli(a->fd, " Outbound reg. timeout: %d secs\n", global_reg_timeout);
|
ast_cli(a->fd, " Outbound reg. timeout: %d secs\n", global_reg_timeout);
|
||||||
ast_cli(a->fd, " Outbound reg. attempts: %d\n", global_regattempts_max);
|
ast_cli(a->fd, " Outbound reg. attempts: %d\n", global_regattempts_max);
|
||||||
ast_cli(a->fd, " Notify ringing state: %s\n", AST_CLI_YESNO(sip_cfg.notifyringing));
|
ast_cli(a->fd, " Notify ringing state: %s\n", AST_CLI_YESNO(sip_cfg.notifyringing));
|
||||||
@@ -26330,7 +26334,7 @@ static int handle_request_publish(struct sip_pvt *p, struct sip_request *req, st
|
|||||||
if (expires_int > max_expiry) {
|
if (expires_int > max_expiry) {
|
||||||
expires_int = max_expiry;
|
expires_int = max_expiry;
|
||||||
} else if (expires_int < min_expiry && expires_int > 0) {
|
} else if (expires_int < min_expiry && expires_int > 0) {
|
||||||
transmit_response_with_minexpires(p, "423 Interval too small", req);
|
transmit_response_with_minexpires(p, "423 Interval too small", req, min_expiry);
|
||||||
pvt_set_needdestroy(p, "Expires is less that the min expires allowed.");
|
pvt_set_needdestroy(p, "Expires is less that the min expires allowed.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -26762,13 +26766,13 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
|
|||||||
p->expiry = atoi(sip_get_header(req, "Expires"));
|
p->expiry = atoi(sip_get_header(req, "Expires"));
|
||||||
|
|
||||||
/* check if the requested expiry-time is within the approved limits from sip.conf */
|
/* check if the requested expiry-time is within the approved limits from sip.conf */
|
||||||
if (p->expiry > max_expiry) {
|
if (p->expiry > max_subexpiry) {
|
||||||
p->expiry = max_expiry;
|
p->expiry = max_subexpiry;
|
||||||
} else if (p->expiry < min_expiry && p->expiry > 0) {
|
} else if (p->expiry < min_subexpiry && p->expiry > 0) {
|
||||||
transmit_response_with_minexpires(p, "423 Interval too small", req);
|
transmit_response_with_minexpires(p, "423 Interval too small", req, min_subexpiry);
|
||||||
ast_log(LOG_WARNING, "Received subscription for extension \"%s\" context \"%s\" "
|
ast_log(LOG_WARNING, "Received subscription for extension \"%s\" context \"%s\" "
|
||||||
"with Expire header less that 'minexpire' limit. Received \"Expire: %d\" min is %d\n",
|
"with Expire header less than 'subminexpire' limit. Received \"Expire: %d\" min is %d\n",
|
||||||
p->exten, p->context, p->expiry, min_expiry);
|
p->exten, p->context, p->expiry, min_subexpiry);
|
||||||
pvt_set_needdestroy(p, "Expires is less that the min expires allowed.");
|
pvt_set_needdestroy(p, "Expires is less that the min expires allowed.");
|
||||||
if (authpeer) {
|
if (authpeer) {
|
||||||
sip_unref_peer(authpeer, "sip_unref_peer, from handle_request_subscribe (authpeer 6)");
|
sip_unref_peer(authpeer, "sip_unref_peer, from handle_request_subscribe (authpeer 6)");
|
||||||
@@ -30108,6 +30112,7 @@ static int reload_config(enum channelreloadreason reason)
|
|||||||
time_t run_start, run_end;
|
time_t run_start, run_end;
|
||||||
int bindport = 0;
|
int bindport = 0;
|
||||||
int acl_change_subscription_needed = 0;
|
int acl_change_subscription_needed = 0;
|
||||||
|
int min_subexpiry_set = 0, max_subexpiry_set = 0;
|
||||||
|
|
||||||
run_start = time(0);
|
run_start = time(0);
|
||||||
ast_unload_realtime("sipregs");
|
ast_unload_realtime("sipregs");
|
||||||
@@ -30324,6 +30329,9 @@ static int reload_config(enum channelreloadreason reason)
|
|||||||
authlimit = DEFAULT_AUTHLIMIT;
|
authlimit = DEFAULT_AUTHLIMIT;
|
||||||
authtimeout = DEFAULT_AUTHTIMEOUT;
|
authtimeout = DEFAULT_AUTHTIMEOUT;
|
||||||
global_store_sip_cause = DEFAULT_STORE_SIP_CAUSE;
|
global_store_sip_cause = DEFAULT_STORE_SIP_CAUSE;
|
||||||
|
min_expiry = DEFAULT_MIN_EXPIRY;
|
||||||
|
max_expiry = DEFAULT_MAX_EXPIRY;
|
||||||
|
default_expiry = DEFAULT_DEFAULT_EXPIRY;
|
||||||
|
|
||||||
sip_cfg.matchexternaddrlocally = DEFAULT_MATCHEXTERNADDRLOCALLY;
|
sip_cfg.matchexternaddrlocally = DEFAULT_MATCHEXTERNADDRLOCALLY;
|
||||||
|
|
||||||
@@ -30595,6 +30603,18 @@ static int reload_config(enum channelreloadreason reason)
|
|||||||
if (default_expiry < 1) {
|
if (default_expiry < 1) {
|
||||||
default_expiry = DEFAULT_DEFAULT_EXPIRY;
|
default_expiry = DEFAULT_DEFAULT_EXPIRY;
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(v->name, "submaxexpirey") || !strcasecmp(v->name, "submaxexpiry")) {
|
||||||
|
max_subexpiry = atoi(v->value);
|
||||||
|
if (max_subexpiry < 1) {
|
||||||
|
max_subexpiry = DEFAULT_MAX_EXPIRY;
|
||||||
|
}
|
||||||
|
max_subexpiry_set = 1;
|
||||||
|
} else if (!strcasecmp(v->name, "subminexpirey") || !strcasecmp(v->name, "subminexpiry")) {
|
||||||
|
min_subexpiry = atoi(v->value);
|
||||||
|
if (min_subexpiry < 1) {
|
||||||
|
min_subexpiry = DEFAULT_MIN_EXPIRY;
|
||||||
|
}
|
||||||
|
min_subexpiry_set = 1;
|
||||||
} else if (!strcasecmp(v->name, "mwiexpiry") || !strcasecmp(v->name, "mwiexpirey")) {
|
} else if (!strcasecmp(v->name, "mwiexpiry") || !strcasecmp(v->name, "mwiexpirey")) {
|
||||||
mwi_expiry = atoi(v->value);
|
mwi_expiry = atoi(v->value);
|
||||||
if (mwi_expiry < 1) {
|
if (mwi_expiry < 1) {
|
||||||
@@ -30866,6 +30886,14 @@ static int reload_config(enum channelreloadreason reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* For backwards compatibility the corresponding registration timer value is used if subscription timer value isn't set by configuration */
|
||||||
|
if (!min_subexpiry_set) {
|
||||||
|
min_subexpiry = min_expiry;
|
||||||
|
}
|
||||||
|
if (!max_subexpiry_set) {
|
||||||
|
max_subexpiry = max_expiry;
|
||||||
|
}
|
||||||
|
|
||||||
if (reason != CHANNEL_MODULE_LOAD) {
|
if (reason != CHANNEL_MODULE_LOAD) {
|
||||||
/* Then, actually destroy users and registry */
|
/* Then, actually destroy users and registry */
|
||||||
ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy);
|
ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy);
|
||||||
|
@@ -258,10 +258,11 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
|
|||||||
;cos_video=4 ; Sets 802.1p priority for RTP video packets.
|
;cos_video=4 ; Sets 802.1p priority for RTP video packets.
|
||||||
;cos_text=3 ; Sets 802.1p priority for RTP text packets.
|
;cos_text=3 ; Sets 802.1p priority for RTP text packets.
|
||||||
|
|
||||||
;maxexpiry=3600 ; Maximum allowed time of incoming registrations
|
;maxexpiry=3600 ; Maximum allowed time of incoming registrations (seconds)
|
||||||
; and subscriptions (seconds)
|
;minexpiry=60 ; Minimum length of registrations (default 60)
|
||||||
;minexpiry=60 ; Minimum length of registrations/subscriptions (default 60)
|
|
||||||
;defaultexpiry=120 ; Default length of incoming/outgoing registration
|
;defaultexpiry=120 ; Default length of incoming/outgoing registration
|
||||||
|
;submaxexpiry=3600 ; Maximum allowed time of incoming subscriptions (seconds), default: maxexpiry
|
||||||
|
;subminexpiry=60 ; Minimum length of subscriptions, default: minexpiry
|
||||||
;mwiexpiry=3600 ; Expiry time for outgoing MWI subscriptions
|
;mwiexpiry=3600 ; Expiry time for outgoing MWI subscriptions
|
||||||
;maxforwards=70 ; Setting for the SIP Max-Forwards: header (loop prevention)
|
;maxforwards=70 ; Setting for the SIP Max-Forwards: header (loop prevention)
|
||||||
; Default value is 70
|
; Default value is 70
|
||||||
|
Reference in New Issue
Block a user