#! /bin/sh ### ### TrIPE interface initialization script ### suitable for Linux; other operating systems probably want something ### similar ###----- Licensing notica --------------------------------------------------- ### ### Redistribution, modification and use of this file is permitted without ### limitation. ### ### This file 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. set -e : ${bindir=@bindir@} : ${tripectl=$bindir/tripectl} PATH=/usr/bin:/usr/sbin:/bin:/sbin:$bindir export PATH TRIPEDIR ###-------------------------------------------------------------------------- ### Collect arguments. ## Collect the simple arguments. if [ $# -lt 3 ]; then echo >&2 "usage: $0 PEER IFNAME ADDR..."; exit 1 fi peer=$1 ifname=$2 family=$3; shift 3 ## Parse the address family. case "$family,$#" in INET,1) addr=$1 port=4070 ;; INET,2) addr=$1 port=$2 ;; INET,*) echo >&2 "$0: bad INET address"; exit 1 ;; *) echo >&2 "$0: unknown address family $family"; exit 1 ;; esac ###-------------------------------------------------------------------------- ### Set the interface name. case "${P_IFNAME+set}" in set) ip link set "$ifname" name "$P_IFNAME" ifname=$P_IFNAME $tripectl setifname "$peer" "$ifname" ;; esac ###-------------------------------------------------------------------------- ### Configure the point-to-point link. ifup=no case "${P_LADDR+set},${P_RADDR+set}" in set,set) case "${P_MTU+set}" in set) mtu=$P_MTU;; *) pathmtu=$(pathmtu "$addr") mtu=$(expr "$pathmtu" - 33 - $A_CIPHER_BLKSZ - $A_MAC_TAGSZ) ;; esac ifconfig "$ifname" "$P_LADDR" pointopoint "$P_RADDR" up mtu "$mtu" ifup=yes ;; esac ###-------------------------------------------------------------------------- ### Set up routing. case "$ifup,${P_NETS+set}" in yes,set) for net in $P_NETS; do route add -net $net gw "$P_RADDR" dev "$ifname" metric 2 done ;; esac ###-------------------------------------------------------------------------- ### Maybe invoke a follow-on script. case "${P_IFUPEXTRA+set}" in set) eval "$P_IFUPEXTRA" ;; esac ###-------------------------------------------------------------------------- ### Issue a notification that we've won. $tripectl notify tripe-ifup configured "$peer" ###----- That's all, folks --------------------------------------------------