document the default privilege drop (Closes #34)
[prads.git] / src / mac.h
blobd12fdb012c63fff4920fec230d7bae81404b8f26
1 /*
2 */
4 #ifndef _HAVE_MAC_H
5 #define _HAVE_MAC_H
7 #define MAXLINE 1024
8 #define MAC_HASHSIZE 19963 //28001 //19963 //18899
10 /* GRR... on 64 bits there is no problem. on 32 bits, not so...
11 * #define MAC_HASH(mac) (( (((uint32_t)mac[0]) ^ ((uint32_t)mac[1]) << 24) ^ ( ((uint32_t)mac[2]) << 16) ^ (mac[3]<<8) ^ (mac[4] ^ mac[5]) ) % MAC_HASHSIZE)
13 * we need a monotonic rising hash for lookups to be just right.
14 * otherwise, we can't search "near" the hash for a match.
16 static inline uint32_t hash_mac(const uint8_t mac[], const uint8_t octets)
18 int i;
19 uint32_t hash = 0;
20 for(i = 0; i < octets; i++){
21 //hash ^= mac[i] << ( (i*8) % 24); // reverse
22 hash ^= mac[i] << (24 - ((i*8) % 24) );
24 //printf("hash is %d\n", hash %MAC_HASHSIZE);
25 return hash % MAC_HASHSIZE;
28 #define SKIP_SPACES(s) do { while(isspace(*s)) s++; } while (0)
30 int load_mac(const char *file, mac_entry **sigp[], int hashsize);
31 mac_entry *match_mac(mac_entry **db, const uint8_t mac[], uint8_t mask);
32 void print_mac(const uint8_t *mac);
33 void dump_macs(mac_entry **db, int len);
34 #endif /* ! _HAVE_MAC_H */