Add support of VLAN configuration
[grml-network.git] / sbin / netcardconfig
index 52a1c6a..dca975a 100755 (executable)
@@ -157,9 +157,6 @@ scanwlan(){
   iwlist $DV scanning | grep "ESSID\|Quality" | sed -e "s/^.*ESSID:\"\|\"$//g" | tac > "$TMP"
   while read line
   do
-    # don't show up empty and hidden (containing "\x00") ESSIDs
-    echo $line | grep -q \\x00 && continue
-    [ -z "$line" ] && continue
     WARRAY[i++]=$line
   done < "$TMP"
   unset i
@@ -264,7 +261,7 @@ configiface() {
       while [ $RESCAN -eq 1 ]
       do
         scanwlan
-        $DIALOG --extra-button --extra-label "Rescan" --menu "$MESSAGEWSCAN2" 20 70 15 "${WARRAY[@] }" 2>"$TMP"
+        $DIALOG --extra-button --extra-label "Rescan" --menu "$MESSAGEWSCAN2" 20 70 15 "${WARRAY[@]}" 2>"$TMP"
         case $? in
           0)
             RESCAN=0
@@ -417,6 +414,16 @@ configiface() {
     writeiwline
   fi
 
+  # Configure VLAN on this interface?
+  if $DIALOG --yesno "$MESSAGE16" 8 45; then
+    $DIALOG --inputbox "$MESSAGE17 $DV" 10 45 2>"$TMP" || bailout 1
+    read -r VLAN <"$TMP" ; rm -f "$TMP"
+    if [ -n "$VLAN" ]; then
+      PDV=$DV
+      DV="vlan$VLAN"
+    fi
+  fi
+
   if $DIALOG --yesno "$MESSAGE2" 8 45; then
     if [ -w /etc/network/interfaces ]; then
       rm -f "$TMP"
@@ -424,7 +431,7 @@ configiface() {
         /^\W$/{if(blank==0){lastblank=1}else{lastblank=0}{blank=1}}
         /\w/{blank=0;lastblank=0}
         {if(!(found+lastblank)){print}}
-        END{print "iface '"$DV"' inet dhcp"}' \
+        END{print "iface '"$DV"' inet dhcp";if("'"$PDV"'"!=""){print "\tvlan-raw-device '"$PDV"'"}}' \
         /etc/network/interfaces >"$TMP"
       echo -e "$IWOURLINE" >> $TMP
       #echo -e "\n\n" >> $TMP
@@ -468,7 +475,7 @@ configiface() {
     if [ -w /etc/network/interfaces ]; then
       awk '/iface/{if(/'"$DV"'/){found=1}else{found=0}}
         {if(!found){print}}
-        END{print "\niface '"$DV"' inet static\n\taddress '"$IP"'\n\tnetmask '"$NM"'\n\tnetwork '"${IP%.*}.0"'";if("'"$BC"'"!=""){print "\tbroadcast '"$BC"'"};if("'"$DG"'"!=""){print "\tgateway '"$DG"'"};if("'"$NS"'"!=""){print "\tdns-nameservers '"$NS"'"};if("'"$IWOURLINE"'"!=""){print "'"$IWOURLINE"'"};print "\n"}' \
+        END{print "\niface '"$DV"' inet static\n\taddress '"$IP"'\n\tnetmask '"$NM"'\n\tnetwork '"${IP%.*}.0"'";if("'"$BC"'"!=""){print "\tbroadcast '"$BC"'"};if("'"$DG"'"!=""){print "\tgateway '"$DG"'"};if("'"$NS"'"!=""){print "\tdns-nameservers '"$NS"'"};if("'"$PDV"'"!=""){print "\tvlan-raw-device '"$PDV"'"};if("'"$IWOURLINE"'"!=""){print "'"$IWOURLINE"'"};print "\n"}' \
         /etc/network/interfaces >"$TMP"
 
       cat "$TMP" >/etc/network/interfaces
@@ -504,6 +511,8 @@ MESSAGE12="Adding Nameserver to /etc/resolv.conf:"
 MESSAGE13="Setup wireless options?"
 MESSAGE14="Failed to bring up the interface, would you like to reconfigure it?"
 MESSAGE15="Interface enabled, do you want it auto enabled at boot?"
+MESSAGE16="Configure VLAN on this interface?"
+MESSAGE17="Please enter VLAN id for"
 MESSAGEW0="No wireless network card found."
 MESSAGEW1="Configuration of wireless parameters for"
 MESSAGEW3="Please configure IP parameters of the interface first"