1 | /* $NetBSD: evt.h,v 1.7 2008/12/23 14:03:12 tteras Exp $ */ |
---|
2 | |
---|
3 | /* Id: evt.h,v 1.5 2006/01/19 10:24:09 fredsen Exp */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Copyright (C) 2004 Emmanuel Dreyfus |
---|
7 | * Copyright (C) 2008 Timo Teras |
---|
8 | * All rights reserved. |
---|
9 | * |
---|
10 | * Redistribution and use in source and binary forms, with or without |
---|
11 | * modification, are permitted provided that the following conditions |
---|
12 | * are met: |
---|
13 | * 1. Redistributions of source code must retain the above copyright |
---|
14 | * notice, this list of conditions and the following disclaimer. |
---|
15 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
16 | * notice, this list of conditions and the following disclaimer in the |
---|
17 | * documentation and/or other materials provided with the distribution. |
---|
18 | * 3. Neither the name of the project nor the names of its contributors |
---|
19 | * may be used to endorse or promote products derived from this software |
---|
20 | * without specific prior written permission. |
---|
21 | * |
---|
22 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND |
---|
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE |
---|
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
32 | * SUCH DAMAGE. |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef _EVT_H |
---|
36 | #define _EVT_H |
---|
37 | |
---|
38 | /* |
---|
39 | * Old style (deprecated) events which are polled. |
---|
40 | */ |
---|
41 | |
---|
42 | struct evtdump { |
---|
43 | size_t len; |
---|
44 | struct sockaddr_storage src; |
---|
45 | struct sockaddr_storage dst; |
---|
46 | time_t timestamp; |
---|
47 | int type; |
---|
48 | /* |
---|
49 | * Optionnal list of struct isakmp_data |
---|
50 | * for type EVTT_ISAKMP_CFG_DONE |
---|
51 | */ |
---|
52 | }; |
---|
53 | |
---|
54 | /* type */ |
---|
55 | #define EVTT_UNSEPC 0 |
---|
56 | #define EVTT_PHASE1_UP 1 |
---|
57 | #define EVTT_PHASE1_DOWN 2 |
---|
58 | #define EVTT_XAUTH_SUCCESS 3 |
---|
59 | #define EVTT_ISAKMP_CFG_DONE 4 |
---|
60 | #define EVTT_PHASE2_UP 5 |
---|
61 | #define EVTT_PHASE2_DOWN 6 |
---|
62 | #define EVTT_DPD_TIMEOUT 7 |
---|
63 | #define EVTT_PEER_NO_RESPONSE 8 |
---|
64 | #define EVTT_PEER_DELETE 9 |
---|
65 | #define EVTT_RACOON_QUIT 10 |
---|
66 | #define EVTT_XAUTH_FAILED 11 |
---|
67 | #define EVTT_OVERFLOW 12 /* Event queue overflowed */ |
---|
68 | #define EVTT_PEERPH1AUTH_FAILED 13 |
---|
69 | #define EVTT_PEERPH1_NOPROP 14 /* NO_PROPOSAL_CHOSEN & friends */ |
---|
70 | #define EVTT_NO_ISAKMP_CFG 15 /* no need to wait for mode_cfg */ |
---|
71 | |
---|
72 | /* |
---|
73 | * New style, asynchronous events. |
---|
74 | */ |
---|
75 | |
---|
76 | struct evt_async { |
---|
77 | uint32_t ec_type; |
---|
78 | time_t ec_timestamp; |
---|
79 | |
---|
80 | struct sockaddr_storage ec_ph1src; |
---|
81 | struct sockaddr_storage ec_ph1dst; |
---|
82 | u_int32_t ec_ph2msgid; |
---|
83 | |
---|
84 | /* |
---|
85 | * Optionnal list of struct isakmp_data |
---|
86 | * for type EVTT_ISAKMP_CFG_DONE |
---|
87 | */ |
---|
88 | }; |
---|
89 | |
---|
90 | /* type */ |
---|
91 | #define EVT_RACOON_QUIT 0x0001 |
---|
92 | |
---|
93 | #define EVT_PHASE1_UP 0x0100 |
---|
94 | #define EVT_PHASE1_DOWN 0x0101 |
---|
95 | #define EVT_PHASE1_NO_RESPONSE 0x0102 |
---|
96 | #define EVT_PHASE1_NO_PROPOSAL 0x0103 |
---|
97 | #define EVT_PHASE1_AUTH_FAILED 0x0104 |
---|
98 | #define EVT_PHASE1_DPD_TIMEOUT 0x0105 |
---|
99 | #define EVT_PHASE1_PEER_DELETED 0x0106 |
---|
100 | #define EVT_PHASE1_MODE_CFG 0x0107 |
---|
101 | #define EVT_PHASE1_XAUTH_SUCCESS 0x0108 |
---|
102 | #define EVT_PHASE1_XAUTH_FAILED 0x0109 |
---|
103 | |
---|
104 | #define EVT_PHASE2_NO_PHASE1 0x0200 |
---|
105 | #define EVT_PHASE2_UP 0x0201 |
---|
106 | #define EVT_PHASE2_DOWN 0x0202 |
---|
107 | #define EVT_PHASE2_NO_RESPONSE 0x0203 |
---|
108 | |
---|
109 | #ifdef ENABLE_ADMINPORT |
---|
110 | |
---|
111 | struct ph1handle; |
---|
112 | struct ph2handle; |
---|
113 | |
---|
114 | struct evt_listener { |
---|
115 | LIST_ENTRY(evt_listener) ll_chain; |
---|
116 | int fd; |
---|
117 | }; |
---|
118 | LIST_HEAD(evt_listener_list, evt_listener); |
---|
119 | #define EVT_LISTENER_LIST(x) struct evt_listener_list x |
---|
120 | |
---|
121 | void evt_generic __P((int type, vchar_t *optdata)); |
---|
122 | void evt_phase1 __P((const struct ph1handle *ph1, int type, vchar_t *optdata)); |
---|
123 | void evt_phase2 __P((const struct ph2handle *ph2, int type, vchar_t *optdata)); |
---|
124 | vchar_t *evt_dump __P((void)); |
---|
125 | |
---|
126 | int evt_subscribe __P((struct evt_listener_list *list, int fd)); |
---|
127 | void evt_list_init __P((struct evt_listener_list *list)); |
---|
128 | void evt_list_cleanup __P((struct evt_listener_list *list)); |
---|
129 | |
---|
130 | #else |
---|
131 | |
---|
132 | #define EVT_LISTENER_LIST(x) |
---|
133 | |
---|
134 | #define evt_generic(type, optdata) ; |
---|
135 | #define evt_phase1(ph1, type, optdata) ; |
---|
136 | #define evt_phase2(ph2, type, optdata) ; |
---|
137 | |
---|
138 | #define evt_subscribe(eventlist, fd) ; |
---|
139 | #define evt_list_init(eventlist) ; |
---|
140 | #define evt_list_cleanup(eventlist) ; |
---|
141 | #define evt_get_fdmask(nfds, fdset) nfds |
---|
142 | #define evt_handle_fdmask(fdset) ; |
---|
143 | |
---|
144 | #endif /* ENABLE_ADMINPORT */ |
---|
145 | |
---|
146 | #endif /* _EVT_H */ |
---|