-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.click
More file actions
197 lines (159 loc) · 4.67 KB
/
router.click
File metadata and controls
197 lines (159 loc) · 4.67 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// Router with three interfaces
// The input/output configuration is as follows:
//
// Input:
// [0]: packets received on the 192.168.1.0/24 network
// [1]: packets received on the 192.168.2.0/24 network
// [2]: packets received on the 192.168.3.0/24 network
//
// Output:
// [0]: packets sent to the 192.168.1.0/24 network
// [1]: packets sent to the 192.168.2.0/24 network
// [2]: packets sent to the 192.168.3.0/24 network
// [3]: packets destined for the router itself
elementclass Router {
$server_address, $client1_address, $client2_address |
// Shared IP input path and routing table
ip :: Strip(14)
-> CheckIPHeader
-> tigmp :: TeeIGMP
-> rt :: StaticIPLookup(
$server_address:ip/32 0,
$client1_address:ip/32 0,
$client2_address:ip/32 0,
$server_address:ipnet 1,
$client1_address:ipnet 2,
$client2_address:ipnet 3);
//192.168.2.0/24 network
tigmp[1]
-> i1 :: IGMPq($client1_address, QQIC 10, MRC 50)
-> EtherEncap(0x0800, $client1_address, multicast_client_address)
-> [1]output;
i1[1] //only IGMP packets should pass here
-> IPEncap(2, $client1_address, multicast_query, TTL 1, TOS 0xc0)
-> StoreData(0, F) //change IP header length to 6 for options
-> SetIPChecksum
-> EtherEncap(0x0800, $client1_address, multicast_query)
-> IGMPsq //adjusts the destination address iff group specific query
-> [1]output;
//192.168.3.0/24 network
tigmp[2]
-> i2 :: IGMPq($client2_address, QQIC 10)
-> EtherEncap(0x0800, $client2_address, multicast_client_address)
-> [2]output;
i2[1] //only IGMP packets should pass here
-> IPEncap(2, $client2_address, multicast_query, TTL 1, TOS 0xc0)
-> StoreData(0, F) //change IP header length to 6 for options
-> SetIPChecksum
-> EtherEncap(0x0800, $client2_address, multicast_query)
-> IGMPsq //adjusts the destination address iff group specific query
-> [2]output;
// ARP responses are copied to each ARPQuerier and the host.
arpt :: Tee (3);
// Input and output paths for interface 0
input
-> HostEtherFilter($server_address)
-> server_class :: Classifier(12/0806 20/0001, 12/0806 20/0002, -)
-> ARPResponder($server_address)
-> output;
server_arpq :: ARPQuerier($server_address)
-> output;
server_class[1]
-> arpt
-> [1]server_arpq;
server_class[2]
-> Paint(1)
-> ip;
// Input and output paths for interface 1
input[1]
-> HostEtherFilter($client1_address)
-> client1_class :: Classifier(12/0806 20/0001, 12/0806 20/0002, -)
-> ARPResponder($client1_address)
-> [1]output;
client1_arpq :: ARPQuerier($client1_address)
-> [1]output;
client1_class[1]
-> arpt[1]
-> [1]client1_arpq;
client1_class[2]
-> Paint(2)
-> ip;
// Input and output paths for interface 2
input[2]
-> HostEtherFilter($client2_address)
-> client2_class :: Classifier(12/0806 20/0001, 12/0806 20/0002, -)
-> ARPResponder($client2_address)
-> [2]output;
client2_arpq :: ARPQuerier($client2_address)
-> [2]output;
client2_class[1]
-> arpt[2]
-> [1]client2_arpq;
client2_class[2]
-> Paint(3)
-> ip;
// Local delivery
rt[0]
-> [3]output
// Forwarding paths per interface
rt[1]
-> DropBroadcasts
-> server_paint :: PaintTee(1)
-> server_ipgw :: IPGWOptions($server_address)
-> FixIPSrc($server_address)
-> server_ttl :: DecIPTTL
-> server_frag :: IPFragmenter(1500)
-> server_arpq;
server_paint[1]
-> ICMPError($server_address, redirect, host)
-> rt;
server_ipgw[1]
-> ICMPError($server_address, parameterproblem)
-> rt;
server_ttl[1]
-> ICMPError($server_address, timeexceeded)
-> rt;
server_frag[1]
-> ICMPError($server_address, unreachable, needfrag)
-> rt;
rt[2]
-> DropBroadcasts
-> client1_paint :: PaintTee(2)
-> client1_ipgw :: IPGWOptions($client1_address)
-> FixIPSrc($client1_address)
-> client1_ttl :: DecIPTTL
-> client1_frag :: IPFragmenter(1500)
-> client1_arpq;
client1_paint[1]
-> ICMPError($client1_address, redirect, host)
-> rt;
client1_ipgw[1]
-> ICMPError($client1_address, parameterproblem)
-> rt;
client1_ttl[1]
-> ICMPError($client1_address, timeexceeded)
-> rt;
client1_frag[1]
-> ICMPError($client1_address, unreachable, needfrag)
-> rt;
rt[3]
-> DropBroadcasts
-> client2_paint :: PaintTee(2)
-> client2_ipgw :: IPGWOptions($client2_address)
-> FixIPSrc($client2_address)
-> client2_ttl :: DecIPTTL
-> client2_frag :: IPFragmenter(1500)
-> client2_arpq;
client2_paint[1]
-> ICMPError($client2_address, redirect, host)
-> rt;
client2_ipgw[1]
-> ICMPError($client2_address, parameterproblem)
-> rt;
client2_ttl[1]
-> ICMPError($client2_address, timeexceeded)
-> rt;
client2_frag[1]
-> ICMPError($client2_address, unreachable, needfrag)
-> rt;
}