Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 1 | package 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 | |
| 13 | import org.jboss.netty.buffer.ChannelBuffer; |
| 14 | import org.openflow.exceptions.OFParseError; |
| 15 | import org.openflow.exceptions.OFShortWrite; |
| 16 | |
| 17 | public 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 | } |