Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -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 | package org.openflow.protocol; |
| 29 | |
| 30 | /** |
| 31 | * The base interface for all OpenFlow message objects |
| 32 | */ |
| 33 | |
| 34 | import org.openflow.types.OFType; |
| 35 | |
| 36 | abstract public class OFAbstractMessage implements OFObject { |
| 37 | private final OFVersion version; |
| 38 | private final OFType type; |
| 39 | private int xid; |
| 40 | |
| 41 | public static int MINIMUM_SIZE = 8; |
| 42 | |
| 43 | public OFAbstractMessage(final OFVersion version, final OFType type) { |
| 44 | this.version = version; |
| 45 | this.type = type; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Return the wire format version of this message, e.g., 0x01 |
| 50 | */ |
| 51 | OFVersion getVersion() { |
| 52 | return version; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @return the transction ID for this message |
| 57 | */ |
| 58 | int getXid() { |
| 59 | return xid; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @param newXid |
| 64 | * Set this transaction ID for this message |
| 65 | */ |
| 66 | void setXid(final int xid) { |
| 67 | this.xid = xid; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * The type that is returned here is agnostic to the underlying wire format |
| 72 | * |
| 73 | * @return the type of OpenFlow message. |
| 74 | */ |
| 75 | OFType getType() { |
| 76 | return type; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public int getLength() { |
| 81 | return MINIMUM_SIZE; |
| 82 | } |
| 83 | } |