summaryrefslogtreecommitdiffstats
path: root/test/patches/scapy-2.4/mpls.py.patch
blob: 2a8fc84b1c4b6a33bf103b44490217e2461ba707 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/scapy/contrib/mpls.py b/scapy/contrib/mpls.py
index 8daddf2..a9dc7fe 100644
--- a/scapy/contrib/mpls.py
+++ b/scapy/contrib/mpls.py
@@ -18,6 +18,7 @@
 from scapy.packet import Packet, bind_layers, Padding
 from scapy.fields import BitField,ByteField
 from scapy.layers.inet import IP
+from scapy.contrib.bier import BIER
 from scapy.layers.inet6 import IPv6
 from scapy.layers.l2 import Ether, GRE
 from scapy.compat import orb
@@ -36,6 +37,8 @@ class MPLS(Packet):
            ip_version = (orb(payload[0]) >> 4) & 0xF
            if ip_version == 4:
                return IP
+           elif ip_version == 5:
+               return BIER
            elif ip_version == 6:
                return IPv6
        return Padding
ighlight .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) 2020 cisco
 * 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 <vat/vat.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vppinfra/error.h>
#include <vppinfra/time_range.h>
#include <vnet/ethernet/ethernet.h>
#include <vpp-api/client/stat_client.h>

#define __plugin_msg_base graph_test_main.msg_id_base
#include <vlibapi/vat_helper_macros.h>

#include <vnet/format_fns.h>
#include <tracedump/graph.api_enum.h>
#include <tracedump/graph.api_types.h>
#include <vpp/api/vpe.api_types.h>

typedef struct
{
  u16 msg_id_base;
  u32 ping_id;
  vat_main_t *vat_main;
} graph_test_main_t;

graph_test_main_t graph_test_main;


uword
api_unformat_node_index (unformat_input_t * input, va_list * args)
{
  u32 *result = va_arg (*args, u32 *);

  return unformat (input, "%u", result);
}


static void
vl_api_graph_node_get_reply_t_handler (vl_api_graph_node_get_reply_t * mp)
{
  vat_main_t *vam = &vat_main;

  clib_warning ("Next node index: %u\n", mp->cursor);
  vam->result_ready = 1;
}

int
api_graph_node_get (vat_main_t * vam)
{
  graph_test_main_t *gtm = &graph_test_main;
  unformat_input_t *i = vam->input;
  vl_api_graph_node_get_t *mp;
  vl_api_control_ping_t *mp_ping;
  u32 node_index;
  char *node_name;
  u32 flags;
  bool want_arcs;

  if (vam->json_output)
    {
      clib_warning ("JSON output not supported for graph_node_get");
      return -99;
    }

  node_index = ~0;
  node_name = 0;
  flags = 0;
  want_arcs = false;

  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
    {
      if (unformat (i, "node_index %u", &node_index))
	;
      else if (unformat (i, "node_name %s", &node_name))
	;
      else if (unformat (i, "want_arcs"))
	want_arcs = true;
      else if (unformat (i, "trace_supported"))
	flags |= NODE_FLAG_TRACE_SUPPORTED;
      else if (unformat (i, "input"))
	flags |= NODE_FLAG_TRACE_SUPPORTED;
      else if (unformat (i, "drop"))
	flags |= NODE_FLAG_IS_DROP;
      else if (unformat (i, "ouptput"))
	flags |= NODE_FLAG_IS_OUTPUT;
      else if (unformat (i, "punt"))
	flags |= NODE_FLAG_IS_PUNT;
      else if (unformat (i, "handoff"))
	flags |= NODE_FLAG_IS_HANDOFF;
      else if (unformat (i, "no_free"))
	flags |= NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH;
      else if (unformat (i, "polling"))
	flags |= NODE_FLAG_SWITCH_FROM_INTERRUPT_TO_POLLING_MODE;
      else if (unformat (i, "interrupt"))
	flags |= NODE_FLAG_SWITCH_FROM_POLLING_TO_INTERRUPT_MODE;
      else
	{
	  clib_warning ("Unknown input: %U\n", format_unformat_error, i);
	  return -99;
	}
    }

  M (GRAPH_NODE_GET, mp);
  mp->index = htonl (node_index);
  mp->flags = htonl (flags);
  mp->want_arcs = want_arcs;

  if (node_name && node_name[0])
    clib_strncpy ((char *) mp->name, node_name, sizeof (mp->name) - 1);

  int ret = 0;
  S (mp);

  if (!gtm->ping_id)
    gtm->ping_id =
      vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));

  mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));
  mp_ping->_vl_msg_id = htons (gtm->ping_id);
  mp_ping->client_index = vam->my_client_index;

  S (mp_ping);
  W (ret);

  return ret;
}

void
vl_api_graph_node_details_t_handler (vl_api_graph_node_details_t * mp)
{
  vat_main_t *vam = &vat_main;
  u32 n_arcs;
  int i;

  fformat (vam->ofp,
	   "Node: %s  Index:%d  Flags:0x%x\n",
	   mp->name, ntohl (mp->index), ntohl (mp->flags));

  n_arcs = ntohl (mp->n_arcs);
  for (i = 0; i < n_arcs; ++i)
    {
      u32 node_index = ntohl (mp->arcs_out[i]);
      fformat (vam->ofp, "    next: %d\n", node_index);
    }
}

void
vl_api_graph_node_details_t_handler_json (vl_api_graph_node_details_t * mp)
{
  clib_error ("graph_node_details JSON not supported");
}

/* Override generated plugin register symbol */
#define vat_plugin_register graph_test_vat_plugin_register
#include <tracedump/graph.api_test.c>

static clib_error_t *
graph_api_hookup_shim (vlib_main_t * vm)
{
  graph_test_vat_plugin_register (&vat_main);
  return 0;
}

VLIB_API_INIT_FUNCTION (graph_api_hookup_shim);

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