controller.handler: g/c now unused code

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
controller.handler: use normal classes rather than a namedtuple

and add some comments.  no functional changes.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
controller.handler: simplify code

and use consistent variable names.  no functional changes.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
RyuApp: add a method to unregister a handler

this method undos register_handler.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
RyuApp.get_handlers: restructure code and add a comment

no functional changes.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
RyuApp: allow observing events without having handlers

this will be used by ofctl app which registers handlers dynamically.
when unobserving an event cls dynamically, there might be events of
the cls left in app's event queue already.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
RyuApp: add methods to observe/unobserve specific event dynamically

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofp_event: add a function to find Event class for given OFP class

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ryu.app.ofctl: implement reception of reply message

an example:
    msg = parser.OFPEchoRequest(datapath=datapath)
    result = ofctl.api.send_msg(self, msg, reply_cls=parser.OFPEchoReply)
    assert isinstance(result, parser.OFPEchoReply)

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ryu.app.ofctl: implement multipart

an example:
    msg = parser.OFPPortDescStatsRequest(datapath=datapath)
    result = ofctl.api.send_msg(self, msg,
                                reply_cls=parser.OFPPortDescStatsReply,
                                reply_multi=True)

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ryu.app.ofctl: raise exceptions on openflow error messages

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
RyuApp: delete a key without handlers when unregistering a handler

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
fix pbb itag related tests

i-tagged packets will have ETH_TYPE=0x88E7. The tests are
rewritten in the same way with MPLS.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
sw test tool: Fix to compare OFPMatch ignoring masks that are all one bits

OF 1.3.3 spec (7.2.3.5 Flow Match Field Masking) says:

    An all-zero-bits oxm_mask is equivalent to omitting the OXM TLV entirely. An all-one-bits oxm_mask
    is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.

This patch fixes to compare OFPMatch ignoring masks that are all one bits.

Reported-by: Arne Goetje <arne_goetje@accton.com>
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
sw test tool: Fix to compare OFPMatch ignoring fields that masks are all zero bits

OF 1.3.3 spec (7.2.3.5 Flow Match Field Masking) says:

    An all-zero-bits oxm_mask is equivalent to omitting the OXM TLV entirely. An all-one-bits oxm_mask
    is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.

This patch fixes to compare OFPMatch ignoring fields that masks are all zero bits.

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
sw test tool: Correct the comparison method to treat matches as the set

OF 1.3.3 spec (3 Glossary) says:

    Flow Entry: an element in a flow table used to match and process packets. It contains a set of
    match fields for matching packets, a priority for matching precedence, a set of counters to track
    packets, and a set of instructions to apply (see 5.2).

According to OF spec, the match fields are treated as the set.
This means that the order of matches which flow_stats message returns is inconsistant.
This patch corrects the comparison method of matches by sorting in a particular order before comparison.

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>