diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-06-23 10:44:03 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-06-23 15:56:53 +0900 |
commit | c9ac97c2b1518b82a15146d8a555dd18d781e0c1 (patch) | |
tree | fe27c31d58bab4724e53d3be6081c2beb79d7991 | |
parent | e931aeb2996775806c3c0901968cc85ee5c17a2d (diff) |
of1.2: add OXM_OF_ICMPV4_TYPE and OXM_OF_ICMPV4_CODE
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | ryu/ofproto/ofproto_v1_2_parser.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index cd21eab0..923ab618 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -878,6 +878,8 @@ class Flow(object): self.udp_dst = 0 self.sctp_src = 0 self.sctp_dst = 0 + self.icmpv4_type = 0 + self.icmpv4_code = 0 self.arp_op = 0 self.arp_spa = 0 self.arp_tpa = 0 @@ -1003,6 +1005,14 @@ class OFPMatch(object): self.fields.append( OFPMatchField.make(ofproto_v1_2.OXM_OF_SCTP_DST)) + if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_ICMPV4_TYPE): + self.fields.append( + OFPMatchField.make(ofproto_v1_2.OXM_OF_ICMPV4_TYPE)) + + if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_ICMPV4_CODE): + self.fields.append( + OFPMatchField.make(ofproto_v1_2.OXM_OF_ICMPV4_CODE)) + if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_ARP_OP): self.fields.append( OFPMatchField.make(ofproto_v1_2.OXM_OF_ARP_OP)) @@ -1153,6 +1163,14 @@ class OFPMatch(object): self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_SCTP_DST) self.flow.sctp_dst = sctp_dst + def set_icmpv4_type(self, icmpv4_type): + self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_ICMPV4_TYPE) + self.flow.icmpv4_type = icmpv4_type + + def set_icmpv4_code(self, icmpv4_code): + self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_ICMPV4_CODE) + self.flow.icmpv4_code = icmpv4_code + def set_arp_opcode(self, arp_op): self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_ARP_OP) self.flow.arp_op = arp_op @@ -1510,6 +1528,32 @@ class MTSCTPDst(OFPMatchField): return MTSCTPDst(header) +@OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_ICMPV4_TYPE]) +class MTICMPV4Type(OFPMatchField): + def __init__(self, header): + super(MTICMPV4Type, self).__init__(header, '!B') + + def serialize(self, buf, offset, match): + self.put(buf, offset, match.flow.icmpv4_type) + + @classmethod + def parser(cls, header, buf, offset): + return MTICMPV4Type(header) + + +@OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_ICMPV4_CODE]) +class MTICMPV4Code(OFPMatchField): + def __init__(self, header): + super(MTICMPV4Code, self).__init__(header, '!B') + + def serialize(self, buf, offset, match): + self.put(buf, offset, match.flow.icmpv4_code) + + @classmethod + def parser(cls, header, buf, offset): + return MTICMPV4Code(header) + + @OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_ARP_OP]) class MTArpOp(OFPMatchField): def __init__(self, header): |