summaryrefslogtreecommitdiffstats
path: root/database/eurephiadb_driver.h
blob: 5ada4597eaaca82090f3c6e86236d158d345e756 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* eurephiadb_driver.h  --  API provided by the database driver
 *
 *  GPLv2 only - Copyright (C) 2008, 2009
 *               David Sommerseth <dazo@users.sourceforge.net>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; version 2
 *  of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include <eurephia_context.h>
#include <eurephiadb_session_struct.h>
#include <eurephia_values_struct.h>
#include <eurephia_admin_struct.h>

#ifdef HAVE_LIBXML2
#include <libxml/tree.h>
#endif

#ifndef EUREPHIADB_DRIVER_H_
#define EUREPHIADB_DRIVER_H_

#define attempt_IPADDR      1
#define attempt_CERTIFICATE 2
#define attempt_USERNAME    3

#define ATTEMPT_RESET    0x0A
#define ATTEMPT_REGISTER 0x0B

#define USERINFO_user       0x01
#define USERINFO_certs      0x02
#define USERINFO_lastlog    0x04
#define USERINFO_attempts   0x08
#define USERINFO_blacklist  0x10

#ifndef DRIVER_MODE

/* Functions needed by all drivers */
const char *(*eDB_DriverVersion) (void);
int (*eDB_DriverAPIVersion) (void);


/*
 *    functions which needs to exists in the eurephiaDB (eDB) module - API Version 1
 */
int (*eDBconnect) (eurephiaCTX *ctx, const int argc, const char **argv);

void (*eDBdisconnect) (eurephiaCTX *ctx);

int (*eDBauth_TLS) (eurephiaCTX *ctx, const char *org, const char *cname, const char *email,
                    const char *digest, const char *depth);

int (*eDBauth_user) (eurephiaCTX *ctx, const int certid, const char *username, const char *passwd);

int (*eDBget_uid) (eurephiaCTX *ctx, const int certid, const char *username);

int (*eDBblacklist_check) (eurephiaCTX *ctx, const int type, const char *val);

void (*eDBregister_attempt) (eurephiaCTX *ctx, int type, int mode, const char *value);


int (*eDBregister_login) (eurephiaCTX *ctx, eurephiaSESSION *skey, const int certid, const int uid,
                          const char *proto, const char *remipaddr, const char *remport,
                          const char *vpnipaddr, const char *vpnipmask);

int (*eDBregister_vpnmacaddr) (eurephiaCTX *ctx, eurephiaSESSION *skey, const char *macaddr);

int (*eDBregister_logout) (eurephiaCTX *ctx, eurephiaSESSION *skey,
                           const char *bytes_sent, const char *bytes_received, const char *duration);

/* firewall functions */
char *(*eDBget_firewall_profile) (eurephiaCTX *ctx, eurephiaSESSION *session);
eurephiaVALUES *(*eDBget_blacklisted_ip) (eurephiaCTX *ctx);

/* The following functions is also declared in eurephia_session_values.c - for local internal usage. */
char *(*eDBget_sessionkey_seed) (eurephiaCTX *ctx, sessionType type, const char *sessionseed);
char *(*eDBget_sessionkey_macaddr) (eurephiaCTX *ctx, const char *macaddr);
int (*eDBcheck_sessionkey_uniqueness) (eurephiaCTX *ctx, const char *seskey);

int (*eDBregister_sessionkey) (eurephiaCTX *ctx, const char *seed, const char *seskey);

eurephiaVALUES *(*eDBload_sessiondata) (eurephiaCTX *ctx, const char *sesskey);

int (*eDBdestroy_session) (eurephiaCTX *ctx, eurephiaSESSION *session);

int (*eDBstore_session_value) (eurephiaCTX *ctx, eurephiaSESSION *skey, int mode,
                               const char *key, const char *val);

/* API version 2 functions */
int (*eDBadminAuth) (eurephiaCTX *ctx, const char *req_acc, const char *uname, const char *pwd);
int (*eDBadminValidateSession) (eurephiaCTX *ctx, const char *sesskey, const char *req_acc);
int (*eDBadminRegisterLogin) (eurephiaCTX *ctx, eurephiaSESSION *session);
int (*eDBadminLogout) (eurephiaCTX *ctx, const char *session);

int (*eDBadminConfigSet) (eurephiaCTX *ctx, const char *key, const char *val);
int (*eDBadminConfigDelete) (eurephiaCTX *ctx, const char *key);

#ifdef HAVE_LIBXML2
xmlDoc *(*eDBadminGetUserList) (eurephiaCTX *ctx, const char *sortkeys);
xmlDoc *(*eDBadminGetUserInfo) (eurephiaCTX *ctx, int infoType, xmlDoc *srch);
int (*eDBadminAddUser) (eurephiaCTX *ctx, xmlDoc *userinfo);
int (*eDBadminUpdateUser) (eurephiaCTX *ctx, const int uid, xmlDoc *userinfo);
int (*eDBadminDeleteUser) (eurephiaCTX *ctx, const int uid, xmlDoc *userinfo);

xmlDoc *(*eDBadminGetCertificateList) (eurephiaCTX *ctx, const char *sortkeys);
xmlDoc *(*eDBadminGetCertificateInfo) (eurephiaCTX *ctx, xmlDoc *searchkey, const char *sortkeys);
int (*eDBadminAddCertificate) (eurephiaCTX *ctx, xmlDoc *certinfo);
int (*eDBadminDeleteCertificate) (eurephiaCTX *ctx, xmlDoc *certinfo);

xmlDoc *(*eDBadminGetUserCertsList) (eurephiaCTX *ctx, const char *sortkeys);
int (*eDBadminUpdateUserCertLink) (eurephiaCTX *ctx, xmlDoc *usrcrt_xml);

xmlDoc *(*eDBadminGetAdminAccess) (eurephiaCTX *ctx, xmlDoc *srch_xml);
int (*eDBadminEditAdminAccess) (eurephiaCTX *ctx, xmlDoc *grant_xml);

xmlDoc *(*eDBadminGetFirewallProfiles) (eurephiaCTX *ctx, xmlDoc *srch);

xmlDoc *(*eDBadminGetLastlog) (eurephiaCTX *ctx, xmlDoc *srch, const char *sortkeys);
xmlDoc *(*eDBadminGetAttemptsLog) (eurephiaCTX *ctx, xmlDoc *usersrch, xmlDoc *certsrch, const char *sortkeys);
#endif /* HAVE_LIBXML2 */

#endif /* !DRIVER_MODE */

#endif /* !EUREPHIADB_DRIVER_H_ */