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