Don't resend IPCP while still in progress
[l2tpns.git] / plugin.h
1 #ifndef __PLUGIN_H__
2 #define __PLUGIN_H__
3
4 #define PLUGIN_API_VERSION 5
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 (*sessionshutdown)(sessionidt s, char *reason, int result, int error);
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_packet_rx
64 {
65 tunnelt *t;
66 sessiont *s;
67 char *buf;
68 int len;
69 };
70
71 struct param_packet_tx
72 {
73 tunnelt *t;
74 sessiont *s;
75 char *buf;
76 int len;
77 };
78
79 struct param_timer
80 {
81 time_t time_now;
82 };
83
84 struct param_control
85 {
86 int iam_master;
87 int argc;
88 char **argv;
89 // output
90 int response;
91 char *additional;
92 };
93
94 struct param_new_session
95 {
96 tunnelt *t;
97 sessiont *s;
98 };
99
100 struct param_kill_session
101 {
102 tunnelt *t;
103 sessiont *s;
104 };
105
106 struct param_radius_response
107 {
108 tunnelt *t;
109 sessiont *s;
110 char *key;
111 char *value;
112 };
113
114 #endif /* __PLUGIN_H__ */