diff options
author | Simon Horman <horms@verge.net.au> | 2012-03-13 09:06:15 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-03-13 21:41:28 -0700 |
commit | cda7026742335baef3ae5a5f20cdc649de1bd263 (patch) | |
tree | 078800e487b400118b8b9be448638074fe5be07b | |
parent | 8033beab94ef6571caddb7d829ab4890b7b99795 (diff) |
NXM: Add MFInPort class
This is to handle IN_PORT NXM fields.
This will be used when sending NXT_FLOW_MOD messages.
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/nx_match.py | 14 | ||||
-rw-r--r-- | ryu/ofproto/ofproto_v1_0.py | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py index 2ff9976a..b368c8e9 100644 --- a/ryu/ofproto/nx_match.py +++ b/ryu/ofproto/nx_match.py @@ -49,6 +49,9 @@ class ClsRule(object): self.wc = FlowWildcards() self.flow = Flow() + def set_in_port(self, port): + self.wc.wildcards &= ~FWW_IN_PORT + self.flow.in_port = port def _set_nxm_headers(nxm_headers): '''Annotate corresponding NXM header''' @@ -102,6 +105,17 @@ class MFField(object): return self.putw(buf, offset, value, mask) +@_register_make +@_set_nxm_headers([ofproto_v1_0.NXM_OF_IN_PORT]) +class MFInPort(MFField): + @classmethod + def make(cls): + return cls(MF_PACK_STRING_BE16) + + def put(self, buf, offset, rule): + return self._put(buf, offset, rule.flow.in_port) + + def serialize_nxm_match(rule, buf, offset): old_offset = offset diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py index 086d17eb..92f03af3 100644 --- a/ryu/ofproto/ofproto_v1_0.py +++ b/ryu/ofproto/ofproto_v1_0.py @@ -515,4 +515,6 @@ def nxm_header_w(vendor, field, length): return nxm_header__(vendor, field, 1, (length) * 2) +NXM_OF_IN_PORT = nxm_header(0x0000, 0, 2) + NXM_HEADER_PACK_STRING = '!I' |