89ef8e035219f99002deab57e2608c8747fbf5d7
[l2tpns.git] / plugin.h
1 #ifndef __PLUGIN_H__
2 #define __PLUGIN_H__
3
4 #define PLUGIN_API_VERSION 3
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_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
26 struct pluginfuncs
27 {
28 void (*log)(int level, ipt address, sessionidt s, tunnelidt t, const char *format, ...);
29 void (*log_hex)(int level, const char *title, const char *data, int maxsize);
30 char *(*inet_toa)(unsigned long addr);
31 sessionidt (*get_session_by_username)(char *username);
32 sessiont *(*get_session_by_id)(sessionidt s);
33 sessionidt (*get_id_by_session)(sessiont *s);
34 u16 (*radiusnew)(sessionidt s);
35 void (*radiussend)(u16 r, u8 state);
36 void *(*getconfig)(char *key, enum config_typet type);
37 void (*sessionkill)(sessionidt s, char *reason);
38 void (*throttle)(sessionidt s, int rate_in, int rate_out);
39 int (*session_changed)(int sid);
40 };
41
42 struct param_pre_auth
43 {
44 tunnelt *t;
45 sessiont *s;
46 char *username;
47 char *password;
48 int protocol;
49 int continue_auth;
50 };
51
52 struct param_post_auth
53 {
54 tunnelt *t;
55 sessiont *s;
56 char *username;
57 short auth_allowed;
58 int protocol;
59 };
60
61 struct param_packet_rx
62 {
63 tunnelt *t;
64 sessiont *s;
65 char *buf;
66 int len;
67 };
68
69 struct param_packet_tx
70 {
71 tunnelt *t;
72 sessiont *s;
73 char *buf;
74 int len;
75 };
76
77 struct param_timer
78 {
79 time_t time_now;
80 };
81
82 struct param_control
83 {
84 int argc;
85 char **argv;
86 int response;
87 char *additional;
88 };
89
90 struct param_new_session
91 {
92 tunnelt *t;
93 sessiont *s;
94 };
95
96 struct param_kill_session
97 {
98 tunnelt *t;
99 sessiont *s;
100 };
101
102 struct param_radius_response
103 {
104 tunnelt *t;
105 sessiont *s;
106 char *key;
107 char *value;
108 };
109
110 #endif /* __PLUGIN_H__ */