Rich Lane | 7708c18 | 2013-10-01 23:27:27 -0700 | [diff] [blame] | 1 | :: # 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 | |
| 28 | function read_scalar(reader, subtree, field_name, length) |
| 29 | subtree:add(fields[field_name], reader.read(length)) |
| 30 | end |
| 31 | |
| 32 | function read_uint8_t(reader, version, subtree, field_name) |
| 33 | read_scalar(reader, subtree, field_name, 1) |
| 34 | end |
| 35 | |
| 36 | function read_uint16_t(reader, version, subtree, field_name) |
| 37 | read_scalar(reader, subtree, field_name, 2) |
| 38 | end |
| 39 | |
| 40 | function read_uint32_t(reader, version, subtree, field_name) |
| 41 | read_scalar(reader, subtree, field_name, 4) |
| 42 | end |
| 43 | |
| 44 | function read_uint64_t(reader, version, subtree, field_name) |
| 45 | read_scalar(reader, subtree, field_name, 8) |
| 46 | end |
| 47 | |
| 48 | function read_of_octets_t(reader, version, subtree, field_name) |
Rich Lane | 4a86826 | 2013-10-02 15:19:44 -0700 | [diff] [blame] | 49 | if not reader.is_empty() then |
| 50 | subtree:add(fields[field_name], reader.read_all()) |
| 51 | end |
Rich Lane | 7708c18 | 2013-10-01 23:27:27 -0700 | [diff] [blame] | 52 | end |
| 53 | |
| 54 | function read_list_of_hello_elem_t(reader, version, subtree, field_name) |
| 55 | -- TODO |
| 56 | end |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 57 | |
| 58 | function 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 |
| 66 | end |
| 67 | |
| 68 | function 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 |
| 74 | end |
| 75 | |
| 76 | function 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 |
| 82 | end |
| 83 | |
Tomasz | c595d5b | 2013-11-02 13:30:32 -0700 | [diff] [blame] | 84 | function read_of_port_name_t(reader, version, subtree, field_name) |
| 85 | read_scalar(reader, subtree, field_name, 16) |
| 86 | end |
| 87 | |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 88 | function read_of_mac_addr_t(reader, version, subtree, field_name) |
| 89 | read_scalar(reader, subtree, field_name, 6) |
| 90 | end |
| 91 | |
| 92 | function read_of_ipv4_t(reader, version, subtree, field_name) |
| 93 | read_scalar(reader, subtree, field_name, 4) |
| 94 | end |
| 95 | |
Rich Lane | 5c56c3b | 2013-10-25 14:39:29 -0700 | [diff] [blame] | 96 | function read_of_ipv6_t(reader, version, subtree, field_name) |
| 97 | read_scalar(reader, subtree, field_name, 16) |
| 98 | end |
| 99 | |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 100 | function read_of_fm_cmd_t(reader, version, subtree, field_name) |
| 101 | if version == 1 then |
| 102 | read_scalar(reader, subtree, field_name, 2) |
| 103 | else |
| 104 | read_scalar(reader, subtree, field_name, 1) |
| 105 | end |
| 106 | end |
| 107 | |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 108 | function read_list_of_action_t(reader, version, subtree, field_name) |
Rich Lane | d03d015 | 2013-10-03 13:24:37 -0700 | [diff] [blame] | 109 | if reader.is_empty() then |
| 110 | return |
| 111 | end |
| 112 | |
Tomasz | f53bf32 | 2013-11-02 13:31:14 -0700 | [diff] [blame] | 113 | local list_len = 0 |
| 114 | |
| 115 | if string.find(field_name,'packet_out') then |
| 116 | if version == 1 then |
| 117 | list_len = reader.peek(-2,2):uint() |
| 118 | else |
| 119 | list_len = reader.peek(-8,2):uint() |
| 120 | end |
| 121 | end |
| 122 | |
| 123 | local list = nil |
| 124 | local reader2 = nil |
| 125 | |
| 126 | if list_len == 0 then |
| 127 | list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 128 | reader2 = reader |
| 129 | else |
| 130 | list = subtree:add(fields[field_name], reader.peek(0, list_len)) |
| 131 | reader2 = reader.slice(list_len) |
| 132 | end |
| 133 | |
| 134 | while not reader2.is_empty() do |
| 135 | local action_len = reader2.peek(2, 2):uint() |
| 136 | local child_reader = reader2.slice(action_len) |
Rich Lane | d03d015 | 2013-10-03 13:24:37 -0700 | [diff] [blame] | 137 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 138 | local info = dissect_of_action(child_reader, child_subtree, version) |
Rich Lane | db927a0 | 2013-10-04 11:00:13 -0700 | [diff] [blame] | 139 | child_subtree:set_text(info) |
Rich Lane | d03d015 | 2013-10-03 13:24:37 -0700 | [diff] [blame] | 140 | end |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 141 | list:set_text("List of actions") |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 142 | end |
| 143 | |
| 144 | function read_list_of_port_desc_t(reader, version, subtree, field_name) |
Tomasz | c595d5b | 2013-11-02 13:30:32 -0700 | [diff] [blame] | 145 | if reader.is_empty() then |
| 146 | return |
| 147 | end |
| 148 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 149 | list:set_text("List of port descriptions") |
| 150 | while not reader.is_empty() do |
| 151 | local port_desc_len = 64 |
| 152 | local child_reader = reader.slice(port_desc_len) |
| 153 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 154 | local info = dissect_of_port_desc(child_reader, child_subtree, version) |
| 155 | child_subtree:set_text(info) |
| 156 | end |
| 157 | end |
| 158 | |
| 159 | function read_list_of_flow_stats_entry_t(reader, version, subtree, field_name) |
| 160 | if reader.is_empty() then |
| 161 | return |
| 162 | end |
| 163 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 164 | list:set_text("List of flow stats entries") |
| 165 | while not reader.is_empty() do |
| 166 | local stats_len = reader.peek(0,2):uint() |
| 167 | local child_reader = reader.slice(stats_len) |
| 168 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 169 | local info = dissect_of_flow_stats_entry(child_reader, child_subtree, version) |
| 170 | child_subtree:set_text(info) |
| 171 | end |
| 172 | end |
| 173 | |
| 174 | function read_list_of_port_stats_entry_t(reader, version, subtree, field_name) |
| 175 | if reader.is_empty() then |
| 176 | return |
| 177 | end |
| 178 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 179 | list:set_text("List of port stats entries") |
| 180 | while not reader.is_empty() do |
| 181 | local stats_len = 112 |
| 182 | local child_reader = reader.slice(stats_len) |
| 183 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 184 | local info = dissect_of_port_stats_entry(child_reader, child_subtree, version) |
| 185 | child_subtree:set_text(info) |
| 186 | end |
| 187 | end |
| 188 | |
| 189 | function read_list_of_table_stats_entry_t(reader, version, subtree, field_name) |
| 190 | if reader.is_empty() then |
| 191 | return |
| 192 | end |
| 193 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 194 | list:set_text("List of table stats entries") |
| 195 | while not reader.is_empty() do |
| 196 | local stats_len = 24 |
| 197 | local child_reader = reader.slice(stats_len) |
| 198 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 199 | local info = dissect_of_table_stats_entry(child_reader, child_subtree, version) |
| 200 | child_subtree:set_text(info) |
| 201 | end |
| 202 | end |
| 203 | |
| 204 | function read_list_of_queue_stats_entry_t(reader, version, subtree, field_name) |
| 205 | if reader.is_empty() then |
| 206 | return |
| 207 | end |
| 208 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 209 | list:set_text("List of flow stats entries") |
| 210 | while not reader.is_empty() do |
| 211 | local stats_len = 40 |
| 212 | local child_reader = reader.slice(stats_len) |
| 213 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 214 | local info = dissect_of_queue_stats_entry(child_reader, child_subtree, version) |
| 215 | child_subtree:set_text(info) |
| 216 | end |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 217 | end |
| 218 | |
| 219 | function read_list_of_packet_queue_t(reader, version, subtree, field_name) |
| 220 | -- TODO |
Tomasz | c595d5b | 2013-11-02 13:30:32 -0700 | [diff] [blame] | 221 | read_of_octets_t() |
| 222 | end |
| 223 | |
| 224 | function read_of_desc_str_t(reader, version, subtree, field_name) |
| 225 | read_scalar(reader, subtree, field_name, 256) |
| 226 | end |
| 227 | |
| 228 | function read_of_serial_num_t(reader, version, subtree, field_name) |
| 229 | read_scalar(reader, subtree, field_name, 32) |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 230 | end |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 231 | |
| 232 | function read_list_of_oxm_t(reader, version, subtree, field_name) |
| 233 | if reader.is_empty() then |
| 234 | return |
| 235 | end |
| 236 | local list_len = reader.peek(-2,2):uint() |
| 237 | local reader2 = reader.slice(list_len - 4) |
Rich Lane | 7493822 | 2013-10-25 14:35:16 -0700 | [diff] [blame] | 238 | local list = nil |
| 239 | if not reader2.is_empty() then |
| 240 | list = subtree:add(fields[field_name], reader2.peek_all(0)) |
Tomasz | a17a669 | 2013-10-30 17:34:18 -0700 | [diff] [blame] | 241 | list:set_text("List of matches") |
Rich Lane | 7493822 | 2013-10-25 14:35:16 -0700 | [diff] [blame] | 242 | end |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 243 | while not reader2.is_empty() do |
| 244 | local match_len = 4 + reader2.peek(3,1):uint() |
| 245 | local child_reader = reader2.slice(match_len) |
| 246 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 247 | local info = dissect_of_oxm(child_reader, child_subtree, version) |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 248 | child_subtree:set_text(info) |
| 249 | end |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 250 | subtree:set_text("OXM") |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 251 | reader.skip_align() |
| 252 | end |
Tomasz | 71a30b3 | 2013-10-23 16:45:09 -0700 | [diff] [blame] | 253 | |
| 254 | function read_list_of_instruction_t(reader, version, subtree, field_name) |
| 255 | if reader.is_empty() then |
| 256 | return |
| 257 | end |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 258 | local child_subtree = subtree:add(fields[field_name], reader.peek_all(0)) |
| 259 | local info = dissect_of_instruction(reader, child_subtree, version) |
| 260 | child_subtree:set_text("Instructions") |
Tomasz | 71a30b3 | 2013-10-23 16:45:09 -0700 | [diff] [blame] | 261 | end |
Tomasz | a17a669 | 2013-10-30 17:34:18 -0700 | [diff] [blame] | 262 | |
| 263 | function read_list_of_bucket_t(reader, version, subtree, field_name) |
| 264 | if reader.is_empty() then |
| 265 | return |
| 266 | end |
Tomasz | ffb3161 | 2013-10-31 09:53:03 -0700 | [diff] [blame] | 267 | local bucket_list_subtree = subtree:add(fields[field_name], reader.peek_all(0)) |
| 268 | bucket_list_subtree:set_text("List of buckets") |
| 269 | while not reader.is_empty() do |
| 270 | local bucket_len = reader.peek(0,2):uint() |
| 271 | local child_reader = reader.slice(bucket_len) |
| 272 | local child_subtree = bucket_list_subtree:add(fields[field_name], child_reader.peek_all(0)) |
| 273 | local info = dissect_of_bucket(child_reader, child_subtree, version) |
| 274 | child_subtree:set_text(info) |
| 275 | end |
Tomasz | a17a669 | 2013-10-30 17:34:18 -0700 | [diff] [blame] | 276 | end |
| 277 | |
| 278 | function read_of_oxm_t(reader, version, subtree, field_name) |
| 279 | if reader.is_empty() then |
| 280 | return |
| 281 | end |
| 282 | local child_subtree = subtree:add(fields[field_name], reader.peek_all(0)) |
| 283 | local info = dissect_of_oxm(reader, child_subtree, version) |
| 284 | child_subtree:set_text(info) |
| 285 | end |