Add a new global and per-peer option to chan_sip, qualifyfreq, which allows you

to set the qualify frequency.

(closes issue #11597)
Reported by: wilder
Patches:
      qualifyfreq5.patch uploaded by wilder (license 362)
	   -- with some mods by me


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98027 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant 2008-01-11 00:38:23 +00:00
parent c0983033ff
commit 5c2beee6c3
3 changed files with 38 additions and 4 deletions

View File

@ -120,6 +120,8 @@ SIP changes
considered advanced, so don't use them unless you have a problem. considered advanced, so don't use them unless you have a problem.
* Added a dial string option to be able to set the To: header in an INVITE to any * Added a dial string option to be able to set the To: header in an INVITE to any
SIP uri. SIP uri.
* Added a new global and per-peer option, qualifyfreq, which allows you to configure
the qualify frequency.
IAX2 changes IAX2 changes
------------ ------------

View File

@ -181,7 +181,7 @@ static int expiry = DEFAULT_EXPIRY;
#define CALLERID_UNKNOWN "Unknown" #define CALLERID_UNKNOWN "Unknown"
#define DEFAULT_MAXMS 2000 /*!< Qualification: Must be faster than 2 seconds by default */ #define DEFAULT_MAXMS 2000 /*!< Qualification: Must be faster than 2 seconds by default */
#define DEFAULT_FREQ_OK 60 * 1000 /*!< Qualification: How often to check for the host to be up */ #define DEFAULT_QUALIFYFREQ 60 * 1000 /*!< Qualification: How often to check for the host to be up */
#define DEFAULT_FREQ_NOTOK 10 * 1000 /*!< Qualification: How often to check, if the host is down... */ #define DEFAULT_FREQ_NOTOK 10 * 1000 /*!< Qualification: How often to check, if the host is down... */
#define DEFAULT_RETRANS 1000 /*!< How frequently to retransmit Default: 2 * 500 ms in RFC 3261 */ #define DEFAULT_RETRANS 1000 /*!< How frequently to retransmit Default: 2 * 500 ms in RFC 3261 */
@ -648,8 +648,9 @@ static int global_regextenonqualify; /*!< Whether to add/remove regexten when q
static int global_autoframing; /*!< Turn autoframing on or off. */ static int global_autoframing; /*!< Turn autoframing on or off. */
static enum transfermodes global_allowtransfer; /*!< SIP Refer restriction scheme */ static enum transfermodes global_allowtransfer; /*!< SIP Refer restriction scheme */
static struct sip_proxy global_outboundproxy; /*!< Outbound proxy */ static struct sip_proxy global_outboundproxy; /*!< Outbound proxy */
static int global_matchexterniplocally; /*!< Match externip/externhost setting against localnet setting */ static int global_matchexterniplocally; /*!< Match externip/externhost setting against localnet setting */
static int global_qualifyfreq; /*!< Qualify frequency */
/*! \brief Codecs that we support by default: */ /*! \brief Codecs that we support by default: */
static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263; static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
@ -1351,6 +1352,7 @@ struct sip_peer {
int pokeexpire; /*!< When to expire poke (qualify= checking) */ int pokeexpire; /*!< When to expire poke (qualify= checking) */
int lastms; /*!< How long last response took (in ms), or -1 for no response */ int lastms; /*!< How long last response took (in ms), or -1 for no response */
int maxms; /*!< Max ms we will accept for the host to be up, 0 to not monitor */ int maxms; /*!< Max ms we will accept for the host to be up, 0 to not monitor */
int qualifyfreq; /*!< Qualification: How often to check for the host to be up */
struct timeval ps; /*!< Time for sending SIP OPTION in sip_pke_peer() */ struct timeval ps; /*!< Time for sending SIP OPTION in sip_pke_peer() */
struct sockaddr_in defaddr; /*!< Default IP address, used until registration */ struct sockaddr_in defaddr; /*!< Default IP address, used until registration */
struct ast_ha *ha; /*!< Access control list */ struct ast_ha *ha; /*!< Access control list */
@ -11722,6 +11724,7 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
ast_cli(fd, "%s\n",status); ast_cli(fd, "%s\n",status);
ast_cli(fd, " Useragent : %s\n", peer->useragent); ast_cli(fd, " Useragent : %s\n", peer->useragent);
ast_cli(fd, " Reg. Contact : %s\n", peer->fullcontact); ast_cli(fd, " Reg. Contact : %s\n", peer->fullcontact);
ast_cli(fd, " Qualify Freq : %d ms\n", peer->qualifyfreq);
if (peer->chanvars) { if (peer->chanvars) {
ast_cli(fd, " Variables :\n"); ast_cli(fd, " Variables :\n");
for (v = peer->chanvars ; v ; v = v->next) for (v = peer->chanvars ; v ; v = v->next)
@ -11798,6 +11801,7 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
astman_append(s, "%s\r\n", status); astman_append(s, "%s\r\n", status);
astman_append(s, "SIP-Useragent: %s\r\n", peer->useragent); astman_append(s, "SIP-Useragent: %s\r\n", peer->useragent);
astman_append(s, "Reg-Contact : %s\r\n", peer->fullcontact); astman_append(s, "Reg-Contact : %s\r\n", peer->fullcontact);
astman_append(s, "Qualify Freq : %d ms\n", peer->qualifyfreq);
if (peer->chanvars) { if (peer->chanvars) {
for (v = peer->chanvars ; v ; v = v->next) { for (v = peer->chanvars ; v ; v = v->next) {
astman_append(s, "ChanVariable:\n"); astman_append(s, "ChanVariable:\n");
@ -12043,6 +12047,7 @@ static char *sip_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_
ast_cli(a->fd, " SIP realtime: Disabled\n" ); ast_cli(a->fd, " SIP realtime: Disabled\n" );
else else
ast_cli(a->fd, " SIP realtime: Enabled\n" ); ast_cli(a->fd, " SIP realtime: Enabled\n" );
ast_cli(a->fd, " Qualify Freq : %d ms\n", global_qualifyfreq);
ast_cli(a->fd, "\nNetwork Settings:\n"); ast_cli(a->fd, "\nNetwork Settings:\n");
ast_cli(a->fd, "---------------------------\n"); ast_cli(a->fd, "---------------------------\n");
@ -14084,7 +14089,7 @@ static void handle_response_peerpoke(struct sip_pvt *p, int resp, struct sip_req
/* Try again eventually */ /* Try again eventually */
peer->pokeexpire = ast_sched_replace(peer->pokeexpire, sched, peer->pokeexpire = ast_sched_replace(peer->pokeexpire, sched,
is_reachable ? DEFAULT_FREQ_OK : DEFAULT_FREQ_NOTOK, is_reachable ? peer->qualifyfreq : DEFAULT_FREQ_NOTOK,
sip_poke_peer_s, peer); sip_poke_peer_s, peer);
} }
@ -17966,6 +17971,7 @@ static void set_peer_defaults(struct sip_peer *peer)
peer->rtpkeepalive = global_rtpkeepalive; peer->rtpkeepalive = global_rtpkeepalive;
peer->allowtransfer = global_allowtransfer; peer->allowtransfer = global_allowtransfer;
peer->autoframing = global_autoframing; peer->autoframing = global_autoframing;
peer->qualifyfreq = global_qualifyfreq;
if (global_callcounter) if (global_callcounter)
peer->call_limit=999; peer->call_limit=999;
strcpy(peer->vmexten, default_vmexten); strcpy(peer->vmexten, default_vmexten);
@ -18278,6 +18284,14 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
ast_log(LOG_WARNING, "Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", peer->name, v->lineno); ast_log(LOG_WARNING, "Qualification of peer '%s' should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", peer->name, v->lineno);
peer->maxms = 0; peer->maxms = 0;
} }
} else if (!strcasecmp(v->name, "qualifyfreq")) {
int i;
if (sscanf(v->value, "%d", &i) == 1)
peer->qualifyfreq = i * 1000;
else {
ast_log(LOG_WARNING, "Invalid qualifyfreq number '%s' at line %d of %s\n",v->value, v->lineno, config);
peer->qualifyfreq = global_qualifyfreq;
}
} else if (!strcasecmp(v->name, "maxcallbitrate")) { } else if (!strcasecmp(v->name, "maxcallbitrate")) {
peer->maxcallbitrate = atoi(v->value); peer->maxcallbitrate = atoi(v->value);
if (peer->maxcallbitrate < 0) if (peer->maxcallbitrate < 0)
@ -18489,7 +18503,8 @@ static int reload_config(enum channelreloadreason reason)
global_callevents = FALSE; global_callevents = FALSE;
global_t1 = SIP_TIMER_T1; global_t1 = SIP_TIMER_T1;
global_timer_b = 64 * SIP_TIMER_T1; global_timer_b = 64 * SIP_TIMER_T1;
global_t1min = DEFAULT_T1MIN; global_t1min = DEFAULT_T1MIN;
global_qualifyfreq = DEFAULT_QUALIFYFREQ;
global_matchexterniplocally = FALSE; global_matchexterniplocally = FALSE;
@ -18758,6 +18773,14 @@ static int reload_config(enum channelreloadreason reason)
ast_log(LOG_WARNING, "Qualification default should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", v->lineno); ast_log(LOG_WARNING, "Qualification default should be 'yes', 'no', or a number of milliseconds at line %d of sip.conf\n", v->lineno);
default_qualify = 0; default_qualify = 0;
} }
} else if (!strcasecmp(v->name, "qualifyfreq")) {
int i;
if (sscanf(v->value, "%d", &i) == 1)
global_qualifyfreq = i * 1000;
else {
ast_log(LOG_WARNING, "Invalid qualifyfreq number '%s' at line %d of %s\n", v->value, v->lineno, config);
global_qualifyfreq = DEFAULT_QUALIFYFREQ;
}
} else if (!strcasecmp(v->name, "callevents")) { } else if (!strcasecmp(v->name, "callevents")) {
global_callevents = ast_true(v->value); global_callevents = ast_true(v->value);
} else if (!strcasecmp(v->name, "maxcallbitrate")) { } else if (!strcasecmp(v->name, "maxcallbitrate")) {

View File

@ -101,6 +101,10 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; and subscriptions (seconds) ; and subscriptions (seconds)
;minexpiry=60 ; Minimum length of registrations/subscriptions (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
;qualifyfreq=60 ; Qualification: How often to check for the
; host to be up in seconds
; Set to low value if you use low timeout for
; NAT of UDP sessions
;notifymimetype=text/plain ; Allow overriding of mime type in MWI NOTIFY ;notifymimetype=text/plain ; Allow overriding of mime type in MWI NOTIFY
;buggymwi=no ; Cisco SIP firmware doesn't support the MWI RFC ;buggymwi=no ; Cisco SIP firmware doesn't support the MWI RFC
; fully. Enable this option to not get error messages ; fully. Enable this option to not get error messages
@ -631,6 +635,7 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; registertrying ; registertrying
; timert1 ; timert1
; timerb ; timerb
; qualifyfreq
;[sip_proxy] ;[sip_proxy]
; For incoming calls only. Example: FWD (Free World Dialup) ; For incoming calls only. Example: FWD (Free World Dialup)
@ -812,6 +817,10 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
;qualify=1000 ; Consider it down if it's 1 second to reply ;qualify=1000 ; Consider it down if it's 1 second to reply
; Helps with NAT session ; Helps with NAT session
; qualify=yes uses default value ; qualify=yes uses default value
;qualifyfreq=60 ; Qualification: How often to check for the
; host to be up in seconds
; Set to low value if you use low timeout for
; NAT of UDP sessions
; ;
; Call group and Pickup group should be in the range from 0 to 63 ; Call group and Pickup group should be in the range from 0 to 63
; ;