1 /* $NetBSD: cftoken.l,v 1.11.4.1 2007/08/01 11:52:20 vanhu Exp $ */
3 /* Id: cftoken.l,v 1.53 2006/08/22 18:17:17 manubsd Exp */
7 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 and 2003 WIDE Project.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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
37 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #ifdef HAVE_NETINET6_IPSEC
43 # include <netinet6/ipsec.h>
45 # include <netinet/ipsec.h>
61 //%%% BUG FIX - 2 missing include files when not using
64 #include <openssl/bn.h>
65 #include <openssl/rsa.h>
74 #include "algorithm.h"
75 #include "cfparse_proto.h"
76 #include "cftoken_proto.h"
77 #include "localconf.h"
79 #include "isakmp_var.h"
81 #include "ipsec_doi.h"
84 #include "remoteconf.h"
85 #include "nattraversal.h"
94 #if defined(YIPS_DEBUG)
95 # define YYDB plog(LLV_DEBUG2, LOCATION, NULL, \
96 "begin <%d>%s\n", yy_start, yytext);
98 plog(LLV_DEBUG2, LOCATION, NULL, "<%d>%s", \
99 yy_start, loglevel >= LLV_DEBUG2 ? "\n" : ""); \
104 #endif /* defined(YIPS_DEBUG) */
106 #define MAX_INCLUDE_DEPTH 10
108 static struct include_stack {
111 YY_BUFFER_STATE prevstate;
115 } incstack[MAX_INCLUDE_DEPTH];
116 static int incstackp = 0;
118 static int yy_first_time = 1;
127 /*octet (([01]?{digit}?{digit})|((2([0-4]{digit}))|(25[0-5]))) */
141 bracketstring \<[^>]*\>
142 quotedstring \"[^"]*\"
143 addrstring [a-fA-F0-9:]([a-fA-F0-9:\.]*|[a-fA-F0-9:\.]*%[a-zA-Z0-9]*)
145 hexstring 0x{hexdigit}+
147 %s S_INI S_PRIV S_PTH S_INF S_LOG S_PAD S_LST S_RTRY S_CFG
150 %s S_RMT S_RMTS S_RMTP
163 <S_INI>privsep { BEGIN S_PRIV; YYDB; return(PRIVSEP); }
164 <S_PRIV>{bcl} { return(BOC); }
165 <S_PRIV>user { YYD; return(USER); }
166 <S_PRIV>group { YYD; return(GROUP); }
167 <S_PRIV>chroot { YYD; return(CHROOT); }
168 <S_PRIV>{ecl} { BEGIN S_INI; return(EOC); }
171 <S_INI>path { BEGIN S_PTH; YYDB; return(PATH); }
172 <S_PTH>include { YYD; yylval.num = LC_PATHTYPE_INCLUDE;
174 <S_PTH>pre_shared_key { YYD; yylval.num = LC_PATHTYPE_PSK;
176 <S_PTH>certificate { YYD; yylval.num = LC_PATHTYPE_CERT;
178 <S_PTH>script { YYD; yylval.num = LC_PATHTYPE_SCRIPT;
180 <S_PTH>backupsa { YYD; yylval.num = LC_PATHTYPE_BACKUPSA;
182 <S_PTH>pidfile { YYD; yylval.num = LC_PATHTYPE_PIDFILE;
184 <S_PTH>logfile { YYD; yylval.num = LC_PATHTYPE_LOGFILE;
186 <S_PTH>{semi} { BEGIN S_INI; YYDB; return(EOS); }
189 <S_INI>include { YYDB; return(INCLUDE); }
191 /* self information */
192 <S_INI>identifier { BEGIN S_INF; YYDB; yywarn("it is obsoleted. use \"my_identifier\" in each remote directives."); return(IDENTIFIER); }
193 <S_INF>{semi} { BEGIN S_INI; return(EOS); }
196 <S_INI>complex_bundle { YYDB; return(COMPLEX_BUNDLE); }
199 <S_INI>log { BEGIN S_LOG; YYDB; return(LOGGING); }
200 <S_LOG>error { YYD; yylval.num = LLV_ERROR; return(LOGLEV); }
201 <S_LOG>warning { YYD; yylval.num = LLV_WARNING; return(LOGLEV); }
202 <S_LOG>notify { YYD; yylval.num = LLV_NOTIFY; return(LOGLEV); }
203 <S_LOG>info { YYD; yylval.num = LLV_INFO; return(LOGLEV); }
204 <S_LOG>debug { YYD; yylval.num = LLV_DEBUG; return(LOGLEV); }
205 <S_LOG>debug2 { YYD; yylval.num = LLV_DEBUG2; return(LOGLEV); }
206 <S_LOG>debug3 { YYD; yywarn("it is obsoleted. use \"debug2\""); yylval.num = LLV_DEBUG2; return(LOGLEV); }
207 <S_LOG>debug4 { YYD; yywarn("it is obsoleted. use \"debug2\""); yylval.num = LLV_DEBUG2; return(LOGLEV); }
208 <S_LOG>{semi} { BEGIN S_INI; return(EOS); }
211 <S_INI>padding { BEGIN S_PAD; YYDB; return(PADDING); }
212 <S_PAD>{bcl} { return(BOC); }
213 <S_PAD>randomize { YYD; return(PAD_RANDOMIZE); }
214 <S_PAD>randomize_length { YYD; return(PAD_RANDOMIZELEN); }
215 <S_PAD>maximum_length { YYD; return(PAD_MAXLEN); }
216 <S_PAD>strict_check { YYD; return(PAD_STRICT); }
217 <S_PAD>exclusive_tail { YYD; return(PAD_EXCLTAIL); }
218 <S_PAD>{ecl} { BEGIN S_INI; return(EOC); }
221 <S_INI>listen { BEGIN S_LST; YYDB; return(LISTEN); }
222 <S_LST>{bcl} { return(BOC); }
223 <S_LST>isakmp { YYD; return(X_ISAKMP); }
224 <S_LST>isakmp_natt { YYD; return(X_ISAKMP_NATT); }
225 <S_LST>admin { YYD; return(X_ADMIN); }
226 <S_LST>adminsock { YYD; return(ADMINSOCK); }
227 <S_LST>disabled { YYD; return(DISABLED); }
228 <S_LST>strict_address { YYD; return(STRICT_ADDRESS); }
229 <S_LST>{ecl} { BEGIN S_INI; return(EOC); }
232 <S_INI>mode_cfg { BEGIN S_CFG; YYDB; return(MODECFG); }
233 <S_CFG>{bcl} { return(BOC); }
234 <S_CFG>network4 { YYD; return(CFG_NET4); }
235 <S_CFG>netmask4 { YYD; return(CFG_MASK4); }
236 <S_CFG>dns4 { YYD; return(CFG_DNS4); }
237 <S_CFG>wins4 { YYD; return(CFG_NBNS4); }
238 <S_CFG>default_domain { YYD; return(CFG_DEFAULT_DOMAIN); }
239 <S_CFG>auth_source { YYD; return(CFG_AUTH_SOURCE); }
240 <S_CFG>auth_groups { YYD; return(CFG_AUTH_GROUPS); }
241 <S_CFG>group_source { YYD; return(CFG_GROUP_SOURCE); }
242 <S_CFG>conf_source { YYD; return(CFG_CONF_SOURCE); }
243 <S_CFG>accounting { YYD; return(CFG_ACCOUNTING); }
244 <S_CFG>system { YYD; return(CFG_SYSTEM); }
245 <S_CFG>local { YYD; return(CFG_LOCAL); }
246 <S_CFG>none { YYD; return(CFG_NONE); }
247 <S_CFG>radius { YYD; return(CFG_RADIUS); }
248 <S_CFG>pam { YYD; return(CFG_PAM); }
249 <S_CFG>pool_size { YYD; return(CFG_POOL_SIZE); }
250 <S_CFG>banner { YYD; return(CFG_MOTD); }
251 <S_CFG>auth_throttle { YYD; return(CFG_AUTH_THROTTLE); }
252 <S_CFG>split_network { YYD; return(CFG_SPLIT_NETWORK); }
253 <S_CFG>local_lan { YYD; return(CFG_SPLIT_LOCAL); }
254 <S_CFG>include { YYD; return(CFG_SPLIT_INCLUDE); }
255 <S_CFG>split_dns { YYD; return(CFG_SPLIT_DNS); }
256 <S_CFG>pfs_group { YYD; return(CFG_PFS_GROUP); }
257 <S_CFG>save_passwd { YYD; return(CFG_SAVE_PASSWD); }
258 <S_CFG>{comma} { YYD; return(COMMA); }
259 <S_CFG>{ecl} { BEGIN S_INI; return(EOC); }
262 <S_INI>timer { BEGIN S_RTRY; YYDB; return(RETRY); }
263 <S_RTRY>{bcl} { return(BOC); }
264 <S_RTRY>counter { YYD; return(RETRY_COUNTER); }
265 <S_RTRY>interval { YYD; return(RETRY_INTERVAL); }
266 <S_RTRY>persend { YYD; return(RETRY_PERSEND); }
267 <S_RTRY>phase1 { YYD; return(RETRY_PHASE1); }
268 <S_RTRY>phase2 { YYD; return(RETRY_PHASE2); }
269 <S_RTRY>natt_keepalive { YYD; return(NATT_KA); }
270 <S_RTRY>auto_exit_delay { YYD; return(AUTO_EXIT_DELAY); }
271 <S_RTRY>{ecl} { BEGIN S_INI; return(EOC); }
274 <S_INI>sainfo { BEGIN S_SAINF; YYDB; return(SAINFO); }
275 <S_SAINF>anonymous { YYD; return(ANONYMOUS); }
276 <S_SAINF>{blcl}any{elcl} { YYD; return(PORTANY); }
277 <S_SAINF>any { YYD; return(ANY); }
278 <S_SAINF>from { YYD; return(FROM); }
279 <S_SAINF>group { YYD; return(GROUP); }
281 <S_SAINF>{bcl} { BEGIN S_SAINFS; return(BOC); }
282 <S_SAINF>{semi} { BEGIN S_INI; return(EOS); }
283 <S_SAINFS>{ecl} { BEGIN S_INI; return(EOC); }
284 <S_SAINFS>pfs_group { YYD; return(PFS_GROUP); }
285 <S_SAINFS>remoteid { YYD; return(REMOTEID); }
286 <S_SAINFS>identifier { YYD; yywarn("it is obsoleted. use \"my_identifier\"."); return(IDENTIFIER); }
287 <S_SAINFS>my_identifier { YYD; return(MY_IDENTIFIER); }
288 <S_SAINFS>lifetime { YYD; return(LIFETIME); }
289 <S_SAINFS>time { YYD; return(LIFETYPE_TIME); }
290 <S_SAINFS>byte { YYD; return(LIFETYPE_BYTE); }
291 <S_SAINFS>encryption_algorithm { YYD; yylval.num = algclass_ipsec_enc; return(ALGORITHM_CLASS); }
292 <S_SAINFS>authentication_algorithm { YYD; yylval.num = algclass_ipsec_auth; return(ALGORITHM_CLASS); }
293 <S_SAINFS>compression_algorithm { YYD; yylval.num = algclass_ipsec_comp; return(ALGORITHM_CLASS); }
294 <S_SAINFS>{comma} { YYD; return(COMMA); }
297 <S_INI>remote { BEGIN S_RMT; YYDB; return(REMOTE); }
298 <S_RMT>anonymous { YYD; return(ANONYMOUS); }
299 <S_RMT>inherit { YYD; return(INHERIT); }
301 <S_RMT>{bcl} { BEGIN S_RMTS; return(BOC); }
302 <S_RMTS>{ecl} { BEGIN S_INI; return(EOC); }
303 <S_RMTS>exchange_mode { YYD; return(EXCHANGE_MODE); }
304 <S_RMTS>{comma} { YYD; /* XXX ignored, but to be handled. */ ; }
305 <S_RMTS>base { YYD; yylval.num = ISAKMP_ETYPE_BASE; return(EXCHANGETYPE); }
306 <S_RMTS>main { YYD; yylval.num = ISAKMP_ETYPE_IDENT; return(EXCHANGETYPE); }
307 <S_RMTS>aggressive { YYD; yylval.num = ISAKMP_ETYPE_AGG; return(EXCHANGETYPE); }
308 <S_RMTS>doi { YYD; return(DOI); }
309 <S_RMTS>ipsec_doi { YYD; yylval.num = IPSEC_DOI; return(DOITYPE); }
310 <S_RMTS>situation { YYD; return(SITUATION); }
311 <S_RMTS>identity_only { YYD; yylval.num = IPSECDOI_SIT_IDENTITY_ONLY; return(SITUATIONTYPE); }
312 <S_RMTS>secrecy { YYD; yylval.num = IPSECDOI_SIT_SECRECY; return(SITUATIONTYPE); }
313 <S_RMTS>integrity { YYD; yylval.num = IPSECDOI_SIT_INTEGRITY; return(SITUATIONTYPE); }
314 <S_RMTS>identifier { YYD; yywarn("it is obsoleted. use \"my_identifier\"."); return(IDENTIFIER); }
315 <S_RMTS>my_identifier { YYD; return(MY_IDENTIFIER); }
316 <S_RMTS>xauth_login { YYD; return(XAUTH_LOGIN); /* formerly identifier type login */ }
317 <S_RMTS>peers_identifier { YYD; return(PEERS_IDENTIFIER); }
318 <S_RMTS>verify_identifier { YYD; return(VERIFY_IDENTIFIER); }
319 <S_RMTS>certificate_type { YYD; return(CERTIFICATE_TYPE); }
320 <S_RMTS>ca_type { YYD; return(CA_TYPE); }
321 <S_RMTS>x509 { YYD; yylval.num = ISAKMP_CERT_X509SIGN; return(CERT_X509); }
324 YYD; yylval.num = ISAKMP_CERT_PLAINRSA; return(CERT_PLAINRSA);
326 yyerror("plainrsa not supported.");
329 <S_RMTS>open_dir_auth_group {
332 return(OPEN_DIR_AUTH_GROUP);
334 yyerror("Apple specific features not compiled in.");
337 <S_RMTS>shared_secret {
339 return(SHARED_SECRET);
341 <S_RMTS>in_keychain {
345 <S_RMTS>certificate_verification {
347 return(CERTIFICATE_VERIFICATION);
349 <S_RMTS>peers_certfile { YYD; return(PEERS_CERTFILE); }
350 <S_RMTS>dnssec { YYD; return(DNSSEC); }
351 <S_RMTS>verify_cert { YYD; return(VERIFY_CERT); }
352 <S_RMTS>send_cert { YYD; return(SEND_CERT); }
353 <S_RMTS>send_cr { YYD; return(SEND_CR); }
354 <S_RMTS>dh_group { YYD; return(DH_GROUP); }
355 <S_RMTS>nonce_size { YYD; return(NONCE_SIZE); }
356 <S_RMTS>generate_policy { YYD; return(GENERATE_POLICY); }
357 <S_RMTS>support_mip6 { YYD; yywarn("it is obsoleted. use \"support_proxy\"."); return(SUPPORT_PROXY); }
358 <S_RMTS>support_proxy { YYD; return(SUPPORT_PROXY); }
359 <S_RMTS>initial_contact { YYD; return(INITIAL_CONTACT); }
360 <S_RMTS>nat_traversal { YYD; return(NAT_TRAVERSAL); }
361 <S_RMTS>force { YYD; yylval.num = NATT_FORCE; return(NAT_TRAVERSAL_LEVEL); }
362 <S_RMTS>nat_traversal_multi_user {
364 return(NAT_TRAVERSAL_MULTI_USER);
366 <S_RMTS>nat_traversal_keepalive {
368 return(NAT_TRAVERSAL_KEEPALIVE);
370 <S_RMTS>proposal_check { YYD; return(PROPOSAL_CHECK); }
371 <S_RMTS>obey { YYD; yylval.num = PROP_CHECK_OBEY; return(PROPOSAL_CHECK_LEVEL); }
372 <S_RMTS>strict { YYD; yylval.num = PROP_CHECK_STRICT; return(PROPOSAL_CHECK_LEVEL); }
373 <S_RMTS>exact { YYD; yylval.num = PROP_CHECK_EXACT; return(PROPOSAL_CHECK_LEVEL); }
374 <S_RMTS>claim { YYD; yylval.num = PROP_CHECK_CLAIM; return(PROPOSAL_CHECK_LEVEL); }
375 <S_RMTS>keepalive { YYD; return(KEEPALIVE); }
376 <S_RMTS>passive { YYD; return(PASSIVE); }
377 <S_RMTS>lifetime { YYD; return(LIFETIME); }
378 <S_RMTS>time { YYD; return(LIFETYPE_TIME); }
379 <S_RMTS>byte { YYD; return(LIFETYPE_BYTE); }
380 <S_RMTS>dpd { YYD; return(DPD); }
381 <S_RMTS>dpd_delay { YYD; return(DPD_DELAY); }
382 <S_RMTS>dpd_retry { YYD; return(DPD_RETRY); }
383 <S_RMTS>dpd_maxfail { YYD; return(DPD_MAXFAIL); }
384 <S_RMTS>dpd_algorithm { YYD; return(DPD_ALGORITHM); }
385 <S_RMTS>disconnect_on_idle { YYD; return(DISCONNECT_ON_IDLE); }
386 <S_RMTS>idle_timeout { YYD; return(IDLE_TIMEOUT); }
387 <S_RMTS>idle_direction { YYD; return(IDLE_DIRECTION); }
388 <S_RMTS>ike_frag { YYD; return(IKE_FRAG); }
389 <S_RMTS>esp_frag { YYD; return(ESP_FRAG); }
390 <S_RMTS>script { YYD; return(SCRIPT); }
391 <S_RMTS>phase1_up { YYD; return(PHASE1_UP); }
392 <S_RMTS>phase1_down { YYD; return(PHASE1_DOWN); }
393 <S_RMTS>mode_cfg { YYD; return(MODE_CFG); }
394 <S_RMTS>weak_phase1_check { YYD; return(WEAK_PHASE1_CHECK); }
395 /* remote proposal */
396 <S_RMTS>proposal { BEGIN S_RMTP; YYDB; return(PROPOSAL); }
397 <S_RMTP>{bcl} { return(BOC); }
398 <S_RMTP>{ecl} { BEGIN S_RMTS; return(EOC); }
399 <S_RMTP>lifetime { YYD; return(LIFETIME); }
400 <S_RMTP>time { YYD; return(LIFETYPE_TIME); }
401 <S_RMTP>byte { YYD; return(LIFETYPE_BYTE); }
402 <S_RMTP>encryption_algorithm { YYD; yylval.num = algclass_isakmp_enc; return(ALGORITHM_CLASS); }
403 <S_RMTP>authentication_method { YYD; yylval.num = algclass_isakmp_ameth; return(ALGORITHM_CLASS); }
404 <S_RMTP>hash_algorithm { YYD; yylval.num = algclass_isakmp_hash; return(ALGORITHM_CLASS); }
405 <S_RMTP>dh_group { YYD; return(DH_GROUP); }
406 <S_RMTP>gss_id { YYD; return(GSS_ID); }
407 <S_RMTP>gssapi_id { YYD; return(GSS_ID); } /* for back compatibility */
409 /* GSS ID encoding type (global) */
410 <S_INI>gss_id_enc { BEGIN S_GSSENC; YYDB; return(GSS_ID_ENC); }
411 <S_GSSENC>latin1 { YYD; yylval.num = LC_GSSENC_LATIN1;
412 return(GSS_ID_ENCTYPE); }
413 <S_GSSENC>utf-16le { YYD; yylval.num = LC_GSSENC_UTF16LE;
414 return(GSS_ID_ENCTYPE); }
415 <S_GSSENC>{semi} { BEGIN S_INI; YYDB; return(EOS); }
418 on { YYD; yylval.num = TRUE; return(SWITCH); }
419 off { YYD; yylval.num = FALSE; return(SWITCH); }
422 {slash}({digit}{1,3}) {
425 yylval.num = atoi(yytext);
430 {blcl}{decstring}{elcl} {
433 while (*++p != ']') ;
436 yylval.num = atoi(yytext);
441 {hyphen}{addrstring} {
444 yylval.val = vmalloc(yyleng + 1);
445 if (yylval.val == NULL) {
446 yyerror("vmalloc failed");
449 memcpy(yylval.val->v, yytext, yylval.val->l);
454 esp { YYD; yylval.num = IPPROTO_ESP; return(UL_PROTO); }
455 ah { YYD; yylval.num = IPPROTO_AH; return(UL_PROTO); }
456 ipcomp { YYD; yylval.num = IPPROTO_IPCOMP; return(UL_PROTO); }
457 icmp { YYD; yylval.num = IPPROTO_ICMP; return(UL_PROTO); }
458 icmp6 { YYD; yylval.num = IPPROTO_ICMPV6; return(UL_PROTO); }
459 tcp { YYD; yylval.num = IPPROTO_TCP; return(UL_PROTO); }
460 udp { YYD; yylval.num = IPPROTO_UDP; return(UL_PROTO); }
463 des_iv64 { YYD; yylval.num = algtype_des_iv64; return(ALGORITHMTYPE); }
464 des { YYD; yylval.num = algtype_des; return(ALGORITHMTYPE); }
465 3des { YYD; yylval.num = algtype_3des; return(ALGORITHMTYPE); }
466 rc5 { YYD; yylval.num = algtype_rc5; return(ALGORITHMTYPE); }
467 idea { YYD; yylval.num = algtype_idea; return(ALGORITHMTYPE); }
468 cast128 { YYD; yylval.num = algtype_cast128; return(ALGORITHMTYPE); }
469 blowfish { YYD; yylval.num = algtype_blowfish; return(ALGORITHMTYPE); }
470 3idea { YYD; yylval.num = algtype_3idea; return(ALGORITHMTYPE); }
471 des_iv32 { YYD; yylval.num = algtype_des_iv32; return(ALGORITHMTYPE); }
472 rc4 { YYD; yylval.num = algtype_rc4; return(ALGORITHMTYPE); }
473 null_enc { YYD; yylval.num = algtype_null_enc; return(ALGORITHMTYPE); }
474 null { YYD; yylval.num = algtype_null_enc; return(ALGORITHMTYPE); }
475 aes { YYD; yylval.num = algtype_aes; return(ALGORITHMTYPE); }
476 rijndael { YYD; yylval.num = algtype_aes; return(ALGORITHMTYPE); }
477 twofish { YYD; yylval.num = algtype_twofish; return(ALGORITHMTYPE); }
478 non_auth { YYD; yylval.num = algtype_non_auth; return(ALGORITHMTYPE); }
479 hmac_md5 { YYD; yylval.num = algtype_hmac_md5; return(ALGORITHMTYPE); }
480 hmac_sha1 { YYD; yylval.num = algtype_hmac_sha1; return(ALGORITHMTYPE); }
481 hmac_sha2_256 { YYD; yylval.num = algtype_hmac_sha2_256; return(ALGORITHMTYPE); }
482 hmac_sha256 { YYD; yylval.num = algtype_hmac_sha2_256; return(ALGORITHMTYPE); }
483 hmac_sha2_384 { YYD; yylval.num = algtype_hmac_sha2_384; return(ALGORITHMTYPE); }
484 hmac_sha384 { YYD; yylval.num = algtype_hmac_sha2_384; return(ALGORITHMTYPE); }
485 hmac_sha2_512 { YYD; yylval.num = algtype_hmac_sha2_512; return(ALGORITHMTYPE); }
486 hmac_sha512 { YYD; yylval.num = algtype_hmac_sha2_512; return(ALGORITHMTYPE); }
487 des_mac { YYD; yylval.num = algtype_des_mac; return(ALGORITHMTYPE); }
488 kpdk { YYD; yylval.num = algtype_kpdk; return(ALGORITHMTYPE); }
489 md5 { YYD; yylval.num = algtype_md5; return(ALGORITHMTYPE); }
490 sha1 { YYD; yylval.num = algtype_sha1; return(ALGORITHMTYPE); }
491 tiger { YYD; yylval.num = algtype_tiger; return(ALGORITHMTYPE); }
492 sha2_256 { YYD; yylval.num = algtype_sha2_256; return(ALGORITHMTYPE); }
493 sha256 { YYD; yylval.num = algtype_sha2_256; return(ALGORITHMTYPE); }
494 sha2_384 { YYD; yylval.num = algtype_sha2_384; return(ALGORITHMTYPE); }
495 sha384 { YYD; yylval.num = algtype_sha2_384; return(ALGORITHMTYPE); }
496 sha2_512 { YYD; yylval.num = algtype_sha2_512; return(ALGORITHMTYPE); }
497 sha512 { YYD; yylval.num = algtype_sha2_512; return(ALGORITHMTYPE); }
498 oui { YYD; yylval.num = algtype_oui; return(ALGORITHMTYPE); }
499 deflate { YYD; yylval.num = algtype_deflate; return(ALGORITHMTYPE); }
500 lzs { YYD; yylval.num = algtype_lzs; return(ALGORITHMTYPE); }
501 modp768 { YYD; yylval.num = algtype_modp768; return(ALGORITHMTYPE); }
502 modp1024 { YYD; yylval.num = algtype_modp1024; return(ALGORITHMTYPE); }
503 modp1536 { YYD; yylval.num = algtype_modp1536; return(ALGORITHMTYPE); }
504 ec2n155 { YYD; yylval.num = algtype_ec2n155; return(ALGORITHMTYPE); }
505 ec2n185 { YYD; yylval.num = algtype_ec2n185; return(ALGORITHMTYPE); }
506 modp2048 { YYD; yylval.num = algtype_modp2048; return(ALGORITHMTYPE); }
507 modp3072 { YYD; yylval.num = algtype_modp3072; return(ALGORITHMTYPE); }
508 modp4096 { YYD; yylval.num = algtype_modp4096; return(ALGORITHMTYPE); }
509 modp6144 { YYD; yylval.num = algtype_modp6144; return(ALGORITHMTYPE); }
510 modp8192 { YYD; yylval.num = algtype_modp8192; return(ALGORITHMTYPE); }
511 pre_shared_key { YYD; yylval.num = algtype_psk; return(ALGORITHMTYPE); }
512 rsasig { YYD; yylval.num = algtype_rsasig; return(ALGORITHMTYPE); }
513 dsssig { YYD; yylval.num = algtype_dsssig; return(ALGORITHMTYPE); }
514 rsaenc { YYD; yylval.num = algtype_rsaenc; return(ALGORITHMTYPE); }
515 rsarev { YYD; yylval.num = algtype_rsarev; return(ALGORITHMTYPE); }
516 gssapi_krb { YYD; yylval.num = algtype_gssapikrb; return(ALGORITHMTYPE); }
519 YYD; yylval.num = algtype_hybrid_rsa_s; return(ALGORITHMTYPE);
521 yyerror("racoon not configured with --enable-hybrid");
526 YYD; yylval.num = algtype_hybrid_dss_s; return(ALGORITHMTYPE);
528 yyerror("racoon not configured with --enable-hybrid");
533 YYD; yylval.num = algtype_hybrid_rsa_c; return(ALGORITHMTYPE);
535 yyerror("racoon not configured with --enable-hybrid");
540 YYD; yylval.num = algtype_hybrid_dss_c; return(ALGORITHMTYPE);
542 yyerror("racoon not configured with --enable-hybrid");
548 YYD; yylval.num = algtype_xauth_psk_s; return(ALGORITHMTYPE);
550 yyerror("racoon not configured with --enable-hybrid");
555 YYD; yylval.num = algtype_xauth_psk_c; return(ALGORITHMTYPE);
557 yyerror("racoon not configured with --enable-hybrid");
562 YYD; yylval.num = algtype_xauth_rsa_s; return(ALGORITHMTYPE);
564 yyerror("racoon not configured with --enable-hybrid");
569 YYD; yylval.num = algtype_xauth_rsa_c; return(ALGORITHMTYPE);
571 yyerror("racoon not configured with --enable-hybrid");
577 /* identifier type */
578 vendor_id { YYD; yywarn("it is obsoleted."); return(VENDORID); }
579 user_fqdn { YYD; yylval.num = IDTYPE_USERFQDN; return(IDENTIFIERTYPE); }
580 fqdn { YYD; yylval.num = IDTYPE_FQDN; return(IDENTIFIERTYPE); }
581 keyid { YYD; yylval.num = IDTYPE_KEYID; return(IDENTIFIERTYPE); }
584 yylval.num = IDTYPE_KEYIDUSE;
585 return(IDENTIFIERTYPE);
587 address { YYD; yylval.num = IDTYPE_ADDRESS; return(IDENTIFIERTYPE); }
588 subnet { YYD; yylval.num = IDTYPE_SUBNET; return(IDENTIFIERTYPE); }
589 asn1dn { YYD; yylval.num = IDTYPE_ASN1DN; return(IDENTIFIERTYPE); }
590 certname { YYD; yywarn("certname will be obsoleted in near future."); yylval.num = IDTYPE_ASN1DN; return(IDENTIFIERTYPE); }
592 /* shared secret type */
595 yylval.num = SECRETTYPE_USE;
600 yylval.num = SECRETTYPE_KEY;
606 yylval.num = SECRETTYPE_KEYCHAIN;
609 yyerror("Apple specific features not compiled in.");
614 yylval.num = SECRETTYPE_KEYCHAIN_BY_ID;
618 /* certificate verification */
621 yylval.num = VERIFICATION_MODULE_OPENSSL;
622 return(VERIFICATION_MODULE);
626 yylval.num = VERIFICATION_MODULE_SEC_FRAMEWORK;
627 return(VERIFICATION_MODULE);
631 yylval.num = VERIFICATION_OPTION_OPEN_DIR;
632 return(VERIFICATION_OPTION);
634 use_peers_identifier {
636 yylval.num = VERIFICATION_OPTION_PEERS_IDENTIFIER;
637 return(VERIFICATION_OPTION);
640 /* identifier qualifier */
641 tag { YYD; yylval.num = IDQUAL_TAG; return(IDENTIFIERQUAL); }
642 file { YYD; yylval.num = IDQUAL_FILE; return(IDENTIFIERQUAL); }
645 B|byte|bytes { YYD; return(UNITTYPE_BYTE); }
646 KB { YYD; return(UNITTYPE_KBYTES); }
647 MB { YYD; return(UNITTYPE_MBYTES); }
648 TB { YYD; return(UNITTYPE_TBYTES); }
649 sec|secs|second|seconds { YYD; return(UNITTYPE_SEC); }
650 min|mins|minute|minutes { YYD; return(UNITTYPE_MIN); }
651 hour|hours { YYD; return(UNITTYPE_HOUR); }
653 dpd_default { YYD; return(DPD_ALGO_TYPE_DEFAULT); }
654 dpd_inbound_detect { YYD; return(DPD_ALGO_TYPE_INBOUND); }
655 dpd_blackhole_detect { YYD; return(DPD_ALGO_TYPE_BLACKHOLE); }
657 idle_any { YYD; return(IDLE_DIRECTION_ANY); }
658 idle_inbound { YYD; return(IDLE_DIRECTION_IN); }
659 idle_outbound { YYD; return(IDLE_DIRECTION_OUT); }
662 yes { YYD; yylval.num = TRUE; return(BOOLEAN); }
663 no { YYD; yylval.num = FALSE; return(BOOLEAN); }
669 yylval.num = strtol(yytext, &bp, 10);
677 yylval.val = vmalloc(yyleng + (yyleng & 1) + 1);
678 if (yylval.val == NULL) {
679 yyerror("vmalloc failed");
687 /* fixed string if length is odd. */
690 memcpy(p, &yytext[2], yyleng - 1);
699 while (*++p != '"') ;
702 yylval.val = vmalloc(yyleng - 1);
703 if (yylval.val == NULL) {
704 yyerror("vmalloc failed");
707 memcpy(yylval.val->v, &yytext[1], yylval.val->l);
709 return(QUOTEDSTRING);
715 yylval.val = vmalloc(yyleng + 1);
716 if (yylval.val == NULL) {
717 yyerror("vmalloc failed");
720 memcpy(yylval.val->v, yytext, yylval.val->l);
726 yy_delete_buffer(YY_CURRENT_BUFFER);
729 if (incstack[incstackp].matches.gl_pathc != 0 &&
730 incstack[incstackp].matches.gl_pathv &&
731 incstack[incstackp].matchon <
732 incstack[incstackp].matches.gl_pathc) {
733 char* filepath = incstack[incstackp].matches.gl_pathv[incstack[incstackp].matchon];
734 incstack[incstackp].matchon++;
736 if (yycf_set_buffer(filepath) != 0) {
740 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
743 globfree(&incstack[incstackp].matches);
747 yy_switch_to_buffer(incstack[incstackp].prevstate);
753 {nl} { incstack[incstackp].lineno++; }
755 {semi} { return(EOS); }
761 yyerror(char *s, ...)
771 snprintf(fmt, sizeof(fmt), "%s:%d: \"%s\" %s\n",
772 incstack[incstackp].path, incstack[incstackp].lineno,
774 plogv(LLV_ERROR, LOCATION, NULL, fmt, &ap);
791 snprintf(fmt, sizeof(fmt), "%s:%d: \"%s\" %s\n",
792 incstack[incstackp].path, incstack[incstackp].lineno,
794 plogv(LLV_WARNING, LOCATION, NULL, fmt, &ap);
799 yycf_switch_buffer(path)
802 char *filepath = NULL;
804 /* got the include file name */
805 if (incstackp >= MAX_INCLUDE_DEPTH) {
806 plog(LLV_ERROR, LOCATION, NULL,
807 "Includes nested too deeply");
811 if (glob(path, GLOB_TILDE, NULL, &incstack[incstackp].matches) != 0 ||
812 incstack[incstackp].matches.gl_pathc == 0) {
813 plog(LLV_WARNING, LOCATION, NULL,
814 "glob found no matches for path \"%s\"\n", path);
817 incstack[incstackp].matchon = 0;
818 incstack[incstackp].prevstate = YY_CURRENT_BUFFER;
821 if (incstack[incstackp].matchon >= incstack[incstackp].matches.gl_pathc)
824 incstack[incstackp].matches.gl_pathv[incstack[incstackp].matchon];
825 incstack[incstackp].matchon++;
828 if (yycf_set_buffer(filepath) != 0) {
833 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
841 yycf_set_buffer(path)
844 yyin = fopen(path, "r");
846 fprintf(stderr, "failed to open file %s (%s)\n",
847 path, strerror(errno));
848 plog(LLV_ERROR, LOCATION, NULL,
849 "failed to open file %s (%s)\n",
850 path, strerror(errno));
855 if (incstack[incstackp].path != NULL) {
856 fclose(incstack[incstackp].fp);
857 racoon_free(incstack[incstackp].path);
859 incstack[incstackp].fp = yyin;
860 incstack[incstackp].path = racoon_strdup(path);
861 STRDUP_FATAL(incstack[incstackp].path);
862 incstack[incstackp].lineno = 1;
863 plog(LLV_DEBUG, LOCATION, NULL,
864 "reading config file %s\n", path);
874 for (i = 0; i < MAX_INCLUDE_DEPTH; i++)
875 memset(&incstack[i], 0, sizeof(incstack[i]));
884 for (i = 0; i < MAX_INCLUDE_DEPTH; i++) {
885 if (incstack[i].path != NULL) {
886 fclose(incstack[i].fp);
887 racoon_free(incstack[i].path);
888 incstack[i].path = NULL;