3 ### TrIPE interface initialization script
4 ### suitable for Linux; other operating systems probably want something
7 ###----- Licensing notica ---------------------------------------------------
9 ### Redistribution, modification and use of this file is permitted without
12 ### This file is distributed in the hope that it will be useful,
13 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 : ${tripectl=$bindir/tripectl}
20 PATH
=/usr
/bin
:/usr
/sbin
:/bin
:/sbin
:$bindir
23 ###--------------------------------------------------------------------------
24 ### Collect arguments.
26 ## Collect the simple arguments.
28 echo >&2 "usage: $0 PEER IFNAME ADDR..."; exit 1
30 peer
=$1 ifname
=$2 family
=$3; shift 3
32 ## Parse the address family.
34 INET
,1) addr
=$1 port
=4070 ;;
35 INET
,2) addr
=$1 port
=$2 ;;
36 INET
,*) echo >&2 "$0: bad INET address"; exit 1 ;;
37 *) echo >&2 "$0: unknown address family $family"; exit 1 ;;
40 ###--------------------------------------------------------------------------
41 ### Set the interface name.
43 case "${P_IFNAME+set}" in
45 ip link
set "$ifname" name
"$P_IFNAME"
47 $tripectl setifname
"$peer" "$ifname"
51 ###--------------------------------------------------------------------------
52 ### Configure the point-to-point link.
55 case "${P_LADDR+set},${P_RADDR+set}" in
57 case "${P_MTU+set}" in
60 pathmtu
=$
(pathmtu
"$addr")
61 mtu
=$
(expr "$pathmtu" - 33 - $A_CIPHER_BLKSZ - $A_MAC_TAGSZ)
64 ifconfig
"$ifname" "$P_LADDR" pointopoint
"$P_RADDR" up mtu
"$mtu"
69 ###--------------------------------------------------------------------------
72 case "$ifup,${P_NETS+set}" in
74 for net
in $P_NETS; do
75 route add
-net
$net gw
"$P_RADDR" dev
"$ifname" metric
2
80 ###--------------------------------------------------------------------------
81 ### Maybe invoke a follow-on script.
83 case "${P_IFUPEXTRA+set}" in
89 ###--------------------------------------------------------------------------
90 ### Issue a notification that we've won.
92 $tripectl notify tripe-ifup configured
"$peer"
94 ###----- That's all, folks --------------------------------------------------