1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-21 04:06:46 +00:00

New port - mpd-l2tp-ipv6pd-client

A sample implementaiton set of "L2TP-IPv6PD" client using mpd.
"OCN IPv6", provided by NTT Communications Corp, was the first
commercial tunnel service using "L2TP-IPv6PD".

NOTE: This port runs on FreeBSD 6.3 and later.  If you want to run it
on FreeBSD 6.2, you need to apply following diff to your ng_ksocket:

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netgraph/ng_ksocket.c.diff?r1=1.59&r2=1.60

WWW: http://www.ocn.v6.ntt.net/ocnipv6/pdf/ocnipv6uni_ver1.0.pdf
This commit is contained in:
Hajimu UMEMOTO 2008-01-01 11:52:51 +00:00
parent 44792150fa
commit 7f5b4d4612
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=204792
14 changed files with 486 additions and 0 deletions

View File

@ -334,6 +334,7 @@
SUBDIR += mopd
SUBDIR += morebalance
SUBDIR += mpd
SUBDIR += mpd-l2tp-ipv6pd-client
SUBDIR += mpd4
SUBDIR += mpd5
SUBDIR += mpich

View File

@ -0,0 +1,92 @@
# New ports collection makefile for: mpd-l2tp-ipv6pd-client
# Date created: Nov 2 2006
# Whom: Hajimu UMEMOTO <ume@FreeBSD.org>
#
# $FreeBSD$
#
PORTNAME= mpd-l2tp-ipv6pd-client
PORTVERSION= 20080101
#PORTREVISION= 0
CATEGORIES= net ipv6
MASTER_SITES= # none
DISTFILES= # none
MAINTAINER= ume@FreeBSD.org
COMMENT= A sample implementaiton set of "L2TP-IPv6PD" client using mpd
BUILD_DEPENDS= ${MPD_NAME}:${PORTSDIR}/net/${MPD_NAME}
RUN_DEPENDS= dhcp6ctl:${PORTSDIR}/net/dhcp6 \
${MPD_NAME}:${PORTSDIR}/net/${MPD_NAME}
MANUAL_PACKAGE_BUILD=yes
NO_PACKAGE= yes
USE_RC_SUBR= yes
CONF_DIR?= etc/${MPD_NAME}
CONF_FILES= dhcp6c.conf.in mpd.conf mpd.links rtadvd.conf
SCRIPT_FILES= dhcp6c_pd.sh linkdown.sh linkup.sh
SECRET_FILES= mpd.secret
SCRIPTS_ENV= WRKDIR="${WRKDIR}" \
SCRIPTDIR="${SCRIPTDIR}" \
PREFIX="${PREFIX}" \
CONF_DIR="${CONF_DIR}" \
MPD_NAME="${MPD_NAME}" \
RC_SUBR="${RC_SUBR}" \
CAT="${CAT}" \
CP="${CP}" \
DIALOG="${DIALOG}" \
MD5="${MD5}" \
MKTEMP="${MKTEMP}" \
RM="${RM}" \
SED="${SED}" \
WHICH="${WHICH}"
PLIST_SUB= CONF_DIR="${CONF_DIR}" \
MPD_NAME="${MPD_NAME}"
PKGMESSAGE= ${WRKDIR}/pkg-message
.if defined(WITH_MPD5)
MPD_NAME= mpd5
.else
MPD_NAME= mpd4
.endif
.include <bsd.port.pre.mk>
.if ${OSVERSION} < 602106 || (${OSVERSION} >= 700000 && ${OSVERSION} < 700031)
IGNORE= does not work with old ng_ksocket
.endif
do-build:
@${SETENV} ${SCRIPTS_ENV} ${SH} ${SCRIPTDIR}/setting
@${DIALOG} --clear
do-install:
@if [ -f ${PREFIX}/${CONF_DIR}/mpd.conf -o \
-f ${PREFIX}/${CONF_DIR}/mpd.links -o \
-f ${PREFIX}/${CONF_DIR}/mpd.secret ]; then \
${ECHO_CMD} "There are ${MPD_NAME} configuration files already"; \
${ECHO_CMD} "Pleae remove at least following files before install:"; \
${ECHO_CMD} " ${PREFIX}/${CONF_DIR}/mpd.conf"; \
${ECHO_CMD} " ${PREFIX}/${CONF_DIR}/mpd.links"; \
${ECHO_CMD} " ${PREFIX}/${CONF_DIR}/mpd.secret"; \
exit 1; \
fi
@${MKDIR} ${PREFIX}/${CONF_DIR}
.for f in ${CONF_FILES}
@${INSTALL_DATA} ${WRKDIR}/${f} ${PREFIX}/${CONF_DIR}/${f}
.endfor
@${INSTALL_DATA} ${WRKDIR}/mpd ${PREFIX}/${CONF_DIR}/${MPD_NAME}
.for f in ${SCRIPT_FILES}
@${INSTALL_SCRIPT} ${WRKDIR}/${f} ${PREFIX}/${CONF_DIR}/${f}
.endfor
.for f in ${SECRET_FILES}
@${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m 400 \
${WRKDIR}/${f} ${PREFIX}/${CONF_DIR}/${f}
.endfor
@${CAT} ${PKGMESSAGE}
.include <bsd.port.post.mk>

View File

@ -0,0 +1,10 @@
A sample implementaiton set of "L2TP-IPv6PD" client using mpd.
"OCN IPv6", provided by NTT Communications Corp, was the first
commercial tunnel service using "L2TP-IPv6PD".
NOTE: This port runs on FreeBSD 6.3 and later. If you want to run it
on FreeBSD 6.2, you need to apply following diff to your ng_ksocket:
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netgraph/ng_ksocket.c.diff?r1=1.59&r2=1.60
WWW: http://www.ocn.v6.ntt.net/ocnipv6/pdf/ocnipv6uni_ver1.0.pdf

View File

@ -0,0 +1,10 @@
%%CONF_DIR%%/dhcp6c.conf.in
%%CONF_DIR%%/dhcp6c_pd.sh
%%CONF_DIR%%/linkdown.sh
%%CONF_DIR%%/linkup.sh
%%CONF_DIR%%/mpd.conf
%%CONF_DIR%%/mpd.links
%%CONF_DIR%%/mpd.secret
%%CONF_DIR%%/%%MPD_NAME%%
%%CONF_DIR%%/rtadvd.conf
@dirrmtry %%CONF_DIR%%

View File

@ -0,0 +1,10 @@
interface __INTERFACE__ {
send ia-pd 0;
};
id-assoc pd 0 {
prefix-interface __PD_INTERFACE__ {
sla-id 0;
sla-len 0;
};
};

View File

@ -0,0 +1,132 @@
#!/bin/sh
#
# Copyright (c) 2007 Hajimu UMEMOTO
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
# PROVIDE: dhcp6c_pd
# REQUIRE: mountcritremote
# KEYWORD: nojail nostart
prefix=%%PREFIX%%
DATE=%%DATE%%
MD5=%%MD5%%
SED=%%SED%%
. %%RC_SUBR%%
name="dhcp6c_pd"
rcvar=
command="${prefix}/sbin/dhcp6c"
start_precmd="dhcp6c_pd_prestart"
start_postcmd="dhcp6c_pd_poststart"
stop_precmd="dhcp6c_pd_precmd"
stop_cmd="dhcp6c_pd_stop"
restart_precmd="dhcp6c_pd_precmd"
# When dhcp6c gets signal, dhcp6c removes its pidfile immediately but
# dhcp6c might not terminate.
getpid()
{
if [ -f "${pidfile}" ]; then
read pid junk < ${pidfile}
echo ${pid}
else
/bin/pgrep -f "dhcp6c -p ${pidfile}"
fi
}
dhcp6c_pd_precmd()
{
if [ -z "${dhcp6c_pd_interface}" ]; then
warn "\$dhcp6c_pd_interface is not set."
return 1
fi
}
dhcp6c_pd_prestart()
{
dhcp6c_pd_precmd
pid=`getpid`
if [ -n "${pid}" ]; then
dhcp6c_pd_stop
sleep 2
fi
# create dhcp6c.conf
${SED} -e "s/__INTERFACE__/${dhcp6c_pd_interface}/" \
-e "s/__PD_INTERFACE__/${dhcp6c_pd_rtadvd_interface}/" \
< ${dhcp6c_pd_conf}.in > ${dhcp6c_pd_conf}.${dhcp6c_pd_interface}
# create dhcp6cctlkey
#if [ ! -f ${prefix}/etc/dhcp6cctlkey ]; then
# ${MD5} -q -s `${DATE} "+%Y-%m-%d-%H-%M-%S"` \
# > ${prefix}/etc/dhcp6cctlkey
#fi
}
dhcp6c_pd_poststart()
{
if checkyesno dhcp6c_pd_rtadvd_enable; then
/sbin/sysctl net.inet6.ip6.accept_rtadv=0
/sbin/sysctl net.inet6.ip6.forwarding=1
/usr/sbin/rtadvd -c ${dhcp6c_pd_rtadvd_conf} \
${dhcp6c_pd_rtadvd_interface}
fi
}
dhcp6c_pd_stop()
{
if checkyesno dhcp6c_pd_rtadvd_enable; then
if [ -f "/var/run/rtadvd.pid" ]; then
read pid junk < "/var/run/rtadvd.pid"
kill ${pid}
/sbin/sysctl net.inet6.ip6.accept_rtadv=1
/sbin/sysctl net.inet6.ip6.forwarding=0
fi
fi
pid=`getpid`
if [ -n "${pid}" ]; then
kill ${pid}
rm -f ${dhcp6c_pd_conf}.${dhcp6c_pd_interface}
fi
}
load_rc_config ${name}
dhcp6c_pd_conf=${dhcp6c_pd_conf:-"${prefix}/%%CONF_DIR%%/dhcp6c.conf"}
dhcp6c_pd_interface=${2:-${dhcp6c_pd_interface}}
dhcp6c_pd_localaddr=${3:-${dhcp6c_pd_localaddr}}
dhcp6c_pd_rtadvd_enable=${dhcp6c_pd_rtadvd_enable:-"NO"}
dhcp6c_pd_rtadvd_interface=${dhcp6c_pd_rtadvd_interface:-"%%PD_INTERFACE%%"}
dhcp6c_pd_rtadvd_conf=${dhcp6c_pd_rtadvd_conf:-"${prefix}/%%CONF_DIR%%/rtadvd.conf"}
required_files="${dhcp6c_pd_conf}.in"
pidfile=/var/run/dhcp6c-${dhcp6c_pd_interface}.pid
dhcp6c_pd_flags="-p ${pidfile} ${dhcp6c_pd_flags}"
command_args="-c ${dhcp6c_pd_conf}.${dhcp6c_pd_interface} ${dhcp6c_pd_interface}"
if [ -n "${dhcp6c_pd_localaddr}" ]; then
command_args="-A ${dhcp6c_pd_localaddr} ${command_args}"
fi
rc_fast=yes
run_rc_command "$1"

View File

@ -0,0 +1,15 @@
#!/bin/sh
iface=$1
family=$2
case ${family} in
inet6)
%%PREFIX%%/%%CONF_DIR%%/dhcp6c_pd.sh stop ${iface}
case ${iface} in
*)
/sbin/route delete -inet6 default
;;
esac
;;
esac

