summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/protocols.def
blob: 4ec0bbc92843ccf9cc6d77fed1b30b302ce0c142 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
 * Copyright (c) 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.
 */
/* Emacs editing mode -*-C-*-

From http://www.iana.org/assignments/protocol-numbers

PROTOCOL NUMBERS

(last updated 18 October 2004)

In the Internet Protocol version 4 (IPv4) [RFC791] there is a field,
called "Protocol", to identify the next level protocol.  This is an 8
bit field.  In Internet Protocol version 6 (IPv6) [RFC1883] this field
is called the "Next Header" field.
*/
ip_protocol (0, IP6_HOP_BY_HOP_OPTIONS)
ip_protocol (1, ICMP)
ip_protocol (2, IGMP)
ip_protocol (3, GGP)
ip_protocol (4, IP_IN_IP)
ip_protocol (5, ST)
ip_protocol (6, TCP)
ip_protocol (7, CBT)
ip_protocol (8, EGP)
ip_protocol (9, IGP)
ip_protocol (10, BBN_RCC_MON)
ip_protocol (11, NVP_II)
ip_protocol (12, PUP)
ip_protocol (13, ARGUS)
ip_protocol (14, EMCON)
ip_protocol (15, XNET)
ip_protocol (16, CHAOS)
ip_protocol (17, UDP)
ip_protocol (18, MUX)
ip_protocol (19, DCN_MEAS)
ip_protocol (20, HMP)
ip_protocol (21, PRM)
ip_protocol (22, XNS_IDP)
ip_protocol (23, TRUNK_1)
ip_protocol (24, TRUNK_2)
ip_protocol (25, LEAF_1)
ip_protocol (26, LEAF_2)
ip_protocol (27, RDP)
ip_protocol (28, IRTP)
ip_protocol (29, ISO_TP4)
ip_protocol (30, NETBLT)
ip_protocol (31, MFE_NSP)
ip_protocol (32, MERIT_INP)
ip_protocol (33, SEP)
ip_protocol (34, 3PC)
ip_protocol (35, IDPR)
ip_protocol (36, XTP)
ip_protocol (37, DDP)
ip_protocol (38, IDPR_CMTP)
ip_protocol (39, TP)
ip_protocol (40, IL)
ip_protocol (41, IPV6)
ip_protocol (42, SDRP)
ip_protocol (43, IPV6_ROUTE)
ip_protocol (44, IPV6_FRAGMENTATION)
ip_protocol (45, IDRP)
ip_protocol (46, RSVP)
ip_protocol (47, GRE)
ip_protocol (48, MHRP)
ip_protocol (49, BNA)
ip_protocol (50, IPSEC_ESP)
ip_protocol (51, IPSEC_AH)
ip_protocol (52, I_NLSP)
ip_protocol (53, SWIPE)
ip_protocol (54, NARP)
ip_protocol (55, MOBILE)
ip_protocol (56, TLSP)
ip_protocol (57, SKIP)
ip_protocol (58, ICMP6)
ip_protocol (59, IP6_NONXT)
ip_protocol (60, IP6_DESTINATION_OPTIONS)
ip_protocol (62, CFTP)
ip_protocol (64, SAT_EXPAK)
ip_protocol (65, KRYPTOLAN)
ip_protocol (66, RVD)
ip_protocol (67, IPPC)
ip_protocol (69, SAT_MON)
ip_protocol (70, VISA)
ip_protocol (71, IPCV)
ip_protocol (72, CPNX)
ip_protocol (73, CPHB)
ip_protocol (74, WSN)
ip_protocol (75, PVP)
ip_protocol (76, BR_SAT_MON)
ip_protocol (77, SUN_ND)
ip_protocol (78, WB_MON)
ip_protocol (79, WB_EXPAK)
ip_protocol (80, ISO_IP)
ip_protocol (81, VMTP)
ip_protocol (82, SECURE_VMTP)
ip_protocol (83, VINES)
ip_protocol (84, TTP)
ip_protocol (85, NSFNET_IGP)
ip_protocol (86, DGP)
ip_protocol (87, TCF)
ip_protocol (88, EIGRP)
ip_protocol (89, OSPF)
ip_protocol (90, SPRITE_RPC)
ip_protocol (91, LARP)
ip_protocol (92, MTP)
ip_protocol (93, AX)
ip_protocol (94, IPIP)
ip_protocol (95, MICP)
ip_protocol (96, SCC_SP)
ip_protocol (97, ETHERIP)
ip_protocol (98, ENCAP)
ip_protocol (100, GMTP)
ip_protocol (101, IFMP)
ip_protocol (102, PNNI)
ip_protocol (103, PIM)
ip_protocol (104, ARIS)
ip_protocol (105, SCPS)
ip_protocol (106, QNX)
ip_protocol (107, A)
ip_protocol (108, IPCOMP)
ip_protocol (109, SNP)
ip_protocol (110, COMPAQ_PEER)
ip_protocol (111, IPX_IN_IP)
ip_protocol (112, VRRP)
ip_protocol (113, PGM)
ip_protocol (115, L2TP)
ip_protocol (116, DDX)
ip_protocol (117, IATP)
ip_protocol (118, STP)
ip_protocol (119, SRP)
ip_protocol (120, UTI)
ip_protocol (121, SMP)
ip_protocol (122, SM)
ip_protocol (123, PTP)
ip_protocol (124, ISIS)
ip_protocol (125, FIRE)
ip_protocol (126, CRTP)
ip_protocol (127, CRUDP)
ip_protocol (128, SSCOPMCE)
ip_protocol (129, IPLT)
ip_protocol (130, SPS)
ip_protocol (131, PIPE)
ip_protocol (132, SCTP)
ip_protocol (133, FC)
ip_protocol (134, RSVP_E2E_IGNORE)
ip_protocol (135, MOBILITY)
ip_protocol (136, UDP_LITE)
ip_protocol (137, MPLS_IN_IP)
/*
 * VPPs way of dealing with fragments is to mark them as 0xfe, to be picked
 * by the corresponding nodes based on this protocol
 */
