fix pep8 1.3.3 warnings
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
1dcf8f76d9
commit
c8cd4226d7
@ -43,7 +43,7 @@ def client_test():
|
||||
'create_port': lambda a: client.create_port(a[1], a[2], a[3]),
|
||||
'update_port': lambda a: client.update_port(a[1], a[2], a[3]),
|
||||
'delete_port': lambda a: client.delete_port(a[1], a[2], a[3])
|
||||
}
|
||||
}
|
||||
|
||||
# allow '-', instead of '_'
|
||||
commands.update(dict([(k.replace('_', '-'), v)
|
||||
|
@ -49,7 +49,7 @@ class EventDumper(app_manager.RyuApp):
|
||||
|
||||
def _register_dump_handler(self, ev_q, dispatcher):
|
||||
if (self._need_dump(ev_q.name, FLAGS.dump_queue) or
|
||||
self._need_dump(dispatcher.name, FLAGS.dump_dispatcher)):
|
||||
self._need_dump(dispatcher.name, FLAGS.dump_dispatcher)):
|
||||
dispatcher.register_all_handler(self._dump_event)
|
||||
|
||||
@set_ev_cls(dispatcher.EventQueueCreate, dispatcher.QUEUE_EV_DISPATCHER)
|
||||
|
@ -138,7 +138,7 @@ class restapi(app_manager.RyuApp):
|
||||
_CONTEXTS = {
|
||||
'network': network.Network,
|
||||
'wsgi': WSGIApplication
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(restapi, self).__init__(*args, **kwargs)
|
||||
|
@ -41,7 +41,7 @@ class SimpleIsolation(app_manager.RyuApp):
|
||||
_CONTEXTS = {
|
||||
'network': network.Network,
|
||||
'dpset': dpset.DPSet,
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SimpleIsolation, self).__init__(*args, **kwargs)
|
||||
@ -136,6 +136,7 @@ class SimpleIsolation(app_manager.RyuApp):
|
||||
# LOG.debug('packet in ev %s msg %s', ev, ev.msg)
|
||||
msg = ev.msg
|
||||
datapath = msg.datapath
|
||||
ofproto = datapath.ofproto
|
||||
|
||||
dst, src, _eth_type = struct.unpack_from('!6s6sH', buffer(msg.data), 0)
|
||||
|
||||
@ -170,10 +171,13 @@ class SimpleIsolation(app_manager.RyuApp):
|
||||
# new port.
|
||||
rule = nx_match.ClsRule()
|
||||
rule.set_dl_dst(src)
|
||||
datapath.send_flow_mod(rule=rule, cookie=0,
|
||||
command=datapath.ofproto.OFPFC_DELETE, idle_timeout=0,
|
||||
hard_timeout=0, priority=datapath.ofproto.OFP_DEFAULT_PRIORITY,
|
||||
out_port=old_port)
|
||||
datapath.send_flow_mod(rule=rule,
|
||||
cookie=0,
|
||||
command=ofproto.OFPFC_DELETE,
|
||||
idle_timeout=0,
|
||||
hard_timeout=0,
|
||||
priority=ofproto.OFP_DEFAULT_PRIORITY,
|
||||
out_port=old_port)
|
||||
|
||||
# to make sure the old flow entries are purged.
|
||||
datapath.send_barrier()
|
||||
|
@ -81,7 +81,7 @@ class Datapath(object):
|
||||
ofproto_v1_0_parser),
|
||||
ofproto_v1_2.OFP_VERSION: (ofproto_v1_2,
|
||||
ofproto_v1_2_parser),
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, socket, address):
|
||||
super(Datapath, self).__init__()
|
||||
|
@ -56,7 +56,7 @@ class EventQueue(TrackInstances):
|
||||
# This can be called when python interpreter exiting.
|
||||
# At that time, other object like EventQueueCreate can be
|
||||
# already destructed. So we can't call it blindly.
|
||||
assert self.aux == None
|
||||
assert self.aux is None
|
||||
ev_q = self._get_ev_q()
|
||||
if ev_q is not None and self != ev_q:
|
||||
self._queue_q_ev(EventQueueCreate(self, False))
|
||||
|
@ -188,7 +188,7 @@ class ConfigHandler(object):
|
||||
set_config = ofproto_parser.OFPSetConfig(
|
||||
datapath, ofproto.OFPC_FRAG_NORMAL,
|
||||
128 # TODO:XXX
|
||||
)
|
||||
)
|
||||
datapath.send_msg(set_config)
|
||||
|
||||
LOG.debug('move onto main mode')
|
||||
|
@ -72,7 +72,7 @@ class Network(object):
|
||||
try:
|
||||
old_network_id = self.dpids.get(dpid, {}).get(port, None)
|
||||
if ((dpid, port) in self.networks[network_id] or
|
||||
_known_nw_id(old_network_id)):
|
||||
_known_nw_id(old_network_id)):
|
||||
if not port_may_exist:
|
||||
raise PortAlreadyExist(network_id=network_id,
|
||||
dpid=dpid, port=port)
|
||||
@ -117,7 +117,8 @@ class Network(object):
|
||||
return True
|
||||
|
||||
if (allow_nw_id_external is not None and
|
||||
(allow_nw_id_external == nw_id or allow_nw_id_external == out_nw)):
|
||||
(allow_nw_id_external == nw_id or
|
||||
allow_nw_id_external == out_nw)):
|
||||
# allow external network -> known network id
|
||||
return True
|
||||
|
||||
|
@ -19,6 +19,7 @@ from . import udp
|
||||
from ryu.ofproto.ofproto_parser import msg_pack_into
|
||||
from ryu.ofproto import inet
|
||||
|
||||
|
||||
class ipv4(packet_base.PacketBase):
|
||||
_PACK_STR = '!BBHHHBBHII'
|
||||
|
||||
@ -64,7 +65,7 @@ class ipv4(packet_base.PacketBase):
|
||||
def checksum(self, data):
|
||||
s = 0
|
||||
for i in range(0, len(data), 2):
|
||||
w = data[i] + (data[i+1] << 8)
|
||||
w = data[i] + (data[i + 1] << 8)
|
||||
s = self.carry_around_add(s, w)
|
||||
return ~s & 0xffff
|
||||
|
||||
@ -74,7 +75,7 @@ class ipv4(packet_base.PacketBase):
|
||||
msg_pack_into(ipv4._PACK_STR, buf, offset, version, self.tos,
|
||||
self.total_length, self.identification, flags,
|
||||
self.ttl, self.proto, 0, self.src, self.dst)
|
||||
self.csum = self.checksum(buf[offset:offset+self.length])
|
||||
self.csum = self.checksum(buf[offset:offset + self.length])
|
||||
msg_pack_into('H', buf, offset + 10, self.csum)
|
||||
|
||||
ipv4.register_packet_type(udp.udp, inet.IPPROTO_UDP)
|
||||
|
@ -709,7 +709,7 @@ class MFRegister(MFField):
|
||||
def put(self, buf, offset, rule):
|
||||
for i in range(FLOW_N_REGS):
|
||||
if (ofproto_v1_0.nxm_nx_reg(i) == self.nxm_header or
|
||||
ofproto_v1_0.nxm_nx_reg_w(i) == self.nxm_header):
|
||||
ofproto_v1_0.nxm_nx_reg_w(i) == self.nxm_header):
|
||||
if rule.wc.regs_mask[i]:
|
||||
return self.putm(buf, offset, rule.flow.regs[i],
|
||||
rule.wc.regs_mask[i])
|
||||
|
@ -611,17 +611,17 @@ assert (calcsize(NX_ROLE_PACK_STR) +
|
||||
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)
|
||||
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) +
|
||||
NICIRA_HEADER_SIZE == NX_SET_FLOW_FORMAT_SIZE)
|
||||
NICIRA_HEADER_SIZE == NX_SET_FLOW_FORMAT_SIZE)
|
||||
|
||||
NX_FLOW_REMOVED_PACK_STR = '!QHBxIIHHQQ'
|
||||
NX_FLOW_REMOVED_SIZE = 56
|
||||
assert (calcsize(NX_FLOW_REMOVED_PACK_STR) +
|
||||
NICIRA_HEADER_SIZE == NX_FLOW_REMOVED_SIZE)
|
||||
NICIRA_HEADER_SIZE == NX_FLOW_REMOVED_SIZE)
|
||||
|
||||
NX_FLOW_MOD_TABLE_ID_PACK_STR = '!B7x'
|
||||
NX_FLOW_MOD_TABLE_ID_SIZE = 24
|
||||
|
@ -79,8 +79,8 @@ def _set_msg_reply(msg_reply):
|
||||
#
|
||||
|
||||
class OFPPhyPort(collections.namedtuple('OFPPhyPort', (
|
||||
'port_no', 'hw_addr', 'name', 'config', 'state', 'curr', 'advertised',
|
||||
'supported', 'peer'))):
|
||||
'port_no', 'hw_addr', 'name', 'config', 'state', 'curr', 'advertised',
|
||||
'supported', 'peer'))):
|
||||
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
@ -90,9 +90,9 @@ class OFPPhyPort(collections.namedtuple('OFPPhyPort', (
|
||||
|
||||
|
||||
class OFPMatch(collections.namedtuple('OFPMatchBase', (
|
||||
'wildcards', 'in_port', 'dl_src', 'dl_dst', 'dl_vlan',
|
||||
'dl_vlan_pcp', 'dl_type', 'nw_tos', 'nw_proto',
|
||||
'nw_src', 'nw_dst', 'tp_src', 'tp_dst'))):
|
||||
'wildcards', 'in_port', 'dl_src', 'dl_dst', 'dl_vlan',
|
||||
'dl_vlan_pcp', 'dl_type', 'nw_tos', 'nw_proto',
|
||||
'nw_src', 'nw_dst', 'tp_src', 'tp_dst'))):
|
||||
|
||||
def __new__(cls, *args):
|
||||
# for convenience when dl_src/dl_dst are wildcard
|
||||
@ -543,8 +543,8 @@ class NXActionRegMove(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, n_bits, src_ofs, dst_ofs,
|
||||
src, dst) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_REG_MOVE_PACK_STR, buf, offset)
|
||||
src, dst) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_REG_MOVE_PACK_STR, buf, offset)
|
||||
return cls(n_bits, src_ofs, dst_ofs, src, dst)
|
||||
|
||||
|
||||
@ -566,8 +566,8 @@ class NXActionRegLoad(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, ofs_nbits, dst,
|
||||
value) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_REG_LOAD_PACK_STR, buf, offset)
|
||||
value) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_REG_LOAD_PACK_STR, buf, offset)
|
||||
return cls(ofs_nbits, dst, value)
|
||||
|
||||
|
||||
@ -615,8 +615,8 @@ class NXActionMultipath(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, fields, basis, algorithm,
|
||||
max_link, arg, ofs_nbits, dst) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_MULTIPATH_PACK_STR, buf, offset)
|
||||
max_link, arg, ofs_nbits, dst) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_MULTIPATH_PACK_STR, buf, offset)
|
||||
return cls(fields, basis, algorithm, max_link, arg, ofs_nbits,
|
||||
dst)
|
||||
|
||||
@ -700,8 +700,8 @@ class NXActionBundleBase(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, action_cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, algorithm, fields, basis,
|
||||
slave_type, n_slaves, ofs_nbits, dst) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_BUNDLE_PACK_STR, buf, offset)
|
||||
slave_type, n_slaves, ofs_nbits, dst) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_BUNDLE_PACK_STR, buf, offset)
|
||||
slave_offset = offset + ofproto_v1_0.NX_ACTION_BUNDLE_SIZE
|
||||
|
||||
slaves = []
|
||||
@ -760,8 +760,8 @@ class NXActionAutopath(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, ofs_nbits, dst,
|
||||
id_) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_AUTOPATH_PACK_STR, buf, offset)
|
||||
id_) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_AUTOPATH_PACK_STR, buf, offset)
|
||||
return cls(ofs_nbits, dst, id_)
|
||||
|
||||
|
||||
@ -783,8 +783,8 @@ class NXActionOutputReg(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, ofs_nbits, src,
|
||||
max_len) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_OUTPUT_REG_PACK_STR, buf, offset)
|
||||
max_len) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_OUTPUT_REG_PACK_STR, buf, offset)
|
||||
return cls(ofs_nbits, src, max_len)
|
||||
|
||||
|
||||
@ -854,9 +854,9 @@ class NXActionLearn(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, idle_timeout, hard_timeout, priority,
|
||||
cookie, flags, table_id, fin_idle_timeout,
|
||||
fin_hard_timeout) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_LEARN_PACK_STR, buf, offset)
|
||||
cookie, flags, table_id, fin_idle_timeout,
|
||||
fin_hard_timeout) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_LEARN_PACK_STR, buf, offset)
|
||||
spec = buf[offset + ofproto_v1_0.NX_ACTION_LEARN_SIZE:]
|
||||
return cls(idle_timeout, hard_timeout, priority,
|
||||
cookie, flags, table_id, fin_idle_timeout,
|
||||
@ -881,8 +881,8 @@ class NXActionController(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, max_len, controller_id, reason,
|
||||
_zero) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_CONTROLLER_PACK_STR, buf, offset)
|
||||
_zero) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_CONTROLLER_PACK_STR, buf, offset)
|
||||
return cls(max_len, controller_id, reason)
|
||||
|
||||
|
||||
@ -903,13 +903,13 @@ class NXActionFinTimeout(NXActionHeader):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(type_, len_, vendor, subtype, fin_idle_timeout,
|
||||
fin_hard_timeout) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_FIN_TIMEOUT_PACK_STR, buf, offset)
|
||||
fin_hard_timeout) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_ACTION_FIN_TIMEOUT_PACK_STR, buf, offset)
|
||||
return cls(fin_idle_timeout, fin_hard_timeout)
|
||||
|
||||
|
||||
class OFPDescStats(collections.namedtuple('OFPDescStats',
|
||||
('mfr_desc', 'hw_desc', 'sw_desc', 'serial_num', 'dp_desc'))):
|
||||
class OFPDescStats(collections.namedtuple('OFPDescStats', (
|
||||
'mfr_desc', 'hw_desc', 'sw_desc', 'serial_num', 'dp_desc'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
desc = struct.unpack_from(ofproto_v1_0.OFP_DESC_STATS_PACK_STR,
|
||||
@ -954,7 +954,7 @@ class OFPFlowStats(object):
|
||||
flow_stats.cookie,
|
||||
flow_stats.packet_count,
|
||||
flow_stats.byte_count) = struct.unpack_from(
|
||||
ofproto_v1_0.OFP_FLOW_STATS_1_PACK_STR, buf, offset)
|
||||
ofproto_v1_0.OFP_FLOW_STATS_1_PACK_STR, buf, offset)
|
||||
offset += ofproto_v1_0.OFP_FLOW_STATS_1_SIZE
|
||||
|
||||
flow_stats.actions = []
|
||||
@ -969,8 +969,8 @@ class OFPFlowStats(object):
|
||||
return flow_stats
|
||||
|
||||
|
||||
class OFPAggregateStats(collections.namedtuple('OFPAggregateStats',
|
||||
('packet_count', 'byte_count', 'flow_count'))):
|
||||
class OFPAggregateStats(collections.namedtuple('OFPAggregateStats', (
|
||||
'packet_count', 'byte_count', 'flow_count'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
agg = struct.unpack_from(
|
||||
@ -980,9 +980,9 @@ class OFPAggregateStats(collections.namedtuple('OFPAggregateStats',
|
||||
return stats
|
||||
|
||||
|
||||
class OFPTableStats(collections.namedtuple('OFPTableStats',
|
||||
('table_id', 'name', 'wildcards', 'max_entries', 'active_count',
|
||||
'lookup_count', 'matched_count'))):
|
||||
class OFPTableStats(collections.namedtuple('OFPTableStats', (
|
||||
'table_id', 'name', 'wildcards', 'max_entries', 'active_count',
|
||||
'lookup_count', 'matched_count'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
tbl = struct.unpack_from(ofproto_v1_0.OFP_TABLE_STATS_PACK_STR,
|
||||
@ -992,10 +992,10 @@ class OFPTableStats(collections.namedtuple('OFPTableStats',
|
||||
return stats
|
||||
|
||||
|
||||
class OFPPortStats(collections.namedtuple('OFPPortStats',
|
||||
('port_no', 'rx_packets', 'tx_packets', 'rx_bytes', 'tx_bytes',
|
||||
'rx_dropped', 'tx_dropped', 'rx_errors', 'tx_errors',
|
||||
'rx_frame_err', 'rx_over_err', 'rx_crc_err', 'collisions'))):
|
||||
class OFPPortStats(collections.namedtuple('OFPPortStats', (
|
||||
'port_no', 'rx_packets', 'tx_packets', 'rx_bytes', 'tx_bytes',
|
||||
'rx_dropped', 'tx_dropped', 'rx_errors', 'tx_errors',
|
||||
'rx_frame_err', 'rx_over_err', 'rx_crc_err', 'collisions'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
port = struct.unpack_from(ofproto_v1_0.OFP_PORT_STATS_PACK_STR,
|
||||
@ -1005,8 +1005,8 @@ class OFPPortStats(collections.namedtuple('OFPPortStats',
|
||||
return stats
|
||||
|
||||
|
||||
class OFPQueueStats(collections.namedtuple('OFPQueueStats',
|
||||
('port_no', 'queue_id', 'tx_bytes', 'tx_packets', 'tx_errors'))):
|
||||
class OFPQueueStats(collections.namedtuple('OFPQueueStats', (
|
||||
'port_no', 'queue_id', 'tx_bytes', 'tx_packets', 'tx_errors'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
queue = struct.unpack_from(ofproto_v1_0.OFP_QUEUE_STATS_PACK_STR,
|
||||
@ -1385,7 +1385,7 @@ class NXTFlowRemoved(NiciraHeader):
|
||||
(cookie, priority, reason, duration_sec, duration_nsec,
|
||||
idle_timeout, match_len,
|
||||
packet_count, byte_count) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_FLOW_REMOVED_PACK_STR, buf, offset)
|
||||
ofproto_v1_0.NX_FLOW_REMOVED_PACK_STR, buf, offset)
|
||||
offset += (ofproto_v1_0.NX_FLOW_REMOVED_SIZE
|
||||
- ofproto_v1_0.NICIRA_HEADER_SIZE)
|
||||
match = nx_match.NXMatch.parser(buf, offset, match_len)
|
||||
@ -1425,8 +1425,8 @@ class NXTPacketIn(NiciraHeader):
|
||||
@classmethod
|
||||
def parser(cls, datapath, buf, offset):
|
||||
(buffer_id, total_len, reason, table_id,
|
||||
cookie, match_len) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_PACKET_IN_PACK_STR, buf, offset)
|
||||
cookie, match_len) = struct.unpack_from(
|
||||
ofproto_v1_0.NX_PACKET_IN_PACK_STR, buf, offset)
|
||||
|
||||
offset += (ofproto_v1_0.NX_PACKET_IN_SIZE
|
||||
- ofproto_v1_0.NICIRA_HEADER_SIZE)
|
||||
@ -1507,8 +1507,8 @@ class OFPSwitchFeatures(MsgBase):
|
||||
msg.n_tables,
|
||||
msg.capabilities,
|
||||
msg.actions) = struct.unpack_from(
|
||||
ofproto_v1_0.OFP_SWITCH_FEATURES_PACK_STR, msg.buf,
|
||||
ofproto_v1_0.OFP_HEADER_SIZE)
|
||||
ofproto_v1_0.OFP_SWITCH_FEATURES_PACK_STR, msg.buf,
|
||||
ofproto_v1_0.OFP_HEADER_SIZE)
|
||||
|
||||
msg.ports = {}
|
||||
n_ports = ((msg_len - ofproto_v1_0.OFP_SWITCH_FEATURES_SIZE) /
|
||||
@ -1532,7 +1532,7 @@ class OFPPortStatus(MsgBase):
|
||||
@classmethod
|
||||
def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
|
||||
msg = super(OFPPortStatus, cls).parser(datapath, version, msg_type,
|
||||
msg_len, xid, buf)
|
||||
msg_len, xid, buf)
|
||||
msg.reason = struct.unpack_from(
|
||||
ofproto_v1_0.OFP_PORT_STATUS_PACK_STR,
|
||||
msg.buf, ofproto_v1_0.OFP_HEADER_SIZE)[0]
|
||||
@ -1560,8 +1560,8 @@ class OFPPacketIn(MsgBase):
|
||||
msg.total_len,
|
||||
msg.in_port,
|
||||
msg.reason) = struct.unpack_from(
|
||||
ofproto_v1_0.OFP_PACKET_IN_PACK_STR,
|
||||
msg.buf, ofproto_v1_0.OFP_HEADER_SIZE)
|
||||
ofproto_v1_0.OFP_PACKET_IN_PACK_STR,
|
||||
msg.buf, ofproto_v1_0.OFP_HEADER_SIZE)
|
||||
msg.data = msg.buf[ofproto_v1_0.OFP_PACKET_IN_DATA_OFFSET:]
|
||||
if msg.total_len < len(msg.data):
|
||||
# discard padding for 8-byte alignment of OFP packet
|
||||
@ -1620,8 +1620,8 @@ class OFPFlowRemoved(MsgBase):
|
||||
msg.idle_timeout,
|
||||
msg.packet_count,
|
||||
msg.byte_count) = struct.unpack_from(
|
||||
ofproto_v1_0.OFP_FLOW_REMOVED_PACK_STR0, msg.buf,
|
||||
ofproto_v1_0.OFP_HEADER_SIZE + ofproto_v1_0.OFP_MATCH_SIZE)
|
||||
ofproto_v1_0.OFP_FLOW_REMOVED_PACK_STR0, msg.buf,
|
||||
ofproto_v1_0.OFP_HEADER_SIZE + ofproto_v1_0.OFP_MATCH_SIZE)
|
||||
|
||||
return msg
|
||||
|
||||
|
@ -140,8 +140,8 @@ class OFPExperimenter(MsgBase):
|
||||
|
||||
|
||||
class OFPPort(collections.namedtuple('OFPPort', (
|
||||
'port_no', 'hw_addr', 'name', 'config', 'state', 'curr',
|
||||
'advertised', 'supported', 'peer', 'curr_speed', 'max_speed'))):
|
||||
'port_no', 'hw_addr', 'name', 'config', 'state', 'curr',
|
||||
'advertised', 'supported', 'peer', 'curr_speed', 'max_speed'))):
|
||||
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
@ -170,8 +170,8 @@ class OFPSwitchFeatures(MsgBase):
|
||||
msg.n_tables,
|
||||
msg.capabilities,
|
||||
msg.reserved) = struct.unpack_from(
|
||||
ofproto_v1_2.OFP_SWITCH_FEATURES_PACK_STR, msg.buf,
|
||||
ofproto_v1_2.OFP_HEADER_SIZE)
|
||||
ofproto_v1_2.OFP_SWITCH_FEATURES_PACK_STR, msg.buf,
|
||||
ofproto_v1_2.OFP_HEADER_SIZE)
|
||||
|
||||
msg.ports = {}
|
||||
n_ports = ((msg_len - ofproto_v1_2.OFP_SWITCH_FEATURES_SIZE) /
|
||||
@ -234,8 +234,8 @@ class OFPPacketIn(MsgBase):
|
||||
msg_len, xid, buf)
|
||||
(msg.buffer_id, msg.total_len, msg.reason,
|
||||
msg.table_id) = struct.unpack_from(
|
||||
ofproto_v1_2.OFP_PACKET_IN_PACK_STR,
|
||||
msg.buf, ofproto_v1_2.OFP_HEADER_SIZE)
|
||||
ofproto_v1_2.OFP_PACKET_IN_PACK_STR,
|
||||
msg.buf, ofproto_v1_2.OFP_HEADER_SIZE)
|
||||
|
||||
msg.match = OFPMatch.parser(msg.buf, ofproto_v1_2.OFP_PACKET_IN_SIZE -
|
||||
ofproto_v1_2.OFP_MATCH_SIZE)
|
||||
@ -266,9 +266,9 @@ class OFPFlowRemoved(MsgBase):
|
||||
msg.table_id, msg.duration_sec, msg.duration_nsec,
|
||||
msg.idle_timeout, msg.hard_timeout, msg.packet_count,
|
||||
msg.byte_count) = struct.unpack_from(
|
||||
ofproto_v1_2.OFP_FLOW_REMOVED_PACK_STR0,
|
||||
msg.buf,
|
||||
ofproto_v1_2.OFP_HEADER_SIZE)
|
||||
ofproto_v1_2.OFP_FLOW_REMOVED_PACK_STR0,
|
||||
msg.buf,
|
||||
ofproto_v1_2.OFP_HEADER_SIZE)
|
||||
|
||||
offset = (ofproto_v1_2.OFP_FLOW_REMOVED_SIZE -
|
||||
ofproto_v1_2.OFP_MATCH_SIZE)
|
||||
@ -922,8 +922,8 @@ class OFPDescStatsRequest(OFPStatsRequest):
|
||||
|
||||
@OFPStatsReply.register_stats_reply_type(ofproto_v1_2.OFPST_DESC,
|
||||
body_single_struct=True)
|
||||
class OFPDescStats(collections.namedtuple('OFPDescStats',
|
||||
('mfr_desc', 'hw_desc', 'sw_desc', 'serial_num', 'dp_desc'))):
|
||||
class OFPDescStats(collections.namedtuple('OFPDescStats', (
|
||||
'mfr_desc', 'hw_desc', 'sw_desc', 'serial_num', 'dp_desc'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
desc = struct.unpack_from(ofproto_v1_2.OFP_DESC_STATS_PACK_STR,
|
||||
@ -984,8 +984,8 @@ class OFPFlowStats(object):
|
||||
duration_nsec, priority,
|
||||
idle_timeout, hard_timeout,
|
||||
cookie, packet_count, byte_count) = struct.unpack_from(
|
||||
ofproto_v1_2.OFP_FLOW_STATS_PACK_STR,
|
||||
buf, offset)
|
||||
ofproto_v1_2.OFP_FLOW_STATS_PACK_STR,
|
||||
buf, offset)
|
||||
offset += (ofproto_v1_2.OFP_FLOW_STATS_SIZE -
|
||||
ofproto_v1_2.OFP_MATCH_SIZE)
|
||||
match = OFPMatch.parser(buf, offset)
|
||||
@ -1036,8 +1036,8 @@ class OFPAggregateStatsRequest(OFPStatsRequest):
|
||||
|
||||
@OFPStatsReply.register_stats_reply_type(ofproto_v1_2.OFPST_AGGREGATE,
|
||||
body_single_struct=True)
|
||||
class OFPAggregateStatsReply(collections.namedtuple('OFPAggregateStats',
|
||||
('packet_count', 'byte_count', 'flow_count'))):
|
||||
class OFPAggregateStatsReply(collections.namedtuple('OFPAggregateStats', (
|
||||
'packet_count', 'byte_count', 'flow_count'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
desc = struct.unpack_from(
|
||||
@ -1176,9 +1176,9 @@ class OFPGroupStats(object):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
(length, group_id, ref_count, packet_count,
|
||||
byte_count) = struct.unpack_from(
|
||||
ofproto_v1_2.OFP_GROUP_STATS_PACK_STR,
|
||||
buf, offset)
|
||||
byte_count) = struct.unpack_from(
|
||||
ofproto_v1_2.OFP_GROUP_STATS_PACK_STR,
|
||||
buf, offset)
|
||||
|
||||
bucket_len = length - ofproto_v1_2.OFP_GROUP_STATS_SIZE
|
||||
offset += ofproto_v1_2.OFP_GROUP_STATS_SIZE
|
||||
|
@ -767,7 +767,7 @@ OFP_PACKET_IN_PACK_STR = '!IHBBQ' + _OFP_MATCH_PACK_STR
|
||||
OFP_PACKET_IN_SIZE = 32
|
||||
OFP_PACKET_IN_DATA_OFFSET = 18
|
||||
assert (calcsize(OFP_PACKET_IN_PACK_STR) + OFP_HEADER_SIZE ==
|
||||
OFP_PACKET_IN_SIZE)
|
||||
OFP_PACKET_IN_SIZE)
|
||||
|
||||
# enum ofp_packet_in_reason
|
||||
OFPR_NO_MATCH = 0 # No matching flow.
|
||||
|
@ -165,8 +165,8 @@ class OFPSwitchFeatures(MsgBase):
|
||||
msg.auxiliary_id,
|
||||
msg.capabilities,
|
||||
msg.reserved) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_SWITCH_FEATURES_PACK_STR, msg.buf,
|
||||
ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
ofproto_v1_3.OFP_SWITCH_FEATURES_PACK_STR, msg.buf,
|
||||
ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
return msg
|
||||
|
||||
|
||||
@ -228,8 +228,8 @@ class OFPPacketIn(MsgBase):
|
||||
msg_len, xid, buf)
|
||||
(msg.buffer_id, msg.total_len, msg.reason,
|
||||
msg.table_id, msg.cookie) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_PACKET_IN_PACK_STR,
|
||||
msg.buf, ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
ofproto_v1_3.OFP_PACKET_IN_PACK_STR,
|
||||
msg.buf, ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
|
||||
offset = ofproto_v1_3.OFP_HEADER_SIZE + ofproto_v1_3.OFP_PACKET_IN_SIZE
|
||||
msg.match = OFPMatch.parser(buf, offset - ofproto_v1_3.OFP_MATCH_SIZE)
|
||||
@ -251,8 +251,8 @@ class OFPFlowRemoved(MsgBase):
|
||||
msg.table_id, msg.duration_sec, msg.duration_nsec,
|
||||
msg.idle_timeout, msg.hard_timeout, msg.packet_count,
|
||||
msg.byte_count) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_FLOW_REMOVED_PACK_STR0,
|
||||
msg.buf, ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
ofproto_v1_3.OFP_FLOW_REMOVED_PACK_STR0,
|
||||
msg.buf, ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
|
||||
offset = (ofproto_v1_3.OFP_FLOW_REMOVED_SIZE -
|
||||
ofproto_v1_3.OFP_MATCH_SIZE)
|
||||
@ -263,8 +263,8 @@ class OFPFlowRemoved(MsgBase):
|
||||
|
||||
|
||||
class OFPPort(collections.namedtuple('OFPPort', (
|
||||
'port_no', 'hw_addr', 'name', 'config', 'state', 'curr',
|
||||
'advertised', 'supported', 'peer', 'curr_speed', 'max_speed'))):
|
||||
'port_no', 'hw_addr', 'name', 'config', 'state', 'curr',
|
||||
'advertised', 'supported', 'peer', 'curr_speed', 'max_speed'))):
|
||||
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
@ -639,7 +639,7 @@ class OFPBucket(object):
|
||||
def parser(cls, buf, offset):
|
||||
(msg.len, msg.weigth, msg.watch_port,
|
||||
msg.watch_group) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_BUCKET_PACK_STR, buf, offset)
|
||||
ofproto_v1_3.OFP_BUCKET_PACK_STR, buf, offset)
|
||||
|
||||
length = ofproto_v1_3.OFP_BUCKET_SIZE
|
||||
offset += ofproto_v1_3.OFP_BUCKET_SIZE
|
||||
@ -786,8 +786,8 @@ class OFPMultipartReply(MsgBase):
|
||||
return msg
|
||||
|
||||
|
||||
class OFPDescStats(collections.namedtuple('OFPDescStats',
|
||||
('mfr_desc', 'hw_desc', 'sw_desc', 'serial_num', 'dp_desc'))):
|
||||
class OFPDescStats(collections.namedtuple('OFPDescStats', (
|
||||
'mfr_desc', 'hw_desc', 'sw_desc', 'serial_num', 'dp_desc'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
desc = struct.unpack_from(ofproto_v1_3.OFP_DESC_PACK_STR,
|
||||
@ -837,7 +837,7 @@ class OFPFlowStats(object):
|
||||
flow_stats.priority, flow_stats.idle_timeout,
|
||||
flow_stats.cookie, flow_stats.packet_count,
|
||||
flow_stats.byte_count) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_FLOW_STATS_0_PACK_STR, buf, offset)
|
||||
ofproto_v1_3.OFP_FLOW_STATS_0_PACK_STR, buf, offset)
|
||||
offset += ofproto_v1_3.OFP_FLOW_STATS_0_SIZE
|
||||
|
||||
flow_stats.match = OFPMatch.parse(buf, offset)
|
||||
@ -884,8 +884,8 @@ class OFPFlowStatsReply(OFPMultipartReply):
|
||||
super(OFPFlowStatsReply, self).__init__(datapath)
|
||||
|
||||
|
||||
class OFPAggregateStats(collections.namedtuple('OFPAggregateStats',
|
||||
('packet_count', 'byte_count', 'flow_count'))):
|
||||
class OFPAggregateStats(collections.namedtuple('OFPAggregateStats', (
|
||||
'packet_count', 'byte_count', 'flow_count'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
agg = struct.unpack_from(
|
||||
@ -916,9 +916,9 @@ class OFPAggregateStatsReply(OFPMultipartReply):
|
||||
super(OFPAggregateStatsReply, self).__init__(datapath)
|
||||
|
||||
|
||||
class OFPTableStats(collections.namedtuple('OFPTableStats',
|
||||
('table_id', 'active_count', 'lookup_count',
|
||||
'matched_count'))):
|
||||
class OFPTableStats(collections.namedtuple('OFPTableStats', (
|
||||
'table_id', 'active_count', 'lookup_count',
|
||||
'matched_count'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
tbl = struct.unpack_from(ofproto_v1_3.OFP_TABLE_STATS_PACK_STR,
|
||||
@ -943,11 +943,11 @@ class OFPTableStatsReply(OFPMultipartReply):
|
||||
super(OFPTableStatsReply, self).__init__(datapath)
|
||||
|
||||
|
||||
class OFPPortStats(collections.namedtuple('OFPPortStats',
|
||||
('port_no', 'rx_packets', 'tx_packets', 'rx_bytes', 'tx_bytes',
|
||||
'rx_dropped', 'tx_dropped', 'rx_errors', 'tx_errors',
|
||||
'rx_frame_err', 'rx_over_err', 'rx_crc_err', 'collisions',
|
||||
'duration_sec', 'duration_nsec'))):
|
||||
class OFPPortStats(collections.namedtuple('OFPPortStats', (
|
||||
'port_no', 'rx_packets', 'tx_packets', 'rx_bytes', 'tx_bytes',
|
||||
'rx_dropped', 'tx_dropped', 'rx_errors', 'tx_errors',
|
||||
'rx_frame_err', 'rx_over_err', 'rx_crc_err', 'collisions',
|
||||
'duration_sec', 'duration_nsec'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
port = struct.unpack_from(ofproto_v1_3.OFP_PORT_STATS_PACK_STR,
|
||||
@ -979,13 +979,13 @@ class OFPPortStatsReply(OFPMultipartReply):
|
||||
super(OFPPortStatsReply, self).__init__(datapath)
|
||||
|
||||
|
||||
class OFPQueueStats(collections.namedtuple('OFPQueueStats',
|
||||
('port_no', 'queue_id', 'tx_bytes', 'tx_packets', 'tx_errors',
|
||||
'duration_sec', 'duration_nsec'))):
|
||||
class OFPQueueStats(collections.namedtuple('OFPQueueStats', (
|
||||
'port_no', 'queue_id', 'tx_bytes', 'tx_packets', 'tx_errors',
|
||||
'duration_sec', 'duration_nsec'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
queue = struct.unpack_from(ofproto_v1_3.OFP_QUEUE_STATS_PACK_STR,
|
||||
buf, offset)
|
||||
buf, offset)
|
||||
stats = cls(*queue)
|
||||
stats.length = ofproto_v1_3.OFP_QUEUE_STATS_SIZE
|
||||
return stats
|
||||
@ -1014,9 +1014,9 @@ class OFPQueueStatsReply(OFPMultipartReply):
|
||||
super(OFPQueueStatsReply, self).__init__(datapath)
|
||||
|
||||
|
||||
class OFPGroupStats(collections.namedtuple('OFPGroupStats',
|
||||
('length', 'group_id', 'ref_count', 'packet_count',
|
||||
'byte_count', 'duration_sec', 'duration_nsec'))):
|
||||
class OFPGroupStats(collections.namedtuple('OFPGroupStats', (
|
||||
'length', 'group_id', 'ref_count', 'packet_count',
|
||||
'byte_count', 'duration_sec', 'duration_nsec'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
group = struct.unpack_from(ofproto_v1_3.OFP_GROUP_STATS_PACK_STR,
|
||||
@ -1091,8 +1091,8 @@ class OFPGroupDescStatsReply(OFPMultipartReply):
|
||||
super(OFPGroupDescStatsReply, self).__init__(datapath)
|
||||
|
||||
|
||||
class OFPGroupFeaturesStats(collections.namedtuple('OFPGroupFeaturesStats',
|
||||
('types', 'capabilities', 'max_groups', 'actions'))):
|
||||
class OFPGroupFeaturesStats(collections.namedtuple('OFPGroupFeaturesStats', (
|
||||
'types', 'capabilities', 'max_groups', 'actions'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
group_features = struct.unpack_from(
|
||||
@ -1150,7 +1150,7 @@ class OFPMeterStats(object):
|
||||
meter_stats.flow_count, meter_stats.packet_in_count,
|
||||
meter_stats.byte_in_count, meter_stats.duration_sec,
|
||||
meter_stats.duration_nsec) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_METER_STATS_PACK_STR, buf, offset)
|
||||
ofproto_v1_3.OFP_METER_STATS_PACK_STR, buf, offset)
|
||||
offset += ofproto_v1_3.OFP_METER_STATS_SIZE
|
||||
|
||||
meter_stats.band_stats = []
|
||||
@ -1214,7 +1214,7 @@ class OFPMeterConfigStats(object):
|
||||
|
||||
(meter_config.length, meter_config.flags,
|
||||
meter_config.meter_id) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_METER_CONFIG_PACK_STR, buf, offset)
|
||||
ofproto_v1_3.OFP_METER_CONFIG_PACK_STR, buf, offset)
|
||||
offset += ofproto_v1_3.OFP_METER_CONFIG_SIZE
|
||||
|
||||
meter_config.bands = []
|
||||
@ -1250,9 +1250,9 @@ class OFPMeterConfigStatsReply(OFPMultipartReply):
|
||||
super(OFPMeterConfigStatsReply, self).__init__(datapath)
|
||||
|
||||
|
||||
class OFPMeterFeaturesStats(collections.namedtuple('OFPMeterFeaturesStats',
|
||||
('max_meter', 'band_types', 'capabilities', 'max_band',
|
||||
'max_color'))):
|
||||
class OFPMeterFeaturesStats(collections.namedtuple('OFPMeterFeaturesStats', (
|
||||
'max_meter', 'band_types', 'capabilities', 'max_band',
|
||||
'max_color'))):
|
||||
@classmethod
|
||||
def parser(cls, buf, offset):
|
||||
meter_features = struct.unpack_from(
|
||||
@ -1295,9 +1295,9 @@ class OFPTableFeaturesStats(object):
|
||||
(table_features.length, table_features.table_id,
|
||||
table_features.name, table_features.metadata_match,
|
||||
table_features.write, table_features.config,
|
||||
table_features.max_entries, table_features.properties) = \
|
||||
struct.unpack_from(ofproto_v1_3.OFP_TABLE_FEATURES_PACK_STR,
|
||||
buf, offset)
|
||||
table_features.max_entries, table_features.properties
|
||||
) = struct.unpack_from(ofproto_v1_3.OFP_TABLE_FEATURES_PACK_STR,
|
||||
buf, offset)
|
||||
offset += ofproto_v1_3.OFP_TABLE_FEATURES_SIZE
|
||||
|
||||
# TODO: parse ofp_table_feature_prop_header
|
||||
@ -1547,8 +1547,8 @@ class OFPGetAsyncReply(MsgBase):
|
||||
xid, buf)
|
||||
(msg.packet_in_mask, msg.port_status_mask,
|
||||
msg.flow_removed_mask) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_ASYNC_CONFIG_PACK_STR, msg.buf,
|
||||
ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
ofproto_v1_3.OFP_ASYNC_CONFIG_PACK_STR, msg.buf,
|
||||
ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
|
||||
|
||||
@_register_parser
|
||||
@ -1564,5 +1564,5 @@ class OFPGetAsyncReply(MsgBase):
|
||||
xid, buf)
|
||||
(msg.packet_in_mask, msg.port_status_mask,
|
||||
msg.flow_removed_mask) = struct.unpack_from(
|
||||
ofproto_v1_3.OFP_ASYNC_CONFIG_PACK_STR, msg.buf,
|
||||
ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
ofproto_v1_3.OFP_ASYNC_CONFIG_PACK_STR, msg.buf,
|
||||
ofproto_v1_3.OFP_HEADER_SIZE)
|
||||
|
3
setup.py
3
setup.py
@ -37,7 +37,7 @@ classifiers = [
|
||||
'Natural Language :: English',
|
||||
'Programming Language :: Python',
|
||||
'Operating System :: Unix',
|
||||
]
|
||||
]
|
||||
|
||||
setup(name='ryu',
|
||||
version=version,
|
||||
@ -53,5 +53,4 @@ setup(name='ryu',
|
||||
scripts=['bin/ryu-manager',
|
||||
'bin/ryu-client'],
|
||||
data_files=[('/etc/ryu', ['etc/ryu/ryu.conf'])],
|
||||
# install_requires=[]
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user