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