Initial revision
[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 #define PLUGIN_PRE_AUTH 1
8 #define PLUGIN_POST_AUTH 2
9 #define PLUGIN_PACKET_RX 3
10 #define PLUGIN_PACKET_TX 4
11 #define PLUGIN_TIMER 5
12 #define PLUGIN_CONFIG 6
13 #define PLUGIN_NEW_SESSION 7
14 #define PLUGIN_KILL_SESSION 8
15 #define PLUGIN_CONTROL 9
16 #define PLUGIN_RADIUS_RESPONSE 10
17
18 #define PLUGIN_RET_ERROR 0
19 #define PLUGIN_RET_OK 1
20 #define PLUGIN_RET_STOP 2
21
22 struct pluginfuncs
23 {
24 void (*_log)(int level, ipt address, sessionidt s, tunnelidt t, const char *format, ...);
25 void (*_log_hex)(int level, ipt address, sessionidt s, tunnelidt t, const char *title, const char *data, int maxsize);
26 char *(*inet_toa)(unsigned long addr);
27 sessionidt (*get_session_by_username)(char *username);
28 sessiont *(*get_session_by_id)(sessionidt s);
29 sessionidt (*get_id_by_session)(sessiont *s);
30 void (*sessionkill)(sessionidt s, char *reason);
31 u8 (*radiusnew)(sessionidt s);
32 void (*radiussend)(u8 r, u8 state);
33 };
34
35 struct param_pre_auth
36 {
37 tunnelt *t;
38 sessiont *s;
39 char *username;
40 char *password;
41 int protocol;
42 int continue_auth;
43 };
44
45 struct param_post_auth
46 {
47 tunnelt *t;
48 sessiont *s;
49 char *username;
50 short auth_allowed;
51 int protocol;
52 };
53
54 struct param_packet_rx
55 {
56 tunnelt *t;
57 sessiont *s;
58 char *buf;
59 int len;
60 };
61
62 struct param_packet_tx
63 {
64 tunnelt *t;
65 sessiont *s;
66 char *buf;
67 int len;
68 };
69
70 struct param_timer
71 {
72 time_t time_now;
73 };
74
75 struct param_config
76 {
77 char *key;
78 char *value;
79 };
80
81 struct param_control
82 {
83 char *buf;
84 int l;
85 unsigned int source_ip;
86 unsigned short source_port;
87 char *response;
88 int response_length;
89 int send_response;
90 short type;
91 int id;
92 char *data;
93 int data_length;
94 };
95
96 struct param_new_session
97 {
98 tunnelt *t;
99 sessiont *s;
100 };
101
102 struct param_kill_session
103 {
104 tunnelt *t;
105 sessiont *s;
106 };
107
108 struct param_radius_response
109 {
110 tunnelt *t;
111 sessiont *s;
112 char *key;
113 char *value;
114 };
115
116 #endif