spx.h revision 192754
1109998Smarkm/*- 2109998Smarkm * Copyright (c) 1984, 1985, 1986, 1987, 1993 3109998Smarkm * The Regents of the University of California. All rights reserved. 4109998Smarkm * 5109998Smarkm * Redistribution and use in source and binary forms, with or without 6109998Smarkm * modification, are permitted provided that the following conditions 7109998Smarkm * are met: 8109998Smarkm * 1. Redistributions of source code must retain the above copyright 9109998Smarkm * notice, this list of conditions and the following disclaimer. 10296465Sdelphij * 2. Redistributions in binary form must reproduce the above copyright 11109998Smarkm * notice, this list of conditions and the following disclaimer in the 12109998Smarkm * documentation and/or other materials provided with the distribution. 13109998Smarkm * 4. Neither the name of the University nor the names of its contributors 14109998Smarkm * may be used to endorse or promote products derived from this software 15109998Smarkm * without specific prior written permission. 16109998Smarkm * 17109998Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18109998Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19109998Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20109998Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21109998Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22109998Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23109998Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24109998Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25109998Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26109998Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27109998Smarkm * SUCH DAMAGE. 28109998Smarkm * 29109998Smarkm * Copyright (c) 1995, Mike Mitchell 30109998Smarkm * 31109998Smarkm * Redistribution and use in source and binary forms, with or without 32109998Smarkm * modification, are permitted provided that the following conditions 33109998Smarkm * are met: 34109998Smarkm * 1. Redistributions of source code must retain the above copyright 35109998Smarkm * notice, this list of conditions and the following disclaimer. 36109998Smarkm * 2. Redistributions in binary form must reproduce the above copyright 37109998Smarkm * notice, this list of conditions and the following disclaimer in the 38109998Smarkm * documentation and/or other materials provided with the distribution. 39109998Smarkm * 3. All advertising materials mentioning features or use of this software 40109998Smarkm * must display the following acknowledgement: 41109998Smarkm * This product includes software developed by the University of 42109998Smarkm * California, Berkeley and its contributors. 43109998Smarkm * 4. Neither the name of the University nor the names of its contributors 44109998Smarkm * may be used to endorse or promote products derived from this software 45109998Smarkm * without specific prior written permission. 46109998Smarkm * 47109998Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 48109998Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49109998Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50109998Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 51109998Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52109998Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53109998Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54109998Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55109998Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56296465Sdelphij * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57296465Sdelphij * SUCH DAMAGE. 58109998Smarkm * 59109998Smarkm * @(#)spx.h 60109998Smarkm * 61109998Smarkm * $FreeBSD: head/sys/netipx/spx.h 192754 2009-05-25 11:50:58Z rwatson $ 62109998Smarkm */ 63109998Smarkm 64109998Smarkm#ifndef _NETIPX_SPX_H_ 65109998Smarkm#define _NETIPX_SPX_H_ 66109998Smarkm 67109998Smarkm/* 68296465Sdelphij * Definitions for IPX style Sequenced Packet Protocol 69296465Sdelphij */ 70296465Sdelphij 71296465Sdelphijstruct spxhdr { 72296465Sdelphij u_char spx_cc; /* connection control */ 73296465Sdelphij u_char spx_dt; /* datastream type */ 74296465Sdelphij#define SPX_SP 0x80 /* system packet */ 75296465Sdelphij#define SPX_SA 0x40 /* send acknowledgement */ 76296465Sdelphij#define SPX_OB 0x20 /* attention (out of band data) */ 77296465Sdelphij#define SPX_EM 0x10 /* end of message */ 78296465Sdelphij u_short spx_sid; /* source connection identifier */ 79296465Sdelphij u_short spx_did; /* destination connection identifier */ 80296465Sdelphij u_short spx_seq; /* sequence number */ 81296465Sdelphij u_short spx_ack; /* acknowledge number */ 82296465Sdelphij u_short spx_alo; /* allocation number */ 83296465Sdelphij} __packed; 84296465Sdelphij 85296465Sdelphij/* 86296465Sdelphij * Definitions for NS(tm) Internet Datagram Protocol 87296465Sdelphij * containing a Sequenced Packet Protocol packet. 88296465Sdelphij */ 89296465Sdelphijstruct spx { 90109998Smarkm struct ipx si_i; 91296465Sdelphij struct spxhdr si_s; 92296465Sdelphij} __packed; 93296465Sdelphijstruct spx_q { 94296465Sdelphij struct spx_q *si_next; 95296465Sdelphij struct spx_q *si_prev; 96296465Sdelphij}; 97296465Sdelphij#define SI(x) ((struct spx *)x) 98296465Sdelphij#define si_sum si_i.ipx_sum 99296465Sdelphij#define si_len si_i.ipx_len 100109998Smarkm#define si_tc si_i.ipx_tc 101109998Smarkm#define si_pt si_i.ipx_pt 102109998Smarkm#define si_dna si_i.ipx_dna 103109998Smarkm#define si_sna si_i.ipx_sna 104296465Sdelphij#define si_sport si_i.ipx_sna.x_port 105296465Sdelphij#define si_cc si_s.spx_cc 106296465Sdelphij#define si_dt si_s.spx_dt 107296465Sdelphij#define si_sid si_s.spx_sid 108109998Smarkm#define si_did si_s.spx_did 109109998Smarkm#define si_seq si_s.spx_seq 110296465Sdelphij#define si_ack si_s.spx_ack 111296465Sdelphij#define si_alo si_s.spx_alo 112109998Smarkm 113109998Smarkm/* 114296465Sdelphij * SPX control block, one per connection 115296465Sdelphij */ 116296465Sdelphijstruct spxpcb { 117109998Smarkm struct spx_q s_q; /* queue for out-of-order receipt */ 118296465Sdelphij struct ipxpcb *s_ipxpcb; /* backpointer to internet pcb */ 119296465Sdelphij u_char s_state; 120109998Smarkm u_char s_flags; 121296465Sdelphij#define SF_ACKNOW 0x01 /* Ack peer immediately */ 122296465Sdelphij#define SF_DELACK 0x02 /* Ack, but try to delay it */ 123109998Smarkm#define SF_HI 0x04 /* Show headers on input */ 124109998Smarkm#define SF_HO 0x08 /* Show headers on output */ 125109998Smarkm#define SF_PI 0x10 /* Packet (datagram) interface */ 126296465Sdelphij#define SF_WIN 0x20 /* Window info changed */ 127296465Sdelphij#define SF_RXT 0x40 /* Rxt info changed */ 128109998Smarkm#define SF_RVD 0x80 /* Calling from read usrreq routine */ 129296465Sdelphij u_short s_mtu; /* Max packet size for this stream */ 130296465Sdelphij/* use sequence fields in headers to store sequence numbers for this 131109998Smarkm connection */ 132109998Smarkm struct ipx s_ipx; 133296465Sdelphij struct spxhdr s_shdr; /* prototype header to transmit */ 134296465Sdelphij#define s_cc s_shdr.spx_cc /* connection control (for EM bit) */ 135109998Smarkm#define s_dt s_shdr.spx_dt /* datastream type */ 136296465Sdelphij#define s_sid s_shdr.spx_sid /* source connection identifier */ 137296465Sdelphij#define s_did s_shdr.spx_did /* destination connection identifier */ 138109998Smarkm#define s_seq s_shdr.spx_seq /* sequence number */ 139109998Smarkm#define s_ack s_shdr.spx_ack /* acknowledge number */ 140109998Smarkm#define s_alo s_shdr.spx_alo /* allocation number */ 141296465Sdelphij#define s_dport s_ipx.ipx_dna.x_port /* where we are sending */ 142109998Smarkm struct spxhdr s_rhdr; /* last received header (in effect!)*/ 143296465Sdelphij u_short s_rack; /* their acknowledge number */ 144296465Sdelphij u_short s_ralo; /* their allocation number */ 145296465Sdelphij u_short s_smax; /* highest packet # we have sent */ 146109998Smarkm u_short s_snxt; /* which packet to send next */ 147109998Smarkm 148296465Sdelphij/* congestion control */ 149296465Sdelphij#define CUNIT 1024 /* scaling for ... */ 150296465Sdelphij int s_cwnd; /* Congestion-controlled window */ 151296465Sdelphij /* in packets * CUNIT */ 152296465Sdelphij short s_swnd; /* == tcp snd_wnd, in packets */ 153 short s_smxw; /* == tcp max_sndwnd */ 154 /* difference of two spx_seq's can be 155 no bigger than a short */ 156 u_short s_swl1; /* == tcp snd_wl1 */ 157 u_short s_swl2; /* == tcp snd_wl2 */ 158 int s_cwmx; /* max allowable cwnd */ 159 int s_ssthresh; /* s_cwnd size threshold for 160 * slow start exponential-to- 161 * linear switch */ 162/* transmit timing stuff 163 * srtt and rttvar are stored as fixed point, for convenience in smoothing. 164 * srtt has 3 bits to the right of the binary point, rttvar has 2. 165 */ 166 short s_idle; /* time idle */ 167#define SPXT_NTIMERS 4 168 short s_timer[SPXT_NTIMERS]; /* timers */ 169 short s_rxtshift; /* log(2) of rexmt exp. backoff */ 170 short s_rxtcur; /* current retransmit value */ 171 u_short s_rtseq; /* packet being timed */ 172 short s_rtt; /* timer for round trips */ 173 short s_srtt; /* averaged timer */ 174 short s_rttvar; /* variance in round trip time */ 175 char s_force; /* which timer expired */ 176 char s_dupacks; /* counter to intuit xmt loss */ 177 178/* out of band data */ 179 char s_oobflags; 180#define SF_SOOB 0x08 /* sending out of band data */ 181#define SF_IOOB 0x10 /* receiving out of band data */ 182 char s_iobc; /* input characters */ 183/* debug stuff */ 184 u_short s_want; /* Last candidate for sending */ 185 char s_outx; /* exit taken from spx_output */ 186 char s_inx; /* exit taken from spx_input */ 187 u_short s_flags2; /* more flags for testing */ 188#define SF_NEWCALL 0x100 /* for new_recvmsg */ 189#define SO_NEWCALL 10 /* for new_recvmsg */ 190}; 191 192#define ipxtospxpcb(np) ((struct spxpcb *)(np)->ipxp_pcb) 193#define sotospxpcb(so) (ipxtospxpcb(sotoipxpcb(so))) 194 195#ifdef _KERNEL 196 197extern struct pr_usrreqs spx_usrreqs; 198extern struct pr_usrreqs spx_usrreq_sps; 199 200void spx_ctlinput(int cmd, struct sockaddr *arg_as_sa, void *dummy); 201int spx_ctloutput(struct socket *so, struct sockopt *sopt); 202void spx_fasttimo(void); 203void spx_init(void); 204void spx_input(struct mbuf *m, struct ipxpcb *ipxp); 205void spx_slowtimo(void); 206 207#endif /* _KERNEL */ 208 209#endif /* !_NETIPX_SPX_H_ */ 210