ip_protocol (0xfe, VPP_FRAGMENTATION)
ip_protocol (255, RESERVED)
s="n">packet.type = inner_type def remove_tags(self, packet, tags): for t in tags: self._remove_tag(packet, t.vlan, t.dot1) return packet def decap_gre(self, pkt): """ Decapsulate the original payload frame by removing GRE header """ self.assertEqual(pkt[Ether].src, self.pg2.local_mac) self.assertEqual(pkt[Ether].dst, self.pg2.remote_mac) self.assertEqual(pkt[IP].src, self.pg2.local_ip4) self.assertEqual(pkt[IP].dst, self.pg2.remote_ip4) return pkt[GRE].payload def decap_vxlan(self, pkt): """ Decapsulate the original payload frame by removing VXLAN header """ self.assertEqual(pkt[Ether].src, self.pg2.local_mac) self.assertEqual(pkt[Ether].dst, self.pg2.remote_mac) self.assertEqual(pkt[IP].src, self.pg2.local_ip4) self.assertEqual(pkt[IP].dst, self.pg2.remote_ip4) return pkt[VXLAN].payload def create_stream(self, src_if, packet_sizes, do_dot1=False, bcast=False): pkts = [] dst_if = self.flows[src_if][0] dst_mac = src_if.remote_mac if bcast: dst_mac = "ff:ff:ff:ff:ff:ff" for i in range(0, self.pkts_per_burst): payload = "span test" size = packet_sizes[(i / 2) % len(packet_sizes)] p = (Ether(src=src_if.local_mac, dst=dst_mac) / IP(src=src_if.remote_ip4, dst=dst_if.remote_ip4) / UDP(sport=10000 + src_if.sw_if_index * 1000 + i, dport=1234) / Raw(payload)) if do_dot1: p = self.sub_if.add_dot1_layer(p) self.extend_packet(p, size) pkts.append(p) return pkts def verify_capture(self, cap1, cap2): self.assertEqual(len(cap1), len(cap2), "Different number of sent and mirrored packets :" "%u != %u" % (len(cap1), len(cap2))) pkts1 = [(pkt[Ether] / pkt[IP] / pkt[UDP]) for pkt in cap1] pkts2 = [(pkt[Ether] / pkt[IP] / pkt[UDP]) for pkt in cap2] self.assertEqual(pkts1.sort(), pkts2.sort()) def test_device_span(self): """ SPAN device rx mirror """ # Create bi-directional cross-connects between pg0 and pg1 self.xconnect(self.pg0.sw_if_index, self.pg1.sw_if_index) # Create incoming packet streams for packet-generator interfaces pkts = self.create_stream(self.pg0, self.pg_if_packet_sizes) self.pg0.add_stream(pkts) # Enable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.pg0.sw_if_index, self.pg2.sw_if_index) self.logger.info(self.vapi.ppcli("show interface span")) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) n_pkts = len(pkts) pg1_pkts = self.pg1.get_capture(n_pkts) pg2_pkts = self.pg2.get_capture(n_pkts) # Disable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.pg0.sw_if_index, self.pg2.sw_if_index, state=0) self.xconnect(self.pg0.sw_if_index, self.pg1.sw_if_index, is_add=0) self.verify_capture(pg1_pkts, pg2_pkts) def test_span_l2_rx(self): """ SPAN l2 rx mirror """ self.sub_if.admin_up() self.bridge(self.pg2.sw_if_index) # Create bi-directional cross-connects between pg0 subif and pg1 self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index) # Create incoming packet streams for packet-generator interfaces pkts = self.create_stream( self.pg0, self.pg_if_packet_sizes, do_dot1=True) self.pg0.add_stream(pkts) # Enable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.pg2.sw_if_index, is_l2=1) self.logger.info(self.vapi.ppcli("show interface span")) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) pg2_expected = len(pkts) pg1_pkts = self.pg1.get_capture(pg2_expected) pg2_pkts = self.pg2.get_capture(pg2_expected) self.bridge(self.pg2.sw_if_index, is_add=0) # Disable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.pg2.sw_if_index, state=0, is_l2=1) self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=0) self.verify_capture(pg1_pkts, pg2_pkts) def test_span_l2_rx_dst_vxlan(self): """ SPAN l2 rx mirror into vxlan """ self.sub_if.admin_up() self.vapi.sw_interface_set_flags(self.vxlan.sw_if_index, admin_up_down=1) self.bridge(self.vxlan.sw_if_index, is_add=1) # Create bi-directional cross-connects between pg0 subif and pg1 self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index) # Create incoming packet streams for packet-generator interfaces pkts = self.create_stream( self.pg0, self.pg_if_packet_sizes, do_dot1=True) self.pg0.add_stream(pkts) # Enable SPAN on pg0 sub if (mirrored to vxlan) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.vxlan.sw_if_index, is_l2=1) self.logger.info(self.vapi.ppcli("show interface span")) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) n_pkts = len(pkts) pg1_pkts = self.pg1.get_capture(n_pkts) pg2_pkts = [self.decap_vxlan(p) for p in self.pg2.get_capture(n_pkts)] self.bridge(self.vxlan.sw_if_index, is_add=0) # Disable SPAN on pg0 sub if (mirrored to vxlan) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.vxlan.sw_if_index, state=0, is_l2=1) self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=0) self.verify_capture(pg1_pkts, pg2_pkts) def test_span_l2_rx_dst_gre_subif_vtr(self): """ SPAN l2 rx mirror into gre-subif+vtr """ self.sub_if.admin_up() gre_if = VppGreInterface(self, self.pg2.local_ip4, self.pg2.remote_ip4, is_teb=1) gre_if.add_vpp_config() gre_if.admin_up() gre_sub_if = VppDot1QSubint(self, gre_if, 500) gre_sub_if.set_vtr(L2_VTR_OP.L2_POP_1, tag=500) gre_sub_if.admin_up() self.bridge(gre_sub_if.sw_if_index) # Create bi-directional cross-connects between pg0 and pg1 self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=1) # Create incoming packet streams for packet-generator interfaces pkts = self.create_stream( self.pg0, self.pg_if_packet_sizes, do_dot1=True) self.pg0.add_stream(pkts) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, gre_sub_if.sw_if_index, is_l2=1) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) n_pkts = len(pkts) pg1_pkts = self.pg1.get_capture(n_pkts) pg2_pkts = self.pg2.get_capture(n_pkts) def decap(p): return self.remove_tags( self.decap_gre(p), [Tag(dot1=DOT1Q, vlan=500)]) pg2_decaped = [decap(p) for p in pg2_pkts] self.bridge(gre_sub_if.sw_if_index, is_add=0) # Disable SPAN on pg0 sub if self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, gre_sub_if.sw_if_index, state=0, is_l2=1) gre_if.remove_vpp_config() self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=0) self.verify_capture(pg1_pkts, pg2_decaped) def test_span_l2_rx_dst_1q_vtr(self): """ SPAN l2 rx mirror into 1q subif+vtr """ self.sub_if.admin_up() self.vlan_sub_if.admin_up() self.bridge(self.vlan_sub_if.sw_if_index) # Create bi-directional cross-connects between pg0 and pg1 self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=1) # Create incoming packet streams for packet-generator interfaces pkts = self.create_stream( self.pg0, self.pg_if_packet_sizes, do_dot1=True) self.pg0.add_stream(pkts) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.vlan_sub_if.sw_if_index, is_l2=1) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) n_pkts = len(pkts) pg1_pkts = self.pg1.get_capture(n_pkts) pg2_pkts = self.pg2.get_capture(n_pkts) pg2_untagged = [self.remove_tags(p, [Tag(dot1=DOT1Q, vlan=300)]) for p in pg2_pkts] self.bridge(self.vlan_sub_if.sw_if_index, is_add=0) # Disable SPAN on pg0 sub if (mirrored to vxlan) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.vlan_sub_if.sw_if_index, state=0, is_l2=1) self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=0) self.verify_capture(pg1_pkts, pg2_untagged) def test_span_l2_rx_dst_1ad_vtr(self): """ SPAN l2 rx mirror into 1ad subif+vtr """ self.sub_if.admin_up() self.qinq_sub_if.admin_up() self.bridge(self.qinq_sub_if.sw_if_index) # Create bi-directional cross-connects between pg0 and pg1 self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=1) # Create incoming packet streams for packet-generator interfaces pkts = self.create_stream( self.pg0, self.pg_if_packet_sizes, do_dot1=True) self.pg0.add_stream(pkts) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.qinq_sub_if.sw_if_index, is_l2=1) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) n_pkts = len(pkts) pg1_pkts = self.pg1.get_capture(n_pkts) pg2_pkts = self.pg2.get_capture(n_pkts) pg2_untagged = [self.remove_tags(p, [Tag(dot1=DOT1AD, vlan=400), Tag(dot1=DOT1Q, vlan=500)]) for p in pg2_pkts] self.bridge(self.qinq_sub_if.sw_if_index, is_add=0) # Disable SPAN on pg0 sub if (mirrored to vxlan) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.qinq_sub_if.sw_if_index, state=0, is_l2=1) self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=0) self.verify_capture(pg1_pkts, pg2_untagged) def test_l2_tx_span(self): """ SPAN l2 tx mirror """ self.sub_if.admin_up() self.bridge(self.pg2.sw_if_index) # Create bi-directional cross-connects between pg0 and pg1 self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index) # Create incoming packet streams for packet-generator interfaces pkts = self.create_stream( self.pg0, self.pg_if_packet_sizes, do_dot1=True) self.pg0.add_stream(pkts) # Enable SPAN on pg1 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.pg1.sw_if_index, self.pg2.sw_if_index, is_l2=1, state=2) self.logger.info(self.vapi.ppcli("show interface span")) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) n_pkts = len(pkts) pg1_pkts = self.pg1.get_capture(n_pkts) pg2_pkts = self.pg2.get_capture(n_pkts) self.bridge(self.pg2.sw_if_index, is_add=0) # Disable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.pg1.sw_if_index, self.pg2.sw_if_index, state=0, is_l2=1) self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=0) self.verify_capture(pg1_pkts, pg2_pkts) def test_l2_rx_tx_span(self): """ SPAN l2 rx tx mirror """ self.sub_if.admin_up() self.bridge(self.pg2.sw_if_index) # Create bi-directional cross-connects between pg0 and pg1 self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index) # Create incoming packet streams for packet-generator interfaces pg0_pkts = self.create_stream( self.pg0, self.pg_if_packet_sizes, do_dot1=True) self.pg0.add_stream(pg0_pkts) pg1_pkts = self.create_stream( self.pg1, self.pg_if_packet_sizes, do_dot1=False) self.pg1.add_stream(pg1_pkts) # Enable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.pg2.sw_if_index, is_l2=1, state=3) self.logger.info(self.vapi.ppcli("show interface span")) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) pg0_expected = len(pg1_pkts) pg1_expected = len(pg0_pkts) pg2_expected = pg0_expected + pg1_expected pg0_pkts = self.pg0.get_capture(pg0_expected) pg1_pkts = self.pg1.get_capture(pg1_expected) pg2_pkts = self.pg2.get_capture(pg2_expected) self.bridge(self.pg2.sw_if_index, is_add=0) # Disable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.pg2.sw_if_index, state=0, is_l2=1) self.xconnect(self.sub_if.sw_if_index, self.pg1.sw_if_index, is_add=0) self.verify_capture(pg0_pkts + pg1_pkts, pg2_pkts) def test_l2_bcast_mirror(self): """ SPAN l2 broadcast mirror """ self.sub_if.admin_up() self.bridge(self.pg2.sw_if_index) # Create bi-directional cross-connects between pg0 and pg1 self.vapi.sw_interface_set_l2_bridge( self.sub_if.sw_if_index, bd_id=99, enable=1) self.vapi.sw_interface_set_l2_bridge( self.pg1.sw_if_index, bd_id=99, enable=1) # Create incoming packet streams for packet-generator interfaces pg0_pkts = self.create_stream( self.pg0, self.pg_if_packet_sizes, do_dot1=True, bcast=True) self.pg0.add_stream(pg0_pkts) pg1_pkts = self.create_stream( self.pg1, self.pg_if_packet_sizes, do_dot1=False, bcast=True) self.pg1.add_stream(pg1_pkts) # Enable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.pg2.sw_if_index, is_l2=1, state=3) self.logger.info(self.vapi.ppcli("show interface span")) # Enable packet capturing and start packet sending self.pg_enable_capture(self.pg_interfaces) self.pg_start() # Verify packets outgoing packet streams on mirrored interface (pg2) pg0_expected = len(pg1_pkts) pg1_expected = len(pg0_pkts) pg2_expected = pg0_expected + pg1_expected pg0_pkts = self.pg0.get_capture(pg0_expected) pg1_pkts = self.pg1.get_capture(pg1_expected) pg2_pkts = self.pg2.get_capture(pg2_expected) self.bridge(self.pg2.sw_if_index, is_add=0) self.vapi.sw_interface_set_l2_bridge( self.sub_if.sw_if_index, bd_id=99, enable=0) self.vapi.sw_interface_set_l2_bridge( self.pg1.sw_if_index, bd_id=99, enable=0) # Disable SPAN on pg0 (mirrored to pg2) self.vapi.sw_interface_span_enable_disable( self.sub_if.sw_if_index, self.pg2.sw_if_index, state=0, is_l2=1) self.verify_capture(pg0_pkts + pg1_pkts, pg2_pkts) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner)