add result/error codes to CDN; use "try another" on out of IP addresses
[l2tpns.git] / plugin.h
1 #ifndef __PLUGIN_H__
2 #define __PLUGIN_H__
3
4 #define PLUGIN_API_VERSION 4
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 #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 char *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 (*sessionkill)(sessionidt s, char *reason);
39 void (*throttle)(sessionidt s, int rate_in, int rate_out);
40 int (*session_changed)(int sid);
41 };
42
43 struct param_pre_auth
44 {
45 tunnelt *t;
46 sessiont *s;
47 char *username;
48 char *password;
49 int protocol;
50 int continue_auth;
51 };
52
53 struct param_post_auth
54 {
55 tunnelt *t;
56 sessiont *s;
57 char *username;
58 short auth_allowed;
59 int protocol;
60 };
61
62 struct param_packet_rx
63 {
64 tunnelt *t;
65 sessiont *s;
66 char *buf;
67 int len;
68 };
69
70 struct param_packet_tx
71 {
72 tunnelt *t;
73 sessiont *s;
74 char *buf;
75 int len;
76 };
77
78 struct param_timer
79 {
80 time_t time_now;
81 };
82
83 struct param_control
84 {
85 int iam_master;
86 int argc;
87 char **argv;
88 // output
89 int response;
90 char *additional;
91 };
92
93 struct param_new_session
94 {
95 tunnelt *t;
96 sessiont *s;
97 };
98
99 struct param_kill_session
100 {
101 tunnelt *t;
102 sessiont *s;
103 };
104
105 struct param_radius_response
106 {
107 tunnelt *t;
108 sessiont *s;
109 char *key;
110 char *value;
111 };
112
113 #endif /* __PLUGIN_H__ */