summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYuichi Ito <ito.yuichi0@gmail.com>2013-11-06 17:14:47 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-11-08 10:44:29 +0900
commit7cce0f9e5f80afca830a2d6ec3d47742e704eea8 (patch)
treef93e6bb5e03ce22ea716605284c9a0754347182a
parentb32dbed5c1503cf879da7fda271acadef1d7acb0 (diff)
packet lib: icmpv6: move ND_OPTION_* constants from classes to the module
the purpose is to avoid keeping the same constant values at several places. Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/icmpv6.py31
1 files changed, 11 insertions, 20 deletions
diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
index 25605a60..0353949d 100644
--- a/ryu/lib/packet/icmpv6.py
+++ b/ryu/lib/packet/icmpv6.py
@@ -56,6 +56,13 @@ ICMPV6_NI_REPLY = 140 # node information reply
ICMPV6_MAXTYPE = 201
+# ND_OPTIONS from RFC 4861
+ND_OPTION_SLA = 1 # Source Link-Layer Address
+ND_OPTION_TLA = 2 # Target Link-Layer Address
+ND_OPTION_PI = 3 # Prefix Information
+ND_OPTION_RH = 4 # Redirected Header
+ND_OPTION_MTU = 5 # MTU
+
class icmpv6(packet_base.PacketBase):
"""ICMPv6 (RFC 2463) header encoder/decoder class.
@@ -165,13 +172,6 @@ class nd_neighbor(stringify.StringifyMixin):
_MIN_LEN = struct.calcsize(_PACK_STR)
_ND_OPTION_TYPES = {}
- # ND option type
- ND_OPTION_SLA = 1 # Source Link-Layer Address
- ND_OPTION_TLA = 2 # Target Link-Layer Address
- ND_OPTION_PI = 3 # Prefix Information
- ND_OPTION_RH = 4 # Redirected Header
- ND_OPTION_MTU = 5 # MTU
-
@staticmethod
def register_nd_option_type(*args):
def _register_nd_option_type(cls):
@@ -250,9 +250,6 @@ class nd_router_solicit(stringify.StringifyMixin):
_MIN_LEN = struct.calcsize(_PACK_STR)
_ND_OPTION_TYPES = {}
- # ND option type
- ND_OPTION_SLA = 1 # Source Link-Layer Address
-
@staticmethod
def register_nd_option_type(*args):
def _register_nd_option_type(cls):
@@ -335,11 +332,6 @@ class nd_router_advert(stringify.StringifyMixin):
_MIN_LEN = struct.calcsize(_PACK_STR)
_ND_OPTION_TYPES = {}
- # ND option type
- ND_OPTION_SLA = 1 # Source Link-Layer Address
- ND_OPTION_PI = 3 # Prefix Information
- ND_OPTION_MTU = 5 # MTU
-
@staticmethod
def register_nd_option_type(*args):
def _register_nd_option_type(cls):
@@ -402,10 +394,9 @@ class nd_router_advert(stringify.StringifyMixin):
return hdr
-@nd_neighbor.register_nd_option_type(nd_neighbor.ND_OPTION_SLA,
- nd_neighbor.ND_OPTION_TLA)
-@nd_router_solicit.register_nd_option_type(nd_router_solicit.ND_OPTION_SLA)
-@nd_router_advert.register_nd_option_type(nd_router_advert.ND_OPTION_SLA)
+@nd_neighbor.register_nd_option_type(ND_OPTION_SLA, ND_OPTION_TLA)
+@nd_router_solicit.register_nd_option_type(ND_OPTION_SLA)
+@nd_router_advert.register_nd_option_type(ND_OPTION_SLA)
class nd_option_la(stringify.StringifyMixin):
"""ICMPv6 sub encoder/decoder class for Neighbor discovery
Source/Target Link-Layer Address Option. (RFC 4861)
@@ -462,7 +453,7 @@ class nd_option_la(stringify.StringifyMixin):
return hdr
-@nd_router_advert.register_nd_option_type(nd_router_advert.ND_OPTION_PI)
+@nd_router_advert.register_nd_option_type(ND_OPTION_PI)
class nd_option_pi(stringify.StringifyMixin):
"""ICMPv6 sub encoder/decoder class for Neighbor discovery
Prefix Information Option. (RFC 4861)