Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # Copyright 2013, Big Switch Networks, Inc. |
| 3 | # |
| 4 | # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with |
| 5 | # the following special exception: |
| 6 | # |
| 7 | # LOXI Exception |
| 8 | # |
| 9 | # As a special exception to the terms of the EPL, you may distribute libraries |
| 10 | # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided |
| 11 | # that copyright and licensing notices generated by LoxiGen are not altered or removed |
| 12 | # from the LoxiGen Libraries and the notice provided below is (i) included in |
| 13 | # the LoxiGen Libraries, if distributed in source code form and (ii) included in any |
| 14 | # documentation for the LoxiGen Libraries, if distributed in binary form. |
| 15 | # |
| 16 | # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler." |
| 17 | # |
| 18 | # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain |
| 19 | # a copy of the EPL at: |
| 20 | # |
| 21 | # http://www.eclipse.org/legal/epl-v10.html |
| 22 | # |
| 23 | # Unless required by applicable law or agreed to in writing, software |
| 24 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 25 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 26 | # EPL for the specific language governing permissions and limitations |
| 27 | # under the EPL. |
| 28 | |
| 29 | # |
| 30 | # Some test code for of_h_utils.py |
| 31 | # |
| 32 | |
| 33 | import sys |
| 34 | sys.path.append("..") |
| 35 | sys.path.append("../loxi_front_end") |
| 36 | sys.path.append("../loxi_utils") |
| 37 | |
| 38 | from of_h_utils import * |
| 39 | |
| 40 | for filename, version in [ |
| 41 | ('../canonical/openflow.h-1.0', 1), |
| 42 | ('../canonical/openflow.h-1.1', 2), |
| 43 | ('../canonical/openflow.h-1.2', 3), |
| 44 | ('../canonical/openflow.h-1.3', 4)]: |
| 45 | |
| 46 | f = open(filename, 'r') |
| 47 | all_lines = f.readlines() |
| 48 | contents = " ".join(all_lines) |
| 49 | |
| 50 | enum_dict = get_enum_dict(version, contents) |
| 51 | print "Got %d LOXI entries %s" % (len(enum_dict), filename) |
| 52 | for name, entry in enum_dict.items(): |
| 53 | print "Enum %s:\n ofp_name: %s.\n ofp_group: %s.\n value: %s" % ( |
| 54 | name, entry.ofp_name, entry.ofp_group, str(entry.value)) |