]> git.entuzijast.net Git - imunes.git/commitdiff
zamijenio ifconfig-l s internim parserom (just for kicks)
authorJosip Rodin <joy@numa-ubuntu-vm.(none)>
Sun, 13 Sep 2009 22:45:08 +0000 (00:45 +0200)
committerJosip Rodin <joy@numa-ubuntu-vm.(none)>
Sun, 13 Sep 2009 22:45:08 +0000 (00:45 +0200)
ifconfig-l [deleted file]
linux/exec.tcl

diff --git a/ifconfig-l b/ifconfig-l
deleted file mode 100755 (executable)
index 37c6ae6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-# ifconfig -l na BSD-u
-
-ip link show | awk '/^[0-9]+: / { a=$2; gsub(":", "", a); printf "%s ", a }'; echo
-
index 70c85a5e6a70a0b295269bbb4784f6043b9f1901..1d205bc7d637b591e4dff2cd7f9492747bfb9543 100755 (executable)
@@ -112,11 +112,25 @@ proc setOperMode { mode } {
 
     # Verify that links to external interfaces are properly configured
     if { $mode == "exec" } {
-       # space-separated popis interfacea (BSD ifconfig -l)
-       set extifcs [nexec ./ifconfig-l]
-       # izbaci loopback interface iz popisa (BSD lo)
-       set extifcs \
-           [lreplace $extifcs [lsearch $extifcs lo] [lsearch $extifcs lo]]
+       # popis interfacea (BSD ifconfig -l)
+       set extifcs_p [open "| ip link show"]
+       set extifcs_s [read $extifcs_p]
+       if { [catch {close $extifcs_p} err] } {
+           puts "ip link show failed: $err"
+       }
+       set extifcs_o [split $extifcs_s \n]
+       set extifcs {}
+       foreach iplink_line $extifcs_o {
+           if { [ regexp -- {^\d+: ([^:]+): } $iplink_line -> extif ] == 0 } {
+               continue
+           }
+               # izbaci loopback interface iz popisa (BSD lo0)
+               if { $extif == "lo" } {
+                       continue
+               }
+               #puts "external interface found: $extif"
+           lappend extifcs $extif
+       }
        foreach node $node_list {
            if { [nodeType $node] == "rj45" } {
                set i [lsearch $extifcs [getNodeName $node]]