Local Fix: ofp-util: Work on decoding OF1.1 flow_mods.

This is a local change to fix some compile errors in
Ben Pfaff's "ofp-util: Work on decoding OF1.1 flow_mods." patch.

It should either be rolled into those changes or dropped.
nx-match: Take into account leading header when calculating pad

In the case of Open Flow 1.2, which is currently the only
time that OXM is be used, there is a 4 byte header before
the match which needs to be taken into account when calculating
the pad length.

This is not entirely pretty, but it does seem to be correct.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Initial post
ofp-util: Add OFPUTIL_P_OF12 and NXFF_OPENFLOW12

Add OFPUTIL_P_OF12 and NXFF_OPENFLOW12 for Open Flow 1.2

OFPUTIL_P_OF12_TID and in turn OFPUTIL_P_OF12_ANY is not provided as
OFPUTIL_P_OF12 supports the use of table ids in modify flow messages.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Don't add NXPIF_OPENFLOW12, it doesn't seem to be needed

v2
* No change
openflow: Add Open Flow 1.2 to ofp_to_string__()

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Add "openflow: " prefix to title

v2
* No change
ofp-util: Add ofputil_put_match()

This wraps nx_put_match() to provide an extra header as necessary.

For Open Flow 1.0 + NXM extensions nx_put_match() is comprises
the entire match.

For Open Flow 1.2 a header is required before
the match supplied by x_put_match().

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Add "ofp-util:" prefix to title
* Set omh pointer after calling nx_put_match() as msg->data may change.
* Add default case to ensure that match_len can never be
  returned unless it was initialised.
* Correct calculation of omh for Open Flow 1.2

v2
* Initial post

Fix ofputil_put_match)
ofp-actions: Enhance ofpacts_to_openflow11 to encode instructions

This adds support for ofpacts_to_openflow11() to encode instructions
although at this point only the OFPIT11_APPLY_ACTIONS instruction
type is supported.

I am unsure if it would be better to use a new function that
wraps the existing ofpacts_to_openflow11(). But for now
I have simply modified ofpacts_to_openflow11().

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Initial post
ofp-print: Use the prevailing protocol to call ofputil_decode_flow_mod()

Pass a protocol based on the prevailing protocol to ofputil_decode_flow_mod()

Note that ofputil_protocol_from_ofp_version() needs to be made
Open Flow 1.1 aware.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* Actually pass calculated protocol to ofputil_decode_flow_mod()
learning-switch: Call ofputil_encode_flow_mod() with correct protocol

Empirically it appears that process_packet_in() should call
ofputil_encode_flow_mod() with protocol rather than sw->protocol.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Initial post
ofp-util: Reduce scope of variables in ofputil_encode_flow_mod()

Reduce scope of per-protocol variables in ofputil_encode_flow_mod()

These variables are only needed in one of the cases covered by the switch
statement and will increase in number as more cases (protocols) are
supported.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* No change
ofp-util: Allow encoding of Open Flow 1.2 Flow Mod messages

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Open Flow 1.2 uses an 8bit command, previously 16 bits was used incorrectly
* Use Open Flow 1.2 action encoding, previously Open Flow 1.0 encoding
  was used incorrectly
* ofp11_match_header is added by ofputil_put_match(),
  previously it was incorectly added in ofputil_encode_flow_mod() as well.

v2
* Use ofputil_put_match()
ofp-util: Add ofputil_ofp12_decode_match()

This may be used by both ofputil_decode_flow_mod() and
ofputil_decode_packet_in()

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Do not pull ofpbuf_pull() in the case of a STANDARD match.
  This simplifies things a little.

v2
* No change
ofp-util: Allow decoding of Open Flow 1.2 Flow Mod messages

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* No change
ofp-util: Allow encoding of Open Flow 1.2 Flow Removed messages

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* Use ofputil_put_match()
ofp-util: Allow decoding of Open Flow 1.2 Flow Removed Messages

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

*v3
Initial post
ofp-util: Allow encoding Open Flow 1.2 Flow Stats Request Messages

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* Use ofputil_put_match()
ofp-util: Allow encoding of Open Flow 1.2 Port Mod Messages

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* No change
ofp-util: Allow decoding of Open Flow 1.2 Port Mod Messages

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* No change
ofp-util: Update ofputil_capabilities for Open Flow 1.2

* OFPUTIL_C_ARP_MATCH_IP is not present in Open Flow 1.2.
* OFPUTIL_C_PORT_BLOCKED is new in Open Flow 1.2.

Otherwise the Open Flow 1.2 capabilities are the same as those of
Open Flow 1.1.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* No change
ofp-util: Update OFPC_COMMON and add ofputil_capabilities_mask

There are capabilities which are present in one, two and three
of Open Flow 1.0, 1.1 and 1.2. Update OFPC_COMMON to only include
capabilities that are prsent in all three Open Flow versions and
add ofputil_capabilities_mask() to return the mask of capabilities
for each version.

This does not cover OFPUTIL_C_STP and OFPUTIL_C_GROUP_STATS, which
both use capability bit 3 and are treated as special cases in
ofputil_encode_switch_features() and ofputil_decode_switch_features().

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* No change

v2
* No change
ofp-util: Allow decoding of Open Flow 1.2 Features Reply Messages

Open Flow 1.2, like Open Flow 1.1, has OFPC11_GROUP_STATS.

All other Open Flow 1.2 capabilities are handled by
ofputil_capabilities_mask() which is used by both
ofputil_decode_switch_features() and ofputil_encode_switch_features().

No update to ofputil_encode_switch_features() is required
to support Open Flow 1.2 due to its protocol version logic
which is looser than that of ofputil_decode_switch_features().

Signed-off-by: Simon Horman <horms@verge.net.au>

---

v3
* Manual rebase

v2
* No change