summaryrefslogtreecommitdiffstats
path: root/cicn-plugin/cicn/cicn_infra_inlines.h
diff options
context:
space:
mode:
Diffstat (limited to 'cicn-plugin/cicn/cicn_infra_inlines.h')
-rw-r--r--cicn-plugin/cicn/cicn_infra_inlines.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/cicn-plugin/cicn/cicn_infra_inlines.h b/cicn-plugin/cicn/cicn_infra_inlines.h
new file mode 100644
index 00000000..c9333f53
--- /dev/null
+++ b/cicn-plugin/cicn/cicn_infra_inlines.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016 by Cisco Systems Inc. All Rights Reserved.
+ *
+ */
+#ifndef _CICN_INFRA_INLINES_H_
+#define _CICN_INFRA_INLINES_H_ 1
+
+#if !CICN_VPP_PLUGIN
+#error "cicn-internal file included externally"
+#endif
+
+#include <vlib/vlib.h>
+
+/*
+ * Wrapper for buffer allocation that returns pointer rather than index
+ */
+static inline vlib_buffer_t *
+cicn_infra_vlib_buffer_alloc (vlib_main_t * vm)
+{
+ vlib_buffer_t *b0;
+ u32 bi0;
+ if (vlib_buffer_alloc (vm, &bi0, 1) != 1)
+ {
+ b0 = 0;
+ goto done;
+ }
+ b0 = vlib_get_buffer (vm, bi0);
+
+done:
+ return (b0);
+}
+
+/*
+ * Wrapper for buffer free that uses pointer rather than index
+ */
+static inline void
+cicn_infra_vlib_buffer_free (vlib_buffer_t * b0, vlib_main_t * vm)
+{
+ u32 bi0 = vlib_get_buffer_index (vm, b0);
+ vlib_buffer_free_one (vm, bi0);
+}
+
+#endif // CICN_INFRA_INLINES_H_