bgp: fix logic for checking BGP capability

BGPOpen that is set to sent_open_msg and recv_open_msg doesn't have
caps and BGP capabilities are stored in opt_param as List.
I changed the way of checking BGP capabilities.

Signed-off-by: Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: fix bug in net_ctrl listen_tcp

due to fdce89a0, _listen_tcp returns tuple.

Reported-by: 坪井俊樹 <t.tsubo2000@gmail.com>
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: shut up runtime warning due to configuration file loading

this patch shut up the warning shown below

/home/wataru/etc/bgpconf01.py:1: RuntimeWarning: Parent module
'bgpspeaker' not found while handling absolute import
  import os

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add med parameter to neighbor_add

Sorry, I changed parameter name for MED to uniform with add_vrf.
I resend patches for neighbor_add method and neighbor_update and
please ignore the patches that I sent before.

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

added neighbor_update method to BGPSpeaker class.
Currently only MED value can be changed.

Signed-off-by: Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: fix bug when restart neighbor

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

stop showing when stringified because it's noisy

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

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: remove an unused variable from bgpspeaker

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add neighbor_reset method to bgpspeaker

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
unit test for ofctl_v1_2/3

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_2/3: fix tcp_dst/src match fields

when enclosed the value of "ip_proto" in double quotes,
following match fields is not set at mod_flow_stats command:

  * tcp_dst, tcp_src

this patch fixes this problem.

Reported-by: jalee <jalee@inno-tech.com.tw>
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_2/3: fix unsuitable log

when using action type below, the log unsuitable is outputted:
Unknown action type: [action type]

  * GOTO_TABLE, WRITE_METADATA, METER(only ofctl_v1_3.py)

this patch fixes this problem.

Reported-by: jalee <jalee@inno-tech.com.tw>
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: move filter class under info_base/

move filter class from bgpspeaker.py to info_base/base.py to fix the error
shown below.

$ sudo env PYTHONPATH=/home/wataru/ryu ~/ryu/bin/ryu run --config-file=~/etc/ryu01.conf ./application.py

loading app ./application.py
instantiating app ./application.py of RyuBGPSpeaker
INFO 2014-07-21 06:14:48,066 base 207 API method core.start called with
args: {'router_id': '10.10.0.1', 'label_range': (100, 100000), 'waiter':
<ryu.lib.hub.Event object at 0x1a15dd0>, 'local_as': 64512,
'bgp_server_port': 179, 'refresh_max_eor_time': 0,
'refresh_stalepath_time': 0}
Traceback (most recent call last):
  File "/home/wataru/ryu/bin/ryu", line 20, in <module>
    main()
  File "/home/wataru/ryu/ryu/cmd/ryu_base.py", line 75, in main
    subcmd.run(base_conf.subcommand_args)
  File "/home/wataru/ryu/ryu/cmd/ryu_base.py", line 58, in run
    self.entry(args=args, prog=prog)
  File "/home/wataru/ryu/ryu/cmd/manager.py", line 81, in main
    services.extend(app_mgr.instantiate_apps(**contexts))
  File "/home/wataru/ryu/ryu/base/app_manager.py", line 486, in
instantiate_apps
    t = app.start()
  File "/home/wataru/ryu/ryu/services/protocols/bgp/application.py",
line 93, in start
    self._start_core(settings)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/application.py",
line 168, in _start_core
    call('core.start', waiter=waiter, **common_settings)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/api/base.py", line
210, in call
    import all  # noqa
  File "/home/wataru/ryu/ryu/services/protocols/bgp/api/all.py", line 4,
in <module>
    import prefix
  File "/home/wataru/ryu/ryu/services/protocols/bgp/api/prefix.py", line
29, in <module>
    from ryu.services.protocols.bgp.core import BgpCoreError
  File "/home/wataru/ryu/ryu/services/protocols/bgp/core.py", line 37,
in <module>
    from ryu.services.protocols.bgp import core_managers
  File
"/home/wataru/ryu/ryu/services/protocols/bgp/core_managers/__init__.py",
line 19, in <module>
    from peer_manager import PeerManager
  File
"/home/wataru/ryu/ryu/services/protocols/bgp/core_managers/peer_manager.py",
line 6, in <module>
    from ryu.services.protocols.bgp.peer import Peer
  File "/home/wataru/ryu/ryu/services/protocols/bgp/peer.py", line 32,
in <module>
    from ryu.services.protocols.bgp.bgpspeaker import PrefixList
  File "/home/wataru/ryu/ryu/services/protocols/bgp/bgpspeaker.py", line
56, in <module>
    from ryu.services.protocols.bgp.application import RyuBGPSpeaker
  File "/home/wataru/ryu/ryu/services/protocols/bgp/application.py",
line 64, in <module>
    def_desc='Unknown bootstrap exception.')
  File "/home/wataru/ryu/ryu/services/protocols/bgp/base.py", line 105,
in add_bgp_error_metadata
    'already defined.' % (code, sub_code))
ValueError: BGPSException with code 300 and sub-code 1 already defined.

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: enable filter configuration via configuration file

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

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: create adjacent rib in peer instance

this will be used when in-bound and out-bound filter changed at runtime
and to implement BMP(BGP monitering protocol) client

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: manage filter in a peer instance instead of rtconf

rtconf is basically for static configuration and filter is
dynamic and also specific configuration for peer instance.

move filter things under peer instance, and change rtconf to do only
static configuration things from a configuration file

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: refine and fix filter code

- change the name of the filter class from PrefixList to PrefixFilter to
  make it easy to understand the role of this class.
- update docs
- fix bugs

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add show neighbor command to ssh client

looks like,

bgpd> show neighbor
 IP Address   AS Number    BGP State
 10.0.0.1     64514        Established

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