mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
fido2/ctap_hid: remove dependency on ztimer64
This commit is contained in:
parent
9d0a2c19e4
commit
efcbc1eab8
@ -18,7 +18,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "ztimer.h"
|
||||
#include "ztimer64.h"
|
||||
#include "usb/usbus.h"
|
||||
#include "usb/usbus/hid.h"
|
||||
#include "usb/usbus/hid_io.h"
|
||||
@ -478,9 +477,8 @@ static uint32_t _handle_init_packet(uint32_t cid, uint16_t bcnt,
|
||||
|
||||
static void _handle_cbor_packet(uint8_t cmd, uint32_t cid, uint8_t *buf, uint16_t bcnt)
|
||||
{
|
||||
ctap_resp_t resp;
|
||||
ctap_resp_t resp = {0x0};
|
||||
uint8_t err;
|
||||
size_t size;
|
||||
|
||||
if (bcnt == 0) {
|
||||
err = CTAP_HID_ERR_INVALID_LEN;
|
||||
@ -489,26 +487,24 @@ static void _handle_cbor_packet(uint8_t cmd, uint32_t cid, uint8_t *buf, uint16_
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&resp, 0, sizeof(ctap_resp_t));
|
||||
ctap_req_t req = {
|
||||
.method = *buf,
|
||||
.buf = buf + 1,
|
||||
.len = bcnt - 1
|
||||
};
|
||||
|
||||
ctap_req_t req;
|
||||
|
||||
req.method = *buf;
|
||||
req.buf = buf + 1;
|
||||
req.len = bcnt - 1;
|
||||
|
||||
size = fido2_ctap_handle_request(&req, &resp);
|
||||
ctap_status_code_t status = fido2_ctap_handle_request(&req, &resp);
|
||||
|
||||
/* transaction done, clear should_cancel flag */
|
||||
_state.should_cancel = false;
|
||||
|
||||
if (resp.status == CTAP2_OK && size > 0) {
|
||||
if (status == CTAP2_OK && resp.len > 0) {
|
||||
/* status + data */
|
||||
_ctap_hid_write(cmd, cid, &resp, size + sizeof(resp.status));
|
||||
_ctap_hid_write(cmd, cid, &resp, resp.len + sizeof(resp.status));
|
||||
}
|
||||
else {
|
||||
/* status only */
|
||||
_ctap_hid_write(cmd, cid, &resp.status, sizeof(resp.status));
|
||||
_ctap_hid_write(cmd, cid, &resp.status, sizeof(status));
|
||||
}
|
||||
}
|
||||
|
||||
@ -529,7 +525,7 @@ bool fido2_ctap_transport_hid_should_cancel(void)
|
||||
|
||||
void fido2_ctap_transport_hid_check_timeouts(void)
|
||||
{
|
||||
uint64_t now = ztimer64_now(ZTIMER64_MSEC);
|
||||
uint32_t now = ztimer_now(ZTIMER_MSEC);
|
||||
|
||||
for (uint8_t i = 0; i < CTAP_HID_CIDS_MAX; i++) {
|
||||
/* transaction timed out because cont packets didn't arrive in time */
|
||||
@ -548,14 +544,14 @@ void fido2_ctap_transport_hid_check_timeouts(void)
|
||||
|
||||
static int8_t _add_cid(uint32_t cid)
|
||||
{
|
||||
uint64_t oldest = ztimer64_now(ZTIMER64_MSEC);
|
||||
uint32_t oldest = ztimer_now(ZTIMER_MSEC);
|
||||
int8_t index_oldest = -1;
|
||||
|
||||
for (int i = 0; i < CTAP_HID_CIDS_MAX; i++) {
|
||||
if (!g_cids[i].taken) {
|
||||
g_cids[i].taken = true;
|
||||
g_cids[i].cid = cid;
|
||||
g_cids[i].last_used = ztimer64_now(ZTIMER64_MSEC);
|
||||
g_cids[i].last_used = ztimer_now(ZTIMER_MSEC);
|
||||
|
||||
return CTAP_HID_OK;
|
||||
}
|
||||
@ -570,7 +566,7 @@ static int8_t _add_cid(uint32_t cid)
|
||||
if (index_oldest > -1) {
|
||||
g_cids[index_oldest].taken = true;
|
||||
g_cids[index_oldest].cid = cid;
|
||||
g_cids[index_oldest].last_used = ztimer64_now(ZTIMER64_MSEC);
|
||||
g_cids[index_oldest].last_used = ztimer_now(ZTIMER_MSEC);
|
||||
return CTAP_HID_OK;
|
||||
}
|
||||
|
||||
@ -581,7 +577,7 @@ static int8_t _refresh_cid(uint32_t cid)
|
||||
{
|
||||
for (int i = 0; i < CTAP_HID_CIDS_MAX; i++) {
|
||||
if (g_cids[i].cid == cid) {
|
||||
g_cids[i].last_used = ztimer64_now(ZTIMER64_MSEC);
|
||||
g_cids[i].last_used = ztimer_now(ZTIMER_MSEC);
|
||||
return CTAP_HID_OK;
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ typedef struct __attribute__((packed)){
|
||||
typedef struct {
|
||||
bool taken; /**< is cid taken? */
|
||||
uint32_t cid; /**< channel identifier */
|
||||
uint64_t last_used; /**< timestamp of last usage */
|
||||
uint32_t last_used; /**< timestamp of last usage */
|
||||
} ctap_hid_cid_t;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user