summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2018-01-09 01:51:43 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2018-01-10 02:43:52 +0000
commitb59bd659388db62b60a4fb887ce272989d7c340c (patch)
tree5598c13a2a4d234dcae9f4ca2ed86db2d464e2d0 /src/plugins
parent580eda7067bee891c00f59fe3927720def3837ec (diff)
Fix stn rules dump api (VPP-1123)
Change-Id: If9e9e4fc348d20396713d9017100dda63a107edb Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/stn/stn_api.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/plugins/stn/stn_api.c b/src/plugins/stn/stn_api.c
index 73136e09f91..1052dd751e7 100644
--- a/src/plugins/stn/stn_api.c
+++ b/src/plugins/stn/stn_api.c
@@ -93,49 +93,48 @@ vl_api_stn_add_del_rule_t_handler (vl_api_stn_add_del_rule_t * mp)
if (mp->is_ip4)
{
ip4_address_t a;
- memcpy(&a, mp->ip_address, sizeof(a));
- ip46_address_set_ip4(&args.address, &a);
+ memcpy (&a, mp->ip_address, sizeof (a));
+ ip46_address_set_ip4 (&args.address, &a);
}
else
- memcpy(&args.address.ip6, mp->ip_address, sizeof(ip6_address_t));
+ memcpy (&args.address.ip6, mp->ip_address, sizeof (ip6_address_t));
- args.sw_if_index = clib_net_to_host_u32(mp->sw_if_index);
+ args.sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
args.del = !mp->is_add;
- rv = stn_rule_add_del(&args);
+ rv = stn_rule_add_del (&args);
REPLY_MACRO (VL_API_STN_ADD_DEL_RULE_REPLY);
}
static void
-send_stn_rule (stn_rule_t *r, svm_queue_t *q, u32 context)
+send_stn_rule_details (stn_rule_t * r, svm_queue_t * q, u32 context)
{
vl_api_stn_rule_details_t *rmp;
- rmp =
- vl_msg_api_alloc (sizeof (*rmp));
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id =
- clib_host_to_net_u32 (VL_API_STN_RULES_DUMP + stn_main.msg_id_base);
+ clib_host_to_net_u32 (VL_API_STN_RULE_DETAILS + stn_main.msg_id_base);
- if (ip46_address_is_ip4(&r->address))
+ if (ip46_address_is_ip4 (&r->address))
{
- clib_memcpy(rmp->ip_address, &r->address.ip4, sizeof(ip4_address_t));
+ clib_memcpy (rmp->ip_address, &r->address.ip4, sizeof (ip4_address_t));
rmp->is_ip4 = 1;
}
else
{
- clib_memcpy(rmp->ip_address, &r->address.ip6, sizeof(ip6_address_t));
+ clib_memcpy (rmp->ip_address, &r->address.ip6, sizeof (ip6_address_t));
}
rmp->context = context;
- rmp->sw_if_index = clib_host_to_net_u32(r->sw_if_index);
+ rmp->sw_if_index = clib_host_to_net_u32 (r->sw_if_index);
vl_msg_api_send_shmem (q, (u8 *) & rmp);
}
static void
-vl_api_stn_rules_dump_t_handler (vl_api_stn_rules_dump_t *mp)
+vl_api_stn_rules_dump_t_handler (vl_api_stn_rules_dump_t * mp)
{
svm_queue_t *q;
stn_main_t *stn = &stn_main;
@@ -146,10 +145,8 @@ vl_api_stn_rules_dump_t_handler (vl_api_stn_rules_dump_t *mp)
return;
/* *INDENT-OFF* */
- pool_foreach (r, stn->rules,
- ({
-
- send_stn_rule (r, q, mp->context);
+ pool_foreach (r, stn->rules,({
+ send_stn_rule_details (r, q, mp->context);
}));
/* *INDENT-ON* */
}
@@ -215,8 +212,8 @@ stn_api_init (vlib_main_t * vm, stn_main_t * sm)
name = format (0, "stn_%08x%c", api_version, 0);
/* Ask for a correctly-sized block of API message decode slots */
- sm->msg_id_base =
- vl_msg_api_get_msg_ids ((char *) name, VL_MSG_FIRST_AVAILABLE);
+ sm->msg_id_base = vl_msg_api_get_msg_ids ((char *) name,
+ VL_MSG_FIRST_AVAILABLE);
error = stn_plugin_api_hookup (vm);
@@ -229,3 +226,11 @@ stn_api_init (vlib_main_t * vm, stn_main_t * sm)
return error;
}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
{ color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 *------------------------------------------------------------------
 * api.h
 *
 * Copyright (c) 2009-2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *------------------------------------------------------------------
 */

#ifndef included_api_h
#define included_api_h

#include <stddef.h>
#include <vppinfra/error.h>
#include <svm/svm.h>
#include <svm/queue.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlibapi/api_common.h>

/* *INDENT-OFF* */
typedef CLIB_PACKED ( struct {
   u8 endian;
   u8 wrapped;
   u32 nitems;
}) vl_api_trace_file_header_t;
/* *INDENT-ON* */

int vl_msg_api_trace_save (api_main_t * am,
			   vl_api_trace_which_t which, FILE * fp);

#define VLIB_API_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,api_init)

/* Call given init function: used for init function dependencies. */
#define vlib_call_api_init_function(vm, x)                              \
  ({                                                                    \
    extern vlib_init_function_t * _VLIB_INIT_FUNCTION_SYMBOL (x,api_init); \
    vlib_init_function_t * _f = _VLIB_INIT_FUNCTION_SYMBOL (x,api_init); \
    clib_error_t * _error = 0;                                          \
    if (! hash_get (vm->init_functions_called, _f))                     \
      {                                                                 \
	hash_set1 (vm->init_functions_called, _f);                      \
	_error = _f (vm);                                               \
      }                                                                 \
    _error;                                                             \
  })

#define _VL_MSG_API_FUNCTION_SYMBOL(x, type)	\
  _vl_msg_api_##type##_function_##x

#define VL_MSG_API_FUNCTION_SYMBOL(x)		\
  _VL_MSG_API_FUNCTION_SYMBOL(x, reaper)

#define VLIB_DECLARE_REAPER_FUNCTION(x, tag)                            \
vl_msg_api_init_function_t * _VL_MSG_API_FUNCTION_SYMBOL (x, tag) = x;  \
static void __vl_msg_api_add_##tag##_function_##x (void)                \
    __attribute__((__constructor__)) ;                                  \
                                                                        \
static void __vl_msg_api_add_##tag##_function_##x (void)                \
{                                                                       \
 api_main_t * am = &api_main;                                           \
 static _vl_msg_api_function_list_elt_t _vl_msg_api_function;           \
 _vl_msg_api_function.next_init_function                                \
    = am->tag##_function_registrations;                                 \
  am->tag##_function_registrations = &_vl_msg_api_function;             \
 _vl_msg_api_function.f = &x;                                           \
}

#define VL_MSG_API_REAPER_FUNCTION(x) VLIB_DECLARE_REAPER_FUNCTION(x,reaper)

/* Call reaper function with client index */
#define vl_msg_api_call_reaper_function(ci)                             \
  ({                                                                    \
    extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (reaper);   \
    vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (reaper);     \
    clib_error_t * _error = 0;                                          \
    _error = _f (ci);                                                   \
  })

static inline u32
vl_msg_api_get_msg_length_inline (void *msg_arg)
{
  u8 *msg = (u8 *) msg_arg;

  msgbuf_t *header = (msgbuf_t *) (msg - offsetof (msgbuf_t, data));

  return clib_net_to_host_u32 (header->data_len);
}

int vl_msg_api_rx_trace_enabled (api_main_t * am);
int vl_msg_api_tx_trace_enabled (api_main_t * am);
void vl_msg_api_trace (api_main_t * am, vl_api_trace_t * tp, void *msg);
int vl_msg_api_trace_onoff (api_main_t * am, vl_api_trace_which_t which,
			    int onoff);
int vl_msg_api_trace_free (api_main_t * am, vl_api_trace_which_t which);
int vl_msg_api_trace_configure (api_main_t * am, vl_api_trace_which_t which,
				u32 nitems);
void vl_msg_api_handler_with_vm_node (api_main_t * am,
				      void *the_msg, vlib_main_t * vm,
				      vlib_node_runtime_t * node);
vl_api_trace_t *vl_msg_api_trace_get (api_main_t * am,
				      vl_api_trace_which_t which);
void vl_msg_api_add_msg_name_crc (api_main_t * am, const char *string,
				  u32 id);
void vl_msg_api_add_version (api_main_t * am, const char *string,
			     u32 major, u32 minor, u32 patch);
/* node_serialize.c prototypes */
u8 *vlib_node_serialize (vlib_main_t * vm, vlib_node_t *** node_dups,
			 u8 * vector, int include_nexts, int include_stats);
vlib_node_t **vlib_node_unserialize (u8 * vector);

u32 vl_msg_api_get_msg_length (void *msg_arg);

#endif /* included_api_h */
/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */