From 6430805381035d3e31f471453722fa919ba35583 Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Fri, 11 Dec 2015 16:29:32 -0800 Subject: [PATCH] return SID in renew response --- miniupnpd/upnpevents.c | 8 ++++---- miniupnpd/upnpevents.h | 4 ++-- miniupnpd/upnphttp.c | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/miniupnpd/upnpevents.c b/miniupnpd/upnpevents.c index 628aff8..159418d 100644 --- a/miniupnpd/upnpevents.c +++ b/miniupnpd/upnpevents.c @@ -143,8 +143,8 @@ upnpevents_addSubscriber(const char * eventurl, } /* renew a subscription (update the timeout) */ -int -renewSubscription(const char * sid, int sidlen, int timeout) +const char * +upnpevents_renewSubscription(const char * sid, int sidlen, int timeout) { struct subscriber * sub; for(sub = subscriberlist.lh_first; sub != NULL; sub = sub->entries.le_next) { @@ -155,10 +155,10 @@ renewSubscription(const char * sid, int sidlen, int timeout) continue; #endif sub->timeout = (timeout ? time(NULL) + timeout : 0); - return 0; + return sub->uuid; } } - return -1; + return NULL; } int diff --git a/miniupnpd/upnpevents.h b/miniupnpd/upnpevents.h index 3bd2df2..630271d 100644 --- a/miniupnpd/upnpevents.h +++ b/miniupnpd/upnpevents.h @@ -36,8 +36,8 @@ upnpevents_addSubscriber(const char * eventurl, int upnpevents_removeSubscriber(const char * sid, int sidlen); -int -renewSubscription(const char * sid, int sidlen, int timeout); +const char * +upnpevents_renewSubscription(const char * sid, int sidlen, int timeout); void upnpevents_selectfds(fd_set *readset, fd_set *writeset, int * max_fd); void upnpevents_processfds(fd_set *readset, fd_set *writeset); diff --git a/miniupnpd/upnphttp.c b/miniupnpd/upnphttp.c index 769b056..d1c21da 100644 --- a/miniupnpd/upnphttp.c +++ b/miniupnpd/upnphttp.c @@ -665,11 +665,13 @@ with HTTP error 412 Precondition Failed. */ BuildResp2_upnphttp(h, 400, "Incompatible header fields", 0, 0); } else #endif - if(renewSubscription(h->req_buf + h->req_SIDOff, h->req_SIDLen, - h->req_Timeout) < 0) { + sid = upnpevents_renewSubscription(h->req_buf + h->req_SIDOff, + h->req_SIDLen, h->req_Timeout); + if(!sid) { BuildResp2_upnphttp(h, 412, "Precondition Failed", 0, 0); } else { - h->respflags = FLAG_TIMEOUT; + h->respflags = FLAG_TIMEOUT | FLAG_SID; + h->res_SID = sid; BuildResp_upnphttp(h, 0, 0); } }