xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_isis.c (revision 10491:8893b747ecdf)
1*10491SRishi.Srivatsavai@Sun.COM /*
2*10491SRishi.Srivatsavai@Sun.COM  * CDDL HEADER START
3*10491SRishi.Srivatsavai@Sun.COM  *
4*10491SRishi.Srivatsavai@Sun.COM  * The contents of this file are subject to the terms of the
5*10491SRishi.Srivatsavai@Sun.COM  * Common Development and Distribution License (the "License").
6*10491SRishi.Srivatsavai@Sun.COM  * You may not use this file except in compliance with the License.
7*10491SRishi.Srivatsavai@Sun.COM  *
8*10491SRishi.Srivatsavai@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*10491SRishi.Srivatsavai@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*10491SRishi.Srivatsavai@Sun.COM  * See the License for the specific language governing permissions
11*10491SRishi.Srivatsavai@Sun.COM  * and limitations under the License.
12*10491SRishi.Srivatsavai@Sun.COM  *
13*10491SRishi.Srivatsavai@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*10491SRishi.Srivatsavai@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*10491SRishi.Srivatsavai@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*10491SRishi.Srivatsavai@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*10491SRishi.Srivatsavai@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*10491SRishi.Srivatsavai@Sun.COM  *
19*10491SRishi.Srivatsavai@Sun.COM  * CDDL HEADER END
20*10491SRishi.Srivatsavai@Sun.COM  */
21*10491SRishi.Srivatsavai@Sun.COM 
22*10491SRishi.Srivatsavai@Sun.COM /*
23*10491SRishi.Srivatsavai@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*10491SRishi.Srivatsavai@Sun.COM  * Use is subject to license terms.
25*10491SRishi.Srivatsavai@Sun.COM  */
26*10491SRishi.Srivatsavai@Sun.COM 
27*10491SRishi.Srivatsavai@Sun.COM #include <stdio.h>
28*10491SRishi.Srivatsavai@Sun.COM #include <sys/types.h>
29*10491SRishi.Srivatsavai@Sun.COM #include <sys/socket.h>
30*10491SRishi.Srivatsavai@Sun.COM #include <sys/ethernet.h>
31*10491SRishi.Srivatsavai@Sun.COM #include <sys/vlan.h>
32*10491SRishi.Srivatsavai@Sun.COM #include <net/trill.h>
33*10491SRishi.Srivatsavai@Sun.COM 
34*10491SRishi.Srivatsavai@Sun.COM #include <snoop.h>
35*10491SRishi.Srivatsavai@Sun.COM 
36*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_OFFSET 4
37*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_HELLO1 15
38*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_HELLO2 16
39*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_HELLOP2P 17
40*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_LSP1 18
41*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_LSP2 20
42*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_CSN1 24
43*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_CSN2 25
44*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_PSN1 26
45*10491SRishi.Srivatsavai@Sun.COM #define	PDUTYPE_PSN2 27
46*10491SRishi.Srivatsavai@Sun.COM 
47*10491SRishi.Srivatsavai@Sun.COM int
interpret_isis(int flags,char * data,int dlen,boolean_t istrill)48*10491SRishi.Srivatsavai@Sun.COM interpret_isis(int flags, char *data, int dlen, boolean_t istrill)
49*10491SRishi.Srivatsavai@Sun.COM {
50*10491SRishi.Srivatsavai@Sun.COM 	uint8_t pdutypenum;
51*10491SRishi.Srivatsavai@Sun.COM 	char *pdutype;
52*10491SRishi.Srivatsavai@Sun.COM 
53*10491SRishi.Srivatsavai@Sun.COM 	pdutypenum = *(data+ PDUTYPE_OFFSET);
54*10491SRishi.Srivatsavai@Sun.COM 	switch (pdutypenum) {
55*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_HELLO1:
56*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_HELLO2:
57*10491SRishi.Srivatsavai@Sun.COM 		pdutype = "Hello";
58*10491SRishi.Srivatsavai@Sun.COM 		break;
59*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_HELLOP2P:
60*10491SRishi.Srivatsavai@Sun.COM 		pdutype = "P2P Hello";
61*10491SRishi.Srivatsavai@Sun.COM 		break;
62*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_LSP1:
63*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_LSP2:
64*10491SRishi.Srivatsavai@Sun.COM 		pdutype = "Link State";
65*10491SRishi.Srivatsavai@Sun.COM 		break;
66*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_CSN1:
67*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_CSN2:
68*10491SRishi.Srivatsavai@Sun.COM 		pdutype = "CSN";
69*10491SRishi.Srivatsavai@Sun.COM 		break;
70*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_PSN1:
71*10491SRishi.Srivatsavai@Sun.COM 	case PDUTYPE_PSN2:
72*10491SRishi.Srivatsavai@Sun.COM 		pdutype = "PSN";
73*10491SRishi.Srivatsavai@Sun.COM 		break;
74*10491SRishi.Srivatsavai@Sun.COM 	default:
75*10491SRishi.Srivatsavai@Sun.COM 		pdutype = "Unknown";
76*10491SRishi.Srivatsavai@Sun.COM 		break;
77*10491SRishi.Srivatsavai@Sun.COM 	}
78*10491SRishi.Srivatsavai@Sun.COM 
79*10491SRishi.Srivatsavai@Sun.COM 	if (flags & F_SUM) {
80*10491SRishi.Srivatsavai@Sun.COM 		(void) snprintf(get_sum_line(), MAXLINE,
81*10491SRishi.Srivatsavai@Sun.COM 		    "%s %s L:%d", istrill ? "Core TRILL IS-IS" : "IS-IS",
82*10491SRishi.Srivatsavai@Sun.COM 		    pdutype, dlen);
83*10491SRishi.Srivatsavai@Sun.COM 	}
84*10491SRishi.Srivatsavai@Sun.COM 
85*10491SRishi.Srivatsavai@Sun.COM 	if (flags & F_DTAIL) {
86*10491SRishi.Srivatsavai@Sun.COM 		if (istrill) {
87*10491SRishi.Srivatsavai@Sun.COM 			show_header("TRILL-IS-IS: ",
88*10491SRishi.Srivatsavai@Sun.COM 			    "Core TRILL IS-IS Frame", dlen);
89*10491SRishi.Srivatsavai@Sun.COM 		} else {
90*10491SRishi.Srivatsavai@Sun.COM 			show_header("IS-IS: ",
91*10491SRishi.Srivatsavai@Sun.COM 			    "IS-IS Frame", dlen);
92*10491SRishi.Srivatsavai@Sun.COM 		}
93*10491SRishi.Srivatsavai@Sun.COM 		show_space();
94*10491SRishi.Srivatsavai@Sun.COM 		(void) snprintf(get_line(0, 0), get_line_remain(),
95*10491SRishi.Srivatsavai@Sun.COM 		    "Frame type = %02X (%s)", pdutypenum, pdutype);
96*10491SRishi.Srivatsavai@Sun.COM 		show_trailer();
97*10491SRishi.Srivatsavai@Sun.COM 	}
98*10491SRishi.Srivatsavai@Sun.COM 	return (0);
99*10491SRishi.Srivatsavai@Sun.COM }
100