blob: 0f38c169a0cfe96e82a5201ce43df2b2c7e05ecd [file] [log] [blame]
Rich Lane7708c182013-10-01 23:27:27 -07001:: # Copyright 2013, Big Switch Networks, Inc.
2:: #
3:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
4:: # the following special exception:
5:: #
6:: # LOXI Exception
7:: #
8:: # As a special exception to the terms of the EPL, you may distribute libraries
9:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
10:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
11:: # from the LoxiGen Libraries and the notice provided below is (i) included in
12:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
13:: # documentation for the LoxiGen Libraries, if distributed in binary form.
14:: #
15:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
16:: #
17:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
18:: # a copy of the EPL at:
19:: #
20:: # http://www.eclipse.org/legal/epl-v10.html
21:: #
22:: # Unless required by applicable law or agreed to in writing, software
23:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
25:: # EPL for the specific language governing permissions and limitations
26:: # under the EPL.
27
28function read_scalar(reader, subtree, field_name, length)
29 subtree:add(fields[field_name], reader.read(length))
30end
31
32function read_uint8_t(reader, version, subtree, field_name)
33 read_scalar(reader, subtree, field_name, 1)
34end
35
36function read_uint16_t(reader, version, subtree, field_name)
37 read_scalar(reader, subtree, field_name, 2)
38end
39
40function read_uint32_t(reader, version, subtree, field_name)
41 read_scalar(reader, subtree, field_name, 4)
42end
43
44function read_uint64_t(reader, version, subtree, field_name)
45 read_scalar(reader, subtree, field_name, 8)
46end
47
48function read_of_octets_t(reader, version, subtree, field_name)
Rich Lane4a868262013-10-02 15:19:44 -070049 if not reader.is_empty() then
50 subtree:add(fields[field_name], reader.read_all())
51 end
Rich Lane7708c182013-10-01 23:27:27 -070052end
53
54function read_list_of_hello_elem_t(reader, version, subtree, field_name)
55 -- TODO
56end
Rich Lanea6e650e2013-10-02 16:30:06 -070057
58function read_of_match_t(reader, version, subtree, field_name)
59 if version == 1 then
60 dissect_of_match_v1_v1(reader, subtree:add(fields[field_name]))
61 elseif version == 2 then
62 dissect_of_match_v2_v2(reader, subtree:add(fields[field_name]))
63 elseif version >= 3 then
64 dissect_of_match_v3_v3(reader, subtree:add(fields[field_name]))
65 end
66end
67
68function read_of_wc_bmap_t(reader, version, subtree, field_name)
69 if version <= 2 then
70 read_scalar(reader, subtree, field_name, 4)
71 else
72 read_scalar(reader, subtree, field_name, 8)
73 end
74end
75
76function read_of_port_no_t(reader, version, subtree, field_name)
77 if version == 1 then
78 read_scalar(reader, subtree, field_name, 2)
79 else
80 read_scalar(reader, subtree, field_name, 4)
81 end
82end
83
84function read_of_mac_addr_t(reader, version, subtree, field_name)
85 read_scalar(reader, subtree, field_name, 6)
86end
87
88function read_of_ipv4_t(reader, version, subtree, field_name)
89 read_scalar(reader, subtree, field_name, 4)
90end
91
Rich Lane5c56c3b2013-10-25 14:39:29 -070092function read_of_ipv6_t(reader, version, subtree, field_name)
93 read_scalar(reader, subtree, field_name, 16)
94end
95
Rich Lanea6e650e2013-10-02 16:30:06 -070096function read_of_fm_cmd_t(reader, version, subtree, field_name)
97 if version == 1 then
98 read_scalar(reader, subtree, field_name, 2)
99 else
100 read_scalar(reader, subtree, field_name, 1)
101 end
102end
103
Rich Lanea6e650e2013-10-02 16:30:06 -0700104function read_list_of_action_t(reader, version, subtree, field_name)
Rich Laned03d0152013-10-03 13:24:37 -0700105 if reader.is_empty() then
106 return
107 end
108
109 local list = subtree:add(fields[field_name], reader.peek_all(0))
110 while not reader.is_empty() do
Rich Laned03d0152013-10-03 13:24:37 -0700111 local action_len = reader.peek(2, 2):uint()
112 local child_reader = reader.slice(action_len)
113 local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
Tomasz742c2ba2013-10-24 22:35:45 -0700114 local info = dissect_of_action(child_reader, child_subtree, version)
Rich Lanedb927a02013-10-04 11:00:13 -0700115 child_subtree:set_text(info)
Rich Laned03d0152013-10-03 13:24:37 -0700116 end
Tomasz742c2ba2013-10-24 22:35:45 -0700117 list:set_text("List of actions")
Rich Lanea6e650e2013-10-02 16:30:06 -0700118end
119
120function read_list_of_port_desc_t(reader, version, subtree, field_name)
121 -- TODO
122end
123
124function read_list_of_packet_queue_t(reader, version, subtree, field_name)
125 -- TODO
126end
Tomasze0584352013-10-23 16:43:26 -0700127
128function read_list_of_oxm_t(reader, version, subtree, field_name)
129 if reader.is_empty() then
130 return
131 end
132 local list_len = reader.peek(-2,2):uint()
133 local reader2 = reader.slice(list_len - 4)
Rich Lane74938222013-10-25 14:35:16 -0700134 local list = nil
135 if not reader2.is_empty() then
136 list = subtree:add(fields[field_name], reader2.peek_all(0))
Tomasza17a6692013-10-30 17:34:18 -0700137 list:set_text("List of matches")
Rich Lane74938222013-10-25 14:35:16 -0700138 end
Tomasze0584352013-10-23 16:43:26 -0700139 while not reader2.is_empty() do
140 local match_len = 4 + reader2.peek(3,1):uint()
141 local child_reader = reader2.slice(match_len)
142 local child_subtree = list:add(fields[field_name], child_reader.peek_all(0))
Tomasz742c2ba2013-10-24 22:35:45 -0700143 local info = dissect_of_oxm(child_reader, child_subtree, version)
Tomasze0584352013-10-23 16:43:26 -0700144 child_subtree:set_text(info)
145 end
Tomasz742c2ba2013-10-24 22:35:45 -0700146 subtree:set_text("OXM")
Tomasze0584352013-10-23 16:43:26 -0700147 reader.skip_align()
148end
Tomasz71a30b32013-10-23 16:45:09 -0700149
150function read_list_of_instruction_t(reader, version, subtree, field_name)
151 if reader.is_empty() then
152 return
153 end
Tomasz742c2ba2013-10-24 22:35:45 -0700154 local child_subtree = subtree:add(fields[field_name], reader.peek_all(0))
155 local info = dissect_of_instruction(reader, child_subtree, version)
156 child_subtree:set_text("Instructions")
Tomasz71a30b32013-10-23 16:45:09 -0700157end
Tomasza17a6692013-10-30 17:34:18 -0700158
159function read_list_of_bucket_t(reader, version, subtree, field_name)
160 if reader.is_empty() then
161 return
162 end
163 local child_subtree = subtree:add(fields[field_name], reader.peek_all(0))
164 local info = dissect_of_bucket(reader, child_subtree, version)
165 child_subtree:set_text("Bucket")
166end
167
168function read_of_oxm_t(reader, version, subtree, field_name)
169 if reader.is_empty() then
170 return
171 end
172 local child_subtree = subtree:add(fields[field_name], reader.peek_all(0))
173 local info = dissect_of_oxm(reader, child_subtree, version)
174 child_subtree:set_text(info)
175end