Skip to content

Commit

Permalink
nxm: add NXM_OF_IP_PROTO support
Browse files Browse the repository at this point in the history
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tested-by: Simon Horman <horms@verge.net.au>
  • Loading branch information
fujita committed Jun 12, 2012
1 parent b7d3844 commit 411e22d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ryu/ofproto/nx_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
FWW_DL_SRC = 1 << 2
FWW_DL_DST = 1 << 3
FWW_DL_TYPE = 1 << 4
FWW_NW_PROTO = 1 << 5
# No corresponding OFPFW_* bits
FWW_ETH_MCAST = 1 << 1
FWW_NW_DSCP = 1 << 6
Expand Down Expand Up @@ -68,6 +69,7 @@ def __init__(self):
self.nw_tos = 0
self.vlan_tci = 0
self.nw_ttl = 0
self.nw_proto = 0


class FlowWildcards(object):
Expand Down Expand Up @@ -150,6 +152,10 @@ def set_dl_tci_masked(self, tci, mask):
self.wc.vlan_tci_mask = mask
self.flow.vlan_tci = tci

def set_nw_proto(self, nw_proto):
self.wc.wildcards &= ~FWW_NW_PROTO
self.flow.nw_proto = nw_proto

def set_nw_dscp(self, nw_dscp):
self.wc.wildcards &= ~FWW_NW_DSCP
self.flow.nw_tos &= ~IP_DSCP_MASK
Expand Down Expand Up @@ -376,6 +382,17 @@ def put(self, buf, offset, rule):
return self._put(buf, offset, rule.flow.nw_ttl)


@_register_make
@_set_nxm_headers([ofproto_v1_0.NXM_OF_IP_PROTO])
class MFIPProto(MFField):
@classmethod
def make(cls):
return cls(MF_PACK_STRING_8)

def put(self, buf, offset, rule):
return self._put(buf, offset, rule.flow.nw_proto)


def serialize_nxm_match(rule, buf, offset):
old_offset = offset

Expand Down Expand Up @@ -404,6 +421,8 @@ def serialize_nxm_match(rule, buf, offset):
offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_IP_ECN, rule)
if not rule.wc.wildcards & FWW_NW_TTL:
offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_IP_TTL, rule)
if not rule.wc.wildcards & FWW_NW_PROTO:
offset += nxm_put(buf, offset, ofproto_v1_0.NXM_OF_IP_PROTO, rule)
# XXX: IP Source and Destination
# XXX: IPv6
# XXX: ARP
Expand Down

0 comments on commit 411e22d

Please sign in to comment.