Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -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 | ## |
| 29 | # @brief Translation data between openflow.h and LOXI |
| 30 | # |
| 31 | |
| 32 | import re |
| 33 | import sys |
| 34 | |
| 35 | def loxi_name(ident): |
| 36 | """ |
| 37 | Return the LOXI name of an openflow.h identifier |
| 38 | """ |
| 39 | |
| 40 | # Order at the outer level matters as super strings are listed first |
| 41 | rules = [ |
| 42 | # The following are for #define macros and have highest precedence |
| 43 | dict(OFP_MAX_TABLE_NAME_LEN = "OF_MAX_TABLE_NAME_LEN"), |
| 44 | dict(OFP_MAX_PORT_NAME_LEN = "OF_MAX_PORT_NAME_LEN"), |
| 45 | dict(OFP_TCP_PORT = "OF_TCP_PORT"), |
| 46 | dict(OFP_SSL_PORT = "OF_SSL_PORT"), |
| 47 | dict(OFP_ETH_ALEN = "OF_ETH_ALEN"), |
| 48 | dict(OFP_DEFAULT_MISS_SEND_LEN = "OF_DEFAULT_MISS_SEND_LEN"), |
| 49 | dict(OFP_VLAN_NONE = "OF_VLAN_UNTAGGED"), |
| 50 | dict(OFP_DL_TYPE_ETH2_CUTOFF = "OF_DL_TYPE_ETH2_CUTOFF"), |
| 51 | dict(OFP_DL_TYPE_NOT_ETH_TYPE = "OF_DL_TYPE_NOT_ETH_TYPE"), |
| 52 | dict(OFP_FLOW_PERMANENT = "OF_FLOW_PERMANENT"), |
| 53 | dict(OFP_DEFAULT_PRIORITY = "OF_DEFAULT_PRIORITY"), |
| 54 | dict(DESC_STR_LEN = "OF_DESC_STR_LEN"), |
| 55 | dict(SERIAL_NUM_LEN = "OF_SERIAL_NUM_LEN"), |
| 56 | dict(OFPQ_ALL = "OF_QUEUE_ALL"), |
| 57 | dict(OFPQ_MIN_RATE_UNCFG = "OF_QUEUE_MIN_RATE_UNCFG"), |
| 58 | dict(OFPQ_MAX_RATE_UNCFG = "OF_QUEUE_MAX_RATE_UNCFG"), |
| 59 | dict(OFP_NO_BUFFER = "OF_BUFFER_ID_NO_BUFFER"), |
| 60 | |
| 61 | # These are for enums; they map the prefixes |
| 62 | dict(OFPP_MAX = "OF_PORT_NUMBER_MAX"), # Special case |
| 63 | dict(OFPP_TABLE = "OF_PORT_DEST_USE_TABLE"), # Special case |
| 64 | dict(OFPP_ANY = "OF_PORT_DEST_WILDCARD"), # Special case |
| 65 | dict(OFPTC_ = "OF_TABLE_CONFIG_"), |
| 66 | dict(OFPIEH_ = "OF_IPV6_EXT_HDR_FLAG_"), |
| 67 | dict(OFPMBT_ = "OF_METER_BAND_TYPE_"), |
| 68 | dict(OFPMC_ = "OF_METER_MOD_COMMAND_"), |
| 69 | dict(OFPMF_ = "OF_METER_FLAG_"), |
| 70 | dict(OFPTFFC_ = "OF_TABLE_REQUEST_FAILED_"), |
| 71 | dict(OFPMMFC_ = "OF_METER_MOD_FAILED_"), |
| 72 | dict(OFPPR_ = "OF_PORT_CHANGE_REASON_"), |
| 73 | dict(OFPPMFC_ = "OF_PORT_MOD_FAILED_"), |
| 74 | dict(OFPP_ = "OF_PORT_DEST_"), |
| 75 | dict(OFPRRFC_ = "OF_ROLE_REQUEST_FAILED_"), |
| 76 | dict(OFPRR_ = "OF_FLOW_REMOVED_REASON_"), |
| 77 | dict(OFPR_ = "OF_PACKET_IN_REASON_"), |
| 78 | dict(OFPC_FRAG_ = "OF_CONFIG_FRAG_"), |
| 79 | dict(OFPC_INVALID_ = "OF_CONFIG_INVALID_"), |
| 80 | dict(OFPCML_ = "OF_CONTROLLER_PKT_"), |
| 81 | dict(OFPCR_ROLE_ = "OF_CONTROLLER_ROLE_"), |
| 82 | dict(OFPC_ = "OF_CAPABILITIES_FLAG_"), |
| 83 | dict(OFPPC_ = "OF_PORT_CONFIG_FLAG_"), |
| 84 | dict(OFPPS_ = "OF_PORT_STATE_FLAG_"), |
| 85 | dict(OFPPF_ = "OF_PORT_FEATURE_FLAG_"), |
| 86 | dict(OFPTT_ = "OF_TABLE_"), |
| 87 | dict(OFPT_ = "OF_OBJ_TYPE_"), |
| 88 | dict(OFPMT_ = "OF_MATCH_TYPE_"), |
| 89 | dict(OFPM_ = "OF_METER_"), |
| 90 | dict(OFPXMC_ = "OF_OXM_CLASS_"), |
| 91 | dict(OFPVID_ = "OF_VLAN_TAG_"), |
| 92 | dict(OFPGC_ = "OF_GROUP_"), |
| 93 | dict(OFPGT_ = "OF_GROUP_TYPE_"), |
| 94 | dict(OFPG_ = "OF_GROUP_"), |
| 95 | dict(OFPET_ = "OF_ERROR_TYPE_"), |
| 96 | dict(OFPFC_ = "OF_FLOW_MOD_COMMAND_"), |
| 97 | dict(OFPHFC_ = "OF_HELLO_FAILED_"), |
| 98 | dict(OFPBRC_ = "OF_REQUEST_FAILED_"), |
| 99 | dict(OFPBAC_ = "OF_ACTION_FAILED_"), |
| 100 | dict(OFPBIC_ = "OF_INSTRUCTION_FAILED_"), |
| 101 | dict(OFPBMC_ = "OF_MATCH_FAILED_"), |
| 102 | dict(OFPGMFC_ = "OF_GROUP_MOD_FAILED_"), |
| 103 | dict(OFPTMFC_ = "OF_TABLE_MOD_FAILED_"), |
| 104 | dict(OFPFMFC_ = "OF_FLOW_MOD_FAILED_"), |
| 105 | dict(OFPQOFC_ = "OF_QUEUE_OP_FAILED_"), |
| 106 | dict(OFPSCFC_ = "OF_SWITCH_CONFIG_FAILED_"), |
| 107 | dict(OFPQCFC_ = "OF_SWITCH_CONFIG_FAILED_"), # See EXT-208 |
| 108 | dict(OFPAT_ = "OF_ACTION_TYPE_"), |
| 109 | dict(OFPFW_ = "OF_FLOW_WC_V1_"), |
| 110 | dict(OFPFF_ = "OF_FLOW_MOD_FLAG_"), |
| 111 | dict(OFPST_ = "OF_STATS_TYPE_"), |
| 112 | dict(OFPSF_ = "OF_STATS_REPLY_FLAG_"), |
| 113 | dict(OFPQT_ = "OF_QUEUE_PROPERTY_"), |
| 114 | dict(OFPIT_ = "OF_INSTRUCTION_TYPE_"), |
| 115 | dict(OFPGFC_ = "OF_GROUP_CAPABILITIES_"), |
| 116 | dict(OFPMP_ = "OF_MULTIPART_"), |
| 117 | dict(OFPMPF_ = "OF_MULTIPART_FLAG_"), |
| 118 | dict(OFPTFPT_ = "OF_TABLE_FEATURE_"), |
| 119 | ] |
| 120 | |
| 121 | for entry in rules: |
| 122 | for id_from, id_to in entry.items(): |
| 123 | if re.match(id_from, ident): |
| 124 | return re.sub(id_from, id_to, ident) |
| 125 | return None |
| 126 | |