X-Git-Url: http://www.project-moonshot.org/gitweb/?p=libeap.git;a=blobdiff_plain;f=src%2Fwps%2Fwps_upnp.c;h=d2b83155dfc0bdb69291603726ec2dbb1bd0b444;hp=410df463a2b74dc15915a4d730ea49506f78b0fc;hb=08a98b6544456e4590b26008b44a7328cbf07bcd;hpb=3904567d0bd5b5ae946ae0e954da257f960e77f8 diff --git a/src/wps/wps_upnp.c b/src/wps/wps_upnp.c index 410df46..d2b8315 100644 --- a/src/wps/wps_upnp.c +++ b/src/wps/wps_upnp.c @@ -209,6 +209,8 @@ #define MAX_SUBSCRIPTIONS 4 /* how many subscribing clients we handle */ #define MAX_ADDR_PER_SUBSCRIPTION 8 +/* Maximum number of Probe Request events per second */ +#define MAX_EVENTS_PER_SEC 5 /* Write the current date/time per RFC */ void format_date(struct wpabuf *buf) @@ -474,12 +476,38 @@ static void upnp_wps_device_send_event(struct upnp_wps_device_sm *sm) "\n" "\n"; const char *format_tail = "\n"; + struct os_time now; if (dl_list_empty(&sm->subscriptions)) { /* optimize */ return; } + if (os_get_time(&now) == 0) { + if (now.sec != sm->last_event_sec) { + sm->last_event_sec = now.sec; + sm->num_events_in_sec = 1; + } else { + sm->num_events_in_sec++; + /* + * In theory, this should apply to all WLANEvent + * notifications, but EAP messages are of much higher + * priority and Probe Request notifications should not + * be allowed to drop EAP messages, so only throttle + * Probe Request notifications. + */ + if (sm->num_events_in_sec > MAX_EVENTS_PER_SEC && + sm->wlanevent_type == + UPNP_WPS_WLANEVENT_TYPE_PROBE) { + wpa_printf(MSG_DEBUG, "WPS UPnP: Throttle " + "event notifications (%u seen " + "during one second)", + sm->num_events_in_sec); + return; + } + } + } + /* Determine buffer size needed first */ buf_size += os_strlen(format_head); buf_size += 50 + 2 * os_strlen("WLANEvent");