157f60867SMark Johnston /* 257f60867SMark Johnston * CDDL HEADER START 357f60867SMark Johnston * 457f60867SMark Johnston * The contents of this file are subject to the terms of the 557f60867SMark Johnston * Common Development and Distribution License (the "License"). 657f60867SMark Johnston * You may not use this file except in compliance with the License. 757f60867SMark Johnston * 857f60867SMark Johnston * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 957f60867SMark Johnston * or http://www.opensolaris.org/os/licensing. 1057f60867SMark Johnston * See the License for the specific language governing permissions 1157f60867SMark Johnston * and limitations under the License. 1257f60867SMark Johnston * 1357f60867SMark Johnston * When distributing Covered Code, include this CDDL HEADER in each 1457f60867SMark Johnston * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1557f60867SMark Johnston * If applicable, add the following below this CDDL HEADER, with the 1657f60867SMark Johnston * fields enclosed by brackets "[]" replaced with your own identifying 1757f60867SMark Johnston * information: Portions Copyright [yyyy] [name of copyright owner] 1857f60867SMark Johnston * 1957f60867SMark Johnston * CDDL HEADER END 2057f60867SMark Johnston */ 2157f60867SMark Johnston /* 2257f60867SMark Johnston * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2357f60867SMark Johnston * Copyright (c) 2013 Mark Johnston <markj@freebsd.org> 2457f60867SMark Johnston */ 2557f60867SMark Johnston 2657f60867SMark Johnston #pragma D depends_on library ip.d 277e518a66SMark Johnston #pragma D depends_on module kernel 2857f60867SMark Johnston #pragma D depends_on provider tcp 2957f60867SMark Johnston 3057f60867SMark Johnston /* 3157f60867SMark Johnston * Convert a TCP state value to a string. 3257f60867SMark Johnston */ 332f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_CLOSED 3457f60867SMark Johnston inline int TCPS_CLOSED = 0; 352f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_LISTEN 3657f60867SMark Johnston inline int TCPS_LISTEN = 1; 372f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_SYN_SENT 3857f60867SMark Johnston inline int TCPS_SYN_SENT = 2; 392f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_SYN_RECEIVED 4057f60867SMark Johnston inline int TCPS_SYN_RECEIVED = 3; 412f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_ESTABLISHED 4257f60867SMark Johnston inline int TCPS_ESTABLISHED = 4; 432f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_CLOSE_WAIT 4457f60867SMark Johnston inline int TCPS_CLOSE_WAIT = 5; 452f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_FIN_WAIT_1 4657f60867SMark Johnston inline int TCPS_FIN_WAIT_1 = 6; 472f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_CLOSING 4857f60867SMark Johnston inline int TCPS_CLOSING = 7; 492f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_LAST_ACK 5057f60867SMark Johnston inline int TCPS_LAST_ACK = 8; 512f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_FIN_WAIT_2 5257f60867SMark Johnston inline int TCPS_FIN_WAIT_2 = 9; 532f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_TIME_WAIT 5457f60867SMark Johnston inline int TCPS_TIME_WAIT = 10; 5557f60867SMark Johnston 56d073fd60SMichael Tuexen /* 57d073fd60SMichael Tuexen * For compatibility also provide the names used by Solaris. 58d073fd60SMichael Tuexen */ 59d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_CLOSED 60d073fd60SMichael Tuexen inline int TCP_STATE_CLOSED = TCPS_CLOSED; 61d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_LISTEN 62d073fd60SMichael Tuexen inline int TCP_STATE_LISTEN = TCPS_LISTEN; 63d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_SYN_SENT 64d073fd60SMichael Tuexen inline int TCP_STATE_SYN_SENT = TCPS_SYN_SENT; 65d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_SYN_RECEIVED 66d073fd60SMichael Tuexen inline int TCP_STATE_SYN_RECEIVED = TCPS_SYN_RECEIVED; 67d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_ESTABLISHED 68d073fd60SMichael Tuexen inline int TCP_STATE_ESTABLISHED = TCPS_ESTABLISHED; 69d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_CLOSE_WAIT 70d073fd60SMichael Tuexen inline int TCP_STATE_CLOSE_WAIT = TCPS_CLOSE_WAIT; 71d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_FIN_WAIT_1 72d073fd60SMichael Tuexen inline int TCP_STATE_FIN_WAIT_1 = TCPS_FIN_WAIT_1; 73d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_CLOSING 74d073fd60SMichael Tuexen inline int TCP_STATE_CLOSING = TCPS_CLOSING; 75d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_LAST_ACK 76d073fd60SMichael Tuexen inline int TCP_STATE_LAST_ACK = TCPS_LAST_ACK; 77d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_FIN_WAIT_2 78d073fd60SMichael Tuexen inline int TCP_STATE_FIN_WAIT_2 = TCPS_FIN_WAIT_2; 79d073fd60SMichael Tuexen #pragma D binding "1.13" TCP_STATE_TIME_WAIT 80d073fd60SMichael Tuexen inline int TCP_STATE_TIME_WAIT = TCPS_TIME_WAIT; 81d073fd60SMichael Tuexen 8257f60867SMark Johnston /* TCP segment flags. */ 832f28ceebSMark Johnston #pragma D binding "1.6.3" TH_FIN 8438c63bdcSRichard Scheffenegger inline uint16_t TH_FIN = 0x01; 852f28ceebSMark Johnston #pragma D binding "1.6.3" TH_SYN 8638c63bdcSRichard Scheffenegger inline uint16_t TH_SYN = 0x02; 872f28ceebSMark Johnston #pragma D binding "1.6.3" TH_RST 8838c63bdcSRichard Scheffenegger inline uint16_t TH_RST = 0x04; 892f28ceebSMark Johnston #pragma D binding "1.6.3" TH_PUSH 9038c63bdcSRichard Scheffenegger inline uint16_t TH_PUSH = 0x08; 912f28ceebSMark Johnston #pragma D binding "1.6.3" TH_ACK 9238c63bdcSRichard Scheffenegger inline uint16_t TH_ACK = 0x10; 932f28ceebSMark Johnston #pragma D binding "1.6.3" TH_URG 9438c63bdcSRichard Scheffenegger inline uint16_t TH_URG = 0x20; 952f28ceebSMark Johnston #pragma D binding "1.6.3" TH_ECE 9638c63bdcSRichard Scheffenegger inline uint16_t TH_ECE = 0x40; 972f28ceebSMark Johnston #pragma D binding "1.6.3" TH_CWR 9838c63bdcSRichard Scheffenegger inline uint16_t TH_CWR = 0x80; 9938c63bdcSRichard Scheffenegger #pragma D binding "1.6.3" TH_AE 10038c63bdcSRichard Scheffenegger inline uint16_t TH_AE = 0x100; 10157f60867SMark Johnston 10257f60867SMark Johnston /* TCP connection state strings. */ 1032f28ceebSMark Johnston #pragma D binding "1.6.3" tcp_state_string 10457f60867SMark Johnston inline string tcp_state_string[int32_t state] = 10557f60867SMark Johnston state == TCPS_CLOSED ? "state-closed" : 10657f60867SMark Johnston state == TCPS_LISTEN ? "state-listen" : 10757f60867SMark Johnston state == TCPS_SYN_SENT ? "state-syn-sent" : 10857f60867SMark Johnston state == TCPS_SYN_RECEIVED ? "state-syn-received" : 10957f60867SMark Johnston state == TCPS_ESTABLISHED ? "state-established" : 11057f60867SMark Johnston state == TCPS_CLOSE_WAIT ? "state-close-wait" : 11157f60867SMark Johnston state == TCPS_FIN_WAIT_1 ? "state-fin-wait-1" : 11257f60867SMark Johnston state == TCPS_CLOSING ? "state-closing" : 11357f60867SMark Johnston state == TCPS_LAST_ACK ? "state-last-ack" : 11457f60867SMark Johnston state == TCPS_FIN_WAIT_2 ? "state-fin-wait-2" : 11557f60867SMark Johnston state == TCPS_TIME_WAIT ? "state-time-wait" : 11657f60867SMark Johnston "<unknown>"; 11757f60867SMark Johnston 11857f60867SMark Johnston /* 11957f60867SMark Johnston * tcpsinfo contains stable TCP details from tcp_t. 12057f60867SMark Johnston */ 12157f60867SMark Johnston typedef struct tcpsinfo { 12257f60867SMark Johnston uintptr_t tcps_addr; 12357f60867SMark Johnston int tcps_local; /* is delivered locally, boolean */ 12457f60867SMark Johnston int tcps_active; /* active open (from here), boolean */ 12557f60867SMark Johnston uint16_t tcps_lport; /* local port */ 12657f60867SMark Johnston uint16_t tcps_rport; /* remote port */ 12757f60867SMark Johnston string tcps_laddr; /* local address, as a string */ 12857f60867SMark Johnston string tcps_raddr; /* remote address, as a string */ 12957f60867SMark Johnston int32_t tcps_state; /* TCP state */ 13057f60867SMark Johnston uint32_t tcps_iss; /* Initial sequence # sent */ 131342af4d5SGeorge V. Neville-Neil uint32_t tcps_irs; /* Initial sequence # received */ 13257f60867SMark Johnston uint32_t tcps_suna; /* sequence # sent but unacked */ 1335d06879aSGeorge V. Neville-Neil uint32_t tcps_smax; /* highest sequence number sent */ 13457f60867SMark Johnston uint32_t tcps_snxt; /* next sequence # to send */ 13557f60867SMark Johnston uint32_t tcps_rack; /* sequence # we have acked */ 13657f60867SMark Johnston uint32_t tcps_rnxt; /* next sequence # expected */ 1372dbc5931SHiren Panchasara u_long tcps_swnd; /* send window size */ 13857f60867SMark Johnston int32_t tcps_snd_ws; /* send window scaling */ 1395d06879aSGeorge V. Neville-Neil uint32_t tcps_swl1; /* window update seg seq number */ 1405d06879aSGeorge V. Neville-Neil uint32_t tcps_swl2; /* window update seg ack number */ 1415d06879aSGeorge V. Neville-Neil uint32_t tcps_rup; /* receive urgent pointer */ 142342af4d5SGeorge V. Neville-Neil uint32_t tcps_radv; /* advertised window */ 1432dbc5931SHiren Panchasara u_long tcps_rwnd; /* receive window size */ 14457f60867SMark Johnston int32_t tcps_rcv_ws; /* receive window scaling */ 1452dbc5931SHiren Panchasara u_long tcps_cwnd; /* congestion window */ 1462dbc5931SHiren Panchasara u_long tcps_cwnd_ssthresh; /* threshold for congestion avoidance */ 147342af4d5SGeorge V. Neville-Neil uint32_t tcps_srecover; /* for use in NewReno Fast Recovery */ 14857f60867SMark Johnston uint32_t tcps_sack_fack; /* SACK sequence # we have acked */ 14957f60867SMark Johnston uint32_t tcps_sack_snxt; /* next SACK seq # for retransmission */ 15057f60867SMark Johnston uint32_t tcps_rto; /* round-trip timeout, msec */ 15157f60867SMark Johnston uint32_t tcps_mss; /* max segment size */ 15257f60867SMark Johnston int tcps_retransmit; /* retransmit send event, boolean */ 153bd537a28SGeorge V. Neville-Neil int tcps_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ 1545d06879aSGeorge V. Neville-Neil int tcps_debug; /* socket has SO_DEBUG set */ 15515dbc160SGeorge V. Neville-Neil int tcps_cookie; /* expose the socket's SO_USER_COOKIE */ 156342af4d5SGeorge V. Neville-Neil int32_t tcps_dupacks; /* consecutive dup acks received */ 157342af4d5SGeorge V. Neville-Neil uint32_t tcps_rtttime; /* RTT measurement start time */ 158342af4d5SGeorge V. Neville-Neil uint32_t tcps_rtseq; /* sequence # being timed */ 159342af4d5SGeorge V. Neville-Neil uint32_t tcps_ts_recent; /* timestamp echo data */ 16057f60867SMark Johnston } tcpsinfo_t; 16157f60867SMark Johnston 16257f60867SMark Johnston /* 16357f60867SMark Johnston * tcplsinfo provides the old tcp state for state changes. 16457f60867SMark Johnston */ 16557f60867SMark Johnston typedef struct tcplsinfo { 16657f60867SMark Johnston int32_t tcps_state; /* previous TCP state */ 16757f60867SMark Johnston } tcplsinfo_t; 16857f60867SMark Johnston 16957f60867SMark Johnston /* 17057f60867SMark Johnston * tcpinfo is the TCP header fields. 17157f60867SMark Johnston */ 17257f60867SMark Johnston typedef struct tcpinfo { 17357f60867SMark Johnston uint16_t tcp_sport; /* source port */ 17457f60867SMark Johnston uint16_t tcp_dport; /* destination port */ 17557f60867SMark Johnston uint32_t tcp_seq; /* sequence number */ 17657f60867SMark Johnston uint32_t tcp_ack; /* acknowledgment number */ 17757f60867SMark Johnston uint8_t tcp_offset; /* data offset, in bytes */ 17838c63bdcSRichard Scheffenegger uint16_t tcp_flags; /* flags */ 17957f60867SMark Johnston uint16_t tcp_window; /* window size */ 18057f60867SMark Johnston uint16_t tcp_checksum; /* checksum */ 18157f60867SMark Johnston uint16_t tcp_urgent; /* urgent data pointer */ 18257f60867SMark Johnston struct tcphdr *tcp_hdr; /* raw TCP header */ 18357f60867SMark Johnston } tcpinfo_t; 18457f60867SMark Johnston 1858298c17cSMark Johnston /* 1868298c17cSMark Johnston * A clone of tcpinfo_t used to handle the fact that the TCP input path 1878298c17cSMark Johnston * overwrites some fields of the TCP header with their host-order equivalents. 1888298c17cSMark Johnston * Unfortunately, DTrace doesn't let us simply typedef a new name for struct 1898298c17cSMark Johnston * tcpinfo and define a separate translator for it. 1908298c17cSMark Johnston */ 1918298c17cSMark Johnston typedef struct tcpinfoh { 1928298c17cSMark Johnston uint16_t tcp_sport; /* source port */ 1938298c17cSMark Johnston uint16_t tcp_dport; /* destination port */ 1948298c17cSMark Johnston uint32_t tcp_seq; /* sequence number */ 1958298c17cSMark Johnston uint32_t tcp_ack; /* acknowledgment number */ 1968298c17cSMark Johnston uint8_t tcp_offset; /* data offset, in bytes */ 19738c63bdcSRichard Scheffenegger uint16_t tcp_flags; /* flags */ 1988298c17cSMark Johnston uint16_t tcp_window; /* window size */ 1998298c17cSMark Johnston uint16_t tcp_checksum; /* checksum */ 2008298c17cSMark Johnston uint16_t tcp_urgent; /* urgent data pointer */ 2018298c17cSMark Johnston struct tcphdr *tcp_hdr; /* raw TCP header */ 2028298c17cSMark Johnston } tcpinfoh_t; 2038298c17cSMark Johnston 2042f28ceebSMark Johnston #pragma D binding "1.6.3" translator 20557f60867SMark Johnston translator csinfo_t < struct tcpcb *p > { 20657f60867SMark Johnston cs_addr = NULL; 207e68b3792SGleb Smirnoff cs_cid = (uint64_t)(p == NULL ? 0 : &p->t_inpcb); 20857f60867SMark Johnston cs_pid = 0; 20957f60867SMark Johnston cs_zoneid = 0; 21057f60867SMark Johnston }; 21157f60867SMark Johnston 2122f28ceebSMark Johnston #pragma D binding "1.6.3" translator 21357f60867SMark Johnston translator tcpsinfo_t < struct tcpcb *p > { 21457f60867SMark Johnston tcps_addr = (uintptr_t)p; 21557f60867SMark Johnston tcps_local = -1; /* XXX */ 21657f60867SMark Johnston tcps_active = -1; /* XXX */ 217e68b3792SGleb Smirnoff tcps_lport = p == NULL ? 0 : ntohs(p->t_inpcb.inp_inc.inc_ie.ie_lport); 218e68b3792SGleb Smirnoff tcps_rport = p == NULL ? 0 : ntohs(p->t_inpcb.inp_inc.inc_ie.ie_fport); 2197575d3dfSMichael Tuexen tcps_laddr = p == NULL ? "<unknown>" : 220e68b3792SGleb Smirnoff p->t_inpcb.inp_vflag == INP_IPV4 ? 221e68b3792SGleb Smirnoff inet_ntoa(&p->t_inpcb.inp_inc.inc_ie.ie_dependladdr.id46_addr.ia46_addr4.s_addr) : 222e68b3792SGleb Smirnoff inet_ntoa6(&p->t_inpcb.inp_inc.inc_ie.ie_dependladdr.id6_addr); 2237575d3dfSMichael Tuexen tcps_raddr = p == NULL ? "<unknown>" : 224e68b3792SGleb Smirnoff p->t_inpcb.inp_vflag == INP_IPV4 ? 225e68b3792SGleb Smirnoff inet_ntoa(&p->t_inpcb.inp_inc.inc_ie.ie_dependfaddr.id46_addr.ia46_addr4.s_addr) : 226e68b3792SGleb Smirnoff inet_ntoa6(&p->t_inpcb.inp_inc.inc_ie.ie_dependfaddr.id6_addr); 22757f60867SMark Johnston tcps_state = p == NULL ? -1 : p->t_state; 22857f60867SMark Johnston tcps_iss = p == NULL ? 0 : p->iss; 229342af4d5SGeorge V. Neville-Neil tcps_irs = p == NULL ? 0 : p->irs; 23057f60867SMark Johnston tcps_suna = p == NULL ? 0 : p->snd_una; 2315d06879aSGeorge V. Neville-Neil tcps_smax = p == NULL ? 0 : p->snd_max; 23257f60867SMark Johnston tcps_snxt = p == NULL ? 0 : p->snd_nxt; 23357f60867SMark Johnston tcps_rack = p == NULL ? 0 : p->last_ack_sent; 23457f60867SMark Johnston tcps_rnxt = p == NULL ? 0 : p->rcv_nxt; 23557f60867SMark Johnston tcps_swnd = p == NULL ? -1 : p->snd_wnd; 23657f60867SMark Johnston tcps_snd_ws = p == NULL ? -1 : p->snd_scale; 2375d06879aSGeorge V. Neville-Neil tcps_swl1 = p == NULL ? -1 : p->snd_wl1; 2385d06879aSGeorge V. Neville-Neil tcps_swl2 = p == NULL ? -1 : p->snd_wl2; 239342af4d5SGeorge V. Neville-Neil tcps_radv = p == NULL ? -1 : p->rcv_adv; 24057f60867SMark Johnston tcps_rwnd = p == NULL ? -1 : p->rcv_wnd; 2415d06879aSGeorge V. Neville-Neil tcps_rup = p == NULL ? -1 : p->rcv_up; 24257f60867SMark Johnston tcps_rcv_ws = p == NULL ? -1 : p->rcv_scale; 24357f60867SMark Johnston tcps_cwnd = p == NULL ? -1 : p->snd_cwnd; 24457f60867SMark Johnston tcps_cwnd_ssthresh = p == NULL ? -1 : p->snd_ssthresh; 245342af4d5SGeorge V. Neville-Neil tcps_srecover = p == NULL ? -1 : p->snd_recover; 24657f60867SMark Johnston tcps_sack_fack = p == NULL ? 0 : p->snd_fack; 247a3574665SMichael Tuexen tcps_sack_snxt = p == NULL ? 0 : p->snd_recover; 248fd8b318aSMark Johnston tcps_rto = p == NULL ? -1 : (p->t_rxtcur * 1000) / `hz; 24957f60867SMark Johnston tcps_mss = p == NULL ? -1 : p->t_maxseg; 2508298c17cSMark Johnston tcps_retransmit = p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0; 251bd537a28SGeorge V. Neville-Neil tcps_srtt = p == NULL ? -1 : p->t_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ 2525d06879aSGeorge V. Neville-Neil tcps_debug = p == NULL ? 0 : 253e68b3792SGleb Smirnoff p->t_inpcb.inp_socket->so_options & 1; 25415dbc160SGeorge V. Neville-Neil tcps_cookie = p == NULL ? -1 : 255e68b3792SGleb Smirnoff p->t_inpcb.inp_socket->so_user_cookie; 256342af4d5SGeorge V. Neville-Neil tcps_dupacks = p == NULL ? -1 : p->t_dupacks; 257342af4d5SGeorge V. Neville-Neil tcps_rtttime = p == NULL ? -1 : p->t_rtttime; 258342af4d5SGeorge V. Neville-Neil tcps_rtseq = p == NULL ? -1 : p->t_rtseq; 259342af4d5SGeorge V. Neville-Neil tcps_ts_recent = p == NULL ? -1 : p->ts_recent; 26057f60867SMark Johnston }; 26157f60867SMark Johnston 2622f28ceebSMark Johnston #pragma D binding "1.6.3" translator 26357f60867SMark Johnston translator tcpinfo_t < struct tcphdr *p > { 26457f60867SMark Johnston tcp_sport = p == NULL ? 0 : ntohs(p->th_sport); 26557f60867SMark Johnston tcp_dport = p == NULL ? 0 : ntohs(p->th_dport); 26657f60867SMark Johnston tcp_seq = p == NULL ? -1 : ntohl(p->th_seq); 26757f60867SMark Johnston tcp_ack = p == NULL ? -1 : ntohl(p->th_ack); 268*c3268c23SMark Johnston tcp_offset = p == NULL ? -1 : (p->th_off << 2); 26938c63bdcSRichard Scheffenegger tcp_flags = p == NULL ? 0 : ((p->th_x2 << 8) | p->th_flags); 27057f60867SMark Johnston tcp_window = p == NULL ? 0 : ntohs(p->th_win); 27157f60867SMark Johnston tcp_checksum = p == NULL ? 0 : ntohs(p->th_sum); 27257f60867SMark Johnston tcp_urgent = p == NULL ? 0 : ntohs(p->th_urp); 27357f60867SMark Johnston tcp_hdr = (struct tcphdr *)p; 27457f60867SMark Johnston }; 27557f60867SMark Johnston 2768298c17cSMark Johnston /* 2778298c17cSMark Johnston * This translator differs from the one for tcpinfo_t in that the sequence 2788298c17cSMark Johnston * number, acknowledgement number, window size and urgent pointer are already 2798298c17cSMark Johnston * in host order and thus don't need to be converted. 2808298c17cSMark Johnston */ 2812f28ceebSMark Johnston #pragma D binding "1.6.3" translator 2828298c17cSMark Johnston translator tcpinfoh_t < struct tcphdr *p > { 2838298c17cSMark Johnston tcp_sport = p == NULL ? 0 : ntohs(p->th_sport); 2848298c17cSMark Johnston tcp_dport = p == NULL ? 0 : ntohs(p->th_dport); 2858298c17cSMark Johnston tcp_seq = p == NULL ? -1 : p->th_seq; 2868298c17cSMark Johnston tcp_ack = p == NULL ? -1 : p->th_ack; 287*c3268c23SMark Johnston tcp_offset = p == NULL ? -1 : (p->th_off << 2); 28838c63bdcSRichard Scheffenegger tcp_flags = p == NULL ? 0 : ((p->th_x2 << 8) | p->th_flags); 2893ddcfe1eSMark Johnston tcp_window = p == NULL ? 0 : p->th_win; 2908298c17cSMark Johnston tcp_checksum = p == NULL ? 0 : ntohs(p->th_sum); 2918298c17cSMark Johnston tcp_urgent = p == NULL ? 0 : p->th_urp; 2928298c17cSMark Johnston tcp_hdr = (struct tcphdr *)p; 2938298c17cSMark Johnston }; 2948298c17cSMark Johnston 2952f28ceebSMark Johnston #pragma D binding "1.6.3" translator 29657f60867SMark Johnston translator tcplsinfo_t < int s > { 29757f60867SMark Johnston tcps_state = s; 29857f60867SMark Johnston }; 2995d06879aSGeorge V. Neville-Neil 3005d06879aSGeorge V. Neville-Neil 3015d06879aSGeorge V. Neville-Neil /* Support for TCP debug */ 3025d06879aSGeorge V. Neville-Neil 3035d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_INPUT 3045d06879aSGeorge V. Neville-Neil inline int TA_INPUT = 0; 3055d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_OUTPUT 3065d06879aSGeorge V. Neville-Neil inline int TA_OUTPUT = 1; 3075d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_USER 3085d06879aSGeorge V. Neville-Neil inline int TA_USER = 2; 3095d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_RESPOND 3105d06879aSGeorge V. Neville-Neil inline int TA_RESPOND = 3; 3115d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_DROP 3125d06879aSGeorge V. Neville-Neil inline int TA_DROP = 4; 3135d06879aSGeorge V. Neville-Neil 3145d06879aSGeorge V. Neville-Neil /* direction strings. */ 3155d06879aSGeorge V. Neville-Neil 31638c63bdcSRichard Scheffenegger #pragma D binding "1.13" tcpdebug_dir_string 3175d06879aSGeorge V. Neville-Neil inline string tcpdebug_dir_string[uint8_t direction] = 3185d06879aSGeorge V. Neville-Neil direction == TA_INPUT ? "input" : 3195d06879aSGeorge V. Neville-Neil direction == TA_OUTPUT ? "output" : 3205d06879aSGeorge V. Neville-Neil direction == TA_USER ? "user" : 3215d06879aSGeorge V. Neville-Neil direction == TA_RESPOND ? "respond" : 32238c63bdcSRichard Scheffenegger direction == TA_DROP ? "drop" : 3235d06879aSGeorge V. Neville-Neil "unknown" ; 3245d06879aSGeorge V. Neville-Neil 32538c63bdcSRichard Scheffenegger #pragma D binding "1.13" tcpflag_string 32638c63bdcSRichard Scheffenegger inline string tcpflag_string[uint16_t flags] = 3275d06879aSGeorge V. Neville-Neil flags & TH_FIN ? "FIN" : 3285d06879aSGeorge V. Neville-Neil flags & TH_SYN ? "SYN" : 3295d06879aSGeorge V. Neville-Neil flags & TH_RST ? "RST" : 3305d06879aSGeorge V. Neville-Neil flags & TH_PUSH ? "PUSH" : 3315d06879aSGeorge V. Neville-Neil flags & TH_ACK ? "ACK" : 3325d06879aSGeorge V. Neville-Neil flags & TH_URG ? "URG" : 3335d06879aSGeorge V. Neville-Neil flags & TH_ECE ? "ECE" : 3345d06879aSGeorge V. Neville-Neil flags & TH_CWR ? "CWR" : 33538c63bdcSRichard Scheffenegger flags & TH_AE ? "AE" : 3365d06879aSGeorge V. Neville-Neil "unknown" ; 3375d06879aSGeorge V. Neville-Neil 3385d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ATTACH 3395d06879aSGeorge V. Neville-Neil inline int PRU_ATTACH = 0; 3405d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_DETACH 3415d06879aSGeorge V. Neville-Neil inline int PRU_DETACH = 1; 3425d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_BIND 3435d06879aSGeorge V. Neville-Neil inline int PRU_BIND = 2; 3445d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_LISTEN 3455d06879aSGeorge V. Neville-Neil inline int PRU_LISTEN = 3; 3465d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONNECT 3475d06879aSGeorge V. Neville-Neil inline int PRU_CONNECT = 4; 3485d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ACCEPT 3495d06879aSGeorge V. Neville-Neil inline int PRU_ACCEPT = 5 ; 3505d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_DISCONNECT 3515d06879aSGeorge V. Neville-Neil inline int PRU_DISCONNECT = 6; 3525d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SHUTDOWN 3535d06879aSGeorge V. Neville-Neil inline int PRU_SHUTDOWN = 7; 3545d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_RCVD 3555d06879aSGeorge V. Neville-Neil inline int PRU_RCVD = 8; 3565d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SEND 3575d06879aSGeorge V. Neville-Neil inline int PRU_SEND = 9; 3585d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ABORT 3595d06879aSGeorge V. Neville-Neil inline int PRU_ABORT = 10; 3605d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONTROL 3615d06879aSGeorge V. Neville-Neil inline int PRU_CONTROL = 11; 3625d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SENSE 3635d06879aSGeorge V. Neville-Neil inline int PRU_SENSE = 12; 3645d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_RCVOOB 3655d06879aSGeorge V. Neville-Neil inline int PRU_RCVOOB = 13; 3665d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SENDOOB 3675d06879aSGeorge V. Neville-Neil inline int PRU_SENDOOB = 14; 3685d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SOCKADDR 3695d06879aSGeorge V. Neville-Neil inline int PRU_SOCKADDR = 15; 3705d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PEERADDR 3715d06879aSGeorge V. Neville-Neil inline int PRU_PEERADDR = 16; 3725d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONNECT2 3735d06879aSGeorge V. Neville-Neil inline int PRU_CONNECT2 = 17; 3745d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_FASTTIMO 3755d06879aSGeorge V. Neville-Neil inline int PRU_FASTTIMO = 18; 3765d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SLOWTIMO 3775d06879aSGeorge V. Neville-Neil inline int PRU_SLOWTIMO = 19; 3785d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PROTORCV 3795d06879aSGeorge V. Neville-Neil inline int PRU_PROTORCV = 20; 3805d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PROTOSEND 3815d06879aSGeorge V. Neville-Neil inline int PRU_PROTOSEND = 21; 3825d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SEND_EOF 3835d06879aSGeorge V. Neville-Neil inline int PRU_SEND_EOF = 22; 3845d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SOSETLABEL 3855d06879aSGeorge V. Neville-Neil inline int PRU_SOSETLABEL = 23; 3865d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CLOSE 3875d06879aSGeorge V. Neville-Neil inline int PRU_CLOSE = 24; 3885d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_FLUSH 3895d06879aSGeorge V. Neville-Neil inline int PRU_FLUSH = 25; 3905d06879aSGeorge V. Neville-Neil 3915d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" prureq_string 3925d06879aSGeorge V. Neville-Neil inline string prureq_string[uint8_t req] = 3935d06879aSGeorge V. Neville-Neil req == PRU_ATTACH ? "ATTACH" : 3945d06879aSGeorge V. Neville-Neil req == PRU_DETACH ? "DETACH" : 3955d06879aSGeorge V. Neville-Neil req == PRU_BIND ? "BIND" : 3965d06879aSGeorge V. Neville-Neil req == PRU_LISTEN ? "LISTEN" : 3975d06879aSGeorge V. Neville-Neil req == PRU_CONNECT ? "CONNECT" : 3985d06879aSGeorge V. Neville-Neil req == PRU_ACCEPT ? "ACCEPT" : 3995d06879aSGeorge V. Neville-Neil req == PRU_DISCONNECT ? "DISCONNECT" : 4005d06879aSGeorge V. Neville-Neil req == PRU_SHUTDOWN ? "SHUTDOWN" : 4015d06879aSGeorge V. Neville-Neil req == PRU_RCVD ? "RCVD" : 4025d06879aSGeorge V. Neville-Neil req == PRU_SEND ? "SEND" : 4035d06879aSGeorge V. Neville-Neil req == PRU_ABORT ? "ABORT" : 4045d06879aSGeorge V. Neville-Neil req == PRU_CONTROL ? "CONTROL" : 4055d06879aSGeorge V. Neville-Neil req == PRU_SENSE ? "SENSE" : 4065d06879aSGeorge V. Neville-Neil req == PRU_RCVOOB ? "RCVOOB" : 4075d06879aSGeorge V. Neville-Neil req == PRU_SENDOOB ? "SENDOOB" : 4085d06879aSGeorge V. Neville-Neil req == PRU_SOCKADDR ? "SOCKADDR" : 4095d06879aSGeorge V. Neville-Neil req == PRU_PEERADDR ? "PEERADDR" : 4105d06879aSGeorge V. Neville-Neil req == PRU_CONNECT2 ? "CONNECT2" : 4115d06879aSGeorge V. Neville-Neil req == PRU_FASTTIMO ? "FASTTIMO" : 4125d06879aSGeorge V. Neville-Neil req == PRU_SLOWTIMO ? "SLOWTIMO" : 4135d06879aSGeorge V. Neville-Neil req == PRU_PROTORCV ? "PROTORCV" : 4145d06879aSGeorge V. Neville-Neil req == PRU_PROTOSEND ? "PROTOSEND" : 4155d06879aSGeorge V. Neville-Neil req == PRU_SEND ? "SEND_EOF" : 4165d06879aSGeorge V. Neville-Neil req == PRU_SOSETLABEL ? "SOSETLABEL" : 4175d06879aSGeorge V. Neville-Neil req == PRU_CLOSE ? "CLOSE" : 4185d06879aSGeorge V. Neville-Neil req == PRU_FLUSH ? "FLUSE" : 4195d06879aSGeorge V. Neville-Neil "unknown" ; 420