1#!%TCLSH% 2 3# 4# Take a "buildgraph" compatible input file, add Wifi sensors according 5# to our Osiris policy, and send to stdout a "buildgraph" compatible 6# file. 7# 8# Syntax: 9# ssidprobes (no argument) 10# 11# History : 12# 2008/07/29 : pda/boggia : conception 13# 14 15 16# 17# Main procedure 18# 19# History 20# 2008/07/29 : pda/boggia : design 21# 22 23 24proc usage {argv0} { 25 puts stderr "usage: $argv0" 26 exit 1 27} 28 29proc main {argv0 argv} { 30 31 # 32 # Check argument 33 # 34 35 if {[llength $argv] != 0} then { 36 usage $argv0 37 return 1 38 } 39 40 # 41 # Read informations on stdin 42 # 43 44 while {[gets stdin line] >= 0} { 45 # 46 # Output line first 47 # 48 49 puts stdout $line 50 51 # 52 # Keep only "node ... type L1" lines which have "radio" attributes 53 # 54 55 if {[regexp {^node (\S+) type L1 eq (\S+) .*radio [0-9]+ [0-9]+\s+(.*)} \ 56 $line \ 57 bidon \ 58 node eq ssids]} then { 59 60 # 61 # Loop through ssids 62 # 63 64 foreach {ssid name mode} $ssids { 65 if {$ssid eq "ssid"} then { 66 switch $mode { 67 open { 68 set id "M$eq.assocwifi.$name" 69 puts stdout "ssidprobe $id eq $eq iface $node ssidname $name mode assoc" 70 71 set id "M$eq.authwifi.$name" 72 puts stdout "ssidprobe $id eq $eq iface $node ssidname $name mode auth" 73 } 74 auth { 75 set id "M$eq.authwifi.$name" 76 puts stdout "ssidprobe $id eq $eq iface $node ssidname $name mode auth" 77 } 78 default { 79 puts stderr "Inconsistency: invalid ssid mode '$mode' in '$line'" 80 } 81 } 82 } else { 83 puts stderr "Inconsistency: bad ssid in '$line'" 84 } 85 } 86 } 87 } 88 89 return 0 90} 91 92exit [main $argv0 $argv] 93