aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/qos/qos_api.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-09-05 09:36:05 -0700
committerDamjan Marion <dmarion@me.com>2018-09-06 08:14:02 +0000
commited234e7f151b05a5b8375dbd9f0add24fe8ebf2f (patch)
tree9020f898ce9e3133ee566f321a72e31a538c6d51 /src/vnet/qos/qos_api.c
parenta7f8b228ff505acc052a77101b12e714ead26536 (diff)
Enum type on the API for QoS sources
Change-Id: I877541ede6e26581c659821502f23b777903b82f Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/qos/qos_api.c')
-rw-r--r--src/vnet/qos/qos_api.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/src/vnet/qos/qos_api.c b/src/vnet/qos/qos_api.c
index e2393137d15..6297c24a843 100644
--- a/src/vnet/qos/qos_api.c
+++ b/src/vnet/qos/qos_api.c
@@ -48,21 +48,46 @@
_(QOS_EGRESS_MAP_UPDATE, qos_egress_map_update) \
_(QOS_MARK_ENABLE_DISABLE, qos_mark_enable_disable)
+static int
+qos_source_decode (vl_api_qos_source_t v, qos_source_t * q)
+{
+ v = ntohl (v);
+
+ switch (v)
+ {
+ case QOS_API_SOURCE_EXT:
+ *q = QOS_SOURCE_EXT;
+ return 0;
+ case QOS_API_SOURCE_VLAN:
+ *q = QOS_SOURCE_VLAN;
+ return 0;
+ case QOS_API_SOURCE_MPLS:
+ *q = QOS_SOURCE_MPLS;
+ return 0;
+ case QOS_API_SOURCE_IP:
+ *q = QOS_SOURCE_IP;
+ return 0;
+ }
+
+ return (VNET_API_ERROR_INVALID_VALUE);
+}
+
void
vl_api_qos_record_enable_disable_t_handler (vl_api_qos_record_enable_disable_t
* mp)
{
vl_api_qos_record_enable_disable_reply_t *rmp;
+ qos_source_t qs;
int rv = 0;
- if (mp->input_source >= QOS_N_SOURCES)
- rv = VNET_API_ERROR_INVALID_VALUE;
- else
+ rv = qos_source_decode (mp->input_source, &qs);
+
+ if (0 == rv)
{
if (mp->enable)
- rv = qos_record_enable (ntohl (mp->sw_if_index), mp->input_source);
+ rv = qos_record_enable (ntohl (mp->sw_if_index), qs);
else
- rv = qos_record_disable (ntohl (mp->sw_if_index), mp->input_source);
+ rv = qos_record_disable (ntohl (mp->sw_if_index), qs);
}
REPLY_MACRO (VL_API_QOS_RECORD_ENABLE_DISABLE_REPLY);
@@ -99,17 +124,18 @@ void
(vl_api_qos_mark_enable_disable_t * mp)
{
vl_api_qos_mark_enable_disable_reply_t *rmp;
+ qos_source_t qs;
int rv = 0;
- if (mp->output_source >= QOS_N_SOURCES)
- rv = VNET_API_ERROR_INVALID_VALUE;
- else
+ rv = qos_source_decode (mp->output_source, &qs);
+
+ if (0 == rv)
{
if (mp->enable)
- rv = qos_mark_enable (ntohl (mp->sw_if_index),
- mp->output_source, ntohl (mp->map_id));
+ rv =
+ qos_mark_enable (ntohl (mp->sw_if_index), qs, ntohl (mp->map_id));
else
- rv = qos_mark_disable (ntohl (mp->sw_if_index), mp->output_source);
+ rv = qos_mark_disable (ntohl (mp->sw_if_index), qs);
}
REPLY_MACRO (VL_API_QOS_MARK_ENABLE_DISABLE_REPLY);