diff options
author | Simon Horman <horms@verge.net.au> | 2012-03-13 09:06:21 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-03-13 21:41:36 -0700 |
commit | 797b5ef385eaf6ffa0019eb16fa06fcc420fae2b (patch) | |
tree | 892249bb1003f06bff2620de6a588f8f68e140cf | |
parent | 07b1afbcfafa01f1e95abea0e0874551eda483d8 (diff) |
Add NXTFlowMod
Allow Nicira Extension NXT_FLOW_MOD vendor messages
to be serialised. This is to allow setting flows
which require the use of NXM matches, for example
matching on the tunnel id.
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_0.py | 6 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_0_parser.py | 37 |
2 files changed, 43 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py index 7e97005f..74ec3c8b 100644 --- a/ryu/ofproto/ofproto_v1_0.py +++ b/ryu/ofproto/ofproto_v1_0.py @@ -487,6 +487,7 @@ NX_VENDOR_ID = 0x00002320 # enum nicira_type (abridged) NXT_SET_FLOW_FORMAT = 12 +NXT_FLOW_MOD = 13 # enum nx_flow_format NXFF_OPENFLOW10 = 0 @@ -497,6 +498,11 @@ NICIRA_HEADER_SIZE = 16 assert (calcsize(NICIRA_HEADER_PACK_STR) + OFP_HEADER_SIZE == NICIRA_HEADER_SIZE) +NX_FLOW_MOD_PACK_STR = '!Q4HI3H6x' +NX_FLOW_MOD_SIZE = 48 +assert (calcsize(NX_FLOW_MOD_PACK_STR) + + NICIRA_HEADER_SIZE == NX_FLOW_MOD_SIZE) + NX_SET_FLOW_FORMAT_PACK_STR = '!I' NX_SET_FLOW_FORMAT_SIZE = 20 assert (calcsize(NX_SET_FLOW_FORMAT_PACK_STR) + diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index 22ed26be..629c5992 100644 --- a/ryu/ofproto/ofproto_v1_0_parser.py +++ b/ryu/ofproto/ofproto_v1_0_parser.py @@ -20,6 +20,7 @@ from ofproto_parser import MsgBase, msg_pack_into, msg_str_attr from ryu.lib import mac from . import ofproto_parser from . import ofproto_v1_0 +from . import nx_match import logging LOG = logging.getLogger('ryu.ofproto.ofproto_v1_0_parser') @@ -673,6 +674,42 @@ class NXTSetFlowFormat(NXTRequest): self.buf, ofproto_v1_0.NICIRA_HEADER_SIZE, self.format) +class NXTFlowMod(NXTRequest): + def __init__(self, datapath, cookie, command, idle_timeout, + hard_timeout, priority, buffer_id, out_port, + flags, rule, actions): + super(NXTFlowMod, self).__init__(datapath) + self.subtype = ofproto_v1_0.NXT_FLOW_MOD + self.cookie = cookie + self.command = command + self.idle_timeout = idle_timeout + self.hard_timeout = hard_timeout + self.priority = priority + self.buffer_id = buffer_id + self.out_port = out_port + self.flags = flags + self.rule = rule + self.actions = actions + + def _serialize_body(self): + self.serialize_header() + + offset = ofproto_v1_0.NX_FLOW_MOD_SIZE + match_len = nx_match.serialize_nxm_match(self.rule, self.buf, offset) + offset += nx_match.round_up(match_len) + + msg_pack_into(ofproto_v1_0.NX_FLOW_MOD_PACK_STR, + self.buf, ofproto_v1_0.NICIRA_HEADER_SIZE, + self.cookie, self.command, self.idle_timeout, + self.hard_timeout, self.priority, self.buffer_id, + self.out_port, self.flags, match_len) + + if self.actions is not None: + for a in self.actions: + a.serialize(self.buf, offset) + offset += a.len + + # # asymmetric message (datapath -> controller) # parser only |