From aa0f5b38aec14428b4b80e06f90ff781f8bca5f1 Mon Sep 17 00:00:00 2001 From: Rene Mayrhofer Date: Mon, 22 May 2006 05:12:18 +0000 Subject: Import initial strongswan 2.7.0 version into SVN. --- programs/tncfg/.cvsignore | 1 + programs/tncfg/Makefile | 52 ++++++ programs/tncfg/tncfg.5 | 109 +++++++++++++ programs/tncfg/tncfg.8 | 113 +++++++++++++ programs/tncfg/tncfg.c | 393 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 668 insertions(+) create mode 100644 programs/tncfg/.cvsignore create mode 100644 programs/tncfg/Makefile create mode 100644 programs/tncfg/tncfg.5 create mode 100644 programs/tncfg/tncfg.8 create mode 100644 programs/tncfg/tncfg.c (limited to 'programs/tncfg') diff --git a/programs/tncfg/.cvsignore b/programs/tncfg/.cvsignore new file mode 100644 index 000000000..c05ca8d9a --- /dev/null +++ b/programs/tncfg/.cvsignore @@ -0,0 +1 @@ +tncfg diff --git a/programs/tncfg/Makefile b/programs/tncfg/Makefile new file mode 100644 index 000000000..ded364dbf --- /dev/null +++ b/programs/tncfg/Makefile @@ -0,0 +1,52 @@ +# Makefile for the KLIPS interface utilities +# Copyright (C) 1998, 1999 Henry Spencer. +# Copyright (C) 1999, 2000, 2001 Richard Guy Briggs +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. See . +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# RCSID $Id: Makefile,v 1.1 2004/03/15 20:35:31 as Exp $ + +FREESWANSRCDIR=../.. +include ${FREESWANSRCDIR}/Makefile.inc + +PROGRAM:=tncfg +EXTRA5PROC=${PROGRAM}.5 + +LIBS:=${FREESWANLIB} + +include ../Makefile.program + +# +# $Log: Makefile,v $ +# Revision 1.1 2004/03/15 20:35:31 as +# added files from freeswan-2.04-x509-1.5.3 +# +# Revision 1.4 2002/06/03 20:25:31 mcr +# man page for files actually existant in /proc/net changed back to +# ipsec_foo via new EXTRA5PROC process. +# +# Revision 1.3 2002/06/02 21:51:41 mcr +# changed TOPDIR->FREESWANSRCDIR in all Makefiles. +# (note that linux/net/ipsec/Makefile uses TOPDIR because this is the +# kernel sense.) +# +# Revision 1.2 2002/04/26 01:21:26 mcr +# while tracking down a missing (not installed) /etc/ipsec.conf, +# MCR has decided that it is not okay for each program subdir to have +# some subset (determined with -f) of possible files. +# Each subdir that defines $PROGRAM, MUST have a PROGRAM.8 file as well as a PROGRAM file. +# Optional PROGRAM.5 files have been added to the makefiles. +# +# Revision 1.1 2002/04/24 07:55:32 mcr +# #include patches and Makefiles for post-reorg compilation. +# +# +# diff --git a/programs/tncfg/tncfg.5 b/programs/tncfg/tncfg.5 new file mode 100644 index 000000000..e4de862c6 --- /dev/null +++ b/programs/tncfg/tncfg.5 @@ -0,0 +1,109 @@ +.TH IPSEC_TNCFG 5 "27 Jun 2000" +.\" +.\" RCSID $Id: tncfg.5,v 1.1 2004/03/15 20:35:31 as Exp $ +.\" +.SH NAME +ipsec_tncfg \- lists IPSEC virtual interfaces attached to real interfaces +.SH SYNOPSIS +.B ipsec +.B tncfg +.PP +.B cat +.B /proc/net/ipsec_tncfg +.SH DESCRIPTION +.I /proc/net/ipsec_tncfg +is a read-only file which lists which IPSEC virtual interfaces are +attached to which real interfaces, through which packets will be +forwarded once processed by IPSEC. +.PP +Each line lists one ipsec I/F. +A table entry consists of: +.IP + 3 +an ipsec virtual I/F name +.IP + +a visual and machine parsable separator '->', separating the virtual I/F +and the physical I/F, +.IP + +a physical I/F name, to which the ipsec virtual I/F is attached or NULL +if it is not attached, +.IP + +the keyword +.BR mtu= , +.IP + +the MTU of the ipsec virtual I/F, +.IP + +the automatically adjusted effective MTU for PMTU discovery, in brackets, +.IP + +a visual and machine parsable separator '->', separating the virtual I/F +MTU and the physical I/F MTU, +.IP + +the MTU of the attached physical I/F. +.BR +.SH EXAMPLES +.TP +.B ipsec2 -> eth3 mtu=16260(1443) -> 1500 +.LP +shows that virtual device +.B ipsec2 +with an MTU of +.B 16260 +is connected to physical device +.B eth3 +with an MTU of +.B 1500 +and that the effective MTU as a result of PMTU discovery has been +automatically set to +.BR 1443. +.TP +.B ipsec0 \-> wvlan0 mtu=1400(16260) \-> 1500 +.LP +shows that virtual device +.B ipsec0 +with an MTU of +.B 1400 +is connected to physical device +.B wvlan0 +with an MTU of +.B 1500 +and no PMTU packets have gotten far enough to bump down the effective MTU +from its default of 16260. +.TP +.B ipsec3 \-> NULL mtu=0(0) \-> 0 +.LP +shows that virtual device +.B ipsec3 +is not connected to any physical device. +.LP +.SH "FILES" +/proc/net/ipsec_tncfg, /usr/local/bin/ipsec +.SH "SEE ALSO" +ipsec(8), ipsec_manual(8), ipsec_eroute(5), ipsec_spi(5), +ipsec_spigrp(5), ipsec_klipsdebug(5), ipsec_tncfg(8), ipsec_version(5), +ipsec_pf_key(5) +.SH HISTORY +Written for the Linux FreeS/WAN project + +by Richard Guy Briggs. +.\" +.\" $Log: tncfg.5,v $ +.\" Revision 1.1 2004/03/15 20:35:31 as +.\" added files from freeswan-2.04-x509-1.5.3 +.\" +.\" Revision 1.5 2002/04/24 07:35:41 mcr +.\" Moved from ./klips/utils/tncfg.5,v +.\" +.\" Revision 1.4 2001/05/29 05:15:53 rgb +.\" Added PMTU to output format. +.\" +.\" Revision 1.3 2000/06/30 18:21:55 rgb +.\" Update SEE ALSO sections to include ipsec_version(5) and ipsec_pf_key(5) +.\" and correct FILES sections to no longer refer to /dev/ipsec which has +.\" been removed since PF_KEY does not use it. +.\" +.\" Revision 1.2 2000/06/28 12:44:12 henry +.\" format touchup +.\" +.\" Revision 1.1 2000/06/28 05:43:01 rgb +.\" Added manpages for all 5 klips utils. +.\" +.\" diff --git a/programs/tncfg/tncfg.8 b/programs/tncfg/tncfg.8 new file mode 100644 index 000000000..f888f2539 --- /dev/null +++ b/programs/tncfg/tncfg.8 @@ -0,0 +1,113 @@ +.TH IPSEC_TNCFG 8 "21 Jun 2000" +.\" +.\" RCSID $Id: tncfg.8,v 1.1 2004/03/15 20:35:31 as Exp $ +.\" +.SH NAME +ipsec tncfg \- associate IPSEC virtual interface with physical interface +.SH SYNOPSIS +.B ipsec +.B tncfg +.PP +.B ipsec +.B tncfg +.B \-\-attach +.B \-\-virtual +virtual +.B \-\-physical +physical +.PP +.B ipsec +.B tncfg +.B \-\-detach +.B \-\-virtual +virtual +.PP +.B ipsec +.B tncfg +.B \-\-clear +.PP +.B ipsec +.B tncfg +.B \-\-version +.PP +.B ipsec +.B tncfg +.B \-\-help +.SH DESCRIPTION +.I Tncfg +attaches/detaches IPSEC virtual interfaces to/from +physical interfaces, +through which packets will be forwarded once processed by IPSEC. +.PP +The form with no additional arguments lists the contents of +/proc/net/ipsec_tncfg. The format of /proc/net/ipsec_tncfg is discussed +in ipsec_tncfg(5). +The +.B \-\-attach +form attaches the +.I virtual +interface to the +.I physical +one. +The +.B \-\-detach +form detaches the +.I virtual +interface from whichever physical interface it is attached to. +The +.B \-\-clear +form clears all the +.I virtual +interfaces from whichever physical interfaces they were attached to. +.PP +Virtual interfaces typically have names like +.BR ipsec0 , +while physical interfaces typically have names like +.B eth0 +or +.BR ppp0 . +.SH EXAMPLES +.TP +.B ipsec tncfg \-\-attach \-\-virtual ipsec0 \-\-physical eth0 +attaches the +.B ipsec0 +virtual device to the +.B eth0 +physical device. +.LP +.SH "FILES" +/proc/net/ipsec_tncfg, /usr/local/bin/ipsec +.SH "SEE ALSO" +ipsec(8), ipsec_manual(8), ipsec_eroute(8), ipsec_spi(8), +ipsec_spigrp(8), ipsec_klipsdebug(8), ipsec_tncfg(5) +.SH HISTORY +Written for the Linux FreeS/WAN project + +by Richard Guy Briggs. +.\" +.\" $Log: tncfg.8,v $ +.\" Revision 1.1 2004/03/15 20:35:31 as +.\" added files from freeswan-2.04-x509-1.5.3 +.\" +.\" Revision 1.15 2002/04/24 07:35:41 mcr +.\" Moved from ./klips/utils/tncfg.8,v +.\" +.\" Revision 1.14 2000/09/12 13:09:04 rgb +.\" Fixed real/physical discrepancy between tncfg.8 and tncfg.c. +.\" +.\" Revision 1.13 2000/06/30 18:21:55 rgb +.\" Update SEE ALSO sections to include ipsec_version(5) and ipsec_pf_key(5) +.\" and correct FILES sections to no longer refer to /dev/ipsec which has +.\" been removed since PF_KEY does not use it. +.\" +.\" Revision 1.12 2000/06/21 16:54:58 rgb +.\" Added 'no additional args' text for listing contents of +.\" /proc/net/ipsec_* files. +.\" +.\" Revision 1.11 1999/07/19 18:47:25 henry +.\" fix slightly-misformed comments +.\" +.\" Revision 1.10 1999/04/06 04:54:39 rgb +.\" Fix/Add RCSID Id: and Log: bits to make PHMDs happy. This includes +.\" patch shell fixes. +.\" diff --git a/programs/tncfg/tncfg.c b/programs/tncfg/tncfg.c new file mode 100644 index 000000000..f6aeae0e2 --- /dev/null +++ b/programs/tncfg/tncfg.c @@ -0,0 +1,393 @@ +/* + * IPSEC interface configuration + * Copyright (C) 1996 John Ioannidis. + * Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +char tncfg_c_version[] = "RCSID $Id: tncfg.c,v 1.1 2004/03/15 20:35:31 as Exp $"; + + +#include +#include +#include /* system(), strtoul() */ +#include /* getuid() */ +#include +#include /* ioctl() */ + +#include +#ifdef NET_21 /* from freeswan.h */ +#include +#include +#endif /* NET_21 */ /* from freeswan.h */ + +#if 0 +#include +#else +#include +#endif +#include +#include +#include + +#include "freeswan/ipsec_tunnel.h" + +static void +usage(char *name) +{ + fprintf(stdout,"%s --attach --virtual --physical \n", + name); + fprintf(stdout,"%s --detach --virtual \n", + name); + fprintf(stdout,"%s --clear\n", + name); + fprintf(stdout,"%s --help\n", + name); + fprintf(stdout,"%s --version\n", + name); + fprintf(stdout,"%s\n", + name); + fprintf(stdout, " [ --debug ] is optional to any %s command.\n", name); + fprintf(stdout, " [ --label