]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
RADIUS DAS: Add Event-Timestamp attribute into ACK/NAK messages
authorJouni Malinen <j@w1.fi>
Sun, 17 Jun 2012 16:35:03 +0000 (19:35 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 17 Jun 2012 16:35:03 +0000 (19:35 +0300)
Signed-hostap: Jouni Malinen <j@w1.fi>

src/radius/radius_das.c

index 61e3518b6f60c6ebb01a50cea094b009cb6ca243..a9fcb692561766a66e255b9a242765b5d2e67f09 100644 (file)
@@ -149,6 +149,7 @@ static void radius_das_receive(int sock, void *eloop_ctx, void *sock_ctx)
        struct wpabuf *rbuf;
        u32 val;
        int res;
+       struct os_time now;
 
        fromlen = sizeof(from);
        len = recvfrom(sock, buf, sizeof(buf), 0,
@@ -185,13 +186,11 @@ static void radius_das_receive(int sock, void *eloop_ctx, void *sock_ctx)
                goto fail;
        }
 
+       os_get_time(&now);
        res = radius_msg_get_attr(msg, RADIUS_ATTR_EVENT_TIMESTAMP,
                                  (u8 *) &val, 4);
        if (res == 4) {
                u32 timestamp = ntohl(val);
-               struct os_time now;
-
-               os_get_time(&now);
                if (abs(now.sec - timestamp) > das->time_window) {
                        wpa_printf(MSG_DEBUG, "DAS: Unacceptable "
                                   "Event-Timestamp (%u; local time %u) in "
@@ -231,6 +230,13 @@ static void radius_das_receive(int sock, void *eloop_ctx, void *sock_ctx)
        if (reply) {
                wpa_printf(MSG_DEBUG, "DAS: Reply to %s:%d", abuf, from_port);
 
+               if (!radius_msg_add_attr_int32(reply,
+                                              RADIUS_ATTR_EVENT_TIMESTAMP,
+                                              now.sec)) {
+                       wpa_printf(MSG_DEBUG, "DAS: Failed to add "
+                                  "Event-Timestamp attribute");
+               }
+
                if (radius_msg_finish_das_resp(reply, das->shared_secret,
                                               das->shared_secret_len, hdr) <
                    0) {