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 |
Tomasz | a0dfec0 | 2013-12-14 21:51:04 -0800 | [diff] [blame] | 60 | dissect_of_match_v1_v1(reader, subtree:add("of_match")) |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 61 | elseif version == 2 then |
Tomasz | a0dfec0 | 2013-12-14 21:51:04 -0800 | [diff] [blame] | 62 | dissect_of_match_v2_v2(reader, subtree:add("of_match")) |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 63 | elseif version >= 3 then |
Tomasz | a0dfec0 | 2013-12-14 21:51:04 -0800 | [diff] [blame] | 64 | dissect_of_match_v3_v3(reader, subtree:add("of_match")) |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 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 | |
Tomasz | c595d5b | 2013-11-02 13:30:32 -0700 | [diff] [blame] | 108 | function read_of_desc_str_t(reader, version, subtree, field_name) |
| 109 | read_scalar(reader, subtree, field_name, 256) |
| 110 | end |
| 111 | |
| 112 | function read_of_serial_num_t(reader, version, subtree, field_name) |
| 113 | read_scalar(reader, subtree, field_name, 32) |
Rich Lane | a6e650e | 2013-10-02 16:30:06 -0700 | [diff] [blame] | 114 | end |
Tomasz | e058435 | 2013-10-23 16:43:26 -0700 | [diff] [blame] | 115 | |
Tomasz | 359147c | 2013-12-17 18:34:20 -0800 | [diff] [blame] | 116 | function read_of_port_desc_t(reader, version, subtree, field_name) |
| 117 | if reader.is_empty() then |
| 118 | return |
| 119 | end |
| 120 | local child_subtree = subtree:add(fields[field_name], reader.peek_all(0)) |
| 121 | local info = of_port_desc_dissectors[version](reader, child_subtree) |
| 122 | child_subtree:set_text(info) |
| 123 | end |
| 124 | |
Tomasz | a17a669 | 2013-10-30 17:34:18 -0700 | [diff] [blame] | 125 | function read_of_oxm_t(reader, version, subtree, field_name) |
| 126 | if reader.is_empty() then |
| 127 | return |
| 128 | end |
| 129 | local child_subtree = subtree:add(fields[field_name], reader.peek_all(0)) |
Tomasz | 2663f4f | 2013-12-10 05:12:42 -0800 | [diff] [blame] | 130 | local info = of_oxm_dissectors[version](reader, child_subtree) |
Tomasz | a17a669 | 2013-10-30 17:34:18 -0700 | [diff] [blame] | 131 | child_subtree:set_text(info) |
| 132 | end |
Tomasz | abaeac3 | 2013-12-16 21:22:13 -0800 | [diff] [blame] | 133 | |
| 134 | function read_list(reader, dissector, subtree, field_name) |
| 135 | if not reader.is_empty() then |
| 136 | local list_subtree = subtree:add(field_name .. " list", reader.peek_all(0)) |
| 137 | while not reader.is_empty() do |
| 138 | local atom_subtree = list_subtree:add(field_name, reader.peek_all(0)) |
| 139 | local info = dissector(reader, atom_subtree) |
| 140 | atom_subtree:set_text(info) |
| 141 | end |
| 142 | else |
| 143 | return |
| 144 | end |
| 145 | end |