View File

@ -0,0 +1,25 @@
#!/bin/sh
#
# link up
#linkup.sh <interface> <family> <local address> <remote address> <authname>
#
iface=$1
family=$2
myaddr=$3
hisaddr=$4
case ${family} in
inet6)
(
sleep $(($(sysctl -n net.inet6.ip6.dad_count) + 1))
%%PREFIX%%/%%CONF_DIR%%/dhcp6c_pd.sh start ${iface}
) &
case ${iface} in
*)
/sbin/route delete -inet6 default
/sbin/route add -inet6 default ::1 -ifp ${iface}
;;
esac
;;
esac

View File

@ -0,0 +1,25 @@
startup:
default:
load l2tp
l2tp:
new -i %%INTERFACE%% l2tp L2TP0
set auth authname %%PPP_ID%%
set iface disable on-demand
set iface idle 0
set bundle no multilink
set bundle no ipcp
set bundle enable ipv6cp
set bundle disable noretry
set link no acfcomp protocomp
set link disable pap chap
set link accept chap
set link keep-alive 15 60
set link max-redial 0
set link mtu 1390
set link mru 1390
set iface up-script %%PREFIX%%/%%CONF_DIR%%/linkup.sh
set iface down-script %%PREFIX%%/%%CONF_DIR%%/linkdown.sh
#set iface route ::/0
open

