aboutsummaryrefslogtreecommitdiff
path: root/src/testing/topo.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/topo.sh')
-rwxr-xr-xsrc/testing/topo.sh95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/testing/topo.sh b/src/testing/topo.sh
new file mode 100755
index 000000000..090c3053f
--- /dev/null
+++ b/src/testing/topo.sh
@@ -0,0 +1,95 @@
1#!/bin/bash
2
3declare -A K_PLUGIN
4declare -A R_TCP
5declare -A R_UDP
6declare -A P_PLUGIN
7
8extract_attributes()
9{
10 line_key=$1
11 line=$2
12
13 if [ "$line_key" = "P" ]
14 then
15 n=$(echo $line|cut -d \| -f 1|awk -F: '{print $2}')
16 echo $n
17 m=$(echo $line|cut -d \| -f 1|awk -F: '{print $3}')
18 echo $m
19 else
20 number=$(echo $line|cut -d \| -f 1| cut -c 2-|cut -d : -f 2 )
21 echo $number
22 fi
23
24
25 nf=$(echo $line|awk -F: '{print NF}')
26 for ((i=2;i<=$nf;i++))
27 do
28 entry=$(echo $line |awk -v i=$i -F\| '{print $i}')
29 key=$(echo $entry|cut -d { -f 2|cut -d } -f 1|cut -d : -f 1)
30 value=$(echo $entry|cut -d { -f 2|cut -d } -f 1|cut -d : -f 2)
31 if [ "$key" = "tcp_port" ]
32 then
33 echo tcp port: $value
34 R_TCP[$number]=$value
35 elif [ "$key" = "udp_port" ]
36 then
37 echo udp port: $value
38 R_UDP[$number]=$value
39 elif [ "$key" = "plugin" ]
40 then
41 echo plugin: $value
42 echo $line_key
43 if [ "$line_key" = "P" ]
44 then
45 P_PLUGIN[$n,$m]=$value
46 echo $n $m ${P_PLUGIN[$n,$m]}
47 elif [ "$line_key" = "K" ]
48 then
49 K_PLUGIN[$number]=$value
50 fi
51 fi
52 done
53}
54
55read_topology(){
56
57local filename=$1
58while read line; do
59# reading each line
60 echo $line
61 key=$(cut -c -1 <<< $line)
62 if [ "$key" = "M" ]
63 then
64 LOCAL_M=$(cut -d : -f 2 <<< $line)
65 echo $LOCAL_M
66 elif [ "$key" = "N" ]
67 then
68 GLOBAL_N=$(cut -d : -f 2 <<< $line)
69 echo $GLOBAL_N
70 elif [ "$key" = "X" ]
71 then
72 KNOWN=$(cut -d : -f 2 <<< $line)
73 echo $KNOWN
74 elif [ "$key" = "T" ]
75 then
76 PLUGIN=$(cut -d : -f 2 <<< $line)
77 echo $PLUGIN
78 elif [ "$key" = "K" ]
79 then
80 echo know node
81 extract_attributes $key $line
82 elif [ "$key" = "R" ]
83 then
84 echo router
85 extract_attributes $key $line
86 elif [ "$key" = "P" ]
87 then
88 echo node
89 extract_attributes $key $line
90 fi
91done < $filename
92}
93
94
95