[ovs-dev] [async 4/6] ofp-util: New functions ofputil_actions_equal(), ofputil_actions_clone().

Ethan Jackson ethan at nicira.com
Wed Jun 1 19:24:28 UTC 2011


Looks Good.

Ethan

On Fri, May 27, 2011 at 14:25, Ben Pfaff <blp at nicira.com> wrote:
> I found that introducing these helper functions provided a very modest
> increase in readability.
> ---
>  lib/ofp-util.c |   13 +++++++++++++
>  lib/ofp-util.h |    4 ++++
>  2 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> index 78cb879..e72c47a 100644
> --- a/lib/ofp-util.c
> +++ b/lib/ofp-util.c
> @@ -2496,3 +2496,16 @@ error:
>     *n_actionsp = 0;
>     return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_BAD_LEN);
>  }
> +
> +bool
> +ofputil_actions_equal(const union ofp_action *a, size_t n_a,
> +                      const union ofp_action *b, size_t n_b)
> +{
> +    return n_a == n_b && (!n_a || !memcmp(a, b, n_a * sizeof *a));
> +}
> +
> +union ofp_action *
> +ofputil_actions_clone(const union ofp_action *actions, size_t n)
> +{
> +    return n ? xmemdup(actions, n * sizeof *actions) : NULL;
> +}
> diff --git a/lib/ofp-util.h b/lib/ofp-util.h
> index 4c6968b..e35fc46 100644
> --- a/lib/ofp-util.h
> +++ b/lib/ofp-util.h
> @@ -289,6 +289,10 @@ bool action_outputs_to_port(const union ofp_action *, ovs_be16 port);
>
>  int ofputil_pull_actions(struct ofpbuf *, unsigned int actions_len,
>                          union ofp_action **, size_t *);
> +
> +bool ofputil_actions_equal(const union ofp_action *a, size_t n_a,
> +                           const union ofp_action *b, size_t n_b);
> +union ofp_action *ofputil_actions_clone(const union ofp_action *, size_t n);
>
>  /* OpenFlow vendors.
>  *
> --
> 1.7.4.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list