1 /* $Id: cfparse.y,v 1.37.2.7 2006/02/02 14:37:17 vanhu 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/queue.h>
38 #include <sys/socket.h>
40 #include <netinet/in.h>
41 #ifdef HAVE_NETINET6_IPSEC
42 # include <netinet6/ipsec.h>
44 # include <netinet/ipsec.h>
48 #include <arpa/inet.h>
70 #include "cfparse_proto.h"
71 #include "cftoken_proto.h"
72 #include "algorithm.h"
73 #include "localconf.h"
78 #include "remoteconf.h"
79 #include "grabmyaddr.h"
80 #include "isakmp_var.h"
84 #include "isakmp_xauth.h"
85 #include "isakmp_cfg.h"
87 #include "ipsec_doi.h"
97 static int num2dhgroup[] = {
99 OAKLEY_ATTR_GRP_DESC_MODP768,
100 OAKLEY_ATTR_GRP_DESC_MODP1024,
101 OAKLEY_ATTR_GRP_DESC_EC2N155,
102 OAKLEY_ATTR_GRP_DESC_EC2N185,
103 OAKLEY_ATTR_GRP_DESC_MODP1536,
112 OAKLEY_ATTR_GRP_DESC_MODP2048,
113 OAKLEY_ATTR_GRP_DESC_MODP3072,
114 OAKLEY_ATTR_GRP_DESC_MODP4096,
115 OAKLEY_ATTR_GRP_DESC_MODP6144,
116 OAKLEY_ATTR_GRP_DESC_MODP8192
119 static struct remoteconf *cur_rmconf;
120 static int tmpalgtype[MAXALGCLASS];
121 static struct sainfo *cur_sainfo;
122 static int cur_algclass;
124 static struct proposalspec *newprspec __P((void));
125 static void insprspec __P((struct proposalspec *, struct proposalspec **));
126 static struct secprotospec *newspspec __P((void));
127 static void insspspec __P((struct secprotospec *, struct proposalspec **));
128 static void adminsock_conf __P((vchar_t *, vchar_t *, vchar_t *, int));
130 static int set_isakmp_proposal
131 __P((struct remoteconf *, struct proposalspec *));
132 static void clean_tmpalgtype __P((void));
133 static int expand_isakmpspec __P((int, int, int *,
134 int, int, time_t, int, int, int, char *, struct remoteconf *));
135 static int listen_addr __P((struct sockaddr *addr, int udp_encap));
137 void freeetypes (struct etypes **etypes);
140 static int fix_lifebyte __P((u_long));
147 struct remoteconf *rmconf;
148 struct sockaddr *saddr;
149 struct sainfoalg *alg;
153 %token PRIVSEP USER GROUP CHROOT
158 /* self information */
159 %token IDENTIFIER VENDORID
161 %token LOGGING LOGLEV
163 %token PADDING PAD_RANDOMIZE PAD_RANDOMIZELEN PAD_MAXLEN PAD_STRICT PAD_EXCLTAIL
165 %token LISTEN X_ISAKMP X_ISAKMP_NATT X_ADMIN STRICT_ADDRESS ADMINSOCK DISABLED
167 %token MODECFG CFG_NET4 CFG_MASK4 CFG_DNS4 CFG_NBNS4
168 %token CFG_AUTH_SOURCE CFG_SYSTEM CFG_RADIUS CFG_PAM CFG_LOCAL CFG_NONE
169 %token CFG_ACCOUNTING CFG_CONF_SOURCE CFG_MOTD CFG_POOL_SIZE CFG_AUTH_THROTTLE
170 %token CFG_PFS_GROUP CFG_SAVE_PASSWD
172 %token RETRY RETRY_COUNTER RETRY_INTERVAL RETRY_PERSEND
173 %token RETRY_PHASE1 RETRY_PHASE2 NATT_KA AUTO_EXIT_DELAY
175 %token ALGORITHM_CLASS ALGORITHMTYPE STRENGTHTYPE
179 %token REMOTE ANONYMOUS INHERIT
180 %token EXCHANGE_MODE EXCHANGETYPE DOI DOITYPE SITUATION SITUATIONTYPE
181 %token CERTIFICATE_TYPE CERTTYPE PEERS_CERTFILE CA_TYPE
182 %token VERIFY_CERT SEND_CERT SEND_CR
183 %token IDENTIFIERTYPE MY_IDENTIFIER PEERS_IDENTIFIER VERIFY_IDENTIFIER
184 %token SHARED_SECRET SECRETTYPE
185 %token OPEN_DIR_AUTH_GROUP IN_KEYCHAIN
186 %token CERTIFICATE_VERIFICATION VERIFICATION_MODULE VERIFICATION_OPTION
187 %token DNSSEC CERT_X509 CERT_PLAINRSA
188 %token NONCE_SIZE DH_GROUP KEEPALIVE PASSIVE INITIAL_CONTACT
189 %token NAT_TRAVERSAL NAT_TRAVERSAL_LEVEL NAT_TRAVERSAL_MULTI_USER
190 %token PROPOSAL_CHECK PROPOSAL_CHECK_LEVEL
191 %token GENERATE_POLICY SUPPORT_PROXY
193 %token EXEC_PATH EXEC_COMMAND EXEC_SUCCESS EXEC_FAILURE
194 %token GSS_ID GSS_ID_ENC GSS_ID_ENCTYPE
195 %token COMPLEX_BUNDLE
196 %token DPD DPD_DELAY DPD_RETRY DPD_MAXFAIL
199 %token PREFIX PORT PORTANY UL_PROTO ANY IKE_FRAG ESP_FRAG MODE_CFG
200 %token PFS_GROUP LIFETIME LIFETYPE_TIME LIFETYPE_BYTE STRENGTH
202 %token SCRIPT PHASE1_UP PHASE1_DOWN
204 %token NUMBER SWITCH BOOLEAN
205 %token HEXSTRING QUOTEDSTRING ADDRSTRING
206 %token UNITTYPE_BYTE UNITTYPE_KBYTES UNITTYPE_MBYTES UNITTYPE_TBYTES
207 %token UNITTYPE_SEC UNITTYPE_MIN UNITTYPE_HOUR
208 %token EOS BOC EOC COMMA
210 %type <num> NUMBER BOOLEAN SWITCH keylength
211 %type <num> PATHTYPE IDENTIFIERTYPE LOGLEV GSS_ID_ENCTYPE
212 %type <num> SECRETTYPE
213 %type <num> ALGORITHM_CLASS dh_group_num
214 %type <num> ALGORITHMTYPE STRENGTHTYPE
215 %type <num> PREFIX prefix PORT port ike_port
216 %type <num> ul_proto UL_PROTO
217 %type <num> EXCHANGETYPE DOITYPE SITUATIONTYPE
218 %type <num> CERTTYPE CERT_X509 CERT_PLAINRSA PROPOSAL_CHECK_LEVEL NAT_TRAVERSAL_LEVEL
219 %type <num> VERIFICATION_MODULE VERIFICATION_OPTION
220 %type <num> unittype_time unittype_byte
221 %type <val> QUOTEDSTRING HEXSTRING ADDRSTRING sainfo_id
222 %type <val> identifierstring
223 %type <saddr> remote_index ike_addrinfo_port
224 %type <alg> algorithm
230 | statements statement
237 | identifier_statement
250 : PRIVSEP BOC privsep_stmts EOC
254 | privsep_stmts privsep_stmt
261 if ((pw = getpwnam($2->v)) == NULL) {
262 yyerror("unkown user \"%s\"", $2->v);
265 lcconf->uid = pw->pw_uid;
268 | USER NUMBER { lcconf->uid = $2; } EOS
273 if ((gr = getgrnam($2->v)) == NULL) {
274 yyerror("unkown group \"%s\"", $2->v);
277 lcconf->gid = gr->gr_gid;
280 | GROUP NUMBER { lcconf->gid = $2; } EOS
281 | CHROOT QUOTEDSTRING { lcconf->chroot = $2->v; } EOS
286 : PATH PATHTYPE QUOTEDSTRING
288 if ($2 >= LC_PATHTYPE_MAX) {
289 yyerror("invalid path type %d", $2);
293 /* free old pathinfo */
294 if (lcconf->pathinfo[$2])
295 racoon_free(lcconf->pathinfo[$2]);
297 /* set new pathinfo */
298 lcconf->pathinfo[$2] = strdup($3->v);
306 : COMPLEX_BUNDLE SWITCH { lcconf->complex_bundle = $2; } EOS
311 : INCLUDE QUOTEDSTRING EOS
313 char path[MAXPATHLEN];
315 getpathname(path, sizeof(path),
316 LC_PATHTYPE_INCLUDE, $2->v);
318 if (yycf_switch_buffer(path) != 0)
325 : GSS_ID_ENC GSS_ID_ENCTYPE EOS
327 if ($2 >= LC_GSSENC_MAX) {
328 yyerror("invalid GSS ID encoding %d", $2);
331 lcconf->gss_id_enc = $2;
335 /* self infomation */
337 : IDENTIFIER identifier_stmt
342 /*XXX to be deleted */
345 | IDENTIFIERTYPE QUOTEDSTRING
347 /*XXX to be deleted */
348 $2->l--; /* nuke '\0' */
349 lcconf->ident[$1] = $2;
350 if (lcconf->ident[$1] == NULL) {
351 yyerror("failed to set my ident: %s",
361 : LOGGING log_level EOS
367 * XXX ignore it because this specification
370 yywarn("see racoon.conf(5), such a log specification will be obsoleted.");
376 * set the loglevel by configuration file only when
377 * the command line did not specify any loglevel.
379 if (loglevel <= LLV_BASE)
386 : PADDING BOC padding_stmts EOC
390 | padding_stmts padding_stmt
393 : PAD_RANDOMIZE SWITCH { lcconf->pad_random = $2; } EOS
394 | PAD_RANDOMIZELEN SWITCH { lcconf->pad_randomlen = $2; } EOS
395 | PAD_MAXLEN NUMBER { lcconf->pad_maxsize = $2; } EOS
396 | PAD_STRICT SWITCH { lcconf->pad_strict = $2; } EOS
397 | PAD_EXCLTAIL SWITCH { lcconf->pad_excltail = $2; } EOS
402 : LISTEN BOC listen_stmts EOC
406 | listen_stmts listen_stmt
409 : X_ISAKMP ike_addrinfo_port
414 | X_ISAKMP_NATT ike_addrinfo_port
419 yyerror("NAT-T support not compiled in.");
425 yyerror("admin directive is obsoleted.");
428 | ADMINSOCK QUOTEDSTRING QUOTEDSTRING QUOTEDSTRING NUMBER
430 #ifdef ENABLE_ADMINPORT
431 adminsock_conf($2, $3, $4, $5);
433 yywarn("admin port support not compiled in");
437 | ADMINSOCK QUOTEDSTRING
439 #ifdef ENABLE_ADMINPORT
440 adminsock_conf($2, NULL, NULL, -1);
442 yywarn("admin port support not compiled in");
448 #ifdef ENABLE_ADMINPORT
449 adminsock_path = NULL;
451 yywarn("admin port support not compiled in");
455 | STRICT_ADDRESS { lcconf->strict_address = TRUE; } EOS
458 : ADDRSTRING ike_port
462 snprintf(portbuf, sizeof(portbuf), "%ld", $2);
463 $$ = str2saddr($1->v, portbuf);
470 : /* nothing */ { $$ = PORT_ISAKMP; }
475 : MODECFG BOC modecfg_stmts EOC
479 | modecfg_stmts modecfg_stmt
482 : CFG_NET4 ADDRSTRING
485 if (inet_pton(AF_INET, $2->v,
486 &isakmp_cfg_config.network4) != 1)
487 yyerror("bad IPv4 network address.");
489 yyerror("racoon not configured with --enable-hybrid");
493 | CFG_MASK4 ADDRSTRING
496 if (inet_pton(AF_INET, $2->v,
497 &isakmp_cfg_config.netmask4) != 1)
498 yyerror("bad IPv4 netmask address.");
500 yyerror("racoon not configured with --enable-hybrid");
504 | CFG_DNS4 ADDRSTRING
507 if (inet_pton(AF_INET, $2->v,
508 &isakmp_cfg_config.dns4) != 1)
509 yyerror("bad IPv4 DNS address.");
511 yyerror("racoon not configured with --enable-hybrid");
515 | CFG_NBNS4 ADDRSTRING
518 if (inet_pton(AF_INET, $2->v,
519 &isakmp_cfg_config.nbns4) != 1)
520 yyerror("bad IPv4 WINS address.");
522 yyerror("racoon not configured with --enable-hybrid");
526 | CFG_AUTH_SOURCE CFG_SYSTEM
529 isakmp_cfg_config.authsource = ISAKMP_CFG_AUTH_SYSTEM;
531 yyerror("racoon not configured with --enable-hybrid");
535 | CFG_AUTH_SOURCE CFG_RADIUS
538 #ifdef HAVE_LIBRADIUS
539 isakmp_cfg_config.authsource = ISAKMP_CFG_AUTH_RADIUS;
540 #else /* HAVE_LIBRADIUS */
541 yyerror("racoon not configured with --with-libradius");
542 #endif /* HAVE_LIBRADIUS */
543 #else /* ENABLE_HYBRID */
544 yyerror("racoon not configured with --enable-hybrid");
545 #endif /* ENABLE_HYBRID */
548 | CFG_AUTH_SOURCE CFG_PAM
552 isakmp_cfg_config.authsource = ISAKMP_CFG_AUTH_PAM;
553 #else /* HAVE_LIBPAM */
554 yyerror("racoon not configured with --with-libpam");
555 #endif /* HAVE_LIBPAM */
556 #else /* ENABLE_HYBRID */
557 yyerror("racoon not configured with --enable-hybrid");
558 #endif /* ENABLE_HYBRID */
561 | CFG_ACCOUNTING CFG_NONE
564 isakmp_cfg_config.accounting = ISAKMP_CFG_ACCT_NONE;
566 yyerror("racoon not configured with --enable-hybrid");
570 | CFG_ACCOUNTING CFG_RADIUS
573 #ifdef HAVE_LIBRADIUS
574 isakmp_cfg_config.accounting = ISAKMP_CFG_ACCT_RADIUS;
575 #else /* HAVE_LIBRADIUS */
576 yyerror("racoon not configured with --with-libradius");
577 #endif /* HAVE_LIBRADIUS */
578 #else /* ENABLE_HYBRID */
579 yyerror("racoon not configured with --enable-hybrid");
580 #endif /* ENABLE_HYBRID */
583 | CFG_ACCOUNTING CFG_PAM
587 isakmp_cfg_config.accounting = ISAKMP_CFG_ACCT_PAM;
588 #else /* HAVE_LIBPAM */
589 yyerror("racoon not configured with --with-libpam");
590 #endif /* HAVE_LIBPAM */
591 #else /* ENABLE_HYBRID */
592 yyerror("racoon not configured with --enable-hybrid");
593 #endif /* ENABLE_HYBRID */
596 | CFG_POOL_SIZE NUMBER
601 isakmp_cfg_config.pool_size = $2;
603 len = $2 * sizeof(*isakmp_cfg_config.port_pool);
604 isakmp_cfg_config.port_pool = racoon_malloc(len);
605 if (isakmp_cfg_config.port_pool == NULL)
606 yyerror("cannot allocate memory for pool");
607 bzero(isakmp_cfg_config.port_pool, len);
608 #else /* ENABLE_HYBRID */
609 yyerror("racoon not configured with --enable-hybrid");
610 #endif /* ENABLE_HYBRID */
613 | CFG_PFS_GROUP NUMBER
616 isakmp_cfg_config.pfs_group = $2;
617 #else /* ENABLE_HYBRID */
618 yyerror("racoon not configured with --enable-hybrid");
619 #endif /* ENABLE_HYBRID */
622 | CFG_SAVE_PASSWD SWITCH
625 isakmp_cfg_config.save_passwd = $2;
626 #else /* ENABLE_HYBRID */
627 yyerror("racoon not configured with --enable-hybrid");
628 #endif /* ENABLE_HYBRID */
631 | CFG_AUTH_THROTTLE NUMBER
634 isakmp_cfg_config.auth_throttle = $2;
635 #else /* ENABLE_HYBRID */
636 yyerror("racoon not configured with --enable-hybrid");
637 #endif /* ENABLE_HYBRID */
640 | CFG_CONF_SOURCE CFG_LOCAL
643 isakmp_cfg_config.confsource = ISAKMP_CFG_CONF_LOCAL;
644 #else /* ENABLE_HYBRID */
645 yyerror("racoon not configured with --enable-hybrid");
646 #endif /* ENABLE_HYBRID */
649 | CFG_CONF_SOURCE CFG_RADIUS
652 #ifdef HAVE_LIBRADIUS
653 isakmp_cfg_config.confsource = ISAKMP_CFG_CONF_RADIUS;
654 #else /* HAVE_LIBRADIUS */
655 yyerror("racoon not configured with --with-libradius");
656 #endif /* HAVE_LIBRADIUS */
657 #else /* ENABLE_HYBRID */
658 yyerror("racoon not configured with --enable-hybrid");
659 #endif /* ENABLE_HYBRID */
662 | CFG_MOTD QUOTEDSTRING
665 strncpy(&isakmp_cfg_config.motd[0], $2->v, MAXPATHLEN);
666 isakmp_cfg_config.motd[MAXPATHLEN] = '\0';
669 yyerror("racoon not configured with --enable-hybrid");
677 : RETRY BOC timer_stmts EOC
681 | timer_stmts timer_stmt
684 : RETRY_COUNTER NUMBER
686 lcconf->retry_counter = $2;
689 | RETRY_INTERVAL NUMBER unittype_time
691 lcconf->retry_interval = $2 * $3;
694 | RETRY_PERSEND NUMBER
696 lcconf->count_persend = $2;
699 | RETRY_PHASE1 NUMBER unittype_time
701 lcconf->retry_checkph1 = $2 * $3;
704 | RETRY_PHASE2 NUMBER unittype_time
706 lcconf->wait_ph2complete = $2 * $3;
709 | AUTO_EXIT_DELAY NUMBER unittype_time
711 lcconf->auto_exit_delay = $2 * $3;
712 lcconf->auto_exit_state |= LC_AUTOEXITSTATE_SET;
716 | NATT_KA NUMBER unittype_time
719 lcconf->natt_ka_interval = $2 * $3;
721 yyerror("NAT-T support not compiled in.");
731 cur_sainfo = newsainfo();
732 if (cur_sainfo == NULL) {
733 yyerror("failed to allocate sainfo");
737 sainfo_name sainfo_peer BOC sainfo_specs
739 struct sainfo *check;
742 if (cur_sainfo->algs[algclass_ipsec_enc] == 0) {
743 yyerror("no encryption algorithm at %s",
744 sainfo2str(cur_sainfo));
747 if (cur_sainfo->algs[algclass_ipsec_auth] == 0) {
748 yyerror("no authentication algorithm at %s",
749 sainfo2str(cur_sainfo));
752 if (cur_sainfo->algs[algclass_ipsec_comp] == 0) {
753 yyerror("no compression algorithm at %s",
754 sainfo2str(cur_sainfo));
758 /* duplicate check */
759 check = getsainfo(cur_sainfo->idsrc,
762 if (check && (!check->idsrc && !cur_sainfo->idsrc)) {
763 yyerror("duplicated sainfo: %s",
764 sainfo2str(cur_sainfo));
767 inssainfo(cur_sainfo);
774 cur_sainfo->idsrc = NULL;
775 cur_sainfo->iddst = NULL;
777 | sainfo_id sainfo_id
779 cur_sainfo->idsrc = $1;
780 cur_sainfo->iddst = $2;
784 : IDENTIFIERTYPE ADDRSTRING prefix port ul_proto
787 struct sockaddr *saddr;
789 if (($5 == IPPROTO_ICMP || $5 == IPPROTO_ICMPV6)
790 && ($4 != IPSEC_PORT_ANY || $4 != IPSEC_PORT_ANY)) {
791 yyerror("port number must be \"any\".");
795 snprintf(portbuf, sizeof(portbuf), "%lu", $4);
796 saddr = str2saddr($2->v, portbuf);
801 switch (saddr->sa_family) {
803 if ($5 == IPPROTO_ICMPV6) {
804 yyerror("upper layer protocol mismatched.\n");
808 $$ = ipsecdoi_sockaddr2id(saddr,
810 $3 == (sizeof(struct in_addr) << 3) &&
814 $3 == ~0 ? (sizeof(struct in_addr) << 3): $3,
820 if ($5 == IPPROTO_ICMP) {
821 yyerror("upper layer protocol mismatched.\n");
825 $$ = ipsecdoi_sockaddr2id(saddr,
827 $3 == (sizeof(struct in6_addr) << 3) &&
831 $3 == ~0 ? (sizeof(struct in6_addr) << 3): $3,
837 yyerror("invalid family: %d", saddr->sa_family);
845 | IDENTIFIERTYPE QUOTEDSTRING
847 struct ipsecdoi_id_b *id_b;
849 if ($1 == IDTYPE_ASN1DN) {
850 yyerror("id type forbidden: %d", $1);
857 $$ = vmalloc(sizeof(*id_b) + $2->l);
859 yyerror("failed to allocate identifier");
863 id_b = (struct ipsecdoi_id_b *)$$->v;
864 id_b->type = idtype2doi($1);
869 memcpy($$->v + sizeof(*id_b), $2->v, $2->l);
875 cur_sainfo->id_i = NULL;
878 | FROM IDENTIFIERTYPE identifierstring
880 struct ipsecdoi_id_b *id_b;
883 if (set_identifier(&idv, $2, $3) != 0) {
884 yyerror("failed to set identifer.\n");
887 cur_sainfo->id_i = vmalloc(sizeof(*id_b) + idv->l);
888 if (cur_sainfo->id_i == NULL) {
889 yyerror("failed to allocate identifier");
893 id_b = (struct ipsecdoi_id_b *)cur_sainfo->id_i->v;
894 id_b->type = idtype2doi($2);
899 memcpy(cur_sainfo->id_i->v + sizeof(*id_b),
906 | sainfo_specs sainfo_spec
909 : PFS_GROUP dh_group_num
911 cur_sainfo->pfs_group = $2;
914 | LIFETIME LIFETYPE_TIME NUMBER unittype_time
916 cur_sainfo->lifetime = $3 * $4;
919 | LIFETIME LIFETYPE_BYTE NUMBER unittype_byte
922 yyerror("byte lifetime support is deprecated");
925 cur_sainfo->lifebyte = fix_lifebyte($3 * $4);
926 if (cur_sainfo->lifebyte == 0)
935 | IDENTIFIER IDENTIFIERTYPE
937 yyerror("it's deprecated to specify a identifier in phase 2");
940 | MY_IDENTIFIER IDENTIFIERTYPE QUOTEDSTRING
942 yyerror("it's deprecated to specify a identifier in phase 2");
950 inssainfoalg(&cur_sainfo->algs[cur_algclass], $1);
954 inssainfoalg(&cur_sainfo->algs[cur_algclass], $1);
959 : ALGORITHMTYPE keylength
965 yyerror("failed to get algorithm allocation");
969 $$->alg = algtype2doi(cur_algclass, $1);
971 yyerror("algorithm mismatched");
977 defklen = default_keylen(cur_algclass, $1);
980 yyerror("keylen not allowed");
986 if ($2 && check_keylen(cur_algclass, $1, $2) < 0) {
987 yyerror("invalid keylen %d", $2);
997 $$->encklen = defklen;
999 /* check if it's supported algorithm by kernel */
1000 if (!(cur_algclass == algclass_ipsec_auth && $1 == algtype_non_auth)
1001 && pk_checkalg(cur_algclass, $1, $$->encklen)) {
1002 int a = algclass2doi(cur_algclass);
1003 int b = algtype2doi(cur_algclass, $1);
1004 if (a == IPSECDOI_ATTR_AUTH)
1005 a = IPSECDOI_PROTO_IPSEC_AH;
1006 yyerror("algorithm %s not supported by the kernel (missing module?)",
1007 s_ipsecdoi_trns(a, b));
1015 : /* nothing */ { $$ = ~0; }
1016 | PREFIX { $$ = $1; }
1019 : /* nothing */ { $$ = IPSEC_PORT_ANY; }
1021 | PORTANY { $$ = IPSEC_PORT_ANY; }
1024 : NUMBER { $$ = $1; }
1025 | UL_PROTO { $$ = $1; }
1026 | ANY { $$ = IPSEC_ULPROTO_ANY; }
1029 : /* nothing */ { $$ = 0; }
1030 | NUMBER { $$ = $1; }
1035 : REMOTE remote_index INHERIT remote_index
1037 struct remoteconf *new;
1038 struct proposalspec *prspec;
1040 new = copyrmconf($4);
1042 yyerror("failed to get remoteconf for %s.", saddr2str ($4));
1047 new->inherited_from = getrmconf_strict($4, 1);
1048 new->proposal = NULL;
1052 prspec = newprspec();
1053 if (prspec == NULL || !cur_rmconf->inherited_from
1054 || !cur_rmconf->inherited_from->proposal)
1056 prspec->lifetime = cur_rmconf->inherited_from->proposal->lifetime;
1057 prspec->lifebyte = cur_rmconf->inherited_from->proposal->lifebyte;
1058 insprspec(prspec, &cur_rmconf->prhead);
1061 | REMOTE remote_index
1063 struct remoteconf *new;
1064 struct proposalspec *prspec;
1068 yyerror("failed to get new remoteconf.");
1075 prspec = newprspec();
1078 prspec->lifetime = oakley_get_defaultlifetime();
1079 insprspec(prspec, &cur_rmconf->prhead);
1085 : BOC remote_specs EOC
1087 /* check a exchange mode */
1088 if (cur_rmconf->etypes == NULL) {
1089 yyerror("no exchange mode specified.\n");
1093 if (cur_rmconf->idvtype == IDTYPE_UNDEFINED)
1094 cur_rmconf->idvtype = IDTYPE_ADDRESS;
1097 if (cur_rmconf->idvtype == IDTYPE_ASN1DN) {
1098 if (cur_rmconf->mycertfile
1100 || cur_rmconf->identity_in_keychain)
1103 if (cur_rmconf->idv)
1104 yywarn("Both CERT and ASN1 ID "
1105 "are set. Hope this is OK.\n");
1106 /* TODO: Preparse the DN here */
1107 } else if (cur_rmconf->idv) {
1108 /* OK, using asn1dn without X.509. */
1110 yyerror("ASN1 ID not specified "
1111 "and no CERT defined!\n");
1117 if (cur_rmconf->cert_verification_option == VERIFICATION_OPTION_PEERS_IDENTIFIER) {
1118 struct genlist_entry *gpb;
1119 if (genlist_next(cur_rmconf->idvl_p, &gpb) == NULL) {
1120 yyerror("peers_identifier required for specified certificate "
1121 "verification option.\n");
1127 if (cur_rmconf->prhead->spspec == NULL
1128 && cur_rmconf->inherited_from
1129 && cur_rmconf->inherited_from->prhead) {
1130 cur_rmconf->prhead->spspec = cur_rmconf->inherited_from->prhead->spspec;
1132 if (set_isakmp_proposal(cur_rmconf, cur_rmconf->prhead) != 0)
1135 /* DH group settting if aggressive mode is there. */
1136 if (check_etypeok(cur_rmconf, ISAKMP_ETYPE_AGG) != NULL) {
1141 for (p = cur_rmconf->proposal; p; p = p->next) {
1142 if (b == 0 || (b && b == p->dh_group)) {
1146 yyerror("DH group must be equal "
1148 "when aggressive mode is "
1152 cur_rmconf->dh_group = b;
1154 if (cur_rmconf->dh_group == 0) {
1155 yyerror("DH group must be set in the proposal.\n");
1159 /* DH group settting if PFS is required. */
1160 if (oakley_setdhgroup(cur_rmconf->dh_group,
1161 &cur_rmconf->dhgrp) < 0) {
1162 yyerror("failed to set DH value.\n");
1167 insrmconf(cur_rmconf);
1171 : ANONYMOUS ike_port
1173 $$ = newsaddr(sizeof(struct sockaddr));
1174 $$->sa_family = AF_UNSPEC;
1175 ((struct sockaddr_in *)$$)->sin_port = htons($2);
1181 yyerror("failed to allocate sockaddr");
1188 | remote_specs remote_spec
1193 cur_rmconf->etypes = NULL;
1196 | DOI DOITYPE { cur_rmconf->doitype = $2; } EOS
1197 | SITUATION SITUATIONTYPE { cur_rmconf->sittype = $2; } EOS
1198 | CERTIFICATE_TYPE cert_spec
1199 | PEERS_CERTFILE QUOTEDSTRING
1201 yywarn("This directive without certtype will be removed!\n");
1202 yywarn("Please use 'peers_certfile x509 \"%s\";' instead\n", $2->v);
1203 cur_rmconf->getcert_method = ISAKMP_GETCERT_LOCALFILE;
1204 cur_rmconf->peerscertfile = strdup($2->v);
1208 | CA_TYPE CERT_X509 QUOTEDSTRING
1210 cur_rmconf->cacerttype = $2;
1211 cur_rmconf->getcacert_method = ISAKMP_GETCERT_LOCALFILE;
1212 cur_rmconf->cacertfile = strdup($3->v);
1216 | PEERS_CERTFILE CERT_X509 QUOTEDSTRING
1218 cur_rmconf->getcert_method = ISAKMP_GETCERT_LOCALFILE;
1219 cur_rmconf->peerscertfile = strdup($3->v);
1223 | PEERS_CERTFILE CERT_PLAINRSA QUOTEDSTRING
1225 char path[MAXPATHLEN];
1228 getpathname(path, sizeof(path),
1229 LC_PATHTYPE_CERT, $3->v);
1232 if (cur_rmconf->getcert_method == ISAKMP_GETCERT_DNS) {
1233 yyerror("Different peers_certfile method "
1234 "already defined: %d!\n",
1235 cur_rmconf->getcert_method);
1238 cur_rmconf->getcert_method = ISAKMP_GETCERT_LOCALFILE;
1239 if (rsa_parse_file(cur_rmconf->rsa_public, path, RSA_TYPE_PUBLIC)) {
1240 yyerror("Couldn't parse keyfile.\n", path);
1243 plog(LLV_DEBUG, LOCATION, NULL, "Public PlainRSA keyfile parsed: %s\n", path);
1246 | PEERS_CERTFILE DNSSEC
1248 if (cur_rmconf->getcert_method) {
1249 yyerror("Different peers_certfile method already defined!\n");
1252 cur_rmconf->getcert_method = ISAKMP_GETCERT_DNS;
1253 cur_rmconf->peerscertfile = NULL;
1256 | VERIFY_CERT SWITCH { cur_rmconf->verify_cert = $2; } EOS
1257 | SEND_CERT SWITCH { cur_rmconf->send_cert = $2; } EOS
1258 | SEND_CR SWITCH { cur_rmconf->send_cr = $2; } EOS
1259 | CERTIFICATE_VERIFICATION VERIFICATION_MODULE
1262 cur_rmconf->cert_verification = $2;
1264 yyerror("Apple specific features not compiled in.");
1268 | CERTIFICATE_VERIFICATION VERIFICATION_MODULE VERIFICATION_OPTION
1271 cur_rmconf->cert_verification = $2;
1272 cur_rmconf->cert_verification_option = $3;
1274 yyerror("Apple specific features not compiled in.");
1279 | OPEN_DIR_AUTH_GROUP QUOTEDSTRING
1282 cur_rmconf->open_dir_auth_group = $2;
1284 yyerror("Apple specific features not compiled in.");
1288 | MY_IDENTIFIER IDENTIFIERTYPE identifierstring
1290 if (set_identifier(&cur_rmconf->idv, $2, $3) != 0) {
1291 yyerror("failed to set identifer.\n");
1292 vfree($3); //%%% BUG FIX - memory leak
1295 vfree($3); //%%% BUG FIX - memory leak
1296 cur_rmconf->idvtype = $2;
1299 | XAUTH_LOGIN identifierstring
1301 #ifdef ENABLE_HYBRID
1302 /* formerly identifier type login */
1303 cur_rmconf->idvtype = IDTYPE_LOGIN;
1304 if (set_identifier(&cur_rmconf->idv, IDTYPE_LOGIN, $2) != 0) {
1305 yyerror("failed to set identifer.\n");
1308 /* cur_rmconf->use_xauth = 1; */
1310 yyerror("racoon not configured with --enable-hybrid");
1314 | PEERS_IDENTIFIER IDENTIFIERTYPE identifierstring
1319 yyerror("failed to allocate idspec");
1322 if (set_identifier(&id->id, $2, $3) != 0) {
1323 yyerror("failed to set identifer.\n");
1325 vfree($3); //%%% BUG FIX - memory leak
1328 vfree($3); //%%% BUG FIX - memory leak
1330 genlist_append (cur_rmconf->idvl_p, id);
1333 | VERIFY_IDENTIFIER SWITCH { cur_rmconf->verify_identifier = $2; } EOS
1334 | SHARED_SECRET SECRETTYPE QUOTEDSTRING
1337 cur_rmconf->secrettype = $2;
1338 cur_rmconf->shared_secret = $3;
1340 yyerror("Apple specific features not compiled in.");
1344 | SHARED_SECRET SECRETTYPE
1347 if ($2 != SECRETTYPE_KEYCHAIN_BY_ID) {
1348 yyerror("shared secret value missing.\n");
1351 cur_rmconf->secrettype = $2;
1353 yyerror("Apple specific features not compiled in.");
1358 | NONCE_SIZE NUMBER { cur_rmconf->nonce_size = $2; } EOS
1361 yyerror("dh_group cannot be defined here.");
1365 | PASSIVE SWITCH { cur_rmconf->passive = $2; } EOS
1366 | IKE_FRAG SWITCH { cur_rmconf->ike_frag = $2; } EOS
1368 #ifdef SADB_X_EXT_NAT_T_FRAG
1369 cur_rmconf->esp_frag = $2;
1371 yywarn("Your kernel does not support esp_frag");
1374 | SCRIPT QUOTEDSTRING PHASE1_UP {
1375 cur_rmconf->script[SCRIPT_PHASE1_UP] =
1376 script_path_add(vdup($2));
1378 | SCRIPT QUOTEDSTRING PHASE1_DOWN {
1379 cur_rmconf->script[SCRIPT_PHASE1_DOWN] =
1380 script_path_add(vdup($2));
1382 | MODE_CFG SWITCH { cur_rmconf->mode_cfg = $2; } EOS
1383 | GENERATE_POLICY SWITCH { cur_rmconf->gen_policy = $2; } EOS
1384 | SUPPORT_PROXY SWITCH { cur_rmconf->support_proxy = $2; } EOS
1385 | INITIAL_CONTACT SWITCH { cur_rmconf->ini_contact = $2; } EOS
1386 | NAT_TRAVERSAL SWITCH
1389 cur_rmconf->nat_traversal = $2;
1391 yyerror("NAT-T support not compiled in.");
1394 | NAT_TRAVERSAL NAT_TRAVERSAL_LEVEL
1397 cur_rmconf->nat_traversal = $2;
1399 yyerror("NAT-T support not compiled in.");
1402 | NAT_TRAVERSAL_MULTI_USER SWITCH
1406 cur_rmconf->natt_multiple_user = $2;
1408 yyerror("Apple specific features not compiled in.");
1411 yyerror("NAT-T support not compiled in.");
1417 cur_rmconf->dpd = $2;
1419 yyerror("DPD support not compiled in.");
1425 cur_rmconf->dpd_interval = $2;
1427 yyerror("DPD support not compiled in.");
1434 cur_rmconf->dpd_retry = $2;
1436 yyerror("DPD support not compiled in.");
1440 | DPD_MAXFAIL NUMBER
1443 cur_rmconf->dpd_maxfails = $2;
1445 yyerror("DPD support not compiled in.");
1449 | LIFETIME LIFETYPE_TIME NUMBER unittype_time
1451 cur_rmconf->prhead->lifetime = $3 * $4;
1454 | PROPOSAL_CHECK PROPOSAL_CHECK_LEVEL { cur_rmconf->pcheck_level = $2; } EOS
1455 | LIFETIME LIFETYPE_BYTE NUMBER unittype_byte
1458 yyerror("byte lifetime support is deprecated in Phase1");
1461 yywarn("the lifetime of bytes in phase 1 "
1462 "will be ignored at the moment.");
1463 cur_rmconf->prhead->lifebyte = fix_lifebyte($3 * $4);
1464 if (cur_rmconf->prhead->lifebyte == 0)
1471 struct secprotospec *spspec;
1473 spspec = newspspec();
1476 insspspec(spspec, &cur_rmconf->prhead);
1478 BOC isakmpproposal_specs EOC
1482 | exchange_types EXCHANGETYPE
1485 new = racoon_malloc(sizeof(struct etypes));
1487 yyerror("filed to allocate etypes");
1492 if (cur_rmconf->etypes == NULL)
1493 cur_rmconf->etypes = new;
1496 for (p = cur_rmconf->etypes;
1505 : CERT_X509 QUOTEDSTRING QUOTEDSTRING
1507 cur_rmconf->certtype = $1;
1508 cur_rmconf->mycertfile = strdup($2->v);
1510 cur_rmconf->myprivfile = strdup($3->v);
1514 | CERT_X509 IN_KEYCHAIN
1517 cur_rmconf->certtype = $1;
1518 cur_rmconf->identity_in_keychain = 1;
1519 cur_rmconf->keychainCertRef = NULL;
1524 | CERT_X509 IN_KEYCHAIN QUOTEDSTRING
1528 cur_rmconf->certtype = $1;
1529 cur_rmconf->identity_in_keychain = 1;
1530 cur_rmconf->keychainCertRef = $3;
1535 | CERT_PLAINRSA QUOTEDSTRING
1537 char path[MAXPATHLEN];
1540 getpathname(path, sizeof(path),
1541 LC_PATHTYPE_CERT, $2->v);
1544 cur_rmconf->certtype = $1;
1545 cur_rmconf->send_cr = FALSE;
1546 cur_rmconf->send_cert = FALSE;
1547 cur_rmconf->verify_cert = FALSE;
1548 if (rsa_parse_file(cur_rmconf->rsa_private, path, RSA_TYPE_PRIVATE)) {
1549 yyerror("Couldn't parse keyfile.\n", path);
1552 plog(LLV_DEBUG, LOCATION, NULL, "Private PlainRSA keyfile parsed: %s\n", path);
1559 $$ = algtype2doi(algclass_isakmp_dh, $1);
1561 yyerror("must be DH group");
1567 if (ARRAYLEN(num2dhgroup) > $1 && num2dhgroup[$1] != 0) {
1568 $$ = num2dhgroup[$1];
1570 yyerror("must be DH group");
1577 : /* nothing */ { $$ = NULL; }
1578 | ADDRSTRING { $$ = $1; }
1579 | QUOTEDSTRING { $$ = $1; }
1581 isakmpproposal_specs
1583 | isakmpproposal_specs isakmpproposal_spec
1588 yyerror("strength directive is obsoleted.");
1590 | LIFETIME LIFETYPE_TIME NUMBER unittype_time
1592 cur_rmconf->prhead->spspec->lifetime = $3 * $4;
1595 | LIFETIME LIFETYPE_BYTE NUMBER unittype_byte
1598 yyerror("byte lifetime support is deprecated");
1601 cur_rmconf->prhead->spspec->lifebyte = fix_lifebyte($3 * $4);
1602 if (cur_rmconf->prhead->spspec->lifebyte == 0)
1607 | DH_GROUP dh_group_num
1609 cur_rmconf->prhead->spspec->algclass[algclass_isakmp_dh] = $2;
1612 | GSS_ID QUOTEDSTRING
1614 if (cur_rmconf->prhead->spspec->vendorid != VENDORID_GSSAPI) {
1615 yyerror("wrong Vendor ID for gssapi_id");
1618 cur_rmconf->prhead->spspec->gssid = strdup($2->v);
1621 | ALGORITHM_CLASS ALGORITHMTYPE keylength
1626 doi = algtype2doi($1, $2);
1628 yyerror("algorithm mismatched 1");
1633 case algclass_isakmp_enc:
1634 /* reject suppressed algorithms */
1635 #ifndef HAVE_OPENSSL_RC5_H
1636 if ($2 == algtype_rc5) {
1637 yyerror("algorithm %s not supported",
1638 s_attr_isakmp_enc(doi));
1642 #ifndef HAVE_OPENSSL_IDEA_H
1643 if ($2 == algtype_idea) {
1644 yyerror("algorithm %s not supported",
1645 s_attr_isakmp_enc(doi));
1650 cur_rmconf->prhead->spspec->algclass[algclass_isakmp_enc] = doi;
1651 defklen = default_keylen($1, $2);
1654 yyerror("keylen not allowed");
1658 if ($3 && check_keylen($1, $2, $3) < 0) {
1659 yyerror("invalid keylen %d", $3);
1664 cur_rmconf->prhead->spspec->encklen = $3;
1666 cur_rmconf->prhead->spspec->encklen = defklen;
1668 case algclass_isakmp_hash:
1669 cur_rmconf->prhead->spspec->algclass[algclass_isakmp_hash] = doi;
1671 case algclass_isakmp_ameth:
1672 cur_rmconf->prhead->spspec->algclass[algclass_isakmp_ameth] = doi;
1674 * We may have to set the Vendor ID for the
1675 * authentication method we're using.
1678 case algtype_gssapikrb:
1679 if (cur_rmconf->prhead->spspec->vendorid !=
1681 yyerror("Vendor ID mismatch "
1686 * For interoperability with Win2k,
1687 * we set the Vendor ID to "GSSAPI".
1689 cur_rmconf->prhead->spspec->vendorid =
1692 case algtype_rsasig:
1693 if (cur_rmconf->certtype == ISAKMP_CERT_PLAINRSA) {
1694 if (rsa_list_count(cur_rmconf->rsa_private) == 0) {
1695 yyerror ("Private PlainRSA key not set. "
1696 "Use directive 'certificate_type plainrsa ...'\n");
1699 if (rsa_list_count(cur_rmconf->rsa_public) == 0) {
1700 yyerror ("Public PlainRSA keys not set. "
1701 "Use directive 'peers_certfile plainrsa ...'\n");
1711 yyerror("algorithm mismatched 2");
1719 : UNITTYPE_SEC { $$ = 1; }
1720 | UNITTYPE_MIN { $$ = 60; }
1721 | UNITTYPE_HOUR { $$ = (60 * 60); }
1724 : UNITTYPE_BYTE { $$ = 1; }
1725 | UNITTYPE_KBYTES { $$ = 1024; }
1726 | UNITTYPE_MBYTES { $$ = (1024 * 1024); }
1727 | UNITTYPE_TBYTES { $$ = (1024 * 1024 * 1024); }
1731 static struct proposalspec *
1734 struct proposalspec *new;
1736 new = racoon_calloc(1, sizeof(*new));
1738 yyerror("failed to allocate proposal");
1744 * insert into head of list.
1747 insprspec(prspec, head)
1748 struct proposalspec *prspec;
1749 struct proposalspec **head;
1752 (*head)->prev = prspec;
1753 prspec->next = *head;
1757 static struct secprotospec *
1760 struct secprotospec *new;
1762 new = racoon_calloc(1, sizeof(*new));
1764 yyerror("failed to allocate spproto");
1768 new->encklen = 0; /*XXX*/
1771 * Default to "uknown" vendor -- we will override this
1772 * as necessary. When we send a Vendor ID payload, an
1773 * "unknown" will be translated to a KAME/racoon ID.
1775 new->vendorid = VENDORID_UNKNOWN;
1781 * insert into head of list.
1784 insspspec(spspec, head)
1785 struct secprotospec *spspec;
1786 struct proposalspec **head;
1788 spspec->back = *head;
1790 if ((*head)->spspec != NULL)
1791 (*head)->spspec->prev = spspec;
1792 spspec->next = (*head)->spspec;
1793 (*head)->spspec = spspec;
1796 /* set final acceptable proposal */
1798 set_isakmp_proposal(rmconf, prspec)
1799 struct remoteconf *rmconf;
1800 struct proposalspec *prspec;
1802 struct proposalspec *p;
1803 struct secprotospec *s;
1806 int32_t types[MAXALGCLASS];
1810 plog(LLV_ERROR, LOCATION, NULL,
1811 "multiple proposal definition.\n");
1815 /* mandatory check */
1816 if (p->spspec == NULL) {
1817 yyerror("no remote specification found: %s.\n",
1818 saddr2str(rmconf->remote));
1821 for (s = p->spspec; s != NULL; s = s->next) {
1822 /* XXX need more to check */
1823 if (s->algclass[algclass_isakmp_enc] == 0) {
1824 yyerror("encryption algorithm required.");
1827 if (s->algclass[algclass_isakmp_hash] == 0) {
1828 yyerror("hash algorithm required.");
1831 if (s->algclass[algclass_isakmp_dh] == 0) {
1832 yyerror("DH group required.");
1835 if (s->algclass[algclass_isakmp_ameth] == 0) {
1836 yyerror("authentication method required.");
1841 /* skip to last part */
1842 for (s = p->spspec; s->next != NULL; s = s->next)
1846 plog(LLV_DEBUG2, LOCATION, NULL,
1847 "lifetime = %ld\n", (long)
1848 (s->lifetime ? s->lifetime : p->lifetime));
1849 plog(LLV_DEBUG2, LOCATION, NULL,
1851 s->lifebyte ? s->lifebyte : p->lifebyte);
1852 plog(LLV_DEBUG2, LOCATION, NULL,
1853 "encklen=%d\n", s->encklen);
1855 memset(types, 0, ARRAYLEN(types));
1856 types[algclass_isakmp_enc] = s->algclass[algclass_isakmp_enc];
1857 types[algclass_isakmp_hash] = s->algclass[algclass_isakmp_hash];
1858 types[algclass_isakmp_dh] = s->algclass[algclass_isakmp_dh];
1859 types[algclass_isakmp_ameth] =
1860 s->algclass[algclass_isakmp_ameth];
1862 /* expanding spspec */
1864 trns_no = expand_isakmpspec(prop_no, trns_no, types,
1865 algclass_isakmp_enc, algclass_isakmp_ameth + 1,
1866 s->lifetime ? s->lifetime : p->lifetime,
1867 s->lifebyte ? s->lifebyte : p->lifebyte,
1868 s->encklen, s->vendorid, s->gssid,
1870 if (trns_no == -1) {
1871 plog(LLV_ERROR, LOCATION, NULL,
1872 "failed to expand isakmp proposal.\n");
1879 if (rmconf->proposal == NULL) {
1880 plog(LLV_ERROR, LOCATION, NULL,
1881 "no proposal found.\n");
1892 for (i = 0; i < MAXALGCLASS; i++)
1893 tmpalgtype[i] = 0; /* means algorithm undefined. */
1897 expand_isakmpspec(prop_no, trns_no, types,
1898 class, last, lifetime, lifebyte, encklen, vendorid, gssid,
1900 int prop_no, trns_no;
1901 int *types, class, last;
1907 struct remoteconf *rmconf;
1909 struct isakmpsa *new;
1915 plog(LLV_DEBUG2, LOCATION, NULL,
1916 "p:%d t:%d\n", prop_no, trns_no);
1917 for (j = class; j < MAXALGCLASS; j++) {
1918 snprintf(tb, sizeof(tb), "%d", types[j]);
1919 plog(LLV_DEBUG2, LOCATION, NULL,
1921 s_algtype(j, types[j]),
1922 types[j] ? "(" : "",
1923 tb[0] == '0' ? "" : tb,
1924 types[j] ? ")" : "");
1926 plog(LLV_DEBUG2, LOCATION, NULL, "\n");
1929 #define TMPALGTYPE2STR(n) \
1930 s_algtype(algclass_isakmp_##n, types[algclass_isakmp_##n])
1931 /* check mandatory values */
1932 if (types[algclass_isakmp_enc] == 0
1933 || types[algclass_isakmp_ameth] == 0
1934 || types[algclass_isakmp_hash] == 0
1935 || types[algclass_isakmp_dh] == 0) {
1936 yyerror("few definition of algorithm "
1937 "enc=%s ameth=%s hash=%s dhgroup=%s.\n",
1938 TMPALGTYPE2STR(enc),
1939 TMPALGTYPE2STR(ameth),
1940 TMPALGTYPE2STR(hash),
1941 TMPALGTYPE2STR(dh));
1944 #undef TMPALGTYPE2STR
1947 new = newisakmpsa();
1949 yyerror("failed to allocate isakmp sa");
1952 new->prop_no = prop_no;
1953 new->trns_no = trns_no++;
1954 new->lifetime = lifetime;
1955 new->lifebyte = lifebyte;
1956 new->enctype = types[algclass_isakmp_enc];
1957 new->encklen = encklen;
1958 new->authmethod = types[algclass_isakmp_ameth];
1959 new->hashtype = types[algclass_isakmp_hash];
1960 new->dh_group = types[algclass_isakmp_dh];
1961 new->vendorid = vendorid;
1963 if (new->authmethod == OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB) {
1964 if (gssid != NULL) {
1965 new->gssid = vmalloc(strlen(gssid));
1966 memcpy(new->gssid->v, gssid, new->gssid->l);
1970 * Allocate the default ID so that it gets put
1971 * into a GSS ID attribute during the Phase 1
1974 new->gssid = gssapi_get_default_gss_id();
1978 insisakmpsa(new, rmconf);
1984 listen_addr (struct sockaddr *addr, int udp_encap)
1990 yyerror("failed to allocate myaddrs");
1994 if (p->addr == NULL) {
1995 yyerror("failed to copy sockaddr ");
1999 p->udp_encap = udp_encap;
2001 /* These need to be initialized for Apple modifications
2002 * to open code for isakmp sockets
2008 insmyaddr(p, &lcconf->myaddrs);
2010 lcconf->autograbaddr = 0;
2017 * Must be more than 1024B because its unit is kilobytes.
2018 * That is defined RFC2407.
2025 yyerror("byte size should be more than 1024B.");
2038 plog(LLV_DEBUG, LOCATION, NULL, "===== parse config\n");
2042 if (yycf_switch_buffer(lcconf->racoon_conf) != 0)
2048 plog(LLV_ERROR, LOCATION, NULL,
2049 "fatal parse failure (%d errors)\n",
2052 plog(LLV_ERROR, LOCATION, NULL,
2053 "fatal parse failure.\n");
2058 if (error == 0 && yyerrorcount) {
2059 plog(LLV_ERROR, LOCATION, NULL,
2060 "parse error is nothing, but yyerrorcount is %d.\n",
2065 yycf_clean_buffer();
2067 plog(LLV_DEBUG2, LOCATION, NULL, "parse successed.\n");
2075 plog(LLV_DEBUG, LOCATION, NULL, "==== Got HUP signal - re-parsing.\n");
2081 check_auto_exit(); /* check/change state of auto exit */
2088 #ifdef ENABLE_ADMINPORT
2090 adminsock_conf(path, owner, group, mode_dec)
2096 struct passwd *pw = NULL;
2097 struct group *gr = NULL;
2103 adminsock_path = path->v;
2109 uid = atoi(owner->v);
2111 if (((pw = getpwnam(owner->v)) == NULL) && !isnum)
2112 yyerror("User \"%s\" does not exist", owner->v);
2115 adminsock_owner = pw->pw_uid;
2117 adminsock_owner = uid;
2123 gid = atoi(group->v);
2125 if (((gr = getgrnam(group->v)) == NULL) && !isnum)
2126 yyerror("Group \"%s\" does not exist", group->v);
2129 adminsock_group = gr->gr_gid;
2131 adminsock_group = gid;
2137 yyerror("Mode 0%03o is invalid", mode_dec);
2138 if (mode_dec >= 400) { mode += 0400; mode_dec -= 400; }
2139 if (mode_dec >= 200) { mode += 0200; mode_dec -= 200; }
2140 if (mode_dec >= 100) { mode += 0200; mode_dec -= 100; }
2143 yyerror("Mode 0%03o is invalid", mode_dec);
2144 if (mode_dec >= 40) { mode += 040; mode_dec -= 40; }
2145 if (mode_dec >= 20) { mode += 020; mode_dec -= 20; }
2146 if (mode_dec >= 10) { mode += 020; mode_dec -= 10; }
2149 yyerror("Mode 0%03o is invalid", mode_dec);
2150 if (mode_dec >= 4) { mode += 04; mode_dec -= 4; }
2151 if (mode_dec >= 2) { mode += 02; mode_dec -= 2; }
2152 if (mode_dec >= 1) { mode += 02; mode_dec -= 1; }
2154 adminsock_mode = mode;