2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

ofproto: Move function find_meter() into ofpacts as ofpacts_get_meter().

ofproto is too big anyway so we might as well move out code that can
reasonably live elsewhere.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
This commit is contained in:
Ben Pfaff
2013-09-06 19:52:14 -07:00
parent b74cb5d8fd
commit d6fb622dcb
3 changed files with 30 additions and 28 deletions

View File

@@ -2117,6 +2117,30 @@ ofpacts_equal(const struct ofpact *a, size_t a_len,
{
return a_len == b_len && !memcmp(a, b, a_len);
}
/* Finds the OFPACT_METER action, if any, in the 'ofpacts_len' bytes of
* 'ofpacts'. If found, returns its meter ID; if not, returns 0.
*
* This function relies on the order of 'ofpacts' being correct (as checked by
* ofpacts_verify()). */
uint32_t
ofpacts_get_meter(const struct ofpact ofpacts[], size_t ofpacts_len)
{
const struct ofpact *a;
OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
enum ovs_instruction_type inst;
inst = ovs_instruction_type_from_ofpact_type(a->type);
if (a->type == OFPACT_METER) {
return ofpact_get_METER(a)->meter_id;
} else if (inst > OVSINST_OFPIT13_METER) {
break;
}
}
return 0;
}
/* Formatting ofpacts. */