From f66fc94340bdf6a30260a1932e3f2f22d8822304 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 30 Jun 2025 15:38:12 -0400 Subject: Ok sending the auth packet sort of works I need to set up retransmitting because the assoc request only happens if I send the auth response twice apparently. --- src/addr_list.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/addr_list.c (limited to 'src/addr_list.c') diff --git a/src/addr_list.c b/src/addr_list.c new file mode 100644 index 0000000..759907e --- /dev/null +++ b/src/addr_list.c @@ -0,0 +1,91 @@ +#include "addr_list.h" + +#include +#include +#include +#include + +void addr_list_init(struct addr_list* list) { + list->top = NULL; +} + +void addr_list_add(struct addr_list* list, unsigned char addr[6]) { + struct addr_list_node* cur = list->top; + struct addr_list_node* prev = NULL; + + while (cur != NULL) { + if (!strncmp(cur->value, addr, 6)) { + return; + } + + prev = cur; + cur = cur->next; + } + + struct addr_list_node* next = (struct addr_list_node*)malloc(sizeof(struct addr_list_node)); + next->next = NULL; + memcpy(next->value, addr, 6); + + if (prev == NULL) { + list->top = next; + } else { + prev->next = next; + } +} + +bool addr_list_contains(struct addr_list* list, unsigned char addr[6]) { + struct addr_list_node* cur = list->top; + + while (cur != NULL) { + if (!strncmp(cur->value, addr, 6)) { + return true; + } + + cur = cur->next; + } + + return false; +} + +void addr_list_remove(struct addr_list* list, unsigned char addr[6]) { + struct addr_list_node* cur = list->top; + struct addr_list_node* prev = NULL; + + if (cur == NULL) { + return; + } + + while (cur != NULL) { + if (!strncmp(cur->value, addr, 6)) { + break; + } + + prev = cur; + cur = cur->next; + + if (cur == NULL) { + return; + } + } + + if (prev == NULL) { + list->top = cur->next; + } else { + prev->next = cur->next; + } + + free(cur); +} + +void addr_list_free(struct addr_list* list) { + struct addr_list_node* cur = list->top; + + while (cur != NULL) { + struct addr_list_node* next = cur->next; + free(cur); + + cur = next; + } + + list->top = NULL; +} -- cgit 1.4.1