xref: /titanic_50/usr/src/cmd/dtrace/demo/tcp/tcpioflags.d (revision 385cc6b4ad1792caef3f84eb61eed3f27085801f)
1 #!/usr/sbin/dtrace -s
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #pragma D option quiet
27 #pragma D option switchrate=10hz
28 
29 dtrace:::BEGIN
30 {
31 	printf(" %15s:%-5s      %15s:%-5s %6s %s\n",
32 	    "LADDR", "PORT", "RADDR", "PORT", "BYTES", "FLAGS");
33 }
34 
35 tcp:::send
36 {
37 	this->length = args[2]->ip_plength - args[4]->tcp_offset;
38 	printf(" %15s:%-5d  ->  %15s:%-5d %6d (",
39 	    args[2]->ip_saddr, args[4]->tcp_sport,
40 	    args[2]->ip_daddr, args[4]->tcp_dport, this->length);
41 }
42 
43 tcp:::receive
44 {
45 	this->length = args[2]->ip_plength - args[4]->tcp_offset;
46 	printf(" %15s:%-5d  <-  %15s:%-5d %6d (",
47 	    args[2]->ip_daddr, args[4]->tcp_dport,
48 	    args[2]->ip_saddr, args[4]->tcp_sport, this->length);
49 }
50 
51 tcp:::send,
52 tcp:::receive
53 {
54 	printf("%s", args[4]->tcp_flags & TH_FIN ? "FIN|" : "");
55 	printf("%s", args[4]->tcp_flags & TH_SYN ? "SYN|" : "");
56 	printf("%s", args[4]->tcp_flags & TH_RST ? "RST|" : "");
57 	printf("%s", args[4]->tcp_flags & TH_PUSH ? "PUSH|" : "");
58 	printf("%s", args[4]->tcp_flags & TH_ACK ? "ACK|" : "");
59 	printf("%s", args[4]->tcp_flags & TH_URG ? "URG|" : "");
60 	printf("%s", args[4]->tcp_flags & TH_ECE ? "ECE|" : "");
61 	printf("%s", args[4]->tcp_flags & TH_CWR ? "CWR|" : "");
62 	printf("%s", args[4]->tcp_flags == 0 ? "null " : "");
63 	printf("\b)\n");
64 }
65