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