Ifconfig uses the MAC for machine identification
authorRonald G. Minnich <rminnich@gmail.com>
Tue, 7 Oct 2014 21:26:06 +0000 (21:26 +0000)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 7 Oct 2014 22:46:38 +0000 (15:46 -0700)
Keys on MAC address.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Git-fu-d-by: brho
kern/kfs/ifconfig

index 4b13d3f..3beaf16 100755 (executable)
@@ -1,9 +1,17 @@
 #!/bin/ash
 
-if [ "$#" -eq "1" ]
-then
-       MACHINE=$1
-fi
+# known good.
+hossinMAC=00241d1054e1
+c89MAC=001e67652333
+altdraMAC=525400b0c2ec
+qemuMAC=525400123456
+tower1MAC=00032d196d88
+tower2MAC=00032d196ddd
+tower3MAC=00032d196d46
+tower4MAC=00032d196db0
+tower5MAC=00032d196daa
+
+MAC=`cat '#l/ether0/addr'`
 
 #bind -a '#I' /net
 #bind -a '#l0' /net
@@ -38,7 +46,35 @@ mask=255.255.255.0
 remote=10.0.2.0
 route=10.0.2.2
 
-if [ "x$MACHINE" = "xc89" ]
+if [ "$MAC" = "$qemuMAC" ]
+then
+    echo "Welcome to QEMU!"
+fi
+
+# the tower of ... tower
+# all defaults are fine.
+if [ "$MAC" = "$tower1MAC" ]
+then
+    me=10.0.2.15
+fi
+if [ "$MAC" = "$tower2MAC" ]
+then
+    me=10.0.2.16
+fi
+if [ "$MAC" = "$tower3MAC" ]
+then
+    me=10.0.2.17
+fi
+if [ "$MAC" = "$tower4MAC" ]
+then
+    me=10.0.2.18
+fi
+if [ "$MAC" = "$tower5MAC" ]
+then
+    me=10.0.2.19
+fi
+
+if [ "$MAC" = "$c89MAC" ]
 then
        # c89's config.  use c96 for eth0 (.196).  if you want, we can also use
        # c97 (.197):
@@ -52,7 +88,7 @@ then
        NIC="0"
 fi
 
-if [ "x$MACHINE" = "xaltdra" ]
+if [ "$MAC" = "$altdraMAC" ]
 then
        # yuzhu's soda hall bridged vm
        me=128.32.37.37
@@ -61,7 +97,7 @@ then
        route=128.32.37.1
 fi
 
-if [ "x$MACHINE" = "xhossin" ]
+if [ "$MAC" = "$hossinMAC" ]
 then
        # brho's soda hall desktop
        me=128.32.37.46
@@ -112,11 +148,11 @@ echo "bind loopback /dev/null " > /net/ipifc/$i/ctl
 echo "add 127.0.0.1 255.0.0.0 127.0.0.0 " > /net/ipifc/$i/ctl
 
 cs&
-if [ ! -e "#s/cs" ] 
+if [ ! -e "#s/cs" ]
 then
        echo "cs hasn't created #s/cs yet, sleeping until it does..."
-       until [ -e "#s/cs" ] 
-       do 
+       until [ -e "#s/cs" ]
+       do
                usleep 1000
        done
 fi