summaryrefslogtreecommitdiffstats
path: root/src/vnet/lawful-intercept/lawful_intercept.h
diff options
context:
space:
mode:
authorsatish.karunanithi <satish.fdio@gmail.com>2017-12-06 16:11:59 +0530
committerDamjan Marion <dmarion.lists@gmail.com>2017-12-06 19:41:26 +0000
commit93fbcc6af9252fda8c261c190b24aaf6c09a38f4 (patch)
tree5ee03134b4d85a03c210f42d5f7880ceb2aa56bf /src/vnet/lawful-intercept/lawful_intercept.h
parentf363ebd4e7cd60dada11daa0e61b64569a9e1cf6 (diff)
VPP-259 Coding standards cleanup - vnet/vnet/lawful-intercept
Change-Id: Ie750c9fe06c067226b90bdcc3ea423b74d16562d Signed-off-by: satish.karunanithi <satish.fdio@gmail.com>
Diffstat (limited to 'src/vnet/lawful-intercept/lawful_intercept.h')
-rw-r--r--src/vnet/lawful-intercept/lawful_intercept.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/vnet/lawful-intercept/lawful_intercept.h b/src/vnet/lawful-intercept/lawful_intercept.h
index bcb18afece2..e39fa0d0752 100644
--- a/src/vnet/lawful-intercept/lawful_intercept.h
+++ b/src/vnet/lawful-intercept/lawful_intercept.h
@@ -19,27 +19,38 @@
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
-typedef struct {
+typedef struct
+{
/* LI collector info */
- ip4_address_t * src_addrs;
- ip4_address_t * collectors;
- u16 * ports;
+ ip4_address_t *src_addrs;
+ ip4_address_t *collectors;
+ u16 *ports;
/* Hit node index */
u32 hit_node_index;
/* convenience */
- vlib_main_t * vlib_main;
- vnet_main_t * vnet_main;
+ vlib_main_t *vlib_main;
+ vnet_main_t *vnet_main;
} li_main_t;
extern li_main_t li_main;
+/* *INDENT-OFF* */
typedef CLIB_PACKED(struct {
ip4_header_t ip4;
udp_header_t udp;
}) ip4_udp_header_t;
+/* *INDENT-ON* */
extern vlib_node_registration_t li_hit_node;
#endif /* __lawful_intercept_h__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
ghlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { 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 */ }
/*
 * Copyright (c) 2018 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.
 */

#include <vppinfra/format.h>
#include <vppinfra/pmalloc.h>
#include <vppinfra/random.h>

typedef struct
{
  uword baseva;
  uword size;
  uword *vas;
  u32 nitems;
  u32 item_size;
  u32 align;
  int max_numa;
  u32 arena_pages;
  u32 arena_numa;
  u32 arena_items;
  u32 arena_log2_pg_sz;
  int verbose;
  clib_pmalloc_main_t pmalloc_main;
} test_main_t;

test_main_t test_main;

clib_error_t *
test_palloc (test_main_t * tm)
{
  clib_pmalloc_main_t *pm = &tm->pmalloc_main;
  void *arena;
  int i;
  uword *va;

  if (clib_pmalloc_init (pm, 0, 0) != 0)
    return clib_error_return (0, "pmalloc init failure");

  fformat (stdout, "Allocate %d items...\n", tm->nitems);

  for (i = 0; i < tm->nitems; i++)
    {
      u32 size = tm->item_size ? tm->item_size : 64 + 64 * (i % 8);
      u32 align = tm->align ? tm->align : 64 << (i % 5);
      u32 numa = i % (tm->max_numa + 1);
      va = clib_pmalloc_alloc_aligned_on_numa (pm, size, align, numa);

      if (va == 0)
	clib_error ("Failed to alloc %u byte chunk with align %u on numa %u,"
		    "\nerror: %U", size, align, numa, format_clib_error,
		    clib_pmalloc_last_error (pm));

      if ((pointer_to_uword (va) & (align - 1)) != 0)
	clib_error (0, "Alignment error: %p not aligned with %u", va, align);

      vec_add1 (tm->vas, pointer_to_uword (va));
    }
  fformat (stdout, "%U\n", format_pmalloc, pm, tm->verbose);

  /* alloc from arena */
  if (tm->arena_items)
    {
      fformat (stdout, "Allocate %d items from arena ...\n", tm->arena_items);
      arena = clib_pmalloc_create_shared_arena (pm, "test arena",
						tm->arena_pages << 21,
						tm->arena_log2_pg_sz,
						tm->arena_numa);
      if (arena == 0)
	clib_error ("Failed to alloc shared arena: %U", format_clib_error,
		    clib_pmalloc_last_error (pm));

      for (i = 0; i < tm->arena_items; i++)
	{
	  u32 size = tm->item_size ? tm->item_size : 64 + 64 * (i % 8);
	  u32 align = tm->align ? tm->align : 64 << (i % 5);
	  va = clib_pmalloc_alloc_from_arena (pm, arena, size, align);
	  vec_add1 (tm->vas, pointer_to_uword (va));
	}
      fformat (stdout, "\n%U\n", format_pmalloc, pm, tm->verbose);
    }


  fformat (stdout, "Freeing %d items ...\n", vec_len (tm->vas));
  for (i = 0; i < vec_len (tm->vas); i++)
    clib_pmalloc_free (pm, (void *) tm->vas[i]);

  fformat (stdout, "\n%U\n", format_pmalloc, pm, tm->verbose);
  return 0;
}

clib_error_t *
test_palloc_main (unformat_input_t * i)
{
  test_main_t *tm = &test_main;
  clib_error_t *error;

  tm->nitems = 5;
  tm->arena_pages = 2;
  tm->arena_numa = CLIB_PMALLOC_NUMA_LOCAL;

  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
    {
      if (unformat (i, "nitems %u", &tm->nitems))
	;
      else if (unformat (i, "max-numa %u", &tm->max_numa))
	;
      else if (unformat (i, "item-size %u", &tm->item_size))
	;
      else if (unformat (i, "align %u", &tm->align))
	;
      else if (unformat (i, "verbose %d", &tm->verbose))
	;
      else if (unformat (i, "arena-pages %u", &tm->arena_pages))
	;
      else if (unformat (i, "arena-numa %u", &tm->arena_numa))
	;
      else if (unformat (i, "arena-items %u", &tm->arena_items))
	;
      else if (unformat (i, "arena-log2-page-size %u", &tm->arena_log2_pg_sz))
	;
      else if (unformat (i, "verbose"))
	tm->verbose = 1;
      else
	return clib_error_return (0, "unknown input '%U'",
				  format_unformat_error, i);
    }

  error = test_palloc (tm);

  return error;
}

#ifdef CLIB_UNIX
int
main (int argc, char *argv[])
{
  unformat_input_t i;
  int rv = 0;
  clib_error_t *error;

  clib_mem_init (0, 3ULL << 30);

  unformat_init_command_line (&i, argv);
  error = test_palloc_main (&i);
  if (error)
    {
      clib_error_report (error);
      rv = 1;
    }
  unformat_free (&i);

  return rv;
}
#endif /* CLIB_UNIX */

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