def test_flow_stats_reply_pack(self): import loxi.of10 as ofp msg = ofp.message.flow_stats_reply(xid=6, flags=0, entries=[ ofp.flow_stats_entry(table_id=3, match=ofp.match(), duration_sec=1, duration_nsec=2, priority=100, idle_timeout=5, hard_timeout=10, cookie=0x0123456789abcdef, packet_count=10, byte_count=1000, actions=[ofp.action.output(port=1), ofp.action.output(port=2)]), ofp.flow_stats_entry(table_id=4, match=ofp.match(), duration_sec=1, duration_nsec=2, priority=100, idle_timeout=5, hard_timeout=10, cookie=0x0123456789abcdef, packet_count=10, byte_count=1000, actions=[ofp.action.output(port=1), ofp.action.output(port=2), ofp.action.output(port=3)])]) self.assertEquals(self.sample_flow_stats_reply_buf, msg.pack())
def test_flow_stats_reply_pack(self): msg = ofp.message.flow_stats_reply( xid=6, flags=0, entries=[ ofp.flow_stats_entry(table_id=3, match=ofp.match(), duration_sec=1, duration_nsec=2, priority=100, idle_timeout=5, hard_timeout=10, cookie=0x0123456789abcdef, packet_count=10, byte_count=1000, actions=[ ofp.action.output(port=1), ofp.action.output(port=2) ]), ofp.flow_stats_entry(table_id=4, match=ofp.match(), duration_sec=1, duration_nsec=2, priority=100, idle_timeout=5, hard_timeout=10, cookie=0x0123456789abcdef, packet_count=10, byte_count=1000, actions=[ ofp.action.output(port=1), ofp.action.output(port=2), ofp.action.output(port=3) ]) ]) self.assertEquals(self.sample_flow_stats_reply_buf, msg.pack())
def test_flow_stats_entry_pack(self): obj = ofp.flow_stats_entry( table_id=3, match=ofp.match(), duration_sec=1, duration_nsec=2, priority=100, idle_timeout=5, hard_timeout=10, cookie=0x0123456789abcdef, packet_count=10, byte_count=1000, actions=[ofp.action.output(port=1), ofp.action.output(port=2)]) expected = ''.join([ '\x00\x68', # length '\x03', # table_id '\x00', # pad '\x00\x3f\xff\xff', # match.wildcards '\x00' * 36, # remaining match fields '\x00\x00\x00\x01', # duration_sec '\x00\x00\x00\x02', # duration_nsec '\x00\x64', # priority '\x00\x05', # idle_timeout '\x00\x0a', # hard_timeout '\x00' * 6, # pad2 '\x01\x23\x45\x67\x89\xab\xcd\xef', # cookie '\x00\x00\x00\x00\x00\x00\x00\x0a', # packet_count '\x00\x00\x00\x00\x00\x00\x03\xe8', # byte_count '\x00\x00', # actions[0].type '\x00\x08', # actions[0].len '\x00\x01', # actions[0].port '\x00\x00', # actions[0].max_len '\x00\x00', # actions[1].type '\x00\x08', # actions[1].len '\x00\x02', # actions[1].port '\x00\x00', # actions[1].max_len ]) self.assertEquals(expected, obj.pack())
def test_flow_stats_entry_pack(self): import loxi.of10 as ofp obj = ofp.flow_stats_entry(table_id=3, match=ofp.match(), duration_sec=1, duration_nsec=2, priority=100, idle_timeout=5, hard_timeout=10, cookie=0x0123456789abcdef, packet_count=10, byte_count=1000, actions=[ofp.action.output(port=1), ofp.action.output(port=2)]) expected = ''.join([ '\x00\x68', # length '\x03', # table_id '\x00', # pad '\x00\x3f\xff\xff', # match.wildcards '\x00' * 36, # remaining match fields '\x00\x00\x00\x01', # duration_sec '\x00\x00\x00\x02', # duration_nsec '\x00\x64', # priority '\x00\x05', # idle_timeout '\x00\x0a', # hard_timeout '\x00' * 6, # pad2 '\x01\x23\x45\x67\x89\xab\xcd\xef', # cookie '\x00\x00\x00\x00\x00\x00\x00\x0a', # packet_count '\x00\x00\x00\x00\x00\x00\x03\xe8', # byte_count '\x00\x00', # actions[0].type '\x00\x08', # actions[0].len '\x00\x01', # actions[0].port '\x00\x00', # actions[0].max_len '\x00\x00', # actions[1].type '\x00\x08', # actions[1].len '\x00\x02', # actions[1].port '\x00\x00', # actions[1].max_len ]) self.assertEquals(expected, obj.pack())