curvetun: adapt shell scripts to use environment
[netsniff-ng.git] / src / ct_usermgmt.h
blob550ce3800323f2a193896c84638a34d79cc68f12
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2011 Daniel Borkmann.
5 * Subject to the GPL, version 2.
6 */
8 #ifndef CT_USERMGMT_H
9 #define CT_USERMGMT_H
11 #include <stdint.h>
13 #include "curve.h"
14 #include "crypto_hash_sha512.h"
16 enum is_user_enum {
17 USERNAMES_OK = 0, /* Usernames match, valid 'token' */
18 USERNAMES_NE, /* Usernames do not match */
19 USERNAMES_TS, /* Usernames match, but 'token' invalid,
20 Drop connection here */
21 USERNAMES_ERR,
24 struct username_struct {
25 uint32_t salt;
26 uint8_t hash[crypto_hash_sha512_BYTES];
29 extern int username_msg(char *username, size_t len, char *dst, size_t dlen);
30 extern enum is_user_enum username_msg_is_user(char *src, size_t slen,
31 char *username, size_t len);
32 extern void parse_userfile_and_generate_user_store_or_die(char *homedir);
33 extern void dump_user_store(void);
34 extern void destroy_user_store(void);
36 extern int get_user_by_socket(int sock, struct curve25519_proto **proto);
37 extern int get_user_by_sockaddr(struct sockaddr_storage *sa, size_t sa_len,
38 struct curve25519_proto **proto);
39 extern int try_register_user_by_socket(struct curve25519_struct *c,
40 char *src, size_t slen, int sock,
41 int log);
42 extern int try_register_user_by_sockaddr(struct curve25519_struct *c,
43 char *src, size_t slen,
44 struct sockaddr_storage *sa,
45 size_t sa_len, int log);
46 extern void remove_user_by_socket(int sock);
47 extern void remove_user_by_sockaddr(struct sockaddr_storage *sa,
48 size_t sa_len);
50 #endif /* CT_USERMGMT_H */