1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#!/bin/ksh
#
# Script to process a "gateways" file into the form needed by
# the Westerhof "ipip" daemon.
#
# gateway file on stdin, ipip format route file on stdout
echo "#\n# ipip route table built by $LOGNAME on `date`\n#\n# local routes"
echo "route 44.102.0.0 0xffff0000 local"
echo "route 44.135.83.0 0xffffff00 local"
echo "#\n# quasi-local routes - we're the open subnet relay"
# echo "route 44.130.48.0 0xffffff00 open 15.15.80.34"
echo "#\n# remote routes"
fgrep encap | grep "^route" | grep -v "141.217.1" | \
awk '{
split($3, s, "/")
split(s[1], n,".")
if (n[1] == "") n[1]="0"
if (n[2] == "") n[2]="0"
if (n[3] == "") n[3]="0"
if (n[4] == "") n[4]="0"
if (s[2] == "1") mask="0x80000000"
else if (s[2] == "2") mask="0xc0000000"
else if (s[2] == "3") mask="0xe0000000"
else if (s[2] == "4") mask="0xf0000000"
else if (s[2] == "5") mask="0xf8000000"
else if (s[2] == "6") mask="0xfc000000"
else if (s[2] == "7") mask="0xfe000000"
else if (s[2] == "8") mask="0xff000000"
else if (s[2] == "9") mask="0xff800000"
else if (s[2] == "10") mask="0xffc00000"
else if (s[2] == "11") mask="0xffe00000"
else if (s[2] == "12") mask="0xfff00000"
else if (s[2] == "13") mask="0xfff80000"
else if (s[2] == "14") mask="0xfffc0000"
else if (s[2] == "15") mask="0xfffe0000"
else if (s[2] == "16") mask="0xffff0000"
else if (s[2] == "17") mask="0xffff8000"
else if (s[2] == "18") mask="0xffffc000"
else if (s[2] == "19") mask="0xffffe000"
else if (s[2] == "20") mask="0xfffff000"
else if (s[2] == "21") mask="0xfffff800"
else if (s[2] == "22") mask="0xfffffc00"
else if (s[2] == "23") mask="0xfffffe00"
else if (s[2] == "24") mask="0xffffff00"
else if (s[2] == "25") mask="0xffffff80"
else if (s[2] == "26") mask="0xffffffc0"
else if (s[2] == "27") mask="0xffffffe0"
else if (s[2] == "28") mask="0xfffffff0"
else if (s[2] == "29") mask="0xfffffff8"
else if (s[2] == "30") mask="0xfffffffc"
else if (s[2] == "31") mask="0xfffffffe"
else if (s[2] == "32") mask="0xffffffff"
printf "route %s.%s.%s.%s %s open %s\n",n[1],n[2],n[3],n[4],mask,$5 }'
# printf "route %s %s open %s\n", subnet, mask, $5 }'
echo "#\n# the world via Brian's machine at UCSD - mirrorshades.ucsd.edu"
echo "route 0.0.0.0 0x00000000 open 128.54.16.18"
echo "#\n# the end"
|