1/* $Id: localconf.h,v 1.9.2.3 2005/11/06 17:18:26 monas Exp $ */ 2 3/* 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the project nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32#ifndef _LOCALCONF_H 33#define _LOCALCONF_H 34 35#if !TARGET_OS_EMBEDDED 36#include <vproc.h> 37#endif 38#include <dispatch/dispatch.h> 39#include "vmbuf.h" 40#include "ipsec_doi.h" 41 42/* local configuration */ 43 44#define LC_DEFAULT_CF SYSCONFDIR "/racoon.conf" 45 46#define LC_PATHTYPE_INCLUDE 0 47#define LC_PATHTYPE_PSK 1 48#define LC_PATHTYPE_CERT 2 49#define LC_PATHTYPE_PIDFILE 3 50#define LC_PATHTYPE_LOGFILE 4 51#define LC_PATHTYPE_MAX 5 52 53#define LC_DEFAULT_PAD_MAXSIZE 20 54#define LC_DEFAULT_PAD_RANDOM TRUE 55#define LC_DEFAULT_PAD_RANDOMLEN FALSE 56#define LC_DEFAULT_PAD_STRICT FALSE 57#define LC_DEFAULT_PAD_EXCLTAIL TRUE 58#define LC_DEFAULT_RETRY_COUNTER 5 59#define LC_DEFAULT_RETRY_INTERVAL 2 60#define LC_DEFAULT_COUNT_PERSEND 1 61#define LC_DEFAULT_RETRY_CHECKPH1 30 62#define LC_DEFAULT_WAIT_PH2COMPLETE 30 63#define LC_DEFAULT_NATT_KA_INTERVAL 20 64 65#define LC_DEFAULT_SECRETSIZE 16 /* 128 bits */ 66 67#define LC_GSSENC_UTF16LE 0 /* GSS ID in UTF-16LE */ 68#define LC_GSSENC_LATIN1 1 /* GSS ID in ISO-Latin-1 */ 69#define LC_GSSENC_MAX 2 70 71#define LC_AUTOEXITSTATE_SET 0x00000001 72#define LC_AUTOEXITSTATE_CLIENT 0x00000010 73#define LC_AUTOEXITSTATE_ENABLED 0x00000011 /* both VPN client and set */ 74 75 76struct vpnctl_socket_elem { 77 LIST_ENTRY(vpnctl_socket_elem) chain; 78 int sock; 79 dispatch_source_t source; 80 LIST_HEAD(_bound_addrs, bound_addr) bound_addresses; 81}; 82 83struct bound_addr { 84 LIST_ENTRY(bound_addr) chain; 85 u_int32_t address; 86 vchar_t *user_id; 87 vchar_t *user_pw; 88 vchar_t *version; /* our version string - if present */ 89}; 90 91struct redirect { 92 LIST_ENTRY(redirect) chain; 93 u_int32_t cluster_address; 94 u_int32_t redirect_address; 95 u_int16_t force; 96}; 97 98struct saved_msg_elem { 99 TAILQ_ENTRY(saved_msg_elem) chain; 100 void* msg; 101}; 102 103 104struct localconf { 105 char *racoon_conf; /* configuration filename */ 106 107 uid_t uid; 108 gid_t gid; 109 u_int16_t port_isakmp; /* port for isakmp as default */ 110 u_int16_t port_isakmp_natt; /* port for NAT-T use */ 111 u_int16_t port_admin; /* port for admin */ 112 int default_af; /* default address family */ 113 114 int sock_vpncontrol; 115 int sock_pfkey; 116 int rtsock; /* routing socket */ 117 dispatch_source_t vpncontrol_source; 118 dispatch_source_t pfkey_source; 119 dispatch_source_t rt_source; 120 121 LIST_HEAD(_vpnctl_socket_elem_, vpnctl_socket_elem) vpnctl_comm_socks; 122 LIST_HEAD(_redirect_, redirect) redirect_addresses; 123 int auto_exit_state; /* auto exit state */ 124 int auto_exit_delay; /* auto exit delay until exit */ 125 schedule_ref auto_exit_sched; /* auto exit schedule */ 126 127 TAILQ_HEAD(_saved_msg_elem, saved_msg_elem) saved_msg_queue; 128 int autograbaddr; 129 struct myaddrs *myaddrs; 130 131 char *logfile_param; /* from command line */ 132 char *pathinfo[LC_PATHTYPE_MAX]; 133 vchar_t *ident[IDTYPE_MAX]; /* base of Identifier payload. */ 134 135 int pad_random; 136 int pad_randomlen; 137 int pad_maxsize; 138 int pad_strict; 139 int pad_excltail; 140 141 int retry_counter; /* times to retry. */ 142 int retry_interval; /* interval each retry. */ 143 int count_persend; /* the number of packets each retry. */ 144 /* above 3 values are copied into a handler. */ 145 146 int retry_checkph1; 147 int wait_ph2complete; 148 149 int natt_ka_interval; /* NAT-T keepalive interval. */ 150 vchar_t *ext_nat_id; /* our address id for our nat address */ 151 152 int secret_size; 153 int strict_address; /* strictly check addresses. */ 154 155 int complex_bundle; 156 /* 157 * If we want to make a packet "IP2 AH ESP IP1 ULP", 158 * the SPD in KAME expresses AH transport + ESP tunnel. 159 * So racoon sent the proposal contained such the order. 160 * But lots of implementation interprets AH tunnel + ESP 161 * tunnel in this case. racoon has changed the format, 162 * usually uses this format. If the option, 'complex_bundle' 163 * is enable, racoon uses old format. 164 */ 165 166#if !TARGET_OS_EMBEDDED 167 vproc_transaction_t vt; /* returned by vproc_transaction_begin */ 168#endif 169}; 170 171 172extern struct localconf *lcconf; 173 174extern void initlcconf(void); 175extern void flushlcconf(void); 176extern void savelcconf(void); 177extern void restorelcconf(void); 178extern vchar_t *getpskbyname(vchar_t *); 179extern vchar_t *getpskbyaddr(struct sockaddr_storage *); 180#if HAVE_KEYCHAIN 181extern vchar_t *getpskfromkeychain(const char *, u_int8_t, int, vchar_t *); 182#endif 183extern void getpathname(char *, int, int, const char *); 184extern int sittype2doi(int); 185extern int doitype2doi(int); 186extern vchar_t *getpsk(const char *, const int); 187 188 189#endif /* _LOCALCONF_H */ 190