1 /* $Id: cftoken.l,v 1.31.2.7 2005/11/06 17:18:26 monas Exp $ */
5 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 and 2003 WIDE Project.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #ifdef HAVE_NETINET6_IPSEC
41 # include <netinet6/ipsec.h>
43 # include <netinet/ipsec.h>
59 //%%% BUG FIX - 2 missing include files when not using
61 #include <openssl/bn.h>
62 #include <openssl/rsa.h>
70 #include "algorithm.h"
71 #include "cfparse_proto.h"
72 #include "cftoken_proto.h"
73 #include "localconf.h"
75 #include "isakmp_var.h"
77 #include "ipsec_doi.h"
79 #include "nattraversal.h"
92 #if defined(YIPS_DEBUG)
93 # define YYDB plog(LLV_DEBUG2, LOCATION, NULL, \
94 "begin <%d>%s\n", yy_start, yytext);
96 plog(LLV_DEBUG2, LOCATION, NULL, "<%d>%s", \
97 yy_start, loglevel >= LLV_DEBUG2 ? "\n" : ""); \
102 #endif /* defined(YIPS_DEBUG) */
104 #define MAX_INCLUDE_DEPTH 10
106 static struct include_stack {
109 YY_BUFFER_STATE prevstate;
113 } incstack[MAX_INCLUDE_DEPTH];
114 static int incstackp = 0;
116 static int yy_first_time = 1;
125 /*octet (([01]?{digit}?{digit})|((2([0-4]{digit}))|(25[0-5]))) */
138 bracketstring \<[^>]*\>
139 quotedstring \"[^"]*\"
140 addrstring [a-fA-F0-9:]([a-fA-F0-9:\.]*|[a-fA-F0-9:\.]*%[a-zA-Z0-9]*)
142 hexstring 0x{hexdigit}+
144 %s S_INI S_PRIV S_PTH S_INF S_LOG S_PAD S_LST S_RTRY S_CFG
147 %s S_RMT S_RMTS S_RMTP
160 <S_INI>privsep { BEGIN S_PRIV; YYDB; return(PRIVSEP); }
161 <S_PRIV>{bcl} { return(BOC); }
162 <S_PRIV>user { YYD; return(USER); }
163 <S_PRIV>group { YYD; return(GROUP); }
164 <S_PRIV>chroot { YYD; return(CHROOT); }
165 <S_PRIV>{ecl} { BEGIN S_INI; return(EOC); }
168 <S_INI>path { BEGIN S_PTH; YYDB; return(PATH); }
169 <S_PTH>include { YYD; yylval.num = LC_PATHTYPE_INCLUDE;
171 <S_PTH>pre_shared_key { YYD; yylval.num = LC_PATHTYPE_PSK;
173 <S_PTH>certificate { YYD; yylval.num = LC_PATHTYPE_CERT;
175 <S_PTH>script { YYD; yylval.num = LC_PATHTYPE_SCRIPT;
177 <S_PTH>backupsa { YYD; yylval.num = LC_PATHTYPE_BACKUPSA;
179 <S_PTH>pidfile { YYD; yylval.num = LC_PATHTYPE_PIDFILE;
181 <S_PTH>logfile { YYD; yylval.num = LC_PATHTYPE_LOGFILE;
183 <S_PTH>{semi} { BEGIN S_INI; YYDB; return(EOS); }
186 <S_INI>include { YYDB; return(INCLUDE); }
188 /* self information */
189 <S_INI>identifier { BEGIN S_INF; YYDB; yywarn("it is obsoleted. use \"my_identifier\" in each remote directives."); return(IDENTIFIER); }
190 <S_INF>{semi} { BEGIN S_INI; return(EOS); }
193 <S_INI>complex_bundle { YYDB; return(COMPLEX_BUNDLE); }
196 <S_INI>log { BEGIN S_LOG; YYDB; return(LOGGING); }
197 <S_LOG>info { YYD; yywarn("it is obsoleted. use \"notify\""); yylval.num = 0; return(LOGLEV); }
198 <S_LOG>notify { YYD; yylval.num = 0; return(LOGLEV); }
199 <S_LOG>debug { YYD; yylval.num = 1; return(LOGLEV); }
200 <S_LOG>debug2 { YYD; yylval.num = 2; return(LOGLEV); }
201 <S_LOG>debug3 { YYD; yywarn("it is osboleted. use \"debug2\""); yylval.num = 2; return(LOGLEV); }
202 <S_LOG>debug4 { YYD; yywarn("it is obsoleted. use \"debug2\""); yylval.num = 2; return(LOGLEV); }
203 <S_LOG>{semi} { BEGIN S_INI; return(EOS); }
206 <S_INI>padding { BEGIN S_PAD; YYDB; return(PADDING); }
207 <S_PAD>{bcl} { return(BOC); }
208 <S_PAD>randomize { YYD; return(PAD_RANDOMIZE); }
209 <S_PAD>randomize_length { YYD; return(PAD_RANDOMIZELEN); }
210 <S_PAD>maximum_length { YYD; return(PAD_MAXLEN); }
211 <S_PAD>strict_check { YYD; return(PAD_STRICT); }
212 <S_PAD>exclusive_tail { YYD; return(PAD_EXCLTAIL); }
213 <S_PAD>{ecl} { BEGIN S_INI; return(EOC); }
216 <S_INI>listen { BEGIN S_LST; YYDB; return(LISTEN); }
217 <S_LST>{bcl} { return(BOC); }
218 <S_LST>isakmp { YYD; return(X_ISAKMP); }
219 <S_LST>isakmp_natt { YYD; return(X_ISAKMP_NATT); }
220 <S_LST>admin { YYD; return(X_ADMIN); }
221 <S_LST>adminsock { YYD; return(ADMINSOCK); }
222 <S_LST>disabled { YYD; return(DISABLED); }
223 <S_LST>strict_address { YYD; return(STRICT_ADDRESS); }
224 <S_LST>{ecl} { BEGIN S_INI; return(EOC); }
227 <S_INI>mode_cfg { BEGIN S_CFG; YYDB; return(MODECFG); }
228 <S_CFG>{bcl} { return(BOC); }
229 <S_CFG>network4 { YYD; return(CFG_NET4); }
230 <S_CFG>netmask4 { YYD; return(CFG_MASK4); }
231 <S_CFG>dns4 { YYD; return(CFG_DNS4); }
232 <S_CFG>wins4 { YYD; return(CFG_NBNS4); }
233 <S_CFG>auth_source { YYD; return(CFG_AUTH_SOURCE); }
234 <S_CFG>conf_source { YYD; return(CFG_CONF_SOURCE); }
235 <S_CFG>accounting { YYD; return(CFG_ACCOUNTING); }
236 <S_CFG>system { YYD; return(CFG_SYSTEM); }
237 <S_CFG>local { YYD; return(CFG_LOCAL); }
238 <S_CFG>none { YYD; return(CFG_NONE); }
239 <S_CFG>radius { YYD; return(CFG_RADIUS); }
240 <S_CFG>pam { YYD; return(CFG_PAM); }
241 <S_CFG>pool_size { YYD; return(CFG_POOL_SIZE); }
242 <S_CFG>banner { YYD; return(CFG_MOTD); }
243 <S_CFG>auth_throttle { YYD; return(CFG_AUTH_THROTTLE); }
244 <S_CFG>pfs_group { YYD; return(CFG_PFS_GROUP); }
245 <S_CFG>save_passwd { YYD; return(CFG_SAVE_PASSWD); }
246 <S_CFG>{ecl} { BEGIN S_INI; return(EOC); }
249 <S_INI>timer { BEGIN S_RTRY; YYDB; return(RETRY); }
250 <S_RTRY>{bcl} { return(BOC); }
251 <S_RTRY>counter { YYD; return(RETRY_COUNTER); }
252 <S_RTRY>interval { YYD; return(RETRY_INTERVAL); }
253 <S_RTRY>persend { YYD; return(RETRY_PERSEND); }
254 <S_RTRY>phase1 { YYD; return(RETRY_PHASE1); }
255 <S_RTRY>phase2 { YYD; return(RETRY_PHASE2); }
256 <S_RTRY>natt_keepalive { YYD; return(NATT_KA); }
257 <S_RTRY>auto_exit_delay { YYD; return(AUTO_EXIT_DELAY); }
258 <S_RTRY>{ecl} { BEGIN S_INI; return(EOC); }
261 <S_INI>sainfo { BEGIN S_SAINF; YYDB; return(SAINFO); }
262 <S_SAINF>anonymous { YYD; return(ANONYMOUS); }
263 <S_SAINF>{blcl}any{elcl} { YYD; return(PORTANY); }
264 <S_SAINF>any { YYD; return(ANY); }
265 <S_SAINF>from { YYD; return(FROM); }
267 <S_SAINF>{bcl} { BEGIN S_SAINFS; return(BOC); }
268 <S_SAINF>{semi} { BEGIN S_INI; return(EOS); }
269 <S_SAINFS>{ecl} { BEGIN S_INI; return(EOC); }
270 <S_SAINFS>pfs_group { YYD; return(PFS_GROUP); }
271 <S_SAINFS>identifier { YYD; yywarn("it is obsoleted. use \"my_identifier\"."); return(IDENTIFIER); }
272 <S_SAINFS>my_identifier { YYD; return(MY_IDENTIFIER); }
273 <S_SAINFS>lifetime { YYD; return(LIFETIME); }
274 <S_SAINFS>time { YYD; return(LIFETYPE_TIME); }
275 <S_SAINFS>byte { YYD; return(LIFETYPE_BYTE); }
276 <S_SAINFS>encryption_algorithm { YYD; yylval.num = algclass_ipsec_enc; return(ALGORITHM_CLASS); }
277 <S_SAINFS>authentication_algorithm { YYD; yylval.num = algclass_ipsec_auth; return(ALGORITHM_CLASS); }
278 <S_SAINFS>compression_algorithm { YYD; yylval.num = algclass_ipsec_comp; return(ALGORITHM_CLASS); }
279 <S_SAINFS>{comma} { YYD; return(COMMA); }
282 <S_INI>remote { BEGIN S_RMT; YYDB; return(REMOTE); }
283 <S_RMT>anonymous { YYD; return(ANONYMOUS); }
284 <S_RMT>inherit { YYD; return(INHERIT); }
286 <S_RMT>{bcl} { BEGIN S_RMTS; return(BOC); }
287 <S_RMTS>{ecl} { BEGIN S_INI; return(EOC); }
288 <S_RMTS>exchange_mode { YYD; return(EXCHANGE_MODE); }
289 <S_RMTS>{comma} { YYD; /* XXX ignored, but to be handled. */ ; }
290 <S_RMTS>base { YYD; yylval.num = ISAKMP_ETYPE_BASE; return(EXCHANGETYPE); }
291 <S_RMTS>main { YYD; yylval.num = ISAKMP_ETYPE_IDENT; return(EXCHANGETYPE); }
292 <S_RMTS>aggressive { YYD; yylval.num = ISAKMP_ETYPE_AGG; return(EXCHANGETYPE); }
293 <S_RMTS>doi { YYD; return(DOI); }
294 <S_RMTS>ipsec_doi { YYD; yylval.num = IPSEC_DOI; return(DOITYPE); }
295 <S_RMTS>situation { YYD; return(SITUATION); }
296 <S_RMTS>identity_only { YYD; yylval.num = IPSECDOI_SIT_IDENTITY_ONLY; return(SITUATIONTYPE); }
297 <S_RMTS>secrecy { YYD; yylval.num = IPSECDOI_SIT_SECRECY; return(SITUATIONTYPE); }
298 <S_RMTS>integrity { YYD; yylval.num = IPSECDOI_SIT_INTEGRITY; return(SITUATIONTYPE); }
299 <S_RMTS>identifier { YYD; yywarn("it is obsoleted. use \"my_identifier\"."); return(IDENTIFIER); }
300 <S_RMTS>my_identifier { YYD; return(MY_IDENTIFIER); }
301 <S_RMTS>xauth_login { YYD; return(XAUTH_LOGIN); /* formerly identifier type login */ }
302 <S_RMTS>peers_identifier { YYD; return(PEERS_IDENTIFIER); }
303 <S_RMTS>verify_identifier { YYD; return(VERIFY_IDENTIFIER); }
304 <S_RMTS>certificate_type { YYD; return(CERTIFICATE_TYPE); }
305 <S_RMTS>ca_type { YYD; return(CA_TYPE); }
306 <S_RMTS>x509 { YYD; yylval.num = ISAKMP_CERT_X509SIGN; return(CERT_X509); }
307 <S_RMTS>plain_rsa { YYD; yylval.num = ISAKMP_CERT_PLAINRSA; return(CERT_PLAINRSA); }
308 <S_RMTS>open_dir_auth_group {
311 return(OPEN_DIR_AUTH_GROUP);
313 yyerror("Apple specific features not compiled in.");
316 <S_RMTS>shared_secret {
319 return(SHARED_SECRET);
321 yyerror("Apple specific features not compiled in.");
324 <S_RMTS>in_keychain {
329 yyerror("Apple specific features not compiled in.");
332 <S_RMTS>certificate_verification {
335 return(CERTIFICATE_VERIFICATION);
337 yyerror("Apple specific features not compiled in.");
340 <S_RMTS>peers_certfile { YYD; return(PEERS_CERTFILE); }
341 <S_RMTS>dnssec { YYD; return(DNSSEC); }
342 <S_RMTS>verify_cert { YYD; return(VERIFY_CERT); }
343 <S_RMTS>send_cert { YYD; return(SEND_CERT); }
344 <S_RMTS>send_cr { YYD; return(SEND_CR); }
345 <S_RMTS>dh_group { YYD; return(DH_GROUP); }
346 <S_RMTS>nonce_size { YYD; return(NONCE_SIZE); }
347 <S_RMTS>generate_policy { YYD; return(GENERATE_POLICY); }
348 <S_RMTS>support_mip6 { YYD; yywarn("it is obsoleted. use \"support_proxy\"."); return(SUPPORT_PROXY); }
349 <S_RMTS>support_proxy { YYD; return(SUPPORT_PROXY); }
350 <S_RMTS>initial_contact { YYD; return(INITIAL_CONTACT); }
351 <S_RMTS>nat_traversal { YYD; return(NAT_TRAVERSAL); }
352 <S_RMTS>force { YYD; yylval.num = NATT_FORCE; return(NAT_TRAVERSAL_LEVEL); }
353 <S_RMTS>nat_traversal_multi_user {
356 return(NAT_TRAVERSAL_MULTI_USER);
358 yyerror("Apple specific features not compiled in.");
361 <S_RMTS>proposal_check { YYD; return(PROPOSAL_CHECK); }
362 <S_RMTS>obey { YYD; yylval.num = PROP_CHECK_OBEY; return(PROPOSAL_CHECK_LEVEL); }
363 <S_RMTS>strict { YYD; yylval.num = PROP_CHECK_STRICT; return(PROPOSAL_CHECK_LEVEL); }
364 <S_RMTS>exact { YYD; yylval.num = PROP_CHECK_EXACT; return(PROPOSAL_CHECK_LEVEL); }
365 <S_RMTS>claim { YYD; yylval.num = PROP_CHECK_CLAIM; return(PROPOSAL_CHECK_LEVEL); }
366 <S_RMTS>keepalive { YYD; return(KEEPALIVE); }
367 <S_RMTS>passive { YYD; return(PASSIVE); }
368 <S_RMTS>lifetime { YYD; return(LIFETIME); }
369 <S_RMTS>time { YYD; return(LIFETYPE_TIME); }
370 <S_RMTS>byte { YYD; return(LIFETYPE_BYTE); }
371 <S_RMTS>dpd { YYD; return(DPD); }
372 <S_RMTS>dpd_delay { YYD; return(DPD_DELAY); }
373 <S_RMTS>dpd_retry { YYD; return(DPD_RETRY); }
374 <S_RMTS>dpd_maxfail { YYD; return(DPD_MAXFAIL); }
375 <S_RMTS>ike_frag { YYD; return(IKE_FRAG); }
376 <S_RMTS>esp_frag { YYD; return(ESP_FRAG); }
377 <S_RMTS>script { YYD; return(SCRIPT); }
378 <S_RMTS>phase1_up { YYD; return(PHASE1_UP); }
379 <S_RMTS>phase1_down { YYD; return(PHASE1_DOWN); }
380 <S_RMTS>mode_cfg { YYD; return(MODE_CFG); }
381 /* remote proposal */
382 <S_RMTS>proposal { BEGIN S_RMTP; YYDB; return(PROPOSAL); }
383 <S_RMTP>{bcl} { return(BOC); }
384 <S_RMTP>{ecl} { BEGIN S_RMTS; return(EOC); }
385 <S_RMTP>lifetime { YYD; return(LIFETIME); }
386 <S_RMTP>time { YYD; return(LIFETYPE_TIME); }
387 <S_RMTP>byte { YYD; return(LIFETYPE_BYTE); }
388 <S_RMTP>encryption_algorithm { YYD; yylval.num = algclass_isakmp_enc; return(ALGORITHM_CLASS); }
389 <S_RMTP>authentication_method { YYD; yylval.num = algclass_isakmp_ameth; return(ALGORITHM_CLASS); }
390 <S_RMTP>hash_algorithm { YYD; yylval.num = algclass_isakmp_hash; return(ALGORITHM_CLASS); }
391 <S_RMTP>dh_group { YYD; return(DH_GROUP); }
392 <S_RMTP>gss_id { YYD; return(GSS_ID); }
393 <S_RMTP>gssapi_id { YYD; return(GSS_ID); } /* for back compatibility */
395 /* GSS ID encoding type (global) */
396 <S_INI>gss_id_enc { BEGIN S_GSSENC; YYDB; return(GSS_ID_ENC); }
397 <S_GSSENC>latin1 { YYD; yylval.num = LC_GSSENC_LATIN1;
398 return(GSS_ID_ENCTYPE); }
399 <S_GSSENC>utf-16le { YYD; yylval.num = LC_GSSENC_UTF16LE;
400 return(GSS_ID_ENCTYPE); }
401 <S_GSSENC>{semi} { BEGIN S_INI; YYDB; return(EOS); }
404 on { YYD; yylval.num = TRUE; return(SWITCH); }
405 off { YYD; yylval.num = FALSE; return(SWITCH); }
408 {slash}({digit}{1,3}) {
411 yylval.num = atoi(yytext);
416 {blcl}{decstring}{elcl} {
419 while (*++p != ']') ;
422 yylval.num = atoi(yytext);
427 esp { YYD; yylval.num = IPPROTO_ESP; return(UL_PROTO); }
428 ah { YYD; yylval.num = IPPROTO_AH; return(UL_PROTO); }
429 ipcomp { YYD; yylval.num = IPPROTO_IPCOMP; return(UL_PROTO); }
430 icmp { YYD; yylval.num = IPPROTO_ICMP; return(UL_PROTO); }
431 icmp6 { YYD; yylval.num = IPPROTO_ICMPV6; return(UL_PROTO); }
432 tcp { YYD; yylval.num = IPPROTO_TCP; return(UL_PROTO); }
433 udp { YYD; yylval.num = IPPROTO_UDP; return(UL_PROTO); }
436 des_iv64 { YYD; yylval.num = algtype_des_iv64; return(ALGORITHMTYPE); }
437 des { YYD; yylval.num = algtype_des; return(ALGORITHMTYPE); }
438 3des { YYD; yylval.num = algtype_3des; return(ALGORITHMTYPE); }
439 rc5 { YYD; yylval.num = algtype_rc5; return(ALGORITHMTYPE); }
440 idea { YYD; yylval.num = algtype_idea; return(ALGORITHMTYPE); }
441 cast128 { YYD; yylval.num = algtype_cast128; return(ALGORITHMTYPE); }
442 blowfish { YYD; yylval.num = algtype_blowfish; return(ALGORITHMTYPE); }
443 3idea { YYD; yylval.num = algtype_3idea; return(ALGORITHMTYPE); }
444 des_iv32 { YYD; yylval.num = algtype_des_iv32; return(ALGORITHMTYPE); }
445 rc4 { YYD; yylval.num = algtype_rc4; return(ALGORITHMTYPE); }
446 null_enc { YYD; yylval.num = algtype_null_enc; return(ALGORITHMTYPE); }
447 null { YYD; yylval.num = algtype_null_enc; return(ALGORITHMTYPE); }
448 aes { YYD; yylval.num = algtype_aes; return(ALGORITHMTYPE); }
449 rijndael { YYD; yylval.num = algtype_aes; return(ALGORITHMTYPE); }
450 twofish { YYD; yylval.num = algtype_twofish; return(ALGORITHMTYPE); }
451 non_auth { YYD; yylval.num = algtype_non_auth; return(ALGORITHMTYPE); }
452 hmac_md5 { YYD; yylval.num = algtype_hmac_md5; return(ALGORITHMTYPE); }
453 hmac_sha1 { YYD; yylval.num = algtype_hmac_sha1; return(ALGORITHMTYPE); }
454 hmac_sha2_256 { YYD; yylval.num = algtype_hmac_sha2_256; return(ALGORITHMTYPE); }
455 hmac_sha256 { YYD; yylval.num = algtype_hmac_sha2_256; return(ALGORITHMTYPE); }
456 hmac_sha2_384 { YYD; yylval.num = algtype_hmac_sha2_384; return(ALGORITHMTYPE); }
457 hmac_sha384 { YYD; yylval.num = algtype_hmac_sha2_384; return(ALGORITHMTYPE); }
458 hmac_sha2_512 { YYD; yylval.num = algtype_hmac_sha2_512; return(ALGORITHMTYPE); }
459 hmac_sha512 { YYD; yylval.num = algtype_hmac_sha2_512; return(ALGORITHMTYPE); }
460 des_mac { YYD; yylval.num = algtype_des_mac; return(ALGORITHMTYPE); }
461 kpdk { YYD; yylval.num = algtype_kpdk; return(ALGORITHMTYPE); }
462 md5 { YYD; yylval.num = algtype_md5; return(ALGORITHMTYPE); }
463 sha1 { YYD; yylval.num = algtype_sha1; return(ALGORITHMTYPE); }
464 tiger { YYD; yylval.num = algtype_tiger; return(ALGORITHMTYPE); }
465 sha2_256 { YYD; yylval.num = algtype_sha2_256; return(ALGORITHMTYPE); }
466 sha256 { YYD; yylval.num = algtype_sha2_256; return(ALGORITHMTYPE); }
467 sha2_384 { YYD; yylval.num = algtype_sha2_384; return(ALGORITHMTYPE); }
468 sha384 { YYD; yylval.num = algtype_sha2_384; return(ALGORITHMTYPE); }
469 sha2_512 { YYD; yylval.num = algtype_sha2_512; return(ALGORITHMTYPE); }
470 sha512 { YYD; yylval.num = algtype_sha2_512; return(ALGORITHMTYPE); }
471 oui { YYD; yylval.num = algtype_oui; return(ALGORITHMTYPE); }
472 deflate { YYD; yylval.num = algtype_deflate; return(ALGORITHMTYPE); }
473 lzs { YYD; yylval.num = algtype_lzs; return(ALGORITHMTYPE); }
474 modp768 { YYD; yylval.num = algtype_modp768; return(ALGORITHMTYPE); }
475 modp1024 { YYD; yylval.num = algtype_modp1024; return(ALGORITHMTYPE); }
476 modp1536 { YYD; yylval.num = algtype_modp1536; return(ALGORITHMTYPE); }
477 ec2n155 { YYD; yylval.num = algtype_ec2n155; return(ALGORITHMTYPE); }
478 ec2n185 { YYD; yylval.num = algtype_ec2n185; return(ALGORITHMTYPE); }
479 modp2048 { YYD; yylval.num = algtype_modp2048; return(ALGORITHMTYPE); }
480 modp3072 { YYD; yylval.num = algtype_modp3072; return(ALGORITHMTYPE); }
481 modp4096 { YYD; yylval.num = algtype_modp4096; return(ALGORITHMTYPE); }
482 modp6144 { YYD; yylval.num = algtype_modp6144; return(ALGORITHMTYPE); }
483 modp8192 { YYD; yylval.num = algtype_modp8192; return(ALGORITHMTYPE); }
484 pre_shared_key { YYD; yylval.num = algtype_psk; return(ALGORITHMTYPE); }
485 rsasig { YYD; yylval.num = algtype_rsasig; return(ALGORITHMTYPE); }
486 dsssig { YYD; yylval.num = algtype_dsssig; return(ALGORITHMTYPE); }
487 rsaenc { YYD; yylval.num = algtype_rsaenc; return(ALGORITHMTYPE); }
488 rsarev { YYD; yylval.num = algtype_rsarev; return(ALGORITHMTYPE); }
489 gssapi_krb { YYD; yylval.num = algtype_gssapikrb; return(ALGORITHMTYPE); }
492 YYD; yylval.num = algtype_hybrid_rsa_s; return(ALGORITHMTYPE);
494 yyerror("racoon not configured with --enable-hybrid");
499 YYD; yylval.num = algtype_hybrid_dss_s; return(ALGORITHMTYPE);
501 yyerror("racoon not configured with --enable-hybrid");
506 YYD; yylval.num = algtype_hybrid_rsa_c; return(ALGORITHMTYPE);
508 yyerror("racoon not configured with --enable-hybrid");
513 YYD; yylval.num = algtype_hybrid_dss_c; return(ALGORITHMTYPE);
515 yyerror("racoon not configured with --enable-hybrid");
520 /* identifier type */
521 vendor_id { YYD; yywarn("it is obsoleted."); return(VENDORID); }
522 user_fqdn { YYD; yylval.num = IDTYPE_USERFQDN; return(IDENTIFIERTYPE); }
523 fqdn { YYD; yylval.num = IDTYPE_FQDN; return(IDENTIFIERTYPE); }
524 keyid { YYD; yylval.num = IDTYPE_KEYID; return(IDENTIFIERTYPE); }
528 yylval.num = IDTYPE_KEYIDUSE;
529 return(IDENTIFIERTYPE);
531 yyerror("Apple specific features not compiled in.");
534 address { YYD; yylval.num = IDTYPE_ADDRESS; return(IDENTIFIERTYPE); }
535 subnet { YYD; yylval.num = IDTYPE_SUBNET; return(IDENTIFIERTYPE); }
536 asn1dn { YYD; yylval.num = IDTYPE_ASN1DN; return(IDENTIFIERTYPE); }
537 certname { YYD; yywarn("certname will be obsoleted in near future."); yylval.num = IDTYPE_ASN1DN; return(IDENTIFIERTYPE); }
539 /* shared secret type */
543 yylval.num = SECRETTYPE_USE;
546 yyerror("Apple specific features not compiled in.");
552 yylval.num = SECRETTYPE_KEY;
555 yyerror("Apple specific features not compiled in.");
561 yylval.num = SECRETTYPE_KEYCHAIN;
564 yyerror("Apple specific features not compiled in.");
570 yylval.num = SECRETTYPE_KEYCHAIN_BY_ID;
573 yyerror("Apple specific features not compiled in.");
577 /* certificate verification */
581 yylval.num = VERIFICATION_MODULE_OPENSSL;
582 return(VERIFICATION_MODULE);
584 yyerror("Apple specific features not compiled in.");
590 yylval.num = VERIFICATION_MODULE_SEC_FRAMEWORK;
591 return(VERIFICATION_MODULE);
593 yyerror("Apple specific features not compiled in.");
599 yylval.num = VERIFICATION_OPTION_OPEN_DIR;
600 return(VERIFICATION_OPTION);
602 yyerror("Apple specific features not compiled in.");
605 use_peers_identifier {
608 yylval.num = VERIFICATION_OPTION_PEERS_IDENTIFIER;
609 return(VERIFICATION_OPTION);
611 yyerror("Apple specific features not compiled in.");
616 B|byte|bytes { YYD; return(UNITTYPE_BYTE); }
617 KB { YYD; return(UNITTYPE_KBYTES); }
618 MB { YYD; return(UNITTYPE_MBYTES); }
619 TB { YYD; return(UNITTYPE_TBYTES); }
620 sec|secs|second|seconds { YYD; return(UNITTYPE_SEC); }
621 min|mins|minute|minutes { YYD; return(UNITTYPE_MIN); }
622 hour|hours { YYD; return(UNITTYPE_HOUR); }
625 yes { YYD; yylval.num = TRUE; return(BOOLEAN); }
626 no { YYD; yylval.num = FALSE; return(BOOLEAN); }
632 yylval.num = strtol(yytext, &bp, 10);
640 yylval.val = vmalloc(yyleng + (yyleng & 1) + 1);
641 if (yylval.val == NULL) {
642 yyerror("vmalloc failed");
650 /* fixed string if length is odd. */
653 memcpy(p, &yytext[2], yyleng - 1);
662 while (*++p != '"') ;
665 yylval.val = vmalloc(yyleng - 1);
666 if (yylval.val == NULL) {
667 yyerror("vmalloc failed");
670 memcpy(yylval.val->v, &yytext[1], yylval.val->l);
672 return(QUOTEDSTRING);
678 yylval.val = vmalloc(yyleng + 1);
679 if (yylval.val == NULL) {
680 yyerror("vmalloc failed");
683 memcpy(yylval.val->v, yytext, yylval.val->l);
689 yy_delete_buffer(YY_CURRENT_BUFFER);
690 yycf_free_buffer(incstackp);
693 if (incstack[incstackp].matchon <
694 incstack[incstackp].matches.gl_pathc) {
695 char* filepath = incstack[incstackp].matches.gl_pathv[incstack[incstackp].matchon];
696 incstack[incstackp].matchon++;
698 if (yycf_set_buffer(filepath) != 0) {
702 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
705 globfree(&incstack[incstackp].matches);
709 yy_switch_to_buffer(incstack[incstackp].prevstate);
715 {nl} { incstack[incstackp].lineno++; }
717 {semi} { return(EOS); }
723 yyerror(char *s, ...)
733 snprintf(fmt, sizeof(fmt), "%s:%d: \"%s\" %s\n",
734 incstack[incstackp].path, incstack[incstackp].lineno,
736 plogv(LLV_ERROR, LOCATION, NULL, fmt, ap);
753 snprintf(fmt, sizeof(fmt), "%s:%d: \"%s\" %s\n",
754 incstack[incstackp].path, incstack[incstackp].lineno,
756 plogv(LLV_WARNING, LOCATION, NULL, fmt, ap);
761 yycf_switch_buffer(path)
764 char *filepath = NULL;
766 /* got the include file name */
767 if (incstackp >= MAX_INCLUDE_DEPTH) {
768 plog(LLV_ERROR, LOCATION, NULL,
769 "Includes nested too deeply");
773 if (glob(path, GLOB_TILDE, NULL, &incstack[incstackp].matches) != 0 ||
774 incstack[incstackp].matches.gl_pathc == 0) {
775 plog(LLV_ERROR, LOCATION, NULL,
776 "glob found no matches for path");
779 incstack[incstackp].matchon = 0;
780 incstack[incstackp].prevstate = YY_CURRENT_BUFFER;
783 if (incstack[incstackp].matchon >= incstack[incstackp].matches.gl_pathc)
786 incstack[incstackp].matches.gl_pathv[incstack[incstackp].matchon];
787 incstack[incstackp].matchon++;
790 if (yycf_set_buffer(filepath) != 0) {
795 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
803 yycf_set_buffer(path)
806 yyin = fopen(path, "r");
808 fprintf(stderr, "failed to open file %s (%s)\n",
809 path, strerror(errno));
810 plog(LLV_ERROR, LOCATION, NULL,
811 "failed to open file %s (%s)\n",
812 path, strerror(errno));
817 incstack[incstackp].fp = yyin;
818 incstack[incstackp].path = strdup(path);
819 incstack[incstackp].lineno = 1;
820 plog(LLV_DEBUG, LOCATION, NULL,
821 "reading config file %s\n", path);
831 for (i = 0; i < MAX_INCLUDE_DEPTH; i++)
832 memset(&incstack[i], 0, sizeof(incstack[i]));
837 yycf_free_buffer(index)
840 fclose(incstack[index].fp);
841 racoon_free(incstack[index].path);
842 incstack[index].path = NULL;
850 for (i = 0; i < MAX_INCLUDE_DEPTH; i++)
851 if (incstack[i].path != NULL)