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 | |
| 113 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 114 | while not reader.is_empty() do |
Rich Lane | d03d015 | 2013-10-03 13:24:37 -0700 | [diff] [blame] | 115 | local action_len = reader.peek(2, 2):uint() |
| 116 | local child_reader = reader.slice(action_len) |
| 117 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 118 | local info = dissect_of_action(child_reader, child_subtree, version) |
Rich Lane | db927a0 | 2013-10-04 11:00:13 -0700 | [diff] [blame] | 119 | child_subtree:set_text(info) |
Rich Lane | d03d015 | 2013-10-03 13:24:37 -0700 | [diff] [blame] | 120 | end |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 121 | list:set_text("List of actions") |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 122 | end |
| 123 | |
| 124 | function read_list_of_port_desc_t(reader, version, subtree, field_name) |
Tomasz | c595d5b | 2013-11-02 13:30:32 -0700 | [diff] [blame^] | 125 | if reader.is_empty() then |
| 126 | return |
| 127 | end |
| 128 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 129 | list:set_text("List of port descriptions") |
| 130 | while not reader.is_empty() do |
| 131 | local port_desc_len = 64 |
| 132 | local child_reader = reader.slice(port_desc_len) |
| 133 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 134 | local info = dissect_of_port_desc(child_reader, child_subtree, version) |
| 135 | child_subtree:set_text(info) |
| 136 | end |
| 137 | end |
| 138 | |
| 139 | function read_list_of_flow_stats_entry_t(reader, version, subtree, field_name) |
| 140 | if reader.is_empty() then |
| 141 | return |
| 142 | end |
| 143 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 144 | list:set_text("List of flow stats entries") |
| 145 | while not reader.is_empty() do |
| 146 | local stats_len = reader.peek(0,2):uint() |
| 147 | local child_reader = reader.slice(stats_len) |
| 148 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 149 | local info = dissect_of_flow_stats_entry(child_reader, child_subtree, version) |
| 150 | child_subtree:set_text(info) |
| 151 | end |
| 152 | end |
| 153 | |
| 154 | function read_list_of_port_stats_entry_t(reader, version, subtree, field_name) |
| 155 | if reader.is_empty() then |
| 156 | return |
| 157 | end |
| 158 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 159 | list:set_text("List of port stats entries") |
| 160 | while not reader.is_empty() do |
| 161 | local stats_len = 112 |
| 162 | local child_reader = reader.slice(stats_len) |
| 163 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 164 | local info = dissect_of_port_stats_entry(child_reader, child_subtree, version) |
| 165 | child_subtree:set_text(info) |
| 166 | end |
| 167 | end |
| 168 | |
| 169 | function read_list_of_table_stats_entry_t(reader, version, subtree, field_name) |
| 170 | if reader.is_empty() then |
| 171 | return |
| 172 | end |
| 173 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 174 | list:set_text("List of table stats entries") |
| 175 | while not reader.is_empty() do |
| 176 | local stats_len = 24 |
| 177 | local child_reader = reader.slice(stats_len) |
| 178 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 179 | local info = dissect_of_table_stats_entry(child_reader, child_subtree, version) |
| 180 | child_subtree:set_text(info) |
| 181 | end |
| 182 | end |
| 183 | |
| 184 | function read_list_of_queue_stats_entry_t(reader, version, subtree, field_name) |
| 185 | if reader.is_empty() then |
| 186 | return |
| 187 | end |
| 188 | local list = subtree:add(fields[field_name], reader.peek_all(0)) |
| 189 | list:set_text("List of flow stats entries") |
| 190 | while not reader.is_empty() do |
| 191 | local stats_len = 40 |
| 192 | local child_reader = reader.slice(stats_len) |
| 193 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
| 194 | local info = dissect_of_queue_stats_entry(child_reader, child_subtree, version) |
| 195 | child_subtree:set_text(info) |
| 196 | end |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 197 | end |
| 198 | |
| 199 | function read_list_of_packet_queue_t(reader, version, subtree, field_name) |
| 200 | -- TODO |
Tomasz | c595d5b | 2013-11-02 13:30:32 -0700 | [diff] [blame^] | 201 | read_of_octets_t() |
| 202 | end |
| 203 | |
| 204 | function read_of_desc_str_t(reader, version, subtree, field_name) |
| 205 | read_scalar(reader, subtree, field_name, 256) |
| 206 | end |
| 207 | |
| 208 | function read_of_serial_num_t(reader, version, subtree, field_name) |
| 209 | read_scalar(reader, subtree, field_name, 32) |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 210 | end |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 211 | |
| 212 | function read_list_of_oxm_t(reader, version, subtree, field_name) |
| 213 | if reader.is_empty() then |
| 214 | return |
| 215 | end |
| 216 | local list_len = reader.peek(-2,2):uint() |
| 217 | local reader2 = reader.slice(list_len - 4) |
Rich Lane | 7493822 | 2013-10-25 14:35:16 -0700 | [diff] [blame] | 218 | local list = nil |
| 219 | if not reader2.is_empty() then |
| 220 | list = subtree:add(fields[field_name], reader2.peek_all(0)) |
Tomasz | a17a669 | 2013-10-30 17:34:18 -0700 | [diff] [blame] | 221 | list:set_text("List of matches") |
Rich Lane | 7493822 | 2013-10-25 14:35:16 -0700 | [diff] [blame] | 222 | end |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 223 | while not reader2.is_empty() do |
| 224 | local match_len = 4 + reader2.peek(3,1):uint() |
| 225 | local child_reader = reader2.slice(match_len) |
| 226 | local child_subtree = list:add(fields[field_name], child_reader.peek_all(0)) |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 227 | local info = dissect_of_oxm(child_reader, child_subtree, version) |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 228 | child_subtree:set_text(info) |
| 229 | end |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 230 | subtree:set_text("OXM") |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 231 | reader.skip_align() |
| 232 | end |
Tomasz | 71a30b3 | 2013-10-23 16:45:09 -0700 | [diff] [blame] | 233 | |
| 234 | function read_list_of_instruction_t(reader, version, subtree, field_name) |
| 235 | if reader.is_empty() then |
| 236 | return |
| 237 | end |
Tomasz | 742c2ba | 2013-10-24 22:35:45 -0700 | [diff] [blame] | 238 | local child_subtree = subtree:add(fields[field_name], reader.peek_all(0)) |
| 239 | local info = dissect_of_instruction(reader, child_subtree, version) |
| 240 | child_subtree:set_text("Instructions") |
Tomasz | 71a30b3 | 2013-10-23 16:45:09 -0700 | [diff] [blame] | 241 | end |
Tomasz | a17a669 | 2013-10-30 17:34:18 -0700 | [diff] [blame] | 242 | |
| 243 | function read_list_of_bucket_t(reader, version, subtree, field_name) |
| 244 | if reader.is_empty() then |
| 245 | return |
| 246 | end |
Tomasz | ffb3161 | 2013-10-31 09:53:03 -0700 | [diff] [blame] | 247 | local bucket_list_subtree = subtree:add(fields[field_name], reader.peek_all(0)) |
| 248 | bucket_list_subtree:set_text("List of buckets") |
| 249 | while not reader.is_empty() do |
| 250 | local bucket_len = reader.peek(0,2):uint() |
| 251 | local child_reader = reader.slice(bucket_len) |
| 252 | local child_subtree = bucket_list_subtree:add(fields[field_name], child_reader.peek_all(0)) |
| 253 | local info = dissect_of_bucket(child_reader, child_subtree, version) |
| 254 | child_subtree:set_text(info) |
| 255 | end |
Tomasz | a17a669 | 2013-10-30 17:34:18 -0700 | [diff] [blame] | 256 | end |
| 257 | |
| 258 | function read_of_oxm_t(reader, version, subtree, field_name) |
| 259 | if reader.is_empty() then |
| 260 | return |
| 261 | end |
| 262 | local child_subtree = subtree:add(fields[field_name], reader.peek_all(0)) |
| 263 | local info = dissect_of_oxm(reader, child_subtree, version) |
| 264 | child_subtree:set_text(info) |
| 265 | end |