Documentation update
[l2tpns.git] / plugin.h
1 #ifndef __PLUGIN_H__
2 #define __PLUGIN_H__
3
4 #define PLUGIN_API_VERSION 1
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, ipt address, sessionidt s, tunnelidt t, 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 void (*sessionkill)(sessionidt s, char *reason);
35 u16 (*radiusnew)(sessionidt s);
36 void (*radiussend)(u16 r, u8 state);
37 };
38
39 struct param_pre_auth
40 {
41 tunnelt *t;
42 sessiont *s;
43 char *username;
44 char *password;
45 int protocol;
46 int continue_auth;
47 };
48
49 struct param_post_auth
50 {
51 tunnelt *t;
52 sessiont *s;
53 char *username;
54 short auth_allowed;
55 int protocol;
56 };
57
58 struct param_packet_rx
59 {
60 tunnelt *t;
61 sessiont *s;
62 char *buf;
63 int len;
64 };
65
66 struct param_packet_tx
67 {
68 tunnelt *t;
69 sessiont *s;
70 char *buf;
71 int len;
72 };
73
74 struct param_timer
75 {
76 time_t time_now;
77 };
78
79 struct param_config
80 {
81 char *key;
82 char *value;
83 };
84
85 struct param_control
86 {
87 char *buf;
88 int l;
89 unsigned int source_ip;
90 unsigned short source_port;
91 char *response;
92 int response_length;
93 int send_response;
94 short type;
95 int id;
96 char *data;
97 int data_length;
98 };
99
100 struct param_new_session
101 {
102 tunnelt *t;
103 sessiont *s;
104 };
105
106 struct param_kill_session
107 {
108 tunnelt *t;
109 sessiont *s;
110 };
111
112 struct param_radius_response
113 {
114 tunnelt *t;
115 sessiont *s;
116 char *key;
117 char *value;
118 };
119
120 #endif /* __PLUGIN_H__ */