Skip to content

Commit

Permalink
- Changed a coding style to "bsd" (described in IMPLEMENTATION,
Browse files Browse the repository at this point in the history
  chapter 8).
- Does not depend on interface.
  'interface' directive was removed in configuration rule, and no
  inbound/outbound distinction in each rule.
- Changed a syntax of configuration command (natptconfig) related to
  the item mentioned above.  The syntax does not change greatly, it
  became simpler.
- Use TAILQ (defined in /usr/include/sys/queue.h) instead of my
  original list handle routines.
  • Loading branch information
fujisawa committed Sep 2, 2001
1 parent 49105ae commit 87b08f2
Show file tree
Hide file tree
Showing 12 changed files with 1,050 additions and 1,619 deletions.
92 changes: 52 additions & 40 deletions kame/kame/natptconfig/Makefile
@@ -1,62 +1,74 @@
# Copyright (c) 1996 WIDE Project. All rights reserved.
# $KAME: Makefile,v 1.5 2001/09/02 19:32:27 fujisawa Exp $

# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 and 2001 WIDE Project.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modifications, are permitted provided that the above copyright notice
# and this paragraph are duplicated in all such forms and that any
# documentation, advertising materials, and other materials related to
# such distribution and use acknowledge that the software was developed
# by the WIDE Project, Japan. The name of the Project may not be used to
# endorse or promote products derived from this software without
# specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS''
# AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE.
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the project nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.

.if exists(${.CURDIR}/../Makefile.opsys)
.include "${.CURDIR}/../Makefile.opsys"
.endif

.PATH: ${.CURDIR}/../../sys/

BINDIR= ${PREFIX}/sbin
PROG= natptconfig
SRCS= main.c natptconfig.y.c natptconfig.l.c misc.c show.c showsubs.c yylex.c
CLEANFILES+= natptconfig.y.c natptconfig.l.c natptconfig.y.h y.output y.tab.c y.tab.h
LDADD+=-ly -ll
SRCS = main.c misc.c show.c showsubs.c yylex.c
SRCS+= cfparse.y cftoken.l
YACC= yacc -tv

.if (${OPSYS} != "NetBSD")
CFLAGS+= -Wall
.if (${OPSYS} == "NetBSD")
YFLAGS+=-d
.endif

CFLAGS+= -g -I${.CURDIR}/../../sys/ -DYYDEBUG -DNATPT -DNATPTCONFIG -DreadKMEM

LDADD+= -L${.CURDIR}/../libinet6 -L${.CURDIR}/../libinet6/obj \
-L/usr/local/v6/lib -linet6 -lkvm -ly -ll
DPADD+= ${.CURDIR}/../libinet6/libinet6.a \
${.CURDIR}/../libinet6/obj/libinet6.a \
/usr/local/v6/lib/libinet6.a

CC=gcc
.if (${OPSYS} != "NetBSD")
CFLAGS+=-g -Wall -DYYDEBUG
.else
CPPFLAGS+=-g
.endif
.if (${OPSYS} != "NetBSD")
MAN1=
MAN8= natptconfig.8
.else
MAN= natptconfig.8
YFLAGS+= -d
.endif

main.o: main.c natptconfig.y.h
misc.o: misc.c natptconfig.y.h
yylex.o: yylex.c natptconfig.y.h

natptconfig.y.c \
natptconfig.y.h: natptconfig.y showvar.h
$(YACC) ${YFLAGS} natptconfig.y
mv y.tab.c natptconfig.y.c
mv y.tab.h natptconfig.y.h

natptconfig.l.c: natptconfig.l
$(LEX) -t -L natptconfig.l > natptconfig.l.c
.if exists(/usr/local/v6/lib/libinet6.a)
LDADD+= -L${.OBJDIR}/../libinet6 -L${.OBJDIR}/../libinet6/obj \
-L/usr/local/v6/lib -linet6 -lkvm
DPADD+= ${.OBJDIR}/../libinet6/libinet6.a \
${.OBJDIR}/../libinet6/obj/libinet6.a \
/usr/local/v6/lib/libinet6.a
.endif

etags:
etags *.[chly] ../../sys/netinet6/*.[ch]
tag:
etags *.[chly] /usr/include/netinet6/natpt_*.h

clean:
-rm -f $(PROG) *.o *.core
-rm -f cfparse.[ch] cfparse.output cftoken.c
-rm -f natptconfig.8.gz

.include <bsd.prog.mk>
63 changes: 47 additions & 16 deletions kame/kame/natptconfig/defs.h
@@ -1,7 +1,9 @@
/* $KAME: defs.h,v 1.6 2001/09/02 19:32:27 fujisawa Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 and 2001 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
Expand All @@ -13,7 +15,7 @@
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand All @@ -25,24 +27,23 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: defs.h,v 1.5 2000/05/16 16:22:33 fujisawa Exp $
*/

#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif

/*
*
*/

#define ERROR (-1)
#define SAME (0)
#define PROTO_ICMP 0x01
#define PROTO_TCP 0x02
#define PROTO_UDP 0x04

#ifndef TRUE
#define TRUE (1)
#define FALSE (~TRUE)
#endif

#define LONG (1)
#define SHORT (2)
#define GETA 64

#define ROUNDUP(x) roundup(x, sizeof(void *))

Expand All @@ -51,15 +52,45 @@
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
#endif

#define SIN6(s) ((struct sockaddr_in6 *)s)

#define isDebug(d) (u_debug & (d))
extern u_int u_debug;


/* Bit assign for _debug */
#define D_LEXTOKEN 0x00000001
#define D_YYDEBUG 0x00000010
#define D_SHOWROUTE 0x00000100
#define D_SHOWCSLOT 0x00000200
#define D_DUMPIOCTL 0x00010000
#define D_NOSOCKET 0x01000000

struct ruletab
{
struct pAddr *from;
struct pAddr *to;
u_short *sports;
u_short dport;
int proto;
int bidir;
};


/*
*
*/

extern int u_debug;
extern char *yytext;


/* cfparse.y */
int yyparse __P((void));

/* cftoken.l */
void switchToBuffer __P((char *));
void reassembleCommandLine __P((int, char *[]));

/* main.c */
void printHelp __P((int, char *));


/* End of defs.h */

0 comments on commit 87b08f2

Please sign in to comment.