blob: a927f947b63b78854d4054f39cf8e4ce3b97f677 [file] [log] [blame]
Rich Lane4d9f0f62013-05-09 15:50:57 -07001# 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
Andreas Wundsamfef7d5f2013-08-01 22:15:44 -070028from generic_utils import find
Rich Lane4d9f0f62013-05-09 15:50:57 -070029from collections import namedtuple
30
Andreas Wundsamd30c1072013-11-15 13:36:57 -080031# This module is represents the frontend IR.
Rich Lane4d9f0f62013-05-09 15:50:57 -070032__all__ = [
33 'OFInput',
Rich Lane4d9f0f62013-05-09 15:50:57 -070034 'OFClass',
35 'OFDataMember',
36 'OFTypeMember',
Andreas Wundsam780e0c92013-08-02 17:48:27 -070037 'OFDiscriminatorMember',
Rich Lane4d9f0f62013-05-09 15:50:57 -070038 'OFLengthMember',
39 'OFFieldLengthMember',
40 'OFPadMember',
41 'OFEnum',
Andreas Wundsam4ee51462013-07-30 11:00:37 -070042 'OFEnumEntry'
Rich Lane4d9f0f62013-05-09 15:50:57 -070043]
44
45"""
46One input file
47
48@param wire_versions Set of integer wire versions this file applies to
49@param classes List of OFClass objects in the same order as in the file
50@param enums List of Enum objects in the same order as in the file
51"""
Andreas Wundsamd30c1072013-11-15 13:36:57 -080052OFInput = namedtuple('OFInput', ['filename', 'wire_versions', 'classes', 'enums'])
Rich Lane7c49d4e2013-10-02 15:57:46 -070053
Rich Lane4d9f0f62013-05-09 15:50:57 -070054"""
55An OpenFlow class
56
57All compound objects like messages, actions, instructions, etc are
58uniformly represented by this class.
59
60The members are in the same order as on the wire.
61
62@param name
Andreas Wundsam780e0c92013-08-02 17:48:27 -070063@param superclass name of the super class
Rich Lane4d9f0f62013-05-09 15:50:57 -070064@param members List of *Member objects
Andreas Wundsamfef7d5f2013-08-01 22:15:44 -070065@param params optional dictionary of parameters
Rich Lane4d9f0f62013-05-09 15:50:57 -070066"""
Andreas Wundsamd30c1072013-11-15 13:36:57 -080067OFClass = namedtuple('OFClass', ['name', 'superclass', 'members', 'virtual', 'params'])
Rich Lane4d9f0f62013-05-09 15:50:57 -070068
69"""
70Normal field
71
72@param name
73@param oftype C-like type string
74
75Example: packet_in.buffer_id
76"""
77OFDataMember = namedtuple('OFDataMember', ['name', 'oftype'])
78
79"""
Andreas Wundsam780e0c92013-08-02 17:48:27 -070080Field that declares that this is an abstract super-class and
81that the sub classes will be discriminated based on this field.
82E.g., 'type' is the discriminator member of the abstract superclass
83of_action.
84
85@param name
86"""
Andreas Wundsam7933beb2013-08-02 22:36:42 -070087OFDiscriminatorMember = namedtuple('OFDiscriminatorMember', ['name', 'oftype'])
Andreas Wundsam780e0c92013-08-02 17:48:27 -070088
89"""
Rich Lane4d9f0f62013-05-09 15:50:57 -070090Field used to determine the type of an OpenFlow object
91
92@param name
93@param oftype C-like type string
94@param value Fixed type value
95
96Example: packet_in.type, flow_add._command
97"""
98OFTypeMember = namedtuple('OFTypeMember', ['name', 'oftype', 'value'])
99
100"""
101Field with the length of the containing object
102
103@param name
104@param oftype C-like type string
105
106Example: packet_in.length, action_output.len
107"""
108OFLengthMember = namedtuple('OFLengthMember', ['name', 'oftype'])
109
110"""
111Field with the length of another field in the containing object
112
113@param name
114@param oftype C-like type string
115@param field_name Peer field whose length this field contains
116
117Example: packet_out.actions_len (only usage)
118"""
119OFFieldLengthMember = namedtuple('OFFieldLengthMember', ['name', 'oftype', 'field_name'])
120
121"""
122Zero-filled padding
123
124@param length Length in bytes
125
126Example: packet_in.pad
127"""
128OFPadMember = namedtuple('OFPadMember', ['length'])
129
130"""
131An OpenFlow enumeration
132
133All values are Python ints.
134
135@param name
Andreas Wundsam4ee51462013-07-30 11:00:37 -0700136@param entries List of OFEnumEntry objects in input order
137@params dict of optional params. Currently defined:
138 - wire_type: the low_level type of the enum values (uint8,...)
Rich Lane4d9f0f62013-05-09 15:50:57 -0700139"""
Andreas Wundsamd30c1072013-11-15 13:36:57 -0800140OFEnum = namedtuple('OFEnum', ['name', 'entries', 'params'])
Andreas Wundsam4ee51462013-07-30 11:00:37 -0700141OFEnumEntry = namedtuple('OFEnumEntry', ['name', 'value', 'params'])