blob: 1e50726b5b65f6e108285c634230bfe7ac9b4dfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#ifndef AUTHDB_H
#define AUTHDB_H
#include <stddef.h>
#include <stdint.h>
#include "blob.h"
#include "addr.h"
#define AUTHDB_IP_HASH_SIZE 64
struct authdb_map_entry;
struct authdb {
struct authdb_map_entry *hash_bucket[AUTHDB_IP_HASH_SIZE];
};
struct authdb_entry {
struct {
char login_name[44];
char mac_address[6];
uint16_t switch_port;
sockaddr_any switch_ip;
uint64_t block_categories;
uint64_t hard_block_categories;
} p;
struct {
uint32_t login_time;
uint32_t override_time;
uint32_t checksum;
} u;
};
struct authdb_map_entry {
struct authdb_map_entry *next;
sockaddr_any baseaddr;
struct authdb_entry * entries;
};
int authdb_open(struct authdb *adb);
void authdb_close(struct authdb *adb);
void *authdb_get(struct authdb *adb, sockaddr_any *addr, struct authdb_entry *entry, int create);
void authdb_clear_entry(struct authdb_entry *entry);
int authdb_set(void *token, struct authdb_entry *entry);
int authdb_check_login(void *token, struct authdb_entry *e, blob_t username, time_t now);
void authdb_commit_login(void *token, struct authdb_entry *e, time_t now);
void authdb_commit_logout(void *token);
void authdb_commit_override(void *token, struct authdb_entry *entry, time_t now);
#endif
|