Acked-by: Jarno Rajahalme <ja...@ovn.org>

> On Jan 18, 2016, at 11:27 PM, Ben Pfaff <b...@ovn.org> wrote:
> 
> The existing functions either assumed that we were working with NXM
> (instead of OXM), or they added or parsed a header before OXM headers.
> These aren't needed when OXM is encapsulated inside a property, as will be
> the case in an upcoming commit.
> 
> Signed-off-by: Ben Pfaff <b...@ovn.org>
> ---
> lib/nx-match.c | 30 ++++++++++++++++++++++++++++--
> lib/nx-match.h |  7 ++++++-
> 2 files changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/nx-match.c b/lib/nx-match.c
> index 11bcd95..0f695f0 100644
> --- a/lib/nx-match.c
> +++ b/lib/nx-match.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
> + * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
> @@ -630,6 +630,18 @@ oxm_pull_match_loose(struct ofpbuf *b, struct match 
> *match)
>     return oxm_pull_match__(b, false, match);
> }
> 
> +/* Parses the OXM match description in the 'oxm_len' bytes in 'oxm'.  Stores
> + * the result in 'match'.
> + *
> + * Fails with an error when encountering unknown OXM headers.
> + *
> + * Returns 0 if successful, otherwise an OpenFlow error code. */
> +enum ofperr
> +oxm_decode_match(const void *oxm, size_t oxm_len, struct match *match)
> +{
> +    return nx_pull_raw(oxm, oxm_len, true, match, NULL, NULL);
> +}
> +
> /* Verify an array of OXM TLVs treating value of each TLV as a mask,
>  * disallowing masks in each TLV and ignoring pre-requisites. */
> enum ofperr
> @@ -1099,7 +1111,7 @@ nx_put_match(struct ofpbuf *b, const struct match 
> *match,
> }
> 
> /* Appends to 'b' an struct ofp11_match_header followed by the OXM format that
> - * expresses 'cr', plus enough zero bytes to pad the data appended out to a
> + * expresses 'match', plus enough zero bytes to pad the data appended out to 
> a
>  * multiple of 8.
>  *
>  * OXM differs slightly among versions of OpenFlow.  Specify the OpenFlow
> @@ -1130,6 +1142,20 @@ oxm_put_match(struct ofpbuf *b, const struct match 
> *match,
>     return match_len;
> }
> 
> +/* Appends to 'b' the OXM formats that expresses 'match', without header or
> + * padding.
> + *
> + * OXM differs slightly among versions of OpenFlow.  Specify the OpenFlow
> + * version in use as 'version'.
> + *
> + * This function can cause 'b''s data to be reallocated. */
> +void
> +oxm_put_raw(struct ofpbuf *b, const struct match *match,
> +            enum ofp_version version)
> +{
> +    nx_put_raw(b, version, match, 0, 0);
> +}
> +
> /* Appends to 'b' the nx_match format that expresses the tlv corresponding
>  * to 'id'. If mask is not all-ones then it is also formated as the value
>  * of the tlv. */
> diff --git a/lib/nx-match.h b/lib/nx-match.h
> index 2625c63..c663e54 100644
> --- a/lib/nx-match.h
> +++ b/lib/nx-match.h
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
> + * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2016 Nicira, Inc.
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
> @@ -47,6 +47,7 @@ char *mf_parse_subfield__(struct mf_subfield *sf, const 
> char **s)
> char *mf_parse_subfield(struct mf_subfield *, const char *s)
>     OVS_WARN_UNUSED_RESULT;
> 
> +/* Decoding matches. */
> enum ofperr nx_pull_match(struct ofpbuf *, unsigned int match_len,
>                           struct match *,
>                           ovs_be64 *cookie, ovs_be64 *cookie_mask);
> @@ -55,11 +56,15 @@ enum ofperr nx_pull_match_loose(struct ofpbuf *, unsigned 
> int match_len,
>                                 ovs_be64 *cookie_mask);
> enum ofperr oxm_pull_match(struct ofpbuf *, struct match *);
> enum ofperr oxm_pull_match_loose(struct ofpbuf *, struct match *);
> +enum ofperr oxm_decode_match(const void *, size_t, struct match *);
> enum ofperr oxm_pull_field_array(const void *, size_t fields_len,
>                                  struct field_array *);
> +
> +/* Encoding matches. */
> int nx_put_match(struct ofpbuf *, const struct match *,
>                  ovs_be64 cookie, ovs_be64 cookie_mask);
> int oxm_put_match(struct ofpbuf *, const struct match *, enum ofp_version);
> +void oxm_put_raw(struct ofpbuf *, const struct match *, enum ofp_version);
> void oxm_format_field_array(struct ds *, const struct field_array *);
> int oxm_put_field_array(struct ofpbuf *, const struct field_array *,
>                         enum ofp_version version);
> -- 
> 2.1.3
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to