1 /* 2 * Copyright (c) 1984, 1985, 1986, 1987, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)spp_var.h 8.1 (Berkeley) 06/10/93 8 */ 9 10 /* 11 * Sp control block, one per connection 12 */ 13 struct sppcb { 14 struct spidp_q s_q; /* queue for out-of-order receipt */ 15 struct nspcb *s_nspcb; /* backpointer to internet pcb */ 16 u_char s_state; 17 u_char s_flags; 18 #define SF_ACKNOW 0x01 /* Ack peer immediately */ 19 #define SF_DELACK 0x02 /* Ack, but try to delay it */ 20 #define SF_HI 0x04 /* Show headers on input */ 21 #define SF_HO 0x08 /* Show headers on output */ 22 #define SF_PI 0x10 /* Packet (datagram) interface */ 23 #define SF_WIN 0x20 /* Window info changed */ 24 #define SF_RXT 0x40 /* Rxt info changed */ 25 #define SF_RVD 0x80 /* Calling from read usrreq routine */ 26 u_short s_mtu; /* Max packet size for this stream */ 27 /* use sequence fields in headers to store sequence numbers for this 28 connection */ 29 struct idp *s_idp; 30 struct sphdr s_shdr; /* prototype header to transmit */ 31 #define s_cc s_shdr.sp_cc /* connection control (for EM bit) */ 32 #define s_dt s_shdr.sp_dt /* datastream type */ 33 #define s_sid s_shdr.sp_sid /* source connection identifier */ 34 #define s_did s_shdr.sp_did /* destination connection identifier */ 35 #define s_seq s_shdr.sp_seq /* sequence number */ 36 #define s_ack s_shdr.sp_ack /* acknowledge number */ 37 #define s_alo s_shdr.sp_alo /* allocation number */ 38 #define s_dport s_idp->idp_dna.x_port /* where we are sending */ 39 struct sphdr s_rhdr; /* last received header (in effect!)*/ 40 u_short s_rack; /* their acknowledge number */ 41 u_short s_ralo; /* their allocation number */ 42 u_short s_smax; /* highest packet # we have sent */ 43 u_short s_snxt; /* which packet to send next */ 44 45 /* congestion control */ 46 #define CUNIT 1024 /* scaling for ... */ 47 int s_cwnd; /* Congestion-controlled window */ 48 /* in packets * CUNIT */ 49 short s_swnd; /* == tcp snd_wnd, in packets */ 50 short s_smxw; /* == tcp max_sndwnd */ 51 /* difference of two spp_seq's can be 52 no bigger than a short */ 53 u_short s_swl1; /* == tcp snd_wl1 */ 54 u_short s_swl2; /* == tcp snd_wl2 */ 55 int s_cwmx; /* max allowable cwnd */ 56 int s_ssthresh; /* s_cwnd size threshhold for 57 * slow start exponential-to- 58 * linear switch */ 59 /* transmit timing stuff 60 * srtt and rttvar are stored as fixed point, for convenience in smoothing. 61 * srtt has 3 bits to the right of the binary point, rttvar has 2. 62 */ 63 short s_idle; /* time idle */ 64 short s_timer[SPPT_NTIMERS]; /* timers */ 65 short s_rxtshift; /* log(2) of rexmt exp. backoff */ 66 short s_rxtcur; /* current retransmit value */ 67 u_short s_rtseq; /* packet being timed */ 68 short s_rtt; /* timer for round trips */ 69 short s_srtt; /* averaged timer */ 70 short s_rttvar; /* variance in round trip time */ 71 char s_force; /* which timer expired */ 72 char s_dupacks; /* counter to intuit xmt loss */ 73 74 /* out of band data */ 75 char s_oobflags; 76 #define SF_SOOB 0x08 /* sending out of band data */ 77 #define SF_IOOB 0x10 /* receiving out of band data */ 78 char s_iobc; /* input characters */ 79 /* debug stuff */ 80 u_short s_want; /* Last candidate for sending */ 81 char s_outx; /* exit taken from spp_output */ 82 char s_inx; /* exit taken from spp_input */ 83 u_short s_flags2; /* more flags for testing */ 84 #define SF_NEWCALL 0x100 /* for new_recvmsg */ 85 #define SO_NEWCALL 10 /* for new_recvmsg */ 86 }; 87 88 #define nstosppcb(np) ((struct sppcb *)(np)->nsp_pcb) 89 #define sotosppcb(so) (nstosppcb(sotonspcb(so))) 90 91 struct sppstat { 92 long spps_connattempt; /* connections initiated */ 93 long spps_accepts; /* connections accepted */ 94 long spps_connects; /* connections established */ 95 long spps_drops; /* connections dropped */ 96 long spps_conndrops; /* embryonic connections dropped */ 97 long spps_closed; /* conn. closed (includes drops) */ 98 long spps_segstimed; /* segs where we tried to get rtt */ 99 long spps_rttupdated; /* times we succeeded */ 100 long spps_delack; /* delayed acks sent */ 101 long spps_timeoutdrop; /* conn. dropped in rxmt timeout */ 102 long spps_rexmttimeo; /* retransmit timeouts */ 103 long spps_persisttimeo; /* persist timeouts */ 104 long spps_keeptimeo; /* keepalive timeouts */ 105 long spps_keepprobe; /* keepalive probes sent */ 106 long spps_keepdrops; /* connections dropped in keepalive */ 107 108 long spps_sndtotal; /* total packets sent */ 109 long spps_sndpack; /* data packets sent */ 110 long spps_sndbyte; /* data bytes sent */ 111 long spps_sndrexmitpack; /* data packets retransmitted */ 112 long spps_sndrexmitbyte; /* data bytes retransmitted */ 113 long spps_sndacks; /* ack-only packets sent */ 114 long spps_sndprobe; /* window probes sent */ 115 long spps_sndurg; /* packets sent with URG only */ 116 long spps_sndwinup; /* window update-only packets sent */ 117 long spps_sndctrl; /* control (SYN|FIN|RST) packets sent */ 118 long spps_sndvoid; /* couldn't find requested packet*/ 119 120 long spps_rcvtotal; /* total packets received */ 121 long spps_rcvpack; /* packets received in sequence */ 122 long spps_rcvbyte; /* bytes received in sequence */ 123 long spps_rcvbadsum; /* packets received with ccksum errs */ 124 long spps_rcvbadoff; /* packets received with bad offset */ 125 long spps_rcvshort; /* packets received too short */ 126 long spps_rcvduppack; /* duplicate-only packets received */ 127 long spps_rcvdupbyte; /* duplicate-only bytes received */ 128 long spps_rcvpartduppack; /* packets with some duplicate data */ 129 long spps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ 130 long spps_rcvoopack; /* out-of-order packets received */ 131 long spps_rcvoobyte; /* out-of-order bytes received */ 132 long spps_rcvpackafterwin; /* packets with data after window */ 133 long spps_rcvbyteafterwin; /* bytes rcvd after window */ 134 long spps_rcvafterclose; /* packets rcvd after "close" */ 135 long spps_rcvwinprobe; /* rcvd window probe packets */ 136 long spps_rcvdupack; /* rcvd duplicate acks */ 137 long spps_rcvacktoomuch; /* rcvd acks for unsent data */ 138 long spps_rcvackpack; /* rcvd ack packets */ 139 long spps_rcvackbyte; /* bytes acked by rcvd acks */ 140 long spps_rcvwinupd; /* rcvd window update packets */ 141 }; 142 struct spp_istat { 143 short hdrops; 144 short badsum; 145 short badlen; 146 short slotim; 147 short fastim; 148 short nonucn; 149 short noconn; 150 short notme; 151 short wrncon; 152 short bdreas; 153 short gonawy; 154 short notyet; 155 short lstdup; 156 struct sppstat newstats; 157 }; 158 159 #ifdef KERNEL 160 struct spp_istat spp_istat; 161 162 /* Following was struct sppstat sppstat; */ 163 #ifndef sppstat 164 #define sppstat spp_istat.newstats 165 #endif 166 167 u_short spp_iss; 168 extern struct sppcb *spp_close(), *spp_disconnect(), 169 *spp_usrclosed(), *spp_timers(), *spp_drop(); 170 #endif 171 172 #define SPP_ISSINCR 128 173 /* 174 * SPP sequence numbers are 16 bit integers operated 175 * on with modular arithmetic. These macros can be 176 * used to compare such integers. 177 */ 178 #ifdef sun 179 short xnsCbug; 180 #define SSEQ_LT(a,b) ((xnsCbug = (short)((a)-(b))) < 0) 181 #define SSEQ_LEQ(a,b) ((xnsCbug = (short)((a)-(b))) <= 0) 182 #define SSEQ_GT(a,b) ((xnsCbug = (short)((a)-(b))) > 0) 183 #define SSEQ_GEQ(a,b) ((xnsCbug = (short)((a)-(b))) >= 0) 184 #else 185 #define SSEQ_LT(a,b) (((short)((a)-(b))) < 0) 186 #define SSEQ_LEQ(a,b) (((short)((a)-(b))) <= 0) 187 #define SSEQ_GT(a,b) (((short)((a)-(b))) > 0) 188 #define SSEQ_GEQ(a,b) (((short)((a)-(b))) >= 0) 189 #endif 190