diff options
author | Guy Harris <gharris@sonic.net> | 2021-06-16 02:01:23 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-06-16 02:01:23 -0700 |
commit | 25a254823f21dee60f621b445e6689b2bbf9d9c4 (patch) | |
tree | 38f5033c9ea6dde5bdfbb9b4399d86be0de7579b /epan/dissectors/packet-openflow_v6.c | |
parent | f541e5e769321df0b4968164f583ecd684152d0e (diff) |
wsutil: add a header that defines some "round to power of 2" macros.
Add macros to round to multiples of 2, 4, 8, 16, and 32.
Use them instead of independently defined macros.
(We don't define a general "round to a power of 2" macro to avoid the
risk of somebody passing something other than a power of 2 to it.)
Diffstat (limited to 'epan/dissectors/packet-openflow_v6.c')
-rw-r--r-- | epan/dissectors/packet-openflow_v6.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/epan/dissectors/packet-openflow_v6.c b/epan/dissectors/packet-openflow_v6.c index 5cdf7e3251..ba59151bfb 100644 --- a/epan/dissectors/packet-openflow_v6.c +++ b/epan/dissectors/packet-openflow_v6.c @@ -19,6 +19,7 @@ #include <epan/expert.h> #include <epan/ipproto.h> #include <epan/addr_resolv.h> +#include <wsutil/ws_roundup.h> void proto_register_openflow_v6(void); void proto_reg_handoff_openflow_v6(void); @@ -1138,7 +1139,7 @@ dissect_openflow_stats_v6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre offset = oxs_end; } - padding = ((stats_length + 7) & ~7) - stats_length; + padding = WS_ROUNDUP_8(stats_length) - stats_length; if (padding) { proto_tree_add_item(tree, hf_openflow_v6_stats_pad, tvb, oxs_end, padding, ENC_NA); offset += padding; @@ -2863,7 +2864,7 @@ dissect_openflow_port_desc_prop_v6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_ while(offset < fields_end) { offset = dissect_openflow_oxm_v6(tvb, pinfo, prop_tree, offset, length); } - offset+=((prop_length + 7) & ~7) - prop_length; + offset+=WS_ROUNDUP_8(prop_length) - prop_length; break; case OFPPDPT_RECIRCULATE: @@ -2872,7 +2873,7 @@ dissect_openflow_port_desc_prop_v6(tvbuff_t *tvb, packet_info *pinfo _U_, proto_ proto_tree_add_item(tree, hf_openflow_v6_port_desc_prop_recirculate_port_no, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; } - offset+=((prop_length + 7) & ~7) - prop_length; + offset+=WS_ROUNDUP_8(prop_length) - prop_length; break; case OFPPDPT_EXPERIMENTER: |