stats: add version field to stat segment base header

Add a version in the base header of the stat segment
To make support for multiple reader implementations safer.

Change-Id: I6816e2a51a98c2df1e621e80d4ef0b4ba4e9f47b
Type: feature
Signed-off-by: Ole Troan <ot@cisco.com>
diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c
index 8991806..cfe213d 100644
--- a/src/vpp-api/client/stat_client.c
+++ b/src/vpp-api/client/stat_client.c
@@ -509,6 +509,20 @@
   return stat_segment_index_to_name_r (index, sm);
 }
 
+uint64_t
+stat_segment_version_r (stat_client_main_t * sm)
+{
+  ASSERT (sm->shared_header);
+  return sm->shared_header->version;
+}
+
+uint64_t
+stat_segment_version (void)
+{
+  stat_client_main_t *sm = &stat_client_main;
+  return stat_segment_version_r (sm);
+}
+
 /*
  * fd.io coding-style-patch-verification: ON
  *
diff --git a/src/vpp-api/client/stat_client.h b/src/vpp-api/client/stat_client.h
index 901ec32..12faddb 100644
--- a/src/vpp-api/client/stat_client.h
+++ b/src/vpp-api/client/stat_client.h
@@ -78,6 +78,8 @@
 
 char *stat_segment_index_to_name_r (uint32_t index, stat_client_main_t * sm);
 char *stat_segment_index_to_name (uint32_t index);
+uint64_t stat_segment_version (void);
+uint64_t stat_segment_version_r (stat_client_main_t * sm);
 
 #endif /* included_stat_client_h */
 
diff --git a/src/vpp-api/python/vpp_papi/vpp_stats.py b/src/vpp-api/python/vpp_papi/vpp_stats.py
index de72249..590549a 100644
--- a/src/vpp-api/python/vpp_papi/vpp_stats.py
+++ b/src/vpp-api/python/vpp_papi/vpp_stats.py
@@ -49,6 +49,7 @@
 
 typedef struct
 {
+  uint64_t version;
   uint64_t epoch;
   uint64_t in_progress;
   uint64_t directory_offset;
@@ -82,6 +83,8 @@
 int stat_segment_vec_len(void *vec);
 uint8_t **stat_segment_string_vector(uint8_t **string_vector, char *string);
 char *stat_segment_index_to_name_r (uint32_t index, stat_client_main_t * sm);
+uint64_t stat_segment_version(void);
+uint64_t stat_segment_version_r(stat_client_main_t *sm);
 void free(void *ptr);
 """)