Update version
[l2tpns.git] / plugin.h
1 #ifndef __PLUGIN_H__
2 #define __PLUGIN_H__
3
4 #define PLUGIN_API_VERSION 7
5 #define MAX_PLUGIN_TYPES 30
6
7 enum
8 {
9 PLUGIN_PRE_AUTH = 1,
10 PLUGIN_POST_AUTH,
11 PLUGIN_TIMER,
12 PLUGIN_NEW_SESSION,
13 PLUGIN_KILL_SESSION,
14 PLUGIN_CONTROL,
15 PLUGIN_RADIUS_RESPONSE,
16 PLUGIN_RADIUS_RESET,
17 PLUGIN_RADIUS_ACCOUNT,
18 PLUGIN_BECOME_MASTER,
19 PLUGIN_NEW_SESSION_MASTER,
20 };
21
22 #define PLUGIN_RET_ERROR 0
23 #define PLUGIN_RET_OK 1
24 #define PLUGIN_RET_STOP 2
25 #define PLUGIN_RET_NOTMASTER 3
26
27 struct pluginfuncs
28 {
29 void (*log)(int level, sessionidt s, tunnelidt t, const char *format, ...);
30 void (*log_hex)(int level, const char *title, const uint8_t *data, int maxsize);
31 char *(*fmtaddr)(in_addr_t addr, int n);
32 sessionidt (*get_session_by_username)(char *username);
33 sessiont *(*get_session_by_id)(sessionidt s);
34 sessionidt (*get_id_by_session)(sessiont *s);
35 uint16_t (*radiusnew)(sessionidt s);
36 void (*radiussend)(uint16_t r, uint8_t state);
37 void *(*getconfig)(char *key, enum config_typet type);
38 void (*sessionshutdown)(sessionidt s, char const *reason, int result, int error, int term_cause);
39 void (*sessionkill)(sessionidt s, char *reason);
40 void (*throttle)(sessionidt s, int rate_in, int rate_out);
41 int (*session_changed)(int sid);
42 };
43
44 struct param_pre_auth
45 {
46 tunnelt *t;
47 sessiont *s;
48 char *username;
49 char *password;
50 int protocol;
51 int continue_auth;
52 };
53
54 struct param_post_auth
55 {
56 tunnelt *t;
57 sessiont *s;
58 char *username;
59 short auth_allowed;
60 int protocol;
61 };
62
63 struct param_timer
64 {
65 time_t time_now;
66 };
67
68 struct param_new_session
69 {
70 tunnelt *t;
71 sessiont *s;
72 };
73
74 struct param_kill_session
75 {
76 tunnelt *t;
77 sessiont *s;
78 };
79
80 struct param_control
81 {
82 int iam_master;
83 int argc;
84 char **argv;
85 // output
86 int response;
87 char *additional;
88 };
89
90 struct param_radius_response
91 {
92 tunnelt *t;
93 sessiont *s;
94 char *key;
95 char *value;
96 };
97
98 struct param_radius_reset
99 {
100 tunnelt *t;
101 sessiont *s;
102 };
103
104 struct param_radius_account
105 {
106 tunnelt *t;
107 sessiont *s;
108 uint8_t **packet;
109 };
110
111 #endif /* __PLUGIN_H__ */