mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-01-24 01:52:23 +01:00
Allow specifing match fields in ClsRule.__init__
Signed-off-by: Jason Kölker <jason@koelker.net> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
1d30f0987f
commit
59da77306c
@ -118,10 +118,26 @@ class FlowWildcards(ofproto_parser.StringifyMixin):
|
||||
class ClsRule(ofproto_parser.StringifyMixin):
|
||||
"""describe a matching rule for OF 1.0 OFPMatch (and NX).
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self, **kwargs):
|
||||
self.wc = FlowWildcards()
|
||||
self.flow = Flow()
|
||||
|
||||
for key, value in kwargs.items():
|
||||
if key[:3] == 'reg':
|
||||
register = int(key[3:] or -1)
|
||||
self.set_reg(register, value)
|
||||
continue
|
||||
|
||||
setter = getattr(self, 'set_' + key, None)
|
||||
if not setter:
|
||||
LOG.error('Invalid kwarg specified to ClsRule (%s)', key)
|
||||
continue
|
||||
|
||||
if not isinstance(value, (tuple, list)):
|
||||
value = (value, )
|
||||
|
||||
setter(*value)
|
||||
|
||||
def set_in_port(self, port):
|
||||
self.wc.wildcards &= ~FWW_IN_PORT
|
||||
self.flow.in_port = port
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user