View File

@ -0,0 +1,15 @@
mpd_confdir="%%PREFIX%%/%%CONF_DIR%%"
mpd_interfaces="%%INTERFACE%%"
mpd_enable="YES"
mpd_flags="-b -d ${mpd_confdir}"
stop_precmd="mpd_prestop"
mpd_prestop()
{
for iface in ${mpd_interfaces}; do
${mpd_confdir}/dhcp6c_pd.sh stop ${iface}
done
sleep 2
}

View File

@ -0,0 +1,6 @@
L2TP0:
set phys type l2tp
set l2tp peer %%FIXED_SERVER%%
set l2tp hostname %%PPP_ID%%
set l2tp disable incoming
set l2tp enable originate

View File

@ -0,0 +1 @@
%%PPP_ID%% "%%PPP_PASSWD%%"

View File

@ -0,0 +1,2 @@
%%PD_INTERFACE%%:\
:vltime#180:pltime#90:maxinterval#30:

View File

@ -0,0 +1,142 @@
#!/bin/sh
DATE=`${WHICH} date`
# user id
tempfile=`${MKTEMP} -t ipv6pd`
${DIALOG} --title "L2TP-IPv6PD Setup Helper" --clear \
--inputbox "Please Input User ID:" -1 -1 2> ${tempfile}
retval=$?
case $retval in
0)
ppp_id=`${CAT} ${tempfile}`
${RM} ${tempfile}
;;
1)
${RM} ${tempfile}
exit
;;
255)
${RM} ${tempfile}
exit
;;
esac
# passwd
tempfile=`${MKTEMP} -t ipv6pd`
${DIALOG} --title "L2TP-IPv6PD Setup Helper" \
--inputbox "Please Input Passwd:" -1 -1 \
2> ${tempfile}
case $retval in
0)
ppp_passwd=`${CAT} ${tempfile}`
${RM} ${tempfile}
;;
1)
${RM} ${tempfile}
exit
;;
255)
${RM} ${tempfile}
exit
;;
esac
# fixed server
tempfile=`${MKTEMP} -t ipv6pd`
${DIALOG} --title "L2TP-IPv6PD Setup Helper" \
--inputbox "Please Input L2TP-IPv6PD Server\n(Fixed Prefix):" \
-1 -1 2> ${tempfile}
case $retval in
0)
fixed_server=`${CAT} ${tempfile}`
${RM} ${tempfile}
;;
1)
${RM} ${tempfile}
exit
;;
255)
${RM} ${tempfile}
exit
;;
esac
# Set PPP Interface
tempfile=`${MKTEMP} -t ipv6pd`
${DIALOG} --title "L2TP-IPv6PD Setup Helper" \
--inputbox "Please Input PPP Interface (default: ng0):" -1 -1 \
2> ${tempfile}
case $retval in
0)
interface=`${CAT} ${tempfile}`
if [ -z "${interface}" ]; then
interface="ng0"
fi
${RM} ${tempfile}
;;
1)
${RM} ${tempfile}
exit
;;
255)
${RM} ${tempfile}
exit
;;
esac
# Set Prefix Delegation Interface
tempfile=`${MKTEMP} -t ipv6pd`
${DIALOG} --title "L2TP-IPv6PD Setup Helper" \
--inputbox "Please Input Prefix Delegation Interface:" -1 -1 \
2> ${tempfile}
case $retval in
0)
pd_interface=`${CAT} ${tempfile}`
${RM} ${tempfile}
;;
1)
${RM} ${tempfile}
exit
;;
255)
${RM} ${tempfile}
exit
;;
esac
for infile in ${SCRIPTDIR}/*.in; do
outfile=${WRKDIR}/`basename ${infile} .in`
${SED} -e "s|%%PPP_ID%%|${ppp_id}|g" \
-e "s|%%PPP_PASSWD%%|${ppp_passwd}|g" \
-e "s|%%FIXED_SERVER%%|${fixed_server}|g" \
-e "s|%%INTERFACE%%|${interface}|g" \
-e "s|%%PD_INTERFACE%%|${pd_interface}|g" \
-e "s|%%RC_SUBR%%|${RC_SUBR}|g" \
-e "s|%%PREFIX%%|${PREFIX}|g" \
-e "s|%%CONF_DIR%%|${CONF_DIR}|g" \
-e "s|%%MD5%%|${MD5}|g" \
-e "s|%%SED%%|${SED}|g" \
-e "s|%%DATE%%|${DATE}|g" \
< ${infile} > ${outfile}
done
outfile="${WRKDIR}/pkg-message"
cat <<EOF > ${outfile}
Type following commands to complete setup:
# mkdir /etc/rc.conf.d
# cp ${PREFIX}/${CONF_DIR}/${MPD_NAME} /etc/rc.conf.d/${MPD_NAME}
If you are not using 6.3-RELEASE nor later, apply following patch and
rebuild your kernel:
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netgraph/ng_ksocket.c.diff?r1=1.59&r2=1.60
EOF