A motivation of this change is a better modularity.
I.e. Make packet lib independent from ofproto.

Signed-off-by: YAMAMOTO Takashi <yamam...@valinux.co.jp>
---
 ryu/lib/packet/arp.py         |  2 +-
 ryu/lib/packet/ether_types.py | 27 +++++++++++++++++++++++++++
 ryu/lib/packet/ethernet.py    |  2 +-
 ryu/lib/packet/in_proto.py    | 31 +++++++++++++++++++++++++++++++
 ryu/lib/packet/ipv4.py        |  2 +-
 ryu/lib/packet/ipv6.py        |  2 +-
 ryu/lib/packet/linux.py       |  2 +-
 ryu/lib/packet/mpls.py        |  2 +-
 ryu/lib/packet/pbb.py         |  1 -
 ryu/lib/packet/vlan.py        |  2 +-
 ryu/lib/packet/vrrp.py        |  4 ++--
 ryu/ofproto/ether.py          | 28 ++--------------------------
 ryu/ofproto/inet.py           | 32 ++------------------------------
 13 files changed, 71 insertions(+), 66 deletions(-)
 create mode 100644 ryu/lib/packet/ether_types.py
 create mode 100644 ryu/lib/packet/in_proto.py

diff --git a/ryu/lib/packet/arp.py b/ryu/lib/packet/arp.py
index 5ccdb02..dc78f2b 100644
--- a/ryu/lib/packet/arp.py
+++ b/ryu/lib/packet/arp.py
@@ -15,8 +15,8 @@
 
 import struct
 
-from ryu.ofproto import ether
 from ryu.lib import addrconv
+from . import ether_types as ether
 from . import packet_base
 
 ARP_HW_TYPE_ETHERNET = 1  # ethernet hardware type
diff --git a/ryu/lib/packet/ether_types.py b/ryu/lib/packet/ether_types.py
new file mode 100644
index 0000000..bfa7899
--- /dev/null
+++ b/ryu/lib/packet/ether_types.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+ETH_TYPE_IP = 0x0800
+ETH_TYPE_ARP = 0x0806
+ETH_TYPE_8021Q = 0x8100
+ETH_TYPE_IPV6 = 0x86dd
+ETH_TYPE_SLOW = 0x8809
+ETH_TYPE_MPLS = 0x8847
+ETH_TYPE_8021AD = 0x88a8
+ETH_TYPE_LLDP = 0x88cc
+ETH_TYPE_8021AH = 0x88e7
+ETH_TYPE_IEEE802_3 = 0x05dc
+ETH_TYPE_CFM = 0x8902
diff --git a/ryu/lib/packet/ethernet.py b/ryu/lib/packet/ethernet.py
index 1d89e0d..33ef9c6 100644
--- a/ryu/lib/packet/ethernet.py
+++ b/ryu/lib/packet/ethernet.py
@@ -17,7 +17,7 @@ import struct
 from . import packet_base
 from . import vlan
 from . import mpls
-from ryu.ofproto import ether
+from . import ether_types as ether
 from ryu.lib import addrconv
 
 
diff --git a/ryu/lib/packet/in_proto.py b/ryu/lib/packet/in_proto.py
new file mode 100644
index 0000000..64f59fd
--- /dev/null
+++ b/ryu/lib/packet/in_proto.py
@@ -0,0 +1,31 @@
+# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+IPPROTO_IP = 0
+IPPROTO_HOPOPTS = 0
+IPPROTO_ICMP = 1
+IPPROTO_IGMP = 2
+IPPROTO_TCP = 6
+IPPROTO_UDP = 17
+IPPROTO_ROUTING = 43
+IPPROTO_FRAGMENT = 44
+IPPROTO_AH = 51
+IPPROTO_ICMPV6 = 58
+IPPROTO_NONE = 59
+IPPROTO_DSTOPTS = 60
+IPPROTO_OSPF = 89
+IPPROTO_VRRP = 112
+IPPROTO_SCTP = 132
diff --git a/ryu/lib/packet/ipv4.py b/ryu/lib/packet/ipv4.py
index 4da0bcc..ac9b109 100644
--- a/ryu/lib/packet/ipv4.py
+++ b/ryu/lib/packet/ipv4.py
@@ -23,7 +23,7 @@ from . import udp
 from . import tcp
 from . import sctp
 from . import ospf
-from ryu.ofproto import inet
+from . import in_proto as inet
 from ryu.lib import addrconv
 
 
diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py
index 8f5fea7..8d0a82e 100644
--- a/ryu/lib/packet/ipv6.py
+++ b/ryu/lib/packet/ipv6.py
@@ -21,7 +21,7 @@ from . import icmpv6
 from . import tcp
 from . import udp
 from . import sctp
