2 * OpenConnect (SSL + DTLS) VPN client
4 * Copyright © 2008 Intel Corporation.
5 * Copyright © 2008 Nick Andrew <nick@nick-andrew.net>
7 * Author: David Woodhouse <dwmw2@infradead.org>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * version 2.1, as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to:
21 * Free Software Foundation, Inc.
22 * 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301 USA
26 #ifndef __OPENCONNECT_ANYCONNECT_H
27 #define __OPENCONNECT_ANYCONNECT_H
29 #include <openssl/ssl.h>
32 #include <sys/socket.h>
33 #include <sys/select.h>
35 #include <sys/types.h>
49 struct vpn_option *next;
55 #define KA_KEEPALIVE 3
58 struct keepalive_info {
68 struct split_include {
70 struct split_include *next;
73 #define RECONNECT_INTERVAL_MIN 10
74 #define RECONNECT_INTERVAL_MAX 100
76 struct openconnect_info {
81 char sid_tokencode[9];
82 char sid_nexttokencode[9];
84 const char *localname;
92 const char *xmlconfig;
93 char xmlsha1[(SHA_DIGEST_LENGTH * 2) + 1];
99 struct vpn_option *cookies;
100 struct vpn_option *cstp_options;
101 struct vpn_option *dtls_options;
105 struct keepalive_info ssl_times;
106 int owe_ssl_dpd_response;
107 struct pkt *deflate_pkt;
108 struct pkt *current_ssl_pkt;
110 z_stream inflate_strm;
111 uint32_t inflate_adler32;
112 z_stream deflate_strm;
113 uint32_t deflate_adler32;
115 int reconnect_timeout;
116 int reconnect_interval;
117 int dtls_attempt_period;
118 time_t new_dtls_started;
122 SSL_SESSION *dtls_session;
123 struct keepalive_info dtls_times;
124 unsigned char dtls_session_id[32];
125 unsigned char dtls_secret[48];
132 const char *vpn_addr;
133 const char *vpn_netmask;
134 const char *vpn_dns[3];
135 const char *vpn_nbns[3];
136 const char *vpn_domain;
137 struct split_include *split_includes;
149 struct pkt *incoming_queue;
150 struct pkt *outgoing_queue;
154 socklen_t peer_addrlen;
155 struct sockaddr *peer_addr;
158 const char *useragent;
162 int (*validate_peer_cert) (struct openconnect_info *vpninfo, X509 *cert);
163 int (*write_new_config) (struct openconnect_info *vpninfo, char *buf, int buflen);
165 void __attribute__ ((format(printf, 3, 4)))
166 (*progress) (struct openconnect_info *vpninfo, int level, const char *fmt, ...);
176 #define AC_PKT_DATA 0 /* Uncompressed data */
177 #define AC_PKT_DPD_OUT 3 /* Dead Peer Detection */
178 #define AC_PKT_DPD_RESP 4 /* DPD response */
179 #define AC_PKT_DISCONN 5 /* Client disconnection notice */
180 #define AC_PKT_KEEPALIVE 7 /* Keepalive */
181 #define AC_PKT_COMPRESSED 8 /* Compressed data */
182 #define AC_PKT_TERM_SERVER 9 /* Server kick */
186 int setup_tun(struct openconnect_info *vpninfo);
187 int tun_mainloop(struct openconnect_info *vpninfo, int *timeout);
190 int setup_dtls(struct openconnect_info *vpninfo);
191 int dtls_mainloop(struct openconnect_info *vpninfo, int *timeout);
192 int dtls_try_handshake(struct openconnect_info *vpninfo);
193 int connect_dtls_socket(struct openconnect_info *vpninfo);
196 int make_cstp_connection(struct openconnect_info *vpninfo);
197 int cstp_mainloop(struct openconnect_info *vpninfo, int *timeout);
198 int cstp_bye(struct openconnect_info *vpninfo, char *reason);
201 void openconnect_init_openssl(void);
202 int __attribute__ ((format (printf, 2, 3)))
203 openconnect_SSL_printf(SSL *ssl, const char *fmt, ...);
204 int openconnect_SSL_gets(SSL *ssl, char *buf, size_t len);
205 int openconnect_open_https(struct openconnect_info *vpninfo);
206 void openconnect_close_https(struct openconnect_info *vpninfo);
212 int vpn_add_pollfd(struct openconnect_info *vpninfo, int fd, short events);
213 int vpn_mainloop(struct openconnect_info *vpninfo);
214 int queue_new_packet(struct pkt **q, int type, void *buf, int len);
215 void queue_packet(struct pkt **q, struct pkt *new);
216 int keepalive_action(struct keepalive_info *ka, int *timeout);
217 int ka_stalled_dpd_time(struct keepalive_info *ka, int *timeout);
222 int config_lookup_host(struct openconnect_info *vpninfo, const char *host);
225 int openconnect_obtain_cookie(struct openconnect_info *vpninfo);
226 char *openconnect_create_useragent(char *base);
229 int set_openssl_ui(void);
232 int generate_securid_tokencodes(struct openconnect_info *vpninfo);
233 int add_securid_pin(char *token, char *pin);
236 extern char openconnect_version[];
238 #endif /* __OPENCONNECT_ANYCONNECT_H */