Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/setkey catch up with latest libipsec/kernel.



details:   https://anonhg.NetBSD.org/src/rev/3eaab11b8095
branches:  trunk
changeset: 481446:3eaab11b8095
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Jan 31 14:22:41 2000 +0000

description:
catch up with latest libipsec/kernel.

diffstat:

 usr.sbin/setkey/Makefile      |   38 +-
 usr.sbin/setkey/parse.y       |  658 +++++++++++++++++------------------------
 usr.sbin/setkey/sample.cf     |  250 +++++++++++----
 usr.sbin/setkey/scriptdump.pl |   18 +-
 usr.sbin/setkey/setkey.8      |  452 +++++++++++++++-------------
 usr.sbin/setkey/setkey.c      |  153 +++++----
 usr.sbin/setkey/test-pfkey.c  |    7 +-
 usr.sbin/setkey/token.l       |   99 +++---
 8 files changed, 865 insertions(+), 810 deletions(-)

diffs (truncated from 2483 to 300 lines):

diff -r c6e485a42b49 -r 3eaab11b8095 usr.sbin/setkey/Makefile
--- a/usr.sbin/setkey/Makefile  Mon Jan 31 14:20:13 2000 +0000
+++ b/usr.sbin/setkey/Makefile  Mon Jan 31 14:22:41 2000 +0000
@@ -1,39 +1,31 @@
-# $NetBSD: Makefile,v 1.2 1999/07/10 11:31:28 tron Exp $
+# $NetBSD: Makefile,v 1.3 2000/01/31 14:22:41 itojun Exp $
 
 PROG=  setkey
 SRCS=  setkey.c parse.y token.l
+CFLAGS+=-g
 LDADD+=        -ll -ly
-CLEANFILES+=   parse.c parse.h key_test.o keytest
-YFLAGS+=
+DPADD+=        ${LIBL} ${LIBY}
+CLEANFILES+=   y.tab.c y.tab.h key_test.o keytest
+YFLAGS+=-d
 
-CPPFLAGS+=-DIPSEC_DEBUG -DYY_NO_UNPUT -DINET6
-CPPFLAGS+=-I.
-
-#SCRIPTS=      scriptdump
+SCRIPTS=       scriptdump
 
-BINOWN  = root
-BINGRP  = bin
-BINMODE = 555
+BINOWN=root
+BINGRP=bin
+BINMODE=555
 
-all: ${PROG} ${SCRIPTS}
+all: ${PROG} scriptdump
 
-# FreeBSD
-#SRCS+=y.tab.h
-#y.tab.h: parse.y
-
+CPPFLAGS+=-DIPSEC_DEBUG -DINET6 -DYY_NO_UNPUT
+CPPFLAGS+=-I. -I${.CURDIR}
 LDADD+= -lipsec
 DPADD+=        ${LIBIPSEC}
-#CLEANFILES+=  scriptdump
+CLEANFILES+=   scriptdump
 
 MAN=   setkey.8
 LOCALPREFIX=   /usr/pkg
 
-#scriptdump: scriptdump.pl
-#      sed -e 's#@LOCALPREFIX@#${LOCALPREFIX}#' < ${.CURDIR}/scriptdump.pl > scriptdump
-
-parse.c parse.h: parse.y
-       ${YACC.y} -d ${.ALLSRC}
-       mv -f y.tab.c parse.c
-       mv -f y.tab.h parse.h
+scriptdump: scriptdump.pl
+       sed -e 's#@LOCALPREFIX@#${LOCALPREFIX}#' < $> > scriptdump
 
 .include <bsd.prog.mk>
