1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
use ofp_header::OfpHeader;

/// OpenFlow Message
///
/// Version-agnostic API for handling OpenFlow messages at the byte-buffer level.
pub trait OfpMessage {
    /// Return the byte-size of an `OfpMessage`.
    fn size_of(&Self) -> usize;
    /// Create an `OfpHeader` for the given transaction id and OpenFlow message.
    fn header_of(u32, &Self) -> OfpHeader;
    /// Return a marshaled buffer containing an OpenFlow header and the message `msg`.
    fn marshal(u32, Self) -> Vec<u8>;
    /// Returns a pair `(u32, OfpMessage)` of the transaction id and OpenFlow message parsed from
    /// the given OpenFlow header `header`, and buffer `buf`.
    fn parse(&OfpHeader, &[u8]) -> (u32, Self);
}