From cda7026742335baef3ae5a5f20cdc649de1bd263 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Tue, 13 Mar 2012 09:06:15 +0900 Subject: 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 Signed-off-by: FUJITA Tomonori --- ryu/ofproto/nx_match.py | 14 ++++++++++++++ ryu/ofproto/ofproto_v1_0.py | 2 ++ 2 files changed, 16 insertions(+) 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' -- cgit v1.2.3