diff -r c6e485a42b49 -r 3eaab11b8095 usr.sbin/setkey/parse.y
--- a/usr.sbin/setkey/parse.y   Mon Jan 31 14:20:13 2000 +0000
+++ b/usr.sbin/setkey/parse.y   Mon Jan 31 14:22:41 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.y,v 1.2 1999/07/06 13:13:03 itojun Exp $ */
+/*     $NetBSD: parse.y,v 1.3 2000/01/31 14:22:42 itojun Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
@@ -28,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-/* KAME Id: parse.y,v 1.1.2.18.2.7.4.12 1999/07/01 20:19:03 sakane Exp */
+/* KAME Id: parse.y,v 1.14 1999/12/30 15:13:27 sakane Exp */
 
 %{
 #include <sys/types.h>
@@ -55,9 +55,10 @@
 
 u_int p_type;
 u_int32_t p_spi;
-struct sockaddr *p_src, *p_dst, *p_proxy;
-u_int p_ports, p_portd, p_prefs, p_prefd, p_upper;
-u_int p_satype, p_ext, p_alg_enc, p_alg_auth, p_replay;
+struct sockaddr *p_src, *p_dst;
+u_int p_prefs, p_prefd, p_upper;
+u_int p_satype, p_ext, p_alg_enc, p_alg_auth, p_replay, p_mode;
+u_int32_t p_reqid;
 u_int p_key_enc_len, p_key_auth_len;
 caddr_t p_key_enc, p_key_auth;
 time_t p_lt_hard, p_lt_soft;
@@ -67,8 +68,8 @@
 
 /* temporary buffer */
 static struct sockaddr *pp_addr;
-static u_int pp_prefix = ~0;
-static u_int pp_port = 0;
+static u_int pp_prefix;
+static u_int pp_port;
 static caddr_t pp_key;
 
 extern u_char m_buf[BUFSIZ];
@@ -95,19 +96,29 @@
 
 %token EOT
 %token ADD GET DELETE FLUSH DUMP
-%token IP4_ADDRESS IP6_ADDRESS PREFIX PORT HOSTNAME
+%token IP4_ADDRESS IP6_ADDRESS PREFIX PORT PORTANY
 %token UP_PROTO PR_ESP PR_AH PR_IPCOMP
-%token DECSTRING QUOTEDSTRING HEXSTRING
 %token F_PROTOCOL F_AUTH F_ENC F_REPLAY F_COMP F_RAWCPI
-%token ALG_AUTH ALG_ENC ALG_ENC_DESDERIV ALG_ENC_DES32IV ALG_COMP EXTENSION
+%token F_MODE MODE F_REQID
+%token F_EXT EXTENSION NOCYCLICSEQ
+%token ALG_AUTH ALG_ENC ALG_ENC_DESDERIV ALG_ENC_DES32IV ALG_COMP
 %token F_LIFETIME_HARD F_LIFETIME_SOFT
+%token DECSTRING QUOTEDSTRING HEXSTRING ANY
        /* SPD management */
 %token SPDADD SPDDELETE SPDDUMP SPDFLUSH
 %token F_POLICY PL_REQUESTS
 
+%type <num> PORT PREFIX EXTENSION MODE
+%type <num> UP_PROTO PR_ESP PR_AH PR_IPCOMP
+%type <num> ALG_AUTH ALG_ENC ALG_ENC_DESDERIV ALG_ENC_DES32IV ALG_COMP
+%type <num> DECSTRING
+%type <val> IP4_ADDRESS IP6_ADDRESS PL_REQUESTS
+%type <val> key_string policy_requests
+%type <val> QUOTEDSTRING HEXSTRING
+
 %%
-commands:
-               /* empty */
+commands
+       :       /*NOTHING*/
        |       commands command
                {
                        if (f_debug) {
@@ -121,8 +132,8 @@
                }
        ;
 
-command:
-               add_command
+command
+       :       add_command
        |       get_command
        |       delete_command
        |       flush_command
@@ -135,120 +146,79 @@
        /* commands concerned with management, there is in tail of this file. */
 
        /* add command */
-add_command:
-               ADD
-               {
-                       p_type = yylval.num;
-               }
-               selector_spec protocol_spec lifetime_hard lifetime_soft EOT
+add_command
+       :       ADD { p_type = SADB_ADD; }
+               sa_selector_spec extension_spec algorithm_spec EOT
        ;
 
        /* delete */
-delete_command:
-               DELETE
-               {
-                       p_type = yylval.num;
-               }
-               selector_spec protocol_spec0 EOT
+delete_command
+       :       DELETE { p_type = SADB_DELETE; }
+               sa_selector_spec extension_spec EOT
        ;
 
        /* get command */
-get_command:
-               GET
-               {
-                       p_type = yylval.num;
-               }
-               selector_spec protocol_spec0 EOT
+get_command
+       :       GET { p_type = SADB_GET; }
+               sa_selector_spec extension_spec EOT
        ;
 
        /* flush */
-flush_command:
-               FLUSH
-               {
-                       p_type = yylval.num;
-               }
-               protocol_spec0 EOT
+flush_command
+       :       FLUSH { p_type = SADB_FLUSH; }
+               protocol_spec EOT
        ;
 
        /* dump */
-dump_command:
-               DUMP
-               {
-                       p_type = yylval.num;
-               }
-               protocol_spec0 EOT
-       ;
-
-       /* selector_spec */
-selector_spec:
-               src_spec dst_spec upper_spec spi proxy_spec
+dump_command
+       :       DUMP { p_type = SADB_DUMP; }
+               protocol_spec EOT
        ;
 
-src_spec:
-               ip_address
-               {
-                       p_src = pp_addr;
-               }
-               prefix
-               {
-                       p_prefs = pp_prefix;
-                       /* initialize */
-                       pp_prefix = ~0;
-               }
-               port
-               {
-                       _INPORTBYSA(p_src) = pp_port;
-                       p_ports = pp_port;
-
-                       /* initialize */
-                       pp_port = 0;
-               }
+       /* sa_selector_spec */
+sa_selector_spec
+       :       ipaddress { p_src = pp_addr; }
+               ipaddress { p_dst = pp_addr; }
+               protocol_spec spi
        ;
 
-dst_spec:
-               ip_address
-               {
-                       p_dst = pp_addr;
-               }
-               prefix
+protocol_spec
+       :       /*NOTHING*/ { p_satype = SADB_SATYPE_UNSPEC; }
+       |       PR_ESP
                {
-                       p_prefd = pp_prefix;
-                       /* initialize */
-                       pp_prefix = ~0;
+                       p_satype = SADB_SATYPE_ESP;
+                       if ($1 == 1)
+                               p_ext |= SADB_X_EXT_OLD;
+                       else
+                               p_ext &= ~SADB_X_EXT_OLD;
                }
-               port
+       |       PR_AH
                {
-                       _INPORTBYSA(p_dst) = pp_port;
-                       p_portd = pp_port;
-
-                       /* initialize */
-                       pp_port = 0;
+                       p_satype = SADB_SATYPE_AH;
+                       if ($1 == 1)
+                               p_ext |= SADB_X_EXT_OLD;
+                       else
+                               p_ext &= ~SADB_X_EXT_OLD;
+               }
+       |       PR_IPCOMP
+               {
+                       p_satype = SADB_X_SATYPE_IPCOMP;
                }
        ;
-
-upper_spec:
-               DECSTRING { p_upper = $1.num; }
-       |       UP_PROTO { p_upper = $1.num; }
-       |       PR_ESP { p_upper = IPPROTO_ESP; };
-       |       PR_AH { p_upper = IPPROTO_AH; };
-       |       PR_IPCOMP { p_upper = IPPROTO_IPCOMP; };
-       ;
-
-spi:
-               DECSTRING
-               {
-                       p_spi = yylval.num;
-               }
+       
+spi
+       :       DECSTRING { p_spi = $1; }
        |       HEXSTRING
                {
                        caddr_t bp;
-                       caddr_t yp = yylval.val.buf;



Home | Main Index | Thread Index | Old Index