diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-03-26 14:34:32 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-03-26 14:34:32 +0000 |
commit | 262c72348dc591c0731e955a45f2a172c192ff77 (patch) | |
tree | f215b5c16e6eddae235e5093711b0ff9e7f0d257 /etc | |
parent | 7fce51bb872afa6c152868f7d14ba188bf132cb6 (diff) |
Add bridge interface handling
Diffstat (limited to 'etc')
-rw-r--r-- | etc/netstart | 101 |
1 files changed, 58 insertions, 43 deletions
diff --git a/etc/netstart b/etc/netstart index 92d22f7d148..0ab94f24cb0 100644 --- a/etc/netstart +++ b/etc/netstart @@ -1,6 +1,6 @@ #!/bin/sh - # -# $OpenBSD: netstart,v 1.46 1999/03/01 05:04:24 millert Exp $ +# $OpenBSD: netstart,v 1.47 1999/03/26 14:34:31 niklas Exp $ # Returns true if $1 contains only alphanumerics isalphanumeric() { @@ -54,7 +54,12 @@ route -n add -net 127 127.0.0.1 -reject # # OR # -# dhcp +# dhcp +# +# OR +# +# bridge +# brconfig-arguments [ several lines if needed ] # # addr_family is the address family of the interface, generally inet # hostname is the host name that belongs to the interface, in /etc/hosts. @@ -66,55 +71,65 @@ route -n add -net 127 127.0.0.1 -reject # has a "destination" (i.e. it's a point-to-point link, like SLIP). # dest_addr is the hostname of the other end of the link, in /etc/hosts # +# the only required contents of the file in this mode are the addr_family field +# and the hostname. +# # dhcp is simply the string "dhcp" (no quotes, though) if the interface # is to be configured using DHCP. See dhclient(8) and dhclient.conf(5) # for details. # -# the only required contents of the file are the addr_family field -# and the hostname. - -( - for hn in /etc/hostname.*; do - # Strip off /etc/hostname. prefix - if=${hn#/etc/hostname.} - - # Interface names must be alphanumeric only. We check to avoid - # configuring backup or temp files, and to catch the "*" case. - if ! isalphanumeric "$if"; then - continue - fi - - # Now parse the hostname.* file - ( - read af name mask bcaddr extras +# bridge is the string "bridge" (still no quotes). Bridge interfaces +# are just configured "up" and then brconfig(8) is called for each +# line of arguments following this first line. + +for hn in /etc/hostname.*; do + # Strip off /etc/hostname. prefix + if=${hn#/etc/hostname.} + + # Interface names must be alphanumeric only. We check to avoid + # configuring backup or temp files, and to catch the "*" case. + if ! isalphanumeric "$if"; then + continue + fi + + # Now parse the hostname.* file + { + read af name mask bcaddr extras + + # $af can be either "bridge", "dhcp", "up" or an address family. + case "$af" in + "bridge") + ifconfig $if up + cmd=`sed "s/\(.*\)/brconfig $if \1;/"` + ;; + "dhcp") + ifconfig $if $extras down + cmd="/sbin/dhclient $if" + ;; + "up") + # The only one of these guaranteed to be set is $if + cmd="ifconfig $if $name $mask $bcaddr $extras up" + ;; + *) read dt dtaddr + if [ ! -n "$name" ]; then + echo "/etc/hostname.$if: invalid network configuration file" + exit + fi - # $af can be either "up", "dhcp", or an address family. - if [ "$af" = "up" ]; then - # The only one of these guaranteed to be set is $if - ifconfig $if $name $mask $bcaddr $extras up - elif [ "$af" = "dhcp" ]; then - ifconfig $if $extras down - cmd="/sbin/dhclient $if"; - else - if [ ! -n "$name" ]; then - echo "/etc/hostname.$if: invalid network configuration file" - exit - fi - - cmd="ifconfig $if $af $name " - if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi - if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi - if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then - cmd="$cmd broadcast $bcaddr"; - fi - cmd="$cmd $extras"; + cmd="ifconfig $if $af $name " + if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi + if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi + if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then + cmd="$cmd broadcast $bcaddr"; fi + cmd="$cmd $extras"; + ;; + esac - $cmd - ) < /etc/hostname.$if - done -) + eval "$cmd" + } < /etc/hostname.$if +done # /etc/mygate, if it exists, contains the name of my gateway host # that name must be in /etc/hosts. |