aboutsummaryrefslogtreecommitdiffstats
path: root/.clang-tidy
blob: f3f69d2d5bb3c5fd566aa5f5f49eae7f2221872d (plain)
1
2
3
4
5
6
7
8
Checks: "-*,\
misc-*,\
bugprone-*,\
-bugprone-reserved-identifier,\
-performance-*,\
clang-analyzer-*,\
-clang-analyzer-valist.Uninitialized,\
"
-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 */
/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright(c) 2021 Cisco Systems, Inc.
 */

#include <vlib/vlib.h>
#include <vnet/vnet.h>
#include <vnet/interface.h>
#include <vnet/hash/hash.h>

vnet_hash_main_t vnet_hash_main;

u8 *
format_vnet_hash (u8 *s, va_list *args)
{
  vnet_hash_function_registration_t *hash =
    va_arg (*args, vnet_hash_function_registration_t *);

  s = format (s, "[name: %s ", hash->name);
  s = format (s, "priority: %u ", hash->priority);
  s = format (s, "description: %s]", hash->description);
  return s;
}

/**
 * select hash func with highest priority
 */
vnet_hash_fn_t
vnet_hash_default_function (vnet_hash_fn_type_t ftype)
{
  vnet_hash_function_registration_t *hash = vnet_hash_main.hash_registrations;
  vnet_hash_function_registration_t *tmp_hash = hash;
  while (hash)
    {
      if (hash->priority > tmp_hash->priority)
	tmp_hash = hash;
      hash = hash->next;
    }
  return tmp_hash->function[ftype];
}

vnet_hash_fn_t
vnet_hash_function_from_name (const char *name, vnet_hash_fn_type_t ftype)
{
  vnet_hash_function_registration_t *hash = vnet_hash_main.hash_registrations;
  while (hash)
    {
      if (strcmp (hash->name, name) == 0)
	break;
      hash = hash->next;
    }
  if (!hash)
    return (0);
  return hash->function[ftype];
}

vnet_hash_function_registration_t *
vnet_hash_function_from_func (vnet_hash_fn_t fn, vnet_hash_fn_type_t ftype)
{
  vnet_hash_function_registration_t *hash = vnet_hash_main.hash_registrations;
  while (hash)
    {
      if (hash->function[ftype] == fn)
	break;
      hash = hash->next;
    }
  return hash;
}

static clib_error_t *
vnet_hash_init (vlib_main_t *vm)
{
  return (0);
}

VLIB_INIT_FUNCTION (vnet_hash_init);