summaryrefslogtreecommitdiff
path: root/src/testing/netjail_stop_v2.sh
blob: 6e9fd1ccc83118c2a13444000a26e777bff37ebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
. "./../testing/netjail_core_v2.sh"
. "./../testing/topo.sh"

set -eu
set -x

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

filename=$1
PREFIX=$2

read_topology $filename

declare -A NODES
declare -A NODE_LINKS

netjail_bridge_name
NETWORK_NET=$RESULT

for X in $(seq $KNOWN); do
    netjail_node_name
	KNOWN_NODES[$X]=$RESULT
    netjail_node_link_bridge_name
    KNOWN_LINKS[$X]=$RESULT
    netjail_node_unlink_bridge ${KNOWN_LINKS[$X]}
	netjail_node_clear ${KNOWN_NODES[$X]}
done

for N in $(seq $GLOBAL_N); do
    netjail_node_name
	ROUTERS[$N]=$RESULT
    netjail_node_link_bridge_name
    NETWORK_LINKS[$N]=$RESULT
    netjail_bridge_name
    ROUTER_NETS[$N]=$RESULT
    netjail_node_link_bridge_name
    ROUTER_LINKS[$N]=$RESULT

    netjail_node_unlink_bridge ${ROUTER_LINKS[$N]}
    
	for M in $(seq $LOCAL_M); do
        netjail_node_name
		NODES[$N,$M]=$RESULT
        netjail_node_link_bridge_name
        NODE_LINKS[$N,$M]=$RESULT
		netjail_node_unlink_bridge ${NODE_LINKS[$N,$M]}
		netjail_node_clear ${NODES[$N,$M]}
	done

	
	netjail_bridge_clear ${ROUTER_NETS[$N]}
	netjail_node_unlink_bridge ${NETWORK_LINKS[$N]}
	netjail_node_clear ${ROUTERS[$N]}
done

netjail_bridge_clear $NETWORK_NET

echo "Done"