Localize the timeout variable within the W message macro.
[vpp.git] / src / vlibapi / vat_helper_macros.h
index 7199364..ffb74fe 100644 (file)
 #define __vat_helper_macros_h__
 
 /* M: construct, but don't yet send a message */
-
-#define M(T,t)                                          \
-do {                                                    \
-    vam->result_ready = 0;                              \
-    mp = vl_msg_api_alloc_as_if_client(sizeof(*mp));    \
-    memset (mp, 0, sizeof (*mp));                       \
-    mp->_vl_msg_id = ntohs (VL_API_##T);                \
-    mp->client_index = vam->my_client_index;            \
+#define M(T, mp)                                                \
+do {                                                            \
+    vam->result_ready = 0;                                      \
+    mp = vl_msg_api_alloc_as_if_client(sizeof(*mp));            \
+    memset (mp, 0, sizeof (*mp));                               \
+    mp->_vl_msg_id = ntohs (VL_API_##T+__plugin_msg_base);      \
+    mp->client_index = vam->my_client_index;                    \
 } while(0);
 
-#define M2(T,t,n)                                               \
+#define M2(T, mp, n)                                            \
 do {                                                            \
     vam->result_ready = 0;                                      \
     mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n));        \
     memset (mp, 0, sizeof (*mp));                               \
-    mp->_vl_msg_id = ntohs (VL_API_##T);                        \
+    mp->_vl_msg_id = ntohs (VL_API_##T+__plugin_msg_base);      \
     mp->client_index = vam->my_client_index;                    \
 } while(0);
 
-
 /* S: send a message */
-#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
+#define S(mp) (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
 
 /* W: wait for results, with timeout */
 #define W                                       \
 do {                                            \
-    timeout = vat_time_now (vam) + 1.0;         \
+    f64 timeout = vat_time_now (vam) + 1.0;     \
                                                 \
     while (vat_time_now (vam) < timeout) {      \
         if (vam->result_ready == 1) {           \
@@ -60,7 +58,7 @@ do {                                            \
 /* W2: wait for results, with timeout */
 #define W2(body)                                \
 do {                                            \
-    timeout = vat_time_now (vam) + 1.0;         \
+    f64 timeout = vat_time_now (vam) + 1.0;     \
                                                 \
     while (vat_time_now (vam) < timeout) {      \
         if (vam->result_ready == 1) {           \