of1.2: fix OFPGroupDescStats parser

- add action's size to offset of bucket.

Signed-off-by: KONDOH Tasuku <kondoh.tasuku@po.ntts.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ryu/controller/dpset.py: duplicate import

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.3: fix error in port_mod and get_config_reply logic

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: fix icmpv6.nd_s.parser() and support NDP option type

This patch fixes parser error if there is no NDP option, and support
the class to handle the NDP option.

I have implemented only the option type = 1 and 2. We also need to
implement other type, but this is enough in mininet for now.

> Traceback (most recent call last):
> (...)
>   File "/usr/local/lib/python2.7/dist-packages/ryu-1.6-py2.7.egg/ryu/lib/packet/icmpv6.py", line 87, in parser
>     msg.data = cls_.parser(buf, offset)
>   File "/usr/local/lib/python2.7/dist-packages/ryu-1.6-py2.7.egg/ryu/lib/packet/icmpv6.py", line 134, in parser
>     buf, offset)
> error: unpack_from requires a buffer of at least 28 bytes

Signed-off-by: HIYAMA Manabu <hiyama.manabu@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
test: remove unnecessary variables

Signed-off-by: HIYAMA Manabu <hiyama.manabu@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
controller: fix that sender thread is never terminated

Empty q.get() is blocking send thread.
Because of this issue, datapath state never transit to DEAD.

This fixes commit 83e3709a0d70f889e794d1c5f70c1c1eb73075f7.
  - controller: fix send_q draining
      https://github.com/osrg/ryu/commit/83e3709a0d70f889e794d1c5f70c1c1eb73075f7

Signed-off-by: YAMADA Hideki <yamada.hideki@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
import oslo-config

import oslo-config as of today.

    https://github.com/openstack/oslo-config.git
    commit df77677698483b58d6026994614cb847d25f9b69

this is a new version of the code which we currently have
in contrib/openstack.
mainly to obtain the following change.

    commit 16c4ecbefc94941821f3ae7ca253fad7bc377c58
    Author: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
    Date:   Wed Feb 13 14:01:46 2013 +0900

    sort options to make --help output prettier

    explicitly sort options when adding them to argparse.
    it's a bit silly to print them in a dict iteration order.

    Change-Id: Id508331d7ee3b24e76be7fa958d27d29905bd3d2
    Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
switch from openstack.common.cfg to oslo.config.cfg

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
remove no longer used contrib/openstack

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
xflow: add sflow support

This patch implements sflow packet parser.
I confirmed that it can parse a sflow packet from Open vSwitch.

Signed-off-by: WATANABE Fumitaka <watanabe.fumitaka@nttcom.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
test of1.2: add test code of max, min, and pattern. review of the test code

Signed-off-by: KONDOH Tasuku <kondoh.tasuku@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
appease pep8

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
change --foo_bar options to --foo-bar

rename options. (s/_/-/)
according to Isaku Yamahata, this makes us look similar to openstack.

caveat: no backward compat is provided.  you need to update both of
config files and cli options.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
update an example after option name changes

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
mechanical documentation update after option name changes

s/_/-/ in option names.

note: some parts of them (eg. eventdumper, nova, ...) looks outdated
but i didn't try to update them at least in this commit.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
try to sync documentation with the reality

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
of1.2: fix OFPErrorExperimenterMsg

- add OFPErrorExperimenterMsg.

Signed-off-by: KONDOH Tasuku <kondoh.tasuku@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
app_manager: allow separated modules of Event and RyuApp

Because handler.set_ev_cls() sets observer to module of ev_cls,
Event class and RyuApp must be in same module now.

This patch let RyuApp have a list of events to be generated in app.
So, AppManager can bind sender app and receiver app via event class.

Signed-off-by: YAMADA Hideki <yamada.hideki@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
lib/mac: fix raise ValueError

Traceback (most recent call last):
  File "/home/openflow/ryu/.venv/local/lib/python2.7/site-packages/nose/tools/nontrivial.py", line 67, in newfunc
    raise AssertionError(message)
AssertionError: test_mac_haddr_to_bin_true() did not raise ValueError

Signed-off-by: EisukeTAKAHASHI <takahashi.eisuke@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
RyuApp: allows observers to specify state

This fixes the following exception:

>   $ ryu-manager ryu_app(OF1.2 app)
>   $ sudo mn --controller remote 127.0.0.1
>   $ sudo ovs-vsctl set bridge s1 protocols='[OpenFlow10,OpenFlow12]'
> connected socket:<socket fileno=4 sock=127.0.0.1:6633 peer=127.0.0.1:60456> address:('127.0.0.1', 60456)
> EVENT ofp_event->dpset EventOFPStateChange
> connected socket:<socket fileno=10 sock=127.0.0.1:6633 peer=127.0.0.1:60457> address:('127.0.0.1', 60457)
> EVENT ofp_event->dpset EventOFPStateChange
> hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x11bf550>
> unsupported version 0x1. If possible, set the switch to use one of the versions [3]
> error msg ev version: 0x3 msg_type 0x1 xid 0xc84d9220 type 0x1 code 0x1 0x3 0x1 0x0 0x5f 0xc8 0x4d 0x92 0x20 0x0 0x0 0x0 0x0 0x75 0x6e 0x73 0x75 0x70 0x70 0x6f
> +0x72 0x74 0x65 0x64 0x20 0x76 0x65 0x72 0x73 0x69 0x6f 0x6e 0x20 0x30 0x78 0x31 0x2e 0x20 0x49 0x66 0x20 0x70 0x6f 0x73 0x73 0x69 0x62 0x6c 0x65 0x2c 0x20 0x73
> +0x65 0x74 0x20 0x74 0x68 0x65 0x20 0x73 0x77 0x69 0x74 0x63 0x68
> EVENT ofp_event->dpset EventOFPPortStatus
> DPSET: A port was modified.(datapath id = None, port number = 1)
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 390, in run
>     result = self._run(*self.args, **self.kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/ryu-1.6-py2.7.egg/ryu/base/app_manager.py", line 86, in _event_loop
>     handler(ev)
>   File "/usr/local/lib/python2.7/dist-packages/ryu-1.6-py2.7.egg/ryu/controller/dpset.py", line 192, in port_status_handler
>     self.port_state[datapath.id].modify(port.port_no, port)
> KeyError: None
> <Greenlet at 0x11bc518: <bound method DPSet._event_loop of <ryu.controller.dpset.DPSet object at 0xd0df10>>> failed with KeyError

Reported-by: HIYAMA Manabu <hiyama.manabu@po.ntts.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>