GBP: Counters per-contract
[vpp.git] / src / plugins / gbp / gbp_api.c
index 3f35555..f6d25dd 100644 (file)
@@ -929,10 +929,10 @@ vl_api_gbp_contract_add_del_t_handler (vl_api_gbp_contract_add_del_t * mp)
 {
   vl_api_gbp_contract_add_del_reply_t *rmp;
   u16 *allowed_ethertypes;
+  u32 stats_index;
   index_t *rules;
   int ii, rv = 0;
-  u8 *data, n_et;
-  u16 *et;
+  u8 n_et;
 
   if (mp->is_add)
     {
@@ -944,32 +944,33 @@ vl_api_gbp_contract_add_del_t_handler (vl_api_gbp_contract_add_del_t * mp)
       allowed_ethertypes = NULL;
 
       /*
-       * move past the variable legnth array of rules to get to the
        * allowed ether types
        */
-      data = (((u8 *) & mp->contract.n_ether_types) +
-             (sizeof (mp->contract.rules[0]) * mp->contract.n_rules));
-      n_et = *data;
-      et = (u16 *) (++data);
+      n_et = mp->contract.n_ether_types;
       vec_validate (allowed_ethertypes, n_et - 1);
 
       for (ii = 0; ii < n_et; ii++)
        {
          /* leave the ether types in network order */
-         allowed_ethertypes[ii] = et[ii];
+         allowed_ethertypes[ii] = mp->contract.allowed_ethertypes[ii];
        }
 
       rv = gbp_contract_update (ntohs (mp->contract.sclass),
                                ntohs (mp->contract.dclass),
                                ntohl (mp->contract.acl_index),
-                               rules, allowed_ethertypes);
+                               rules, allowed_ethertypes, &stats_index);
     }
   else
     rv = gbp_contract_delete (ntohs (mp->contract.sclass),
                              ntohs (mp->contract.dclass));
 
 out:
-  REPLY_MACRO (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE);
+  /* *INDENT-OFF* */
+  REPLY_MACRO2 (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE,
+  ({
+    rmp->stats_index = htonl (stats_index);
+  }));
+  /* *INDENT-ON* */
 }
 
 static int