-from ryu.ofproto import inet
+from . import in_proto as inet
 from ryu.lib import addrconv
 from ryu.lib import stringify
 
diff --git a/ryu/lib/packet/linux.py b/ryu/lib/packet/linux.py
index 0b7d10f..f571cfe 100644
--- a/ryu/lib/packet/linux.py
+++ b/ryu/lib/packet/linux.py
@@ -17,7 +17,7 @@ import struct
 from . import packet_base
 from . import vlan
 from . import mpls
-from ryu.ofproto import ether
+from . import ether_types as ether
 from ryu.lib import addrconv
 
 
diff --git a/ryu/lib/packet/mpls.py b/ryu/lib/packet/mpls.py
index 7a56766..6e8c364 100644
--- a/ryu/lib/packet/mpls.py
+++ b/ryu/lib/packet/mpls.py
@@ -18,7 +18,7 @@ import socket
 from . import packet_base
 from . import packet_utils
 from . import ipv4
-from ryu.ofproto import ether
+from . import ether_types as ether
 
 
 class mpls(packet_base.PacketBase):
diff --git a/ryu/lib/packet/pbb.py b/ryu/lib/packet/pbb.py
index 7892436..e240be6 100644
--- a/ryu/lib/packet/pbb.py
+++ b/ryu/lib/packet/pbb.py
@@ -15,7 +15,6 @@
 
 import struct
 from ryu.lib.packet import packet_base
-from ryu.ofproto import ether
 
 
 class itag(packet_base.PacketBase):
diff --git a/ryu/lib/packet/vlan.py b/ryu/lib/packet/vlan.py
index f759e2c..5181517 100644
--- a/ryu/lib/packet/vlan.py
+++ b/ryu/lib/packet/vlan.py
@@ -25,7 +25,7 @@ from . import slow
 from . import llc
 from . import pbb
 from . import cfm
-from ryu.ofproto import ether
+from . import ether_types as ether
 
 
 @six.add_metaclass(abc.ABCMeta)
diff --git a/ryu/lib/packet/vrrp.py b/ryu/lib/packet/vrrp.py
index 2067fb2..cca5690 100644
--- a/ryu/lib/packet/vrrp.py
+++ b/ryu/lib/packet/vrrp.py
@@ -70,14 +70,14 @@ VRRP v3 packet format
 import struct
 
 from ryu.lib.packet import ethernet
+from ryu.lib.packet import ether_types as ether
+from ryu.lib.packet import in_proto as inet
 from ryu.lib.packet import ipv4
 from ryu.lib.packet import ipv6
 from ryu.lib.packet import packet
 from ryu.lib.packet import packet_base
 from ryu.lib.packet import packet_utils
 from ryu.lib.packet import vlan
-from ryu.ofproto import ether
-from ryu.ofproto import inet
 from ryu.lib import addrconv
 
 
diff --git a/ryu/ofproto/ether.py b/ryu/ofproto/ether.py
index bfa7899..80df988 100644
--- a/ryu/ofproto/ether.py
+++ b/ryu/ofproto/ether.py
@@ -1,27 +1,3 @@
-# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# This module is for backward compat
 
-
-ETH_TYPE_IP = 0x0800
-ETH_TYPE_ARP = 0x0806
-ETH_TYPE_8021Q = 0x8100
-ETH_TYPE_IPV6 = 0x86dd
-ETH_TYPE_SLOW = 0x8809
-ETH_TYPE_MPLS = 0x8847
-ETH_TYPE_8021AD = 0x88a8
-ETH_TYPE_LLDP = 0x88cc
-ETH_TYPE_8021AH = 0x88e7
-ETH_TYPE_IEEE802_3 = 0x05dc
-ETH_TYPE_CFM = 0x8902
+from ryu.lib.packet.ether_types import *
diff --git a/ryu/ofproto/inet.py b/ryu/ofproto/inet.py
index 64f59fd..7a6478e 100644
--- a/ryu/ofproto/inet.py
+++ b/ryu/ofproto/inet.py
@@ -1,31 +1,3 @@
-# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# This module is for backward compat
 
-
-IPPROTO_IP = 0
-IPPROTO_HOPOPTS = 0
-IPPROTO_ICMP = 1
-IPPROTO_IGMP = 2
-IPPROTO_TCP = 6
-IPPROTO_UDP = 17
-IPPROTO_ROUTING = 43
-IPPROTO_FRAGMENT = 44
-IPPROTO_AH = 51
-IPPROTO_ICMPV6 = 58
-IPPROTO_NONE = 59
-IPPROTO_DSTOPTS = 60
-IPPROTO_OSPF = 89
-IPPROTO_VRRP = 112
-IPPROTO_SCTP = 132
+from ryu.lib.packet.in_proto import *
-- 
2.1.0


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to