bgp: support add/delete VPNv6 VRF

added VPNv6 route family VRF support.
This patch enables addition and deletion of VPNv6 VRF.

Signed-off-by: Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: support add/delete vpnv6 prefix

added VPNv6 prefix support.
This patch enables addition and deletion of VPNv6 prefix.

Signed-off-by: Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet/bgp: add open capability code of 128

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: show VPNv4 Prefix information

But the result looks unexpected regarding of show_command .
I can’t find the advertised labels or assigned labels for vpnv4 prefix .
 (reference: http://sourceforge.net/p/ryu/mailman/message/32686423/ )
Therfore, I've patched the codes for formatting as follows .
=> needs for fixing labels attribute after that .

INFO:bgpspeaker.api.base:API method operator.show called with args: {'params': ['rib', 'all'], 'format': 'cli'}
Status codes: * valid, > best
     Network                          Labels   Next Hop             Reason          Metric LocPrf Path/Origin
Family: rtfilter
 *>  64512:64511:101                  None     0.0.0.0              Only Path                     2
Family: vpnv6
Family: vpnv4
 *>  64511:101:10.10.0.1/32           ([17],)  192.168.100.100      Only Path       0             64511 2
 *>  64511:101:10.20.2.0/24           ([100],) 0.0.0.0              Only Path                     2
 *>  64511:101:10.20.1.0/24           ([100],) 0.0.0.0              Only Path                     2
 *>  64511:101:10.20.3.0/24           ([100],) 0.0.0.0              Only Path                     2
Family: ipv4
Family: ipv6

Signed-off-by: Toshiki Tsuboi <t.tsubo2000@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: fix bug of Path(Origin) formatting for show VPNv4 prefix information

The field of 'Path(Origin)' has not displayed in properly ,because Origin codes '2 (incomplete)' is not defined in the latest code .
Therfore, I've patched the codes for formatting as follows .

INFO:bgpspeaker.api.base:API method operator.show called with args: {'params': ['rib', 'all'], 'format': 'cli'}
Status codes: * valid, > best
Origin codes: i - IGP, e - EGP, ? - incomplete
     Network                          Labels   Next Hop             Reason          Metric LocPrf Path
Family: rtfilter
 *>  64512:64511:101                  None     0.0.0.0              Only Path                     ?
Family: vpnv6
Family: vpnv4
 *>  64511:101:10.10.0.1/32           [17]     192.168.100.100      Only Path       0             64511 ?
 *>  64511:101:10.20.2.0/24           [100]    0.0.0.0              Only Path                     ?
 *>  64511:101:10.20.1.0/24           [100]    0.0.0.0              Only Path                     ?
 *>  64511:101:10.20.3.0/24           [100]    0.0.0.0              Only Path                     ?
Family: ipv4
Family: ipv6

Signed-off-by: Toshiki Tsuboi <t.tsubo2000@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: fix bug of labels formatting for show VPNv4 prefix information

The field of 'Labels' has not displayed in properly because of extracting 'label_list' in python slicing tuples.

INFO:bgpspeaker.api.base:API method operator.show called with args: {'params': ['rib', 'all'], 'format': 'cli'}
Status codes: * valid, > best
    Network                          Labels   Next Hop             Reason          Metric LocPrf Path/Origin
Family: rtfilter
*>  64512:64511:101                  None     0.0.0.0              Only Path                     2
Family: vpnv6
Family: vpnv4
*>  64511:101:10.10.0.1/32           ([17],)  192.168.100.100      Only Path       0             64511 2
*>  64511:101:10.20.2.0/24           ([100],) 0.0.0.0              Only Path                     2
*>  64511:101:10.20.1.0/24           ([100],) 0.0.0.0              Only Path                     2
*>  64511:101:10.20.3.0/24           ([100],) 0.0.0.0              Only Path                     2
Family: ipv4
Family: ipv6

Reported-by: Toshiki Tsuboi <t.tsubo2000@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add route server function to bgpspeaker

implemented draft-ietf-idr-ix-bgp-route-server-05 partially.

you can enable this function like below

>    speaker = BGPSpeaker(as_number=64512, router_id='10.10.0.1')
>    speaker.neighbor_add('10.0.0.1', 64514, is_route_server_client=True)
>    speaker.neighbor_add('10.10.0.2', 64513, is_route_server_client=True)

add multiple rib function is a future work

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: move ssh configuration to bgp config file

You can't pass ssh.py to run command any more. If you need ssh CLI,
update the bgp config file and then:

ryu run —-config-file /path/to/ryu.conf /path/to/ryu/ryu/services/protocols/application.py

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add attribute ORIGINATOR_ID and CLUSTER_LIST

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add BGP capability code 64 (graceful restart)

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: refine the API for connecting to bmp server

We might want a bgp speaker to talk with multiple bmp servers in the
future so I renamed these functions. Note that currently a speaker can
connect to only one bmp server.

I also update the example code on how to make the speaker to connect
to a bmp server.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: fix bug of receiving 'RouteRefresh' Message

When Ryu BGP received 'RouteRefresh' Message from the peering router, BGP session has closed as follows .

DEBUG 2014-08-15 02:20:08,718 speaker 447 Received msg from ('192.168.100.100', '34939') << BGPRouteRefresh(afi=1,demarcation=1,len=23,safi=128,type=5)
DEBUG 2014-08-15 02:20:08,719 speaker 566 Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/speaker.py", line 560, in _recv_loop
    self.data_received(next_bytes)
  File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/speaker.py", line 275, in data_received
    self._data_received(next_bytes)
  File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/speaker.py", line 355, in _data_received
    self._handle_msg(msg)
  File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/speaker.py", line 508, in _handle_msg
    self._peer.handle_msg(msg)
  File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/peer.py", line 1585, in handle_msg
    self._handle_route_refresh_msg(msg)
  File "/usr/local/lib/python2.7/dist-packages/ryu/services/protocols/bgp/peer.py", line 1619, in _handle_route_refresh_msg
    afi = msg.route_family.afi
AttributeError: 'BGPRouteRefresh' object has no attribute 'route_family'

INFO 2014-08-15 02:20:08,722 peer 1901 Connection to peer 192.168.100.100 lost, reason: 'BGPRouteRefresh' object has no attribute 'route_family' Resetting retry connect loop: False

Signed-off-by: Toshiki Tsuboi <t.tsubo2000@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: simplify CLUSTER_LIST attribute parser

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
fix setup.cfg entry

SubmittingPatches.rst was renamed to CONTRIBUTING.rst.
setup.py sdist will check this dependency.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add support for RFC3107

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
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>
stringify: introduce _class_suffixes for easy jsonize

class variable '_class_suffixes' can be used for the same purpose as
'_class_prefixes' but match with the suffix of the class name.

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: use _class_suffixes to support various AddrPrefix

the AddrPrefix which variable 'nlri' has is not limited to
_BinAddrPrefix. this patch enables to encode to/decode from json dict
with various AddrPrefix in 'nlri'.

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: encode 'next_hop' in human readable format

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: make reserved private variable

reserved field must be 0. this patch add an assertion and
make reserved field invisible when stringified

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>