diff --git a/include/re_sipevent.h b/include/re_sipevent.h index 4b98a37..b080669 100644 --- a/include/re_sipevent.h +++ b/include/re_sipevent.h @@ -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 */ diff --git a/src/sipevent/listen.c b/src/sipevent/listen.c index d7e0145..a4b6434 100644 --- a/src/sipevent/listen.c +++ b/src/sipevent/listen.c @@ -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); diff --git a/src/sipevent/notify.c b/src/sipevent/notify.c index c7cd909..4626775 100644 --- a/src/sipevent/notify.c +++ b/src/sipevent/notify.c @@ -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); diff --git a/src/sipevent/sipevent.h b/src/sipevent/sipevent.h index a2e8214..7f51a0f 100644 --- a/src/sipevent/sipevent.h +++ b/src/sipevent/sipevent.h @@ -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; diff --git a/src/sipevent/subscribe.c b/src/sipevent/subscribe.c index 84de1e2..3fa9e2b 100644 --- a/src/sipevent/subscribe.c +++ b/src/sipevent/subscribe.c @@ -20,6 +20,7 @@ enum { + DEFAULT_EXPIRES = 3600, RESUB_FAIL_WAIT = 60000, RESUB_FAILC_MAX = 7, };