1/* 2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef __VPNOPTIONS_H__ 25#define __VPNOPTIONS_H__ 26 27#ifndef DAEMON_NAME 28 #define DAEMON_NAME "vpnd" 29#endif 30 31#define SERVER_TYPE_PPP 1 32#define SERVER_TYPE_IPSEC 2 33 34#define OPT_STR_LEN 256 35#define MAXARG 100 36 37/* PATHS definitions for PPP */ 38 39#define DIR_KEXT "/System/Library/Extensions/" 40#define DIR_LOGS "/var/log/ppp/" 41#define PATH_PPPD "/usr/sbin/pppd" 42#define PPPD_PRGM "pppd" 43#define PATH_VPND "/usr/sbin/vpnd" 44#define VPND_PRGM "vpnd" 45 46/* Comm default values */ 47 48#define OPT_COMM_IDLETIMER_DEF 0 // no idle timer 49#define OPT_COMM_SESSIONTIMER_DEF 0 // no session timer 50 51/* Values for flags */ 52#define OPT_VALUE 0xff /* mask for presupplied value */ 53#define OPT_HEX 0x100 /* int option is in hex */ 54#define OPT_NOARG 0x200 /* option doesn't take argument */ 55#define OPT_OR 0x400 /* OR in argument to value */ 56#define OPT_INC 0x800 /* increment value */ 57#define OPT_A2OR 0x800 /* for o_bool, OR arg to *(u_char *)addr2 */ 58#define OPT_PRIV 0x1000 /* privileged option */ 59#define OPT_STATIC 0x2000 /* string option goes into static array */ 60#define OPT_LLIMIT 0x4000 /* check value against lower limit */ 61#define OPT_ULIMIT 0x8000 /* check value against upper limit */ 62#define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT) 63#define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */ 64#define OPT_HIDE 0x10000 /* for o_string, print value as ?????? */ 65#define OPT_A2LIST 0x10000 /* for o_special, keep list of values */ 66#define OPT_A2CLRB 0x10000 /* o_bool, clr val bits in *(u_char *)addr2 */ 67#define OPT_NOINCR 0x20000 /* value mustn't be increased */ 68#define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */ 69#define OPT_PRIO 0x80000 /* process option priorities for this option */ 70#define OPT_PRIOSUB 0x100000 /* subsidiary member of priority group */ 71#define OPT_ALIAS 0x200000 /* option is alias for previous option */ 72#define OPT_A2COPY 0x400000 /* addr2 -> second location to rcv value */ 73#define OPT_ENABLE 0x800000 /* use *addr2 as enable for option */ 74#define OPT_A2CLR 0x1000000 /* clear *(bool *)addr2 */ 75#define OPT_PRIVFIX 0x2000000 /* user can't override if set by root */ 76#define OPT_INITONLY 0x4000000 /* option can only be set in init phase */ 77#define OPT_DEVEQUIV 0x8000000 /* equiv to device name */ 78#define OPT_DEVNAM (OPT_INITONLY | OPT_DEVEQUIV) 79#define OPT_A2PRINTER 0x10000000 /* *addr2 is a fn for printing option */ 80#define OPT_A2STRVAL 0x20000000 /* *addr2 points to current string value */ 81#define OPT_NOPRINT 0x40000000 /* don't print this option at all */ 82 83#define OPT_VAL(x) ((x) & OPT_VALUE) 84 85/* Values for priority */ 86#define OPRIO_DEFAULT 0 /* a default value */ 87#define OPRIO_CFGFILE 1 /* value from a configuration file */ 88#define OPRIO_CMDLINE 2 /* value from the command line */ 89#define OPRIO_SECFILE 3 /* value from options in a secrets file */ 90#define OPRIO_ROOT 100 /* added to priority if OPT_PRIVFIX && root */ 91 92/* LCP default values */ 93 94#define OPT_LCP_ACCOMP_DEF 1 // address and control fields compression activated 95#define OPT_LCP_PCOMP_DEF 1 // protocol field compression activated 96#define OPT_LCP_RCACCM_DEF 0 // default asyncmap value 97#define OPT_LCP_TXACCM_DEF 0 // default asyncmap value 98#define OPT_LCP_MRU_DEF 1500 99#define OPT_LCP_MRU_PPPoE_DEF 1492 /* use standart PPPoE MTU */ 100#define OPT_LCP_MRU_PPTP_DEF 1500 /* use standart PPP MTU */ 101#define OPT_LCP_MRU_L2TP_DEF 1500 /* use standart PPP MTU */ 102#define OPT_LCP_MTU_DEF 1500 103#define OPT_LCP_MTU_PPPoE_DEF 1492 /* use standart PPPoE MTU */ 104#define OPT_LCP_MTU_PPTP_DEF 1448 /* avoid fragmentation */ 105 /* 1500-IPHdr(20)-GRE(16)-PPP/MPPE(8)-PPPoE(8) */ 106#define OPT_LCP_MTU_L2TP_DEF 1280 /* avoid fragmentation */ 107#define OPT_LCP_ECHOINTERVAL_DEF 10 108#define OPT_LCP_ECHOFAILURE_DEF 4 109 110/* IPCP default values */ 111 112#define OPT_IPCP_HDRCOMP_DEF 1 // tcp vj compression activated 113 114enum opt_type { 115 o_special_noarg = 0, 116 o_special = 1, 117 o_bool, 118 o_int, 119 o_uint32, 120 o_string, 121 o_wild 122}; 123 124typedef struct { 125 char *name; /* name of the option */ 126 enum opt_type type; 127 void *addr; 128 char *description; 129 unsigned int flags; 130 void *addr2; 131 int upper_limit; 132 int lower_limit; 133 const char *source; 134 short int priority; 135 short int winner; 136 void *addr3; 137} option_t; 138 139/* load balancing */ 140//#define LB_MAX_PRIORITY 10 141#define LB_DEFAULT_PORT 4112 142 143 144struct vpn_params { 145 int debug; 146 int log_verbose; 147 int daemonize; 148 SCDynamicStoreRef storeRef; 149 CFStringRef serverIDRef; 150 CFPropertyListRef serverRef; 151 char *server_id; 152 u_int32_t max_sessions; 153 char log_path[MAXPATHLEN]; 154 155 /* command line arguments used for the give type */ 156 u_int32_t next_arg_index; /* indicates end of argument array */ 157 char *exec_args[MAXARG]; 158 159 int server_type; /* PPP or IPSEC */ 160 161 /* parameter for type PPP */ 162 CFStringRef serverSubTypeRef; 163 u_int32_t server_subtype; 164 char *plugin_path; 165 166 /* parameter for type Load Balancing */ 167 int lb_enable; 168 //int lb_priority; 169 u_int16_t lb_port; // network order 170 struct in_addr lb_cluster_address; // network order 171 struct in_addr lb_redirect_address; // network order 172 char lb_interface[IFNAMSIZ+1]; 173 174 /* parameter for type IPSEC */ 175 176 177}; 178 179 180int process_options(struct vpn_params *options, int argc, char *argv[]); 181CFArrayRef get_active_servers(struct vpn_params *params); 182int check_conflicts(struct vpn_params *params); 183int process_prefs(struct vpn_params *params); 184int publish_state(struct vpn_params* params); 185int kill_orphans(struct vpn_params* params); 186void open_dynamic_store(struct vpn_params* params); 187void close_dynamic_store(struct vpn_params* params); 188int add_builtin_plugin(struct vpn_params* params, void *channel); 189int plugin_exists(const char *inPath); 190char* validate_ip_string(const char *inIPString, char *outIPString, size_t outSize); 191 192void addparam(char **arg, u_int32_t *argi, char *param); 193void addintparam(char **arg, u_int32_t *argi, char *param, u_int32_t val); 194void addstrparam(char **arg, u_int32_t *argi, char *param, char *val); 195 196#endif 197 198