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