openflow: Experimental refactor of OF handlers

This is an early experimental refactor of some of of_01 inspired by the
noxrepo/pox#108 issue.  It works well enough to test l2_learning and
l2_pairs with Mininet, but no doubt has bugs (and it definitely breaks
the message handling hook in openflow.nicira).

In short, each connection now has its own handler list.  We now use one
per-connection set of handlers during the handshaking phase, and then
switch to a default set of handlers for the rest of the time (which are
basically the same as the old ones but with the features reply handler
significantly simplified since its functionality is now part of the
handshaking handlers).  One outcome here is that we have to build a
handlers list for each new connection which may be dumb.  We do this
because we keep some state for handshaking.  If we moved that state to
Connection itself, this could be undone (at the expense of putting some
handshaking-only junk into Connection).

There's also a new event which fires when switching to the normal
connected handlers, which could let another component switch a connection's
handlers right then.  It might be nice to do the same thing when the socket
first connects to allow replacing the handshake handlers, but it's not
clear where this event should be sourced since the connection isn't
assigned a nexus yet.  The connection arbiter is one possibility.
openflow: Fix new handshake event

This new event didn't call the superclass constructor.  Also adds .dpid
property consistent with other OpenFlow events.

Signed-off-by: Murphy McCauley <murphy.mccauley@gmail.com>
openflow.nicira: Use custom OF message handlers

The new OpenFlow message handler mechanism both broke the fairly
hacky way the nicira module used to hook vendor messages and also
allows for a more elegant solution.  This commit rectifies things.

Specifically, it creates a new handler subclass for switches with
Nicira extensions, which it enables in a ConnectionHandshakeComplete
handler.

Signed-off-by: Murphy McCauley <murphy.mccauley@gmail.com>
openflow: Tweak OpenFlowHandlers init

Rather than a hard-coded list of messages the handler is interested in,
we now generate this at runtime from ofp_type_map.

Signed-off-by: Murphy McCauley <murphy.mccauley@gmail.com>
openflow.nicira: Use single OF handler instance

Rather than creating a new instance of NiciraOpenFlowHandlers for
every connection, we now just create one and reuse it.  This avoids
the relatively expensive initialization process for each connection.
(We still pay this price for the handshake handlers, unfortunately,
but at least we don't pay it twice.)
openflow: Tweaks to OF handlers init

* Adds some assertions
* Avoid name collision with Python builtin "type"
* Minor other changes
openflow: Log aborted connections at DEBUG

If we never even get a DPID from a switch, we now log its disconnection
at DEBUG level instead of INFO.  We never logged a connect message at
INFO in this case anyway, and it's not uncommon to have fairly meaningless
disconnection messages like this anyway, particularly with Mininet since
it probes the controller to see if it's listening.
openflow: Request switch desc on connection

It can be useful to know early on what type of switch you're connected to.
For example, you may need/wish to do special initialization if a switch
supports some extension.  To facilitate this, we now send a switch desc
stats request as part of handshaking by default (it can be disabled
relatively easily), and the result shows up as Connection.description which
should be available by ConnectionUp time.
openflow.nicira: Only enable extensions for OVS

Previously, as long as openflow.nicira was loaded, all switches were
treated as if they supported those extensions.  We now check to see if
the switch actually appears to be OVS.
Merge branch 'no_early_events' into refactor_events

Conflicts:
	pox/openflow/nicira.py
	pox/openflow/of_01.py