summaryrefslogtreecommitdiffstats
path: root/src/plugins/map/map.api
blob: ba733e35de3c7b164587fe22e91beb318d29e936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .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 */
}
#!/usr/bin/env python
""" Container integration tests """

import unittest
from framework import VppTestCase, VppTestRunner, running_extended_tests
from scapy.layers.l2 import Ether
from scapy.packet import Raw
from scapy.layers.inet import IP, UDP, TCP
from scapy.packet import Packet
from socket import inet_pton, AF_INET, AF_INET6
from scapy.layers.inet6 import IPv6, ICMPv6Unknown, ICMPv6EchoRequest
from scapy.layers.inet6 import ICMPv6EchoReply, IPv6ExtHdrRouting
from scapy.layers.inet6 import IPv6ExtHdrFragment
from pprint import pprint
from random import randint
from util import L4_Conn


class Conn(L4_Conn):
    # for now same as L4_Conn
    pass


@unittest.skipUnless(running_extended_tests(), "part of extended tests")
clas
/*
 * Copyright (c) 2016 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.
 */

option version = "4.2.1";

import "vnet/ip/ip_types.api";
import "vnet/interface_types.api";

/** \brief Add MAP domains
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param ip6_prefix - Rule IPv6 prefix
    @param ip4_prefix - Rule IPv4 prefix
    @param ip6_src - MAP domain IPv6 BR address / Tunnel source
    @param ea_bits_len - Embedded Address bits length
    @param psid_offset - Port Set Identifier (PSID) offset
    @param psid_length - PSID length
    @param mtu - MTU. default 1280
    @param tag - A user field stored with the MAP
*/
autoendian define map_add_domain
{
  u32 client_index;
  u32 context;
  vl_api_ip6_prefix_t ip6_prefix;
  vl_api_ip4_prefix_t ip4_prefix;
  vl_api_ip6_prefix_t ip6_src;
  u8 ea_bits_len;
  u8 psid_offset;
  u8 psid_length;
  u16 mtu [default=1280];
  string tag[64];
};

/** \brief Reply for MAP domain add
    @param context - returned sender context, to match reply w/ request
    @param index - MAP domain index
    @param retval - return code
*/
define map_add_domain_reply
{
  u32 context;
  u32 index;
  i32 retval;
};

/** \brief Delete MAP domain
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param index - MAP Domain index
*/
autoreply define map_del_domain
{
  u32 client_index;
  u32 context;
  u32 index;
};


/** \brief Add or Delete MAP rule from a domain (Only used for shared IPv4 per subscriber)
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param index - MAP Domain index
    @param is_add - If 1 add rule, if 0 delete rule
    @param ip6_dst - MAP CE IPv6 address
    @param psid - Rule PSID
*/
autoreply define map_add_del_rule
{
  u32 client_index;
  u32 context;
  u32 index;
  bool is_add;
  vl_api_ip6_address_t ip6_dst;
  u16 psid;
};


/** \brief Get list of map domains
    @param client_index - opaque cookie to identify the sender
*/
service {
  rpc map_domains_get returns map_domains_get_reply
    stream map_domain_details;
};

define map_domains_get
{
  u32 client_index;
  u32 context;
  u32 cursor;
};

define map_domains_get_reply
{
  u32 context;
  i32 retval;
  u32 cursor;
};

define map_domain_dump
{
  option deprecated;
  u32 client_index;
  u32 context;
};

/** \brief Details about a single MAP domain
    @param context - returned sender context, to match reply w/ request
    @param domain_index - MAP domain index
    @param ip6_prefix - Rule IPv6 prefix
    @param ip4_prefix - Rule IPv4 prefix
    @param ip6_src - MAP domain IPv6 BR address / Tunnel source
    @param ea_bits_len - Embedded Address bits length
    @param psid_offset - Port Set Identifier (PSID) offset
    @param psid_length - PSID length
    @param flags -
    @param mtu - MTU
    @param tag - The user field stored with the MAP at creation time
*/
define map_domain_details
{
  u32 context;
  u32 domain_index;
  vl_api_ip6_prefix_t ip6_prefix;
  vl_api_ip4_prefix_t ip4_prefix;
  vl_api_ip6_prefix_t ip6_src;
  u8 ea_bits_len;
  u8 psid_offset;
  u8 psid_length;
  u8 flags;
  u16 mtu;
  string tag[64];
};

define map_rule_dump
{
  u32 client_index;
  u32 context;
  u32 domain_index;
};

define map_rule_details
{
  u32 context;
  vl_api_ip6_address_t ip6_dst;
  u16 psid;
};

/** \brief Enable or disable a MAP interface
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index -
    @param is_enable - 0=disable, 1=enable interface
    @param is_translation -  0=encapsulation, 1=translation
*/
autoreply define map_if_enable_disable
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  bool is_enable;
  bool is_translation; /* 0 - encapsulation, 1 - translation */
};

/** \brief Request for a single block of summary stats
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
define map_summary_stats
{
  u32 client_index;
  u32 context;
};

/** \brief Reply for map_summary_stats request
    @param context - sender context, to match reply w/ request
    @param retval - return code for request
    @param total_bindings -
    @param total_pkts -
    @param total_ip4_fragments -
    @param total_security_check -
*/
define map_summary_stats_reply
{
  u32 context;
  i32 retval;
  u64 total_bindings;
  u64 total_pkts[2];
  u64 total_bytes[2];
  u64 total_ip4_fragments;
  u64 total_security_check[2];
};


