expires_min option
This commit is contained in:
parent
f6bdc84b80
commit
aefada5c81
4 changed files with 23 additions and 10 deletions
|
@ -60,8 +60,9 @@ 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_dfl,
|
||||
uint32_t expires_max, const char *cuser, const char *ctype,
|
||||
uint16_t scode, const char *reason, uint32_t expires_min,
|
||||
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, bool term,
|
||||
|
|
|
@ -254,6 +254,20 @@ static void subscribe_handler(struct sipevent_sock *sock,
|
|||
return;
|
||||
}
|
||||
|
||||
if (pl_isset(&msg->expires))
|
||||
expires = pl_u32(&msg->expires);
|
||||
else
|
||||
expires = not->expires_dfl;
|
||||
|
||||
if (expires > 0 && expires < not->expires_min) {
|
||||
(void)sip_replyf(sip, msg, 423, "Interval Too Brief",
|
||||
"Min-Expires: %u\r\n"
|
||||
"Content-Length: 0\r\n"
|
||||
"\r\n",
|
||||
not->expires_min);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sip_dialog_rseq_valid(not->dlg, msg)) {
|
||||
(void)sip_reply(sip, msg, 500, "Bad Sequence");
|
||||
return;
|
||||
|
@ -261,11 +275,6 @@ static void subscribe_handler(struct sipevent_sock *sock,
|
|||
|
||||
(void)sip_dialog_update(not->dlg, msg);
|
||||
|
||||
if (pl_isset(&msg->expires))
|
||||
expires = pl_u32(&msg->expires);
|
||||
else
|
||||
expires = not->expires_dfl;
|
||||
|
||||
sipnot_refresh(not, expires);
|
||||
|
||||
(void)sipnot_reply(not, msg, 200, "OK");
|
||||
|
|
|
@ -293,8 +293,9 @@ 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_dfl,
|
||||
uint32_t expires_max, const char *cuser, const char *ctype,
|
||||
uint16_t scode, const char *reason, uint32_t expires_min,
|
||||
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, ...)
|
||||
{
|
||||
|
@ -303,7 +304,7 @@ int sipevent_accept(struct sipnot **notp, struct sipevent_sock *sock,
|
|||
int err;
|
||||
|
||||
if (!notp || !sock || !msg || !scode || !reason || !expires_dfl ||
|
||||
!expires_max || !cuser || !ctype)
|
||||
!expires_max || !cuser || !ctype || expires_dfl < expires_min)
|
||||
return EINVAL;
|
||||
|
||||
not = mem_zalloc(sizeof(*not), destructor);
|
||||
|
@ -373,6 +374,7 @@ int sipevent_accept(struct sipnot **notp, struct sipevent_sock *sock,
|
|||
goto out;
|
||||
}
|
||||
|
||||
not->expires_min = expires_min;
|
||||
not->expires_dfl = expires_dfl;
|
||||
not->expires_max = expires_max;
|
||||
not->sock = mem_ref(sock);
|
||||
|
|
|
@ -35,6 +35,7 @@ struct sipnot {
|
|||
char *ctype;
|
||||
sipevent_close_h *closeh;
|
||||
void *arg;
|
||||
uint32_t expires_min;
|
||||
uint32_t expires_dfl;
|
||||
uint32_t expires_max;
|
||||
enum sipevent_reason reason;
|
||||
|
|
Loading…
Add table
Reference in a new issue