blob: 21a4607f13a61a07f1f941ac68a98d3fe11a11e1 [file] [log] [blame]
Andreas Wundsam40e14f72013-05-06 14:49:08 -07001package org.openflow.protocol;
2
3/**
4 * Base interface of all OpenFlow objects (e.g., messages, actions, stats, etc.)
5 *
6 * All objects have a length and can be read and written from a buffer.
7 * When writing, the length field is dynamically updated, so it need not be
8 * managed manually. However, you can override the auto calculated length with
9 * overrideLength() call, if, for example, you want to intentionally create
10 * malformed packets, for example, for negative testing.
11 */
12
13import org.jboss.netty.buffer.ChannelBuffer;
14import org.openflow.exceptions.OFParseError;
15import org.openflow.exceptions.OFShortWrite;
16
17public interface OFObject {
18 /**
19 * Return a number equal or greater than zero (and currently in OF less than
20 * 65536)
21 *
22 * @return the number of bytes this object will represent on the wire
23 */
24 public int getLength();
25
26 /**
27 * Automatically calculate any lengths and write an openflow object into the
28 * byte buffer.
29 *
30 * @param bb
31 * A valid byte buffer with sufficient capacity to hold this
32 * object/
33 */
34 public void writeTo(ChannelBuffer bb) throws OFParseError, OFShortWrite;
35}