blob: c5445f377f60e879a1e52cf8c0c301e1bfb76adc [file] [log] [blame]
Rich Lanedacbe732013-01-29 17:32:11 -08001import logging
2import struct
3
4from oftest import config
5import of10 as ofp
6import oftest.base_tests as base_tests
7
8from oftest.testutils import *
9
10class action_nx_dec_ttl(ofp.action.action_vendor):
11 def __init__(self):
12 ofp.action.action_vendor.__init__(self)
13 self.vendor = 0x00002320
14
15 def pack(self):
16 return ofp.action.action_vendor.pack(self) + struct.pack("!HHL", 18, 0x0, 0x0)
17
18 def __len__(self):
19 return 16
20
21 def show(self, prefix=''):
22 return prefix + 'dec_ttl: ' + '\n' + ofp.action.action_vendor.show(self)
23
24@nonstandard
25class TtlDecrement(base_tests.SimpleDataPlane):
26 def runTest(self):
27 of_ports = config["port_map"].keys()
28 of_ports.sort()
29 self.assertTrue(len(of_ports) >= 3, "Not enough ports for test")
30 portA = of_ports[0]
31 portB = of_ports[1]
32 portC = of_ports[2]
33
34 outpkt = simple_tcp_packet(pktlen=100, ip_ttl=3)
35 msg = ofp.message.packet_out(in_port=ofp.OFPP_NONE,
36 data=str(outpkt),
37 actions=[
38 action_nx_dec_ttl(),
39 ofp.action.output(port=portA),
40 action_nx_dec_ttl(),
41 ofp.action.output(port=portB),
42 action_nx_dec_ttl(),
43 ofp.action.output(port=portC)])
44 self.controller.message_send(msg)
45
46 receive_pkt_check(self.dataplane, simple_tcp_packet(ip_ttl=2), [portA], [], self)
47 receive_pkt_check(self.dataplane, simple_tcp_packet(ip_ttl=1), [portB], [], self)
48 receive_pkt_check(self.dataplane, simple_tcp_packet(ip_ttl=0), [], [portC], self)