On Tue, Jun 12, 2012 at 12:32:24AM -0700, Ben Pfaff wrote:
> A work in progress.  Doesn't build.
> 
> I'm not really sure I want separate OFPUTIL_ constants for OF1.0 and OF1.1
> versions of each message.  It's something I'm trying out as I write the
> code.
> 
> Signed-off-by: Ben Pfaff <b...@nicira.com>
> ---

[snip]

> diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> index 11c467e..9414cd4 100644
> --- a/lib/ofp-util.c
> +++ b/lib/ofp-util.c
> @@ -263,6 +263,31 @@ ofputil_cls_rule_to_ofp10_match(const struct cls_rule 
> *rule,
>      memset(match->pad2, '\0', sizeof match->pad2);
>  }
>  
> +enum ofperr
> +ofputil_pull_ofp11_match(struct ofpbuf *buf, unsigned int priority,
> +                         struct cls_rule *rule)

Do you have any users outside of lib/ofp-util.c?
Else perhaps this function could be static?

> +{
> +    struct ofp11_match_header *omh;

I think that ohm needs to be pulled, so perhaps:

    struct ofp11_match_header *omh = ofpbuf_pull(buf, sizeof *omh);

> +    struct ofp11_match *om;
> +
> +    if (buf->size < sizeof(struct ofp11_match_header)) {

I think that "sizeof *omh" would be consistent with other OVS code
I have read recently.

    if (buf->size < sizeof *omh) {


> +        return OFPERR_OFPBMC_BAD_LEN;
> +    }
> +
> +    omh = buf->data;

This line is not needed if omh is set usng ofpbuf_pull().

> +    switch (ntohs(omh->type)) {
> +    case OFPMT_STANDARD:
> +        if (omh->length != htons(sizeof *om) || buf->size < sizeof *om) {
> +            return OFPERR_OFPBMC_BAD_LEN;
> +        }
> +        om = ofpbuf_pull(buf, sizeof *om);
> +        return ofputil_cls_rule_from_ofp11_match(om, priority, rule);
> +
> +    default:
> +        return OFPERR_OFPBMC_BAD_TYPE;
> +    }
> +}
> +
>  /* Converts the ofp11_match in 'match' into a cls_rule in 'rule', with the
>   * given 'priority'.  Returns 0 if successful, otherwise an OFPERR_* value. 
> */
>  enum ofperr

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

Reply via email to