xref: /onnv-gate/usr/src/cmd/dtrace/demo/ip/ipproto.d (revision 6878:360e73ea6b0c)
1*6878Sbrendan /*
2*6878Sbrendan  * CDDL HEADER START
3*6878Sbrendan  *
4*6878Sbrendan  * The contents of this file are subject to the terms of the
5*6878Sbrendan  * Common Development and Distribution License (the "License").
6*6878Sbrendan  * You may not use this file except in compliance with the License.
7*6878Sbrendan  *
8*6878Sbrendan  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*6878Sbrendan  * or http://www.opensolaris.org/os/licensing.
10*6878Sbrendan  * See the License for the specific language governing permissions
11*6878Sbrendan  * and limitations under the License.
12*6878Sbrendan  *
13*6878Sbrendan  * When distributing Covered Code, include this CDDL HEADER in each
14*6878Sbrendan  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*6878Sbrendan  * If applicable, add the following below this CDDL HEADER, with the
16*6878Sbrendan  * fields enclosed by brackets "[]" replaced with your own identifying
17*6878Sbrendan  * information: Portions Copyright [yyyy] [name of copyright owner]
18*6878Sbrendan  *
19*6878Sbrendan  * CDDL HEADER END
20*6878Sbrendan  */
21*6878Sbrendan /*
22*6878Sbrendan  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*6878Sbrendan  * Use is subject to license terms.
24*6878Sbrendan  */
25*6878Sbrendan 
26*6878Sbrendan #pragma D option quiet
27*6878Sbrendan 
28*6878Sbrendan dtrace:::BEGIN
29*6878Sbrendan {
30*6878Sbrendan 	printf("Tracing... Hit Ctrl-C to end.\n");
31*6878Sbrendan }
32*6878Sbrendan 
33*6878Sbrendan ip:::send,
34*6878Sbrendan ip:::receive
35*6878Sbrendan {
36*6878Sbrendan 	this->protostr = args[2]->ip_ver == 4 ?
37*6878Sbrendan 	    args[4]->ipv4_protostr : args[5]->ipv6_nextstr;
38*6878Sbrendan 	@num[args[2]->ip_saddr, args[2]->ip_daddr, this->protostr] = count();
39*6878Sbrendan }
40*6878Sbrendan 
41*6878Sbrendan dtrace:::END
42*6878Sbrendan {
43*6878Sbrendan 	printf("   %-28s %-28s %6s %8s\n", "SADDR", "DADDR", "PROTO", "COUNT");
44*6878Sbrendan 	printa("   %-28s %-28s %6s %@8d\n", @num);
45*6878Sbrendan }
46