nicira: fix and clean ofp_flow_mod_table_id

Fix error raised when calling ofp_flow_mod_table_id.pack() due to
_command property accessor returning a string rather than int expected
by struct.pack.

_command property has been replaced with decorator `splice_table_id`
which temporarily injects `table_id` into MSB of `command` during
wrapped function call.

Closes #81
Merge pull request #86 from noxrepo/fix_flow_mod_table_id

nicira: fix and clean ofp_flow_mod_table_id
of_json: Better port info for list_switches()

We now read *current* port info from each Connection object instead
of the stored info from when the switch connected.  Additionally,
nonzero config and state flags are now returned.
flow_table: Fix FlowTable.flow_stats return value

Due to requiring accessing content by index and determination of length
of the return value, the return value is changed from a generator to
a list. This is ideal in face of any further complications.
datapaths: Implemented queue stats requests

Since the switch doesn't actually have any queues, upon requesting
statistics on all queues, an empty list will be returned to be packed
and sent back.

As of yet, no checks against port_no are currently implemented, no
matter if port_no is invalid or not. On the other hand, if the queue_id
is invalid, then an approximate error would be returned.
flow_table: Implement aggregate flow stats
datapaths: Moved process_flow_mod from flow_table

Moved SwitchFlowTable.process_flow_mod from a FlowTable subclass to
a private method in SoftwareSwitchBase.

The method header and SoftwareSwitchBase._rx_flow_mod are changed to
accommodate for error sending and table selection. Currently, nothing
inside of the method itself is changed.

THIS COMMIT IS KNOWN TO BE BROKEN. The fix is in the next commit.
datapaths: Fix issues from moving process_flow_mod

1. Always explicitly specify the table fror _process_flow_mod()
2. All references to self are changed to table, as previously discussed
3. Minor cleanup (table._table is changed to table.entries)
4. Add helper to FlowTable for adding entry based on a flow_mod
datapaths: Remove extra info in _process_flow_mod

_process_flow_mod()'s return value was not particularly useful and
has been removed.  Furthermore, since the entries are no longer
returned, the modified variable is now a boolean instead of a list.
datapaths: Send error if table is full

This is just simply checking the table size against the max_entries
attribute of the SoftwardSwitchBase. Somehow I still think we should
have the self.max_entries as an attribute of the table, but for now
there is no need, I guess.
datapaths: Implement flow deletion port filtering

Added code in the flow deletion option to handle parameter out_port.
Removed the NotImplemented Error associated with the fact that checking
against the out_port when deleting an entry is not implemented.

This required adding a field to FlowTable's remove_matching_entries
in order to allow filtering by out_port.
datapaths: Implement table entry overlap checking

Implemented the check for overlap if the OFPFF_CHECK_OVERLAP flag is
set to be on. Before the attempt to add an entry, matching and priority
comparison is done to see if there is any overlap with the current
to-be-added entry. Removed the NotImplemented Error about this.

From both test detailed_contr_sw_messages.OverlapChecking and from the
specs, it seems that the matching should be allowed to go either ways.
Unfortunately, this means it is impossible to just use matching_entries
to find overlaps, and is_matched_by would require both sides to be of
the TableEntry class. Along with requiring comparison of effective
priorities, the flow mod is already converted to a table entry to ease
the comparison.
datapaths: Remove exception on bad flow_mod cmd

_process_flow_mod() would raise an exception when given an unknown
command.  In spirit of the changes made recently throughout to get rid
of exceptions like this this, we now log a warning and send back the
proper OpenFlow error.
datapaths: Use send_error() helper

A previous commit added a send_error() helper.  We now actually use
it in lots of instances where we previously hand-crafted ofp_errors.
datapaths: Minor fix to _error_handler on versions

The ERR_BAD_VERSION case had a couple of errors/typos:
1. There is no io_worker passed in. We need to use self.io_worker.
2. There is no port_mod. Rather, xid is manually unpacked.

Additionally, since we currently only send back an error when it's in
response to the first message, we assume it's from a HELLO message and
send back a HELLO failure message instead of a more generic one.
datapaths: Improve NO_RECV port config flags

The previous implementation of OFPPC_NO_RECV didn't honor the STP-related
semantics laid out in the spec, and OFPPC_NO_RECV_STP was not implemented
at all.  This commit attempts to remedy that.
datapaths: Refactor/rewrite port_mod handling

This is an attempt to rewrite how port config flags are handled for
port_mods.  The goals are to reduce duplicated code and to improve the
ability for subclasses to override behavior.
datapaths: Improve port config

1. Set STP-disable flag by default
2. Don't allow enabling of STP
3. All other port config flags are handled
flow_table: Remove SwitchFlowTable subclass

All this subclass did was process flow_mod entries.  This functionality
has been integrated into SoftwareSwitchBase.  So as not to have to
maintain two versions of similar code, we remove it here.
datapaths: Use FlowTable, not SwitchFlowTable

The SwitchFlowTable subclass was removed by a previous commit as its
functionality has been moved to SoftwareSwitchBase itself. This commit
actually adjusts SoftwareSwitchBase to use the FlowTable superclass.