summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2014-08-18 09:19:06 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-08-18 14:14:55 +0900
commit7a5b83daa6ea22938fcfbf177a94cacb4ff7aa7a (patch)
treec4e17f34819ee9cc048fe57bdc3893e999d5de21
parentf92b674def10254038e4c9a7c55f16944bb3a661 (diff)
bgp: move _TYPE declaration of IPAddrPrefix to the appropriate place.
_IPAddrPrefix can be inherited by labeled addr prefix. In that case, variable 'addr' is tuple and not string. so declare to parse 'addr' in 'ascii' format in _IPAddrPrefix cause following error. this patch fix this bug. p = LabelledIPAddrPrefix(28, ([1], '192.168.0.0')) p.to_jsondict() Traceback (most recent call last): File "./parse_labeled_addr_prefix.py", line 11, in <module> p.to_jsondict() File "/home/wataru/ryu/ryu/lib/stringify.py", line 210, in to_jsondict dict_[k] = encode(k, v) File "/home/wataru/ryu/ryu/lib/stringify.py", line 208, in <lambda> encode = lambda k, x: self._encode_value(k, x, encode_string) File "/home/wataru/ryu/ryu/lib/stringify.py", line 155, in _encode_value return cls._get_encoder(k, encode_string)(v) File "/home/wataru/ryu/ryu/lib/stringify.py", line 56, in encode return unicode(v, 'ascii') TypeError: coercing to Unicode: need string or buffer, tuple found Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/bgp.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py
index 698d0fdb..0a96b42a 100644
--- a/ryu/lib/packet/bgp.py
+++ b/ryu/lib/packet/bgp.py
@@ -852,12 +852,6 @@ class _UnlabelledAddrPrefix(_AddrPrefix):
class _IPAddrPrefix(_AddrPrefix):
- _TYPE = {
- 'ascii': [
- 'addr'
- ]
- }
-
@staticmethod
def _prefix_to_bin(addr):
(addr,) = addr
@@ -869,12 +863,6 @@ class _IPAddrPrefix(_AddrPrefix):
class _IP6AddrPrefix(_AddrPrefix):
- _TYPE = {
- 'ascii': [
- 'addr'
- ]
- }
-
@staticmethod
def _prefix_to_bin(addr):
(addr,) = addr
@@ -923,6 +911,11 @@ class _VPNAddrPrefix(_AddrPrefix):
class IPAddrPrefix(_UnlabelledAddrPrefix, _IPAddrPrefix):
ROUTE_FAMILY = RF_IPv4_UC
+ _TYPE = {
+ 'ascii': [
+ 'addr'
+ ]
+ }
@property
def prefix(self):
@@ -935,6 +928,11 @@ class IPAddrPrefix(_UnlabelledAddrPrefix, _IPAddrPrefix):
class IP6AddrPrefix(_UnlabelledAddrPrefix, _IP6AddrPrefix):
ROUTE_FAMILY = RF_IPv6_UC
+ _TYPE = {
+ 'ascii': [
+ 'addr'
+ ]
+ }
@property
def prefix(self):