configurable default expires

This commit is contained in:
Richard Aas 2011-12-15 10:29:02 +00:00
parent 068758967c
commit 4bfebde51b
5 changed files with 13 additions and 14 deletions

View file

@ -56,12 +56,13 @@ typedef void (sipevent_close_h)(int err, const struct sip_msg *msg, void *arg);
int sipevent_accept(struct sipnot **notp, struct sipevent_sock *sock,
const struct sip_msg *msg, struct sip_dialog *dlg,
const struct sipevent_event *event,
uint16_t scode, const char *reason, uint32_t expires_max,
const char *cuser, const char *ctype,
uint16_t scode, const char *reason, uint32_t expires_dfl,
uint32_t expires_max, const char *cuser, const char *ctype,
sip_auth_h *authh, void *aarg, bool aref,
sipevent_close_h *closeh, void *arg, const char *fmt, ...);
int sipevent_notify(struct sipnot *not, struct mbuf *mb);
int sipevent_notifyf(struct sipnot *not, const char *fmt, ...);
int sipevent_notifyf(struct sipnot *not, struct mbuf **mbp,
const char *fmt, ...);
/* Subscriber */

View file

@ -264,7 +264,7 @@ static void subscribe_handler(struct sipevent_sock *sock,
if (pl_isset(&msg->expires))
expires = pl_u32(&msg->expires);
else
expires = DEFAULT_EXPIRES;
expires = not->expires_dfl;
sipnot_refresh(not, expires);

View file

@ -290,8 +290,8 @@ int sipnot_reply(struct sipnot *not, const struct sip_msg *msg,
int sipevent_accept(struct sipnot **notp, struct sipevent_sock *sock,
const struct sip_msg *msg, struct sip_dialog *dlg,
const struct sipevent_event *event,
uint16_t scode, const char *reason, uint32_t expires_max,
const char *cuser, const char *ctype,
uint16_t scode, const char *reason, uint32_t expires_dfl,
uint32_t expires_max, const char *cuser, const char *ctype,
sip_auth_h *authh, void *aarg, bool aref,
sipevent_close_h *closeh, void *arg, const char *fmt, ...)
{
@ -299,8 +299,8 @@ int sipevent_accept(struct sipnot **notp, struct sipevent_sock *sock,
uint32_t expires;
int err;
if (!notp || !sock || !msg || !scode || !reason || !expires_max ||
!cuser || !ctype)
if (!notp || !sock || !msg || !scode || !reason || !expires_dfl ||
!expires_max || !cuser || !ctype)
return EINVAL;
not = mem_zalloc(sizeof(*not), destructor);
@ -370,6 +370,7 @@ int sipevent_accept(struct sipnot **notp, struct sipevent_sock *sock,
goto out;
}
not->expires_dfl = expires_dfl;
not->expires_max = expires_max;
not->sock = mem_ref(sock);
not->sip = mem_ref(sock->sip);
@ -379,7 +380,7 @@ int sipevent_accept(struct sipnot **notp, struct sipevent_sock *sock,
if (pl_isset(&msg->expires))
expires = pl_u32(&msg->expires);
else
expires = DEFAULT_EXPIRES;
expires = not->expires_dfl;
sipnot_refresh(not, expires);

View file

@ -4,11 +4,6 @@
* Copyright (C) 2010 Creytiv.com
*/
enum {
DEFAULT_EXPIRES = 3600,
};
/* Listener Socket */
struct sipevent_sock {
@ -40,6 +35,7 @@ struct sipnot {
char *ctype;
sipevent_close_h *closeh;
void *arg;
uint32_t expires_dfl;
uint32_t expires_max;
enum sipevent_reason reason;
bool notify_pending;

View file

@ -20,6 +20,7 @@
enum {
DEFAULT_EXPIRES = 3600,
RESUB_FAIL_WAIT = 60000,
RESUB_FAILC_MAX = 7,
};