[ovs-dev] [multipath 6/7] nx-match: Rename and export functions for parsing and formatting subfields.

Justin Pettit jpettit at nicira.com
Fri Dec 17 18:41:07 UTC 2010


Looks good.

--Justin


On Dec 16, 2010, at 2:42 PM, Ben Pfaff wrote:

> These will be used from other source files in upcoming commits.
> ---
> lib/nx-match.c |   20 ++++++++++----------
> lib/nx-match.h |    4 ++++
> 2 files changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/nx-match.c b/lib/nx-match.c
> index 7d7abb2..47cce83 100644
> --- a/lib/nx-match.c
> +++ b/lib/nx-match.c
> @@ -824,8 +824,8 @@ nx_match_from_string(const char *s, struct ofpbuf *b)
>     return match_len;
> }
> 
> -static const char *
> -parse_nxm_field_bits(const char *s, uint32_t *headerp, int *ofsp, int *n_bitsp)
> +const char *
> +nxm_parse_field_bits(const char *s, uint32_t *headerp, int *ofsp, int *n_bitsp)
> {
>     const char *full_s = s;
>     const char *name;
> @@ -886,12 +886,12 @@ nxm_parse_reg_move(struct nx_action_reg_move *move, const char *s)
>     int src_ofs, dst_ofs;
>     int src_n_bits, dst_n_bits;
> 
> -    s = parse_nxm_field_bits(s, &src, &src_ofs, &src_n_bits);
> +    s = nxm_parse_field_bits(s, &src, &src_ofs, &src_n_bits);
>     if (strncmp(s, "->", 2)) {
>         ovs_fatal(0, "%s: missing `->' following source", full_s);
>     }
>     s += 2;
> -    s = parse_nxm_field_bits(s, &dst, &dst_ofs, &dst_n_bits);
> +    s = nxm_parse_field_bits(s, &dst, &dst_ofs, &dst_n_bits);
>     if (*s != '\0') {
>         ovs_fatal(0, "%s: trailing garbage following destination", full_s);
>     }
> @@ -925,7 +925,7 @@ nxm_parse_reg_load(struct nx_action_reg_load *load, const char *s)
>         ovs_fatal(0, "%s: missing `->' following value", full_s);
>     }
>     s += 2;
> -    s = parse_nxm_field_bits(s, &dst, &ofs, &n_bits);
> +    s = nxm_parse_field_bits(s, &dst, &ofs, &n_bits);
>     if (*s != '\0') {
>         ovs_fatal(0, "%s: trailing garbage following destination", full_s);
>     }
> @@ -946,8 +946,8 @@ nxm_parse_reg_load(struct nx_action_reg_load *load, const char *s)
> 
> /* nxm_format_reg_move(), nxm_format_reg_load(). */
> 
> -static void
> -format_nxm_field_bits(struct ds *s, uint32_t header, int ofs, int n_bits)
> +void
> +nxm_format_field_bits(struct ds *s, uint32_t header, int ofs, int n_bits)
> {
>     format_nxm_field_name(s, header);
>     if (ofs == 0 && n_bits == nxm_field_bits(header)) {
> @@ -969,9 +969,9 @@ nxm_format_reg_move(const struct nx_action_reg_move *move, struct ds *s)
>     uint32_t dst = ntohl(move->dst);
> 
>     ds_put_format(s, "move:");
> -    format_nxm_field_bits(s, src, src_ofs, n_bits);
> +    nxm_format_field_bits(s, src, src_ofs, n_bits);
>     ds_put_cstr(s, "->");
> -    format_nxm_field_bits(s, dst, dst_ofs, n_bits);
> +    nxm_format_field_bits(s, dst, dst_ofs, n_bits);
> }
> 
> void
> @@ -983,7 +983,7 @@ nxm_format_reg_load(const struct nx_action_reg_load *load, struct ds *s)
>     uint64_t value = ntohll(load->value);
> 
>     ds_put_format(s, "load:%"PRIu64"->", value);
> -    format_nxm_field_bits(s, dst, ofs, n_bits);
> +    nxm_format_field_bits(s, dst, ofs, n_bits);
> }
> 
> /* nxm_check_reg_move(), nxm_check_reg_load(). */
> diff --git a/lib/nx-match.h b/lib/nx-match.h
> index 07d695d..bd4fea2 100644
> --- a/lib/nx-match.h
> +++ b/lib/nx-match.h
> @@ -56,6 +56,10 @@ void nxm_execute_reg_load(const struct nx_action_reg_load *, struct flow *);
> int nxm_field_bytes(uint32_t header);
> int nxm_field_bits(uint32_t header);
> 
> +const char *nxm_parse_field_bits(const char *s,
> +                                 uint32_t *headerp, int *ofsp, int *n_bitsp);
> +void nxm_format_field_bits(struct ds *, uint32_t header, int ofs, int n_bits);
> +
> /* Dealing with the 'ofs_nbits' members of struct nx_action_reg_load and struct
>  * nx_action_multipath. */
> 
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list