diff options
-rw-r--r-- | ryu/ofproto/ofproto_v1_0.py | 17 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_0_parser.py | 40 |
2 files changed, 57 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py index 74ec3c8b..e666ad93 100644 --- a/ryu/ofproto/ofproto_v1_0.py +++ b/ryu/ofproto/ofproto_v1_0.py @@ -230,6 +230,23 @@ OFP_ACTION_PACK_STR = '!H' # OFP_ACTION_SIZE = 8 # assert calcsize(OFP_ACTION_PACK_STR) == OFP_ACTION_SIZE +# enum nx_action_subtype (truncated) +NXAST_SET_TUNNEL = 2 +NXAST_SET_TUNNEL64 = 9 + +NX_ACTION_SET_TUNNEL_PACK_STR = '!HHIH2xI' +NX_ACTION_SET_TUNNEL_SIZE = 16 +assert calcsize(NX_ACTION_SET_TUNNEL_PACK_STR) == NX_ACTION_SET_TUNNEL_SIZE + +NX_ACTION_SET_TUNNEL64_PACK_STR = '!HHIH6xQ' +NX_ACTION_SET_TUNNEL64_SIZE = 24 +assert calcsize(NX_ACTION_SET_TUNNEL64_PACK_STR) == NX_ACTION_SET_TUNNEL64_SIZE + +NX_ACTION_HEADER_PACK_STR = '!H' +NX_ACTION_HEADER_SIZE = 10 +assert (OFP_ACTION_VENDOR_HEADER_SIZE + + calcsize(NX_ACTION_HEADER_PACK_STR)) == NX_ACTION_HEADER_SIZE + OFP_PACKET_OUT_PACK_STR = '!IHH' OFP_PACKET_OUT_SIZE = 16 assert (calcsize(OFP_PACKET_OUT_PACK_STR) + OFP_HEADER_SIZE == diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index 629c5992..13d5688d 100644 --- a/ryu/ofproto/ofproto_v1_0_parser.py +++ b/ryu/ofproto/ofproto_v1_0_parser.py @@ -352,6 +352,46 @@ class OFPActionEnqueue(OFPAction): # TODO:XXX OFPActionVendor +# NXAction* is a partial implementatoin, only handling serilalisation +# of a subset of Nicira vendor actions + + +class NXActionHeader(object): + def __init__(self, subtype_, len_): + self.type = ofproto_v1_0.OFPAT_VENDOR + self.len = len_ + self.vendor = ofproto_v1_0.NX_VENDOR_ID + self.subtype = subtype_ + + def serialise(self, buf, offset): + msg_pack_into(ofproto_v1_0.OFP_ACTION_HEADER_PACK_STR, + buf, offset, self.type, self.len) + + +class NXActionSetTunnel(NXActionHeader): + def __init__(self, tun_id_): + self.tun_id = tun_id_ + super(NXActionSetTunnel, self).__init__( + ofproto_v1_0.NXAST_SET_TUNNEL, + ofproto_v1_0.NX_ACTION_SET_TUNNEL_SIZE) + + def serialize(self, buf, offset): + msg_pack_into(ofproto_v1_0.NX_ACTION_SET_TUNNEL_PACK_STR, buf, + offset, self.type, self.len, self.vendor, self.subtype, + self.tun_id) + + +class NXActionSetTunnel64(NXActionHeader): + def __init__(self, tun_id_): + self.tun_id = tun_id_ + super(NXActionSetTunnel64, self).__init__( + ofproto_v1_0.NXAST_SET_TUNNEL64, + ofproto_v1_0.NX_ACTION_SET_TUNNEL64_SIZE) + + def serialize(self, buf, offset): + msg_pack_into(ofproto_v1_0.NX_ACTION_SET_TUNNEL64_PACK_STR, buf, + offset, self.type, self.len, self.vendor, self.subtype, + self.tun_id) class OFPDescStats(collections.namedtuple('OFPDescStats', |