util: Add function hexits_value() for parsing multiple hex digits.
[sliver-openvswitch.git] / tests / ovs-ofctl.at
1 AT_BANNER([ovs-ofctl])
2
3 AT_SETUP([ovs-ofctl parse-flows])
4 AT_DATA([flows.txt], [
5 # comment
6 tcp,tp_src=123,actions=flood
7 in_port=LOCAL dl_vlan=9 dl_src=00:0A:E4:25:6B:B0 actions=drop
8 arp,nw_src=192.168.0.1 actions=drop_spoofed_arp,NORMAL
9 udp dl_vlan_pcp=7 idle_timeout=5 actions=strip_vlan output:0
10 tcp,nw_src=192.168.0.3,tp_dst=80 actions=set_queue:37,output:1
11 udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
12 cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller
13 actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note
14 actions=drop
15 ])
16 AT_CHECK([ovs-ofctl parse-flows flows.txt], [0], [stdout])
17 AT_CHECK([[sed 's/ (xid=0x[0-9a-fA-F]*)//' stdout]], [0], [dnl
18 flow_mod: tcp,tp_src=123, ADD: actions=FLOOD
19 flow_mod: in_port=65534,dl_vlan=9,dl_src=00:0a:e4:25:6b:b0, ADD: actions=drop
20 flow_mod: arp,nw_src=192.168.0.1, ADD: actions=drop_spoofed_arp,NORMAL
21 flow_mod: udp,dl_vlan_pcp=7, ADD: idle:5 actions=strip_vlan,output:0
22 flow_mod: tcp,nw_src=192.168.0.3,tp_dst=80, ADD: actions=set_queue:37,output:1
23 flow_mod: udp,nw_src=192.168.0.3,tp_dst=53, ADD: actions=pop_queue,output:1
24 flow_mod: ADD: cookie:0x123456789abcdef hard:10 pri:60000 actions=CONTROLLER:65535
25 flow_mod: ADD: actions=note:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00
26 flow_mod: ADD: actions=drop
27 ])
28 AT_CLEANUP
29
30 AT_SETUP([ovs-ofctl parse-nx-match])
31 AT_KEYWORDS([nx-match])
32 AT_DATA([nx-match.txt], [dnl
33 <any>
34
35 # in port
36 NXM_OF_IN_PORT(0000)
37 NXM_OF_IN_PORT(fffe)
38
39 # eth dst
40 NXM_OF_ETH_DST(0002e30f80a4)
41 NXM_OF_ETH_DST_W(010000000000/010000000000)
42 NXM_OF_ETH_DST_W(000000000000/010000000000)
43 NXM_OF_ETH_DST_W(ffffffffffff/010000000000)
44 NXM_OF_ETH_DST_W(0002e30f80a4/ffffffffffff)
45 NXM_OF_ETH_DST_W(0002e30f80a4/feffffffffff)
46
47 # eth src
48 NXM_OF_ETH_SRC(020898456ddb)
49
50 # eth type
51 NXM_OF_ETH_TYPE(0800)
52 NXM_OF_ETH_TYPE(0800) NXM_OF_IN_PORT(0012)
53
54 # vlan tci
55 NXM_OF_VLAN_TCI(f009)
56 NXM_OF_VLAN_TCI(f009) NXM_OF_VLAN_TCI(f009)
57 NXM_OF_VLAN_TCI(0000)           # Packets without 802.1Q header.
58 NXM_OF_VLAN_TCI(3123)           # Packets with VID=123, PCP=1.
59 NXM_OF_VLAN_TCI(0123)           # Does not make sense.
60 NXM_OF_VLAN_TCI_W(1123/1fff)    # Packets with VID=123, any PCP.
61 NXM_OF_VLAN_TCI_W(f000/f000)    # Packets with any VID, PCP=7.
62 NXM_OF_VLAN_TCI_W(0000/e000)    # No 802.1Q or with VID=0 (not yet supported)
63
64 # IP TOS
65 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_TOS(f0)
66 NXM_OF_IP_TOS(f0)
67
68 # IP protocol
69 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01)
70 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(05)
71 NXM_OF_IP_PROTO(05)
72
73 # IP source
74 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_SRC(ac100014)
75 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_SRC_W(C0a80000/FFFF0000)
76 NXM_OF_ETH_TYPE(0806) NXM_OF_IP_SRC(ac100014)
77 NXM_OF_IP_SRC_W(C0D80000/FFFF0000)
78
79 # IP destination
80 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_DST(ac100014)
81 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_DST_W(C0a88012/FFFF0000)
82 NXM_OF_IP_DST(ac100014)
83 NXM_OF_ETH_TYPE(0806) NXM_OF_IP_DST_W(C0D80000/FFFF0000)
84
85 # TCP source port
86 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_TCP_SRC(4231)
87 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(07) NXM_OF_TCP_SRC(4231)
88
89 # TCP destination port
90 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_TCP_DST(4231)
91 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(07) NXM_OF_TCP_DST(4231)
92
93 # UDP source port
94 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(11) NXM_OF_UDP_SRC(8732)
95 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_UDP_SRC(7823)
96
97 # UDP destination port
98 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(11) NXM_OF_UDP_DST(1782)
99 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(02) NXM_OF_UDP_DST(1293)
100
101 # ICMP type
102 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01) NXM_OF_ICMP_TYPE(12)
103 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(00) NXM_OF_ICMP_TYPE(10)
104
105 # ICMP code
106 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01) NXM_OF_ICMP_CODE(12)
107 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(00) NXM_OF_ICMP_CODE(10)
108 NXM_OF_ETH_TYPE(0800) NXM_OF_ICMP_CODE(10)
109 NXM_OF_ICMP_CODE(00)
110
111 # ARP opcode
112 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(0001)
113 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(1111)
114 NXM_OF_ETH_TYPE(0000) NXM_OF_ARP_OP(0001)
115 NXM_OF_ARP_OP(0001)
116 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(0001) NXM_OF_ARP_OP(0001)
117
118 # ARP source
119 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_SPA(ac100014)
120 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_SPA_W(C0a81234/FFFFFF00)
121 NXM_OF_ETH_TYPE(0800) NXM_OF_ARP_SPA(ac100014)
122 NXM_OF_ARP_SPA_W(C0D8fedc/FFFF0000)
123
124 # ARP destination
125 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_TPA(ac100014)
126 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_TPA_W(C0a812fe/FFFFFF00)
127 NXM_OF_ETH_TYPE(0800) NXM_OF_ARP_TPA(ac100014)
128 NXM_OF_ARP_TPA_W(C0D80000/FFFF0000)
129
130 # Tunnel ID.
131 NXM_NX_TUN_ID(00000000abcdef01)
132
133 # Register 0.
134 NXM_NX_REG0(acebdf56)
135 NXM_NX_REG0_W(a0e0d050/f0f0f0f0)
136 ])
137 AT_CHECK([ovs-ofctl parse-nx-match < nx-match.txt], [0], [stdout])
138 AT_CHECK([cat stdout], [0], [dnl
139 <any>
140
141 # in port
142 NXM_OF_IN_PORT(fffe)
143 NXM_OF_IN_PORT(fffe)
144
145 # eth dst
146 NXM_OF_ETH_DST(0002e30f80a4)
147 NXM_OF_ETH_DST_W(010000000000/010000000000)
148 NXM_OF_ETH_DST_W(000000000000/010000000000)
149 NXM_OF_ETH_DST_W(010000000000/010000000000)
150 NXM_OF_ETH_DST(0002e30f80a4)
151 NXM_OF_ETH_DST_W(0002e30f80a4/feffffffffff)
152
153 # eth src
154 NXM_OF_ETH_SRC(020898456ddb)
155
156 # eth type
157 NXM_OF_ETH_TYPE(0800)
158 NXM_OF_IN_PORT(0012), NXM_OF_ETH_TYPE(0800) 
159
160 # vlan tci
161 NXM_OF_VLAN_TCI(f009)
162 nx_pull_match() returned error 44010105
163 NXM_OF_VLAN_TCI(0000)
164 NXM_OF_VLAN_TCI(3123)
165 nx_pull_match() returned error 44010100
166 NXM_OF_VLAN_TCI_W(1123/1fff)
167 NXM_OF_VLAN_TCI_W(f000/f000)
168 nx_pull_match() returned error 44010100
169
170 # IP TOS
171 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_TOS(f0)
172 nx_pull_match() returned error 44010104
173
174 # IP protocol
175 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01)
176 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(05)
177 nx_pull_match() returned error 44010104
178
179 # IP source
180 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_SRC(ac100014)
181 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_SRC_W(c0a80000/ffff0000)
182 nx_pull_match() returned error 44010104
183 nx_pull_match() returned error 44010104
184
185 # IP destination
186 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_DST(ac100014)
187 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_DST_W(c0a80000/ffff0000)
188 nx_pull_match() returned error 44010104
189 nx_pull_match() returned error 44010104
190
191 # TCP source port
192 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(06), NXM_OF_TCP_SRC(4231)
193 nx_pull_match() returned error 44010104
194
195 # TCP destination port
196 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(06), NXM_OF_TCP_DST(4231)
197 nx_pull_match() returned error 44010104
198
199 # UDP source port
200 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(11), NXM_OF_UDP_SRC(8732)
201 nx_pull_match() returned error 44010104
202
203 # UDP destination port
204 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(11), NXM_OF_UDP_DST(1782)
205 nx_pull_match() returned error 44010104
206
207 # ICMP type
208 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01), NXM_OF_ICMP_TYPE(12)
209 nx_pull_match() returned error 44010104
210
211 # ICMP code
212 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01), NXM_OF_ICMP_CODE(12)
213 nx_pull_match() returned error 44010104
214 nx_pull_match() returned error 44010104
215 nx_pull_match() returned error 44010104
216
217 # ARP opcode
218 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_OP(0001)
219 nx_pull_match() returned error 44010102
220 nx_pull_match() returned error 44010104
221 nx_pull_match() returned error 44010104
222 nx_pull_match() returned error 44010105
223
224 # ARP source
225 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_SPA(ac100014)
226 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_SPA_W(c0a81200/ffffff00)
227 nx_pull_match() returned error 44010104
228 nx_pull_match() returned error 44010104
229
230 # ARP destination
231 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_TPA(ac100014)
232 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_TPA_W(c0a81200/ffffff00)
233 nx_pull_match() returned error 44010104
234 nx_pull_match() returned error 44010104
235
236 # Tunnel ID.
237 NXM_NX_TUN_ID(00000000abcdef01)
238
239 # Register 0.
240 NXM_NX_REG0(acebdf56)
241 NXM_NX_REG0_W(a0e0d050/f0f0f0f0)
242 ])
243 AT_CLEANUP