--- _startklips.old	2008-05-17 15:41:46.000000000 +0200
+++ _startklips	2008-05-17 15:52:10.000000000 +0200
@@ -104,23 +104,35 @@
 
 	# figure out ifconfig for interface
 	addr=
-	eval `ifconfig $phys |
-		awk '$1 == "inet" && $2 ~ /^addr:/ && $NF ~ /^Mask:/ {
-			gsub(/:/, " ", $0)
-			print "addr=" $3
-			other = $5
-			if ($4 == "Bcast")
-				print "type=broadcast"
-			else if ($4 == "P-t-P")
-				print "type=pointopoint"
-			else if (NF == 5) {
-				print "type="
-				other = ""
-			} else
-				print "type=unknown"
-			print "otheraddr=" other
-			print "mask=" $NF
-		}'`
+	eval `ip addr show $phys | awk '$3 ~ /BROADCAST|POINTOPOINT/ { 
+				if ($3 ~ /BROADCAST/) 
+					print "type=broadcast"; 
+				else if ($3 ~ /POINTOPOINT/) 
+					print "type=pointopoint";
+				else {
+					print "type=";
+				}
+			}'`
+			
+	if [ "$type" == "broadcast" ]; then
+		eval `ip addr show $phys | awk '$1 == "inet"  { gsub(/\//, " "); 
+					print "addr=" $2;
+					print "mask=" $3;
+					print "otheraddr=" $5;
+					}'`
+	elif [ "$type" == "pointopoint" ]; then
+		eval `ip addr show $phys | awk '$1 == "inet"  { gsub(/\//, " "); 
+					print "addr=" $2;
+					print "mask=" $5;
+					print "otheraddr=" $4;
+					}'`
+	else
+		type="unknown"
+		otheraddr=
+	fi
+	
+	eval `whatmask /$mask | awk -F': ' '$1 ~ /^Netmask =/ { print "mask=" $2 }'`
+	
 	if test " $addr" = " "
 	then
 		echo "unable to determine address of \`$phys'"
@@ -129,7 +141,7 @@
 	if test " $type" = " unknown"
 	then
 		echo "\`$phys' is of an unknown type"
-		exit 1
+		exit 1 
 	fi
 	if test " $omtu" != " "
 	then
@@ -223,10 +235,10 @@
 	fi
 	next=`netstat -nr |
 		awk '$1 == "0.0.0.0" && $3 == "0.0.0.0" { print $2; exit 0 }'`
-	if [ "$next" = "0.0.0.0" ] ; then
-		next=`ip addr list $phys | grep -E "^ +inet6*.*scope global $phys" |
-			awk '{ if($3=="peer")print $4; else print $2 }' | awk -F / '{ print $1 }'`
-	fi
+#	if [ "$next" = "0.0.0.0" ] ; then
+#		next=`ip addr list $phys | grep -E "^ +inet6*.*scope global $phys" |
+#			awk '{ if($3=="peer")print $4; else print $2 }' | awk -F / '{ print $1 }'`
+#	fi
 	klipsinterface "ipsec0=$phys" $next
 }
 
