Signed-off-by: FUJITA Tomonori <[email protected]>
---
 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 82d6e69..4a980ea 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -872,6 +872,8 @@ class Flow(object):
         self.ip_proto = 0
         self.ipv4_src = 0
         self.ipv4_dst = 0
+        self.tcp_src = 0
+        self.tcp_dst = 0
         self.arp_op = 0
         self.arp_spa = 0
         self.arp_tpa = 0
@@ -973,6 +975,14 @@ class OFPMatch(object):
                 self.fields.append(
                     OFPMatchField.make(ofproto_v1_2.OXM_OF_IPV4_DST_W))
 
+        if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_TCP_SRC):
+            self.fields.append(
+                OFPMatchField.make(ofproto_v1_2.OXM_OF_TCP_SRC))
+
+        if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_TCP_DST):
+            self.fields.append(
+                OFPMatchField.make(ofproto_v1_2.OXM_OF_TCP_DST))
+
         if self.wc.ft_test(ofproto_v1_2.OFPXMT_OFB_ARP_OP):
             self.fields.append(
                 OFPMatchField.make(ofproto_v1_2.OXM_OF_ARP_OP))
@@ -1099,6 +1109,14 @@ class OFPMatch(object):
         self.flow.ipv4_dst = ipv4_dst
         self.wc.ipv4_dst_mask = mask
 
+    def set_tcp_src(self, tcp_src):
+        self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_TCP_SRC)
+        self.flow.tcp_src = tcp_src
+
+    def set_tcp_dst(self, tcp_dst):
+        self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_TCP_DST)
+        self.flow.tcp_dst = tcp_dst
+
     def set_arp_opcode(self, arp_op):
         self.wc.ft_set(ofproto_v1_2.OFPXMT_OFB_ARP_OP)
         self.flow.arp_op = arp_op
@@ -1378,6 +1396,32 @@ class MTIPV4Dst(OFPMatchField):
         return MTIPV4Dst(header)
 
 
[email protected]_field_header([ofproto_v1_2.OXM_OF_TCP_SRC])
+class MTTCPSrc(OFPMatchField):
+    def __init__(self, header):
+        super(MTTCPSrc, self).__init__(header, '!H')
+
+    def serialize(self, buf, offset, match):
+        self.put(buf, offset, match.flow.tcp_src)
+
+    @classmethod
+    def parser(cls, header, buf, offset):
+        return MTTCPSrc(header)
+
+
[email protected]_field_header([ofproto_v1_2.OXM_OF_TCP_DST])
+class MTTCPDst(OFPMatchField):
+    def __init__(self, header):
+        super(MTTCPDst, self).__init__(header, '!H')
+
+    def serialize(self, buf, offset, match):
+        self.put(buf, offset, match.flow.tcp_dst)
+
+    @classmethod
+    def parser(cls, header, buf, offset):
+        return MTTCPDst(header)
+
+
 @OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_ARP_OP])
 class MTArpOp(OFPMatchField):
     def __init__(self, header):
-- 
1.7.4.4


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to