/** \brief Set MAP fragmentation parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param inner - 1=frag inner packet, 0=frag tunnel packets
    @param ignore_df - 1=IP4 fragment despite DF bit, 0=honor DF
*/
autoreply define map_param_set_fragmentation
{
  u32 client_index;
  u32 context;
  bool inner;
  bool ignore_df;
};


/** \brief Set MAP ICMP parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param icmp4_err_relay_src - IPv4 ICMP err relay src address
*/
autoreply define map_param_set_icmp
{
  u32 client_index;
  u32 context;
  vl_api_ip4_address_t ip4_err_relay_src;
};


/** \brief Set MAP ICMP6 parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param enable_unreachable - 1 = send ICMP unreachable err msgs
*/
autoreply define map_param_set_icmp6
{
  u32 client_index;
  u32 context;
  bool enable_unreachable;
};


/** \brief Add/delete MAP pre-resolve IP addresses parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add - 1 = Add non-zero IP addresses, 0 = delete
    @param ip4_nh_address - direct IP4 next-hop address
    @param ip6_nh_address - direct IP6 next-hop address
*/
autoreply define map_param_add_del_pre_resolve
{
  u32 client_index;
  u32 context;
  bool is_add;
  vl_api_ip4_address_t ip4_nh_address;
  vl_api_ip6_address_t ip6_nh_address;
};

/** \brief Set MAP security-check parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param enable - 1=enable security check on first inbound packet
    @param fragments - 1=enable check on (subsequent) fragments too
*/
autoreply define map_param_set_security_check
{
  u32 client_index;
  u32 context;
  bool enable;
  bool fragments;
};


/** \brief Set MAP traffic class parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param copy - 1 = copy packet class/TOS field, 0 = use tc_class instead
    @param tc_class - class field value when copy == 0
*/
autoreply define map_param_set_traffic_class
{
  u32 client_index;
  u32 context;
  bool copy;
  u8 tc_class;
};


/** \brief Set MAP TCP parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @parma tcp_mss - TCP MSS clamping value
*/
autoreply define map_param_set_tcp
{
  u32 client_index;
  u32 context;
  u16 tcp_mss;
};


/** \brief Request for a single block of MAP parameters
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
define map_param_get
{
  u32 client_index;
  u32 context;
};


/** \brief Reply for map_param_get request
    @param context - sender context, to match reply w/ request
    @param retval - return code for request
    @param inner - 1=frag inner packet, 0=frag tunnel packets, ~0=untouched
    @param ignore_df - 1=IP4 fragm despite DF bit, 0=honor DF, ~0=untouched
    @param icmp_ip4_err_relay_src - IPv4 ICMP err relay src address
    @param icmp6_enable_unreachable - 1 = send ICMP unreachable err msgs
    @param ip4_nh_address - direct IP4 next-hop address
    @param ip6_nh_address - direct IP6 next-hop address
    @param sec_check_enable - 1=enable security check on first inbound packet
    @param sec_check_fragments - 1=enable check on (subsequent) fragments too
    @param tc_copy - 1 = copy packet class/TOS field, 0 = use class instead
    @param tc_class - class field value when copy == 0
*/
define map_param_get_reply
{
  u32 context;
  i32 retval;
  u8 frag_inner;
  u8 frag_ignore_df;
  vl_api_ip4_address_t icmp_ip4_err_relay_src;
  bool icmp6_enable_unreachable;
  vl_api_ip4_address_t ip4_nh_address;
  vl_api_ip6_address_t ip6_nh_address;
  u16 ip4_lifetime_ms;
  u16 ip4_pool_size;
  u32 ip4_buffers;
  f64 ip4_ht_ratio;
  bool sec_check_enable;
  bool sec_check_fragments;
  bool tc_copy;
  u8 tc_class;
};

/*
 * MAP Error counters/messages
 */
counters map {
  none {
    severity info;
    type counter64;
    units "packets";
    description "valid MAP packets";
  };
  bad_protocol {
    severity error;
    type counter64;
    units "packets";
    description "bad protocol";
  };
  sec_check {
    severity error;
    type counter64;
    units "packets";
    description "security check failed";
  };
  encap_sec_check {
    severity error;
    type counter64;
    units "packets";
    description "encap security check failed";
  };
  decap_sec_check {
    severity error;
    type counter64;
    units "packets";
    description "decap security check failed";
  };
  icmp {
    severity error;
    type counter64;
    units "packets";
    description "unable to translate ICMP";
  };
  icmp_relay {
    severity error;
    type counter64;
    units "packets";
    description "unable to relay ICMP";
  };
  unknown {
    severity error;
    type counter64;
    units "packets";
    description "unknown";
  };
  no_binding {
    severity error;
    type counter64;
    units "packets";
    description "no binding";
  };
  no_domain {
    severity error;
    type counter64;
    units "packets";
    description "no domain";
  };
  fragmented {
    severity error;
    type counter64;
    units "packets";
    description "packet is a fragment";
  };
  fragment_memory {
    severity error;
    type counter64;
    units "packets";
    description "could not cache fragment";
  };
  fragment_malformed {
    severity error;
    type counter64;
    units "packets";
    description "fragment has unexpected format";
  };
  fragment_dropped {
    severity error;
    type counter64;
    units "packets";
    description "dropped cached fragment";
  };
  malformed {
    severity error;
    type counter64;
    units "packets";
    description "malformed packet";
  };
  df_set {
    severity error;
    type counter64;
    units "packets";
    description "can't fragment, DF set";
  };
  time_exceeded {
    severity error;
    type counter64;
    units "packets";
    description "time exceeded";
  };
};
paths {
  "/err/ip4-map" "map";
  "/err/ip6-map" "map";
  "/err/ip4-t-map" "map";
  "/err/ip6-t-map" "map";
};