11dfaa6f1SGeorge V. Neville-Neil#!/usr/sbin/dtrace -s 21dfaa6f1SGeorge V. Neville-Neil/* 31dfaa6f1SGeorge V. Neville-Neil * Copyright (c) 2015 George V. Neville-Neil 41dfaa6f1SGeorge V. Neville-Neil * All rights reserved. 51dfaa6f1SGeorge V. Neville-Neil * 61dfaa6f1SGeorge V. Neville-Neil * Redistribution and use in source and binary forms, with or without 71dfaa6f1SGeorge V. Neville-Neil * modification, are permitted provided that the following conditions 81dfaa6f1SGeorge V. Neville-Neil * are met: 91dfaa6f1SGeorge V. Neville-Neil * 1. Redistributions of source code must retain the above copyright 101dfaa6f1SGeorge V. Neville-Neil * notice, this list of conditions and the following disclaimer. 111dfaa6f1SGeorge V. Neville-Neil * 2. Redistributions in binary form must reproduce the above copyright 121dfaa6f1SGeorge V. Neville-Neil * notice, this list of conditions and the following disclaimer in the 131dfaa6f1SGeorge V. Neville-Neil * documentation and/or other materials provided with the distribution. 141dfaa6f1SGeorge V. Neville-Neil * 151dfaa6f1SGeorge V. Neville-Neil * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 161dfaa6f1SGeorge V. Neville-Neil * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 171dfaa6f1SGeorge V. Neville-Neil * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 181dfaa6f1SGeorge V. Neville-Neil * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 191dfaa6f1SGeorge V. Neville-Neil * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 201dfaa6f1SGeorge V. Neville-Neil * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 211dfaa6f1SGeorge V. Neville-Neil * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 221dfaa6f1SGeorge V. Neville-Neil * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 231dfaa6f1SGeorge V. Neville-Neil * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 241dfaa6f1SGeorge V. Neville-Neil * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 251dfaa6f1SGeorge V. Neville-Neil * SUCH DAMAGE. 261dfaa6f1SGeorge V. Neville-Neil * 271dfaa6f1SGeorge V. Neville-Neil * The udptrack D script shows various information about UDP 281dfaa6f1SGeorge V. Neville-Neil * data that are sent and received on the host. 291dfaa6f1SGeorge V. Neville-Neil * 301dfaa6f1SGeorge V. Neville-Neil * Usage: udptrack 311dfaa6f1SGeorge V. Neville-Neil */ 321dfaa6f1SGeorge V. Neville-Neil 331dfaa6f1SGeorge V. Neville-Neil#pragma D option quiet 341dfaa6f1SGeorge V. Neville-Neiludp:kernel::receive 351dfaa6f1SGeorge V. Neville-Neil{ 361dfaa6f1SGeorge V. Neville-Neil printf("Received %d bytes of data from %s:%d\n", 371dfaa6f1SGeorge V. Neville-Neil args[4]->udp_length, 38*8a502e74SGeorge V. Neville-Neil args[2]->ip_saddr, 39*8a502e74SGeorge V. Neville-Neil args[4]->udp_sport); 401dfaa6f1SGeorge V. Neville-Neil tracemem(args[4]->udp_hdr, 64); 411dfaa6f1SGeorge V. Neville-Neil} 421dfaa6f1SGeorge V. Neville-Neil 431dfaa6f1SGeorge V. Neville-Neiludp:kernel::send 441dfaa6f1SGeorge V. Neville-Neil{ 451dfaa6f1SGeorge V. Neville-Neil printf("Sent %d bytes of data to %s:%d\n", 461dfaa6f1SGeorge V. Neville-Neil args[4]->udp_length, 471dfaa6f1SGeorge V. Neville-Neil args[2]->ip_daddr, 48*8a502e74SGeorge V. Neville-Neil args[4]->udp_dport); 491dfaa6f1SGeorge V. Neville-Neil tracemem(args[4]->udp_hdr, 64); 501dfaa6f1SGeorge V. Neville-Neil} 511dfaa6f1SGeorge V. Neville-Neil 52