1139823Simp/*- 211819Sjulian * Copyright (c) 1984, 1985, 1986, 1987, 1993 311819Sjulian * The Regents of the University of California. All rights reserved. 411819Sjulian * 511819Sjulian * Redistribution and use in source and binary forms, with or without 611819Sjulian * modification, are permitted provided that the following conditions 711819Sjulian * are met: 811819Sjulian * 1. Redistributions of source code must retain the above copyright 911819Sjulian * notice, this list of conditions and the following disclaimer. 1011819Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1111819Sjulian * notice, this list of conditions and the following disclaimer in the 1211819Sjulian * documentation and/or other materials provided with the distribution. 13165899Srwatson * 4. Neither the name of the University nor the names of its contributors 14165899Srwatson * may be used to endorse or promote products derived from this software 15165899Srwatson * without specific prior written permission. 16165899Srwatson * 17165899Srwatson * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18165899Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19165899Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20165899Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21165899Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22165899Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23165899Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24165899Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25165899Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26165899Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27165899Srwatson * SUCH DAMAGE. 28165899Srwatson * 29165899Srwatson * Copyright (c) 1995, Mike Mitchell 30165899Srwatson * 31165899Srwatson * Redistribution and use in source and binary forms, with or without 32165899Srwatson * modification, are permitted provided that the following conditions 33165899Srwatson * are met: 34165899Srwatson * 1. Redistributions of source code must retain the above copyright 35165899Srwatson * notice, this list of conditions and the following disclaimer. 36165899Srwatson * 2. Redistributions in binary form must reproduce the above copyright 37165899Srwatson * notice, this list of conditions and the following disclaimer in the 38165899Srwatson * documentation and/or other materials provided with the distribution. 3911819Sjulian * 3. All advertising materials mentioning features or use of this software 4011819Sjulian * must display the following acknowledgement: 4111819Sjulian * This product includes software developed by the University of 4211819Sjulian * California, Berkeley and its contributors. 4311819Sjulian * 4. Neither the name of the University nor the names of its contributors 4411819Sjulian * may be used to endorse or promote products derived from this software 4511819Sjulian * without specific prior written permission. 4611819Sjulian * 4711819Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 4811819Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4911819Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5011819Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5111819Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5211819Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5311819Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5411819Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5511819Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5611819Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5711819Sjulian * SUCH DAMAGE. 5811819Sjulian * 5912057Sjulian * @(#)spx.h 6012057Sjulian * 6150477Speter * $FreeBSD$ 6211819Sjulian */ 6311819Sjulian 6411819Sjulian#ifndef _NETIPX_SPX_H_ 6512470Sbde#define _NETIPX_SPX_H_ 6611819Sjulian 6711819Sjulian/* 6811819Sjulian * Definitions for IPX style Sequenced Packet Protocol 6911819Sjulian */ 7011819Sjulian 7111819Sjulianstruct spxhdr { 7211819Sjulian u_char spx_cc; /* connection control */ 7311819Sjulian u_char spx_dt; /* datastream type */ 7411819Sjulian#define SPX_SP 0x80 /* system packet */ 7511819Sjulian#define SPX_SA 0x40 /* send acknowledgement */ 7611819Sjulian#define SPX_OB 0x20 /* attention (out of band data) */ 7711819Sjulian#define SPX_EM 0x10 /* end of message */ 7811819Sjulian u_short spx_sid; /* source connection identifier */ 7911819Sjulian u_short spx_did; /* destination connection identifier */ 8011819Sjulian u_short spx_seq; /* sequence number */ 8111819Sjulian u_short spx_ack; /* acknowledge number */ 8211819Sjulian u_short spx_alo; /* allocation number */ 83139582Srwatson} __packed; 8411819Sjulian 8511819Sjulian/* 8611819Sjulian * Definitions for NS(tm) Internet Datagram Protocol 8711819Sjulian * containing a Sequenced Packet Protocol packet. 8811819Sjulian */ 8911819Sjulianstruct spx { 9011819Sjulian struct ipx si_i; 9111819Sjulian struct spxhdr si_s; 92139582Srwatson} __packed; 9311819Sjulianstruct spx_q { 94194547Srwatson struct mbuf *sq_msi; 95194547Srwatson struct spx *sq_si; 96194547Srwatson LIST_ENTRY(spx_q) sq_entry; 9711819Sjulian}; 9811819Sjulian#define SI(x) ((struct spx *)x) 9911819Sjulian#define si_sum si_i.ipx_sum 10011819Sjulian#define si_len si_i.ipx_len 10111819Sjulian#define si_tc si_i.ipx_tc 10211819Sjulian#define si_pt si_i.ipx_pt 10311819Sjulian#define si_dna si_i.ipx_dna 10411819Sjulian#define si_sna si_i.ipx_sna 10511819Sjulian#define si_sport si_i.ipx_sna.x_port 10611819Sjulian#define si_cc si_s.spx_cc 10711819Sjulian#define si_dt si_s.spx_dt 10811819Sjulian#define si_sid si_s.spx_sid 10911819Sjulian#define si_did si_s.spx_did 11011819Sjulian#define si_seq si_s.spx_seq 11111819Sjulian#define si_ack si_s.spx_ack 11211819Sjulian#define si_alo si_s.spx_alo 11311819Sjulian 11411947Sjulian/* 11511947Sjulian * SPX control block, one per connection 11611947Sjulian */ 11711947Sjulianstruct spxpcb { 118194547Srwatson LIST_HEAD(, spx_q) s_q; /* queue for out-of-order receipt */ 11911947Sjulian struct ipxpcb *s_ipxpcb; /* backpointer to internet pcb */ 12011947Sjulian u_char s_state; 12111947Sjulian u_char s_flags; 12211947Sjulian#define SF_ACKNOW 0x01 /* Ack peer immediately */ 12311947Sjulian#define SF_DELACK 0x02 /* Ack, but try to delay it */ 12411947Sjulian#define SF_HI 0x04 /* Show headers on input */ 12511947Sjulian#define SF_HO 0x08 /* Show headers on output */ 12611947Sjulian#define SF_PI 0x10 /* Packet (datagram) interface */ 12711947Sjulian#define SF_WIN 0x20 /* Window info changed */ 12811947Sjulian#define SF_RXT 0x40 /* Rxt info changed */ 12911947Sjulian#define SF_RVD 0x80 /* Calling from read usrreq routine */ 13011947Sjulian u_short s_mtu; /* Max packet size for this stream */ 13111947Sjulian/* use sequence fields in headers to store sequence numbers for this 13211947Sjulian connection */ 133192754Srwatson struct ipx s_ipx; 13411947Sjulian struct spxhdr s_shdr; /* prototype header to transmit */ 13511947Sjulian#define s_cc s_shdr.spx_cc /* connection control (for EM bit) */ 13611947Sjulian#define s_dt s_shdr.spx_dt /* datastream type */ 13711947Sjulian#define s_sid s_shdr.spx_sid /* source connection identifier */ 13811947Sjulian#define s_did s_shdr.spx_did /* destination connection identifier */ 13911947Sjulian#define s_seq s_shdr.spx_seq /* sequence number */ 14011947Sjulian#define s_ack s_shdr.spx_ack /* acknowledge number */ 14111947Sjulian#define s_alo s_shdr.spx_alo /* allocation number */ 142192754Srwatson#define s_dport s_ipx.ipx_dna.x_port /* where we are sending */ 14311947Sjulian struct spxhdr s_rhdr; /* last received header (in effect!)*/ 14411947Sjulian u_short s_rack; /* their acknowledge number */ 14511947Sjulian u_short s_ralo; /* their allocation number */ 14611947Sjulian u_short s_smax; /* highest packet # we have sent */ 14711947Sjulian u_short s_snxt; /* which packet to send next */ 14811947Sjulian 14911947Sjulian/* congestion control */ 15011947Sjulian#define CUNIT 1024 /* scaling for ... */ 15111947Sjulian int s_cwnd; /* Congestion-controlled window */ 15211947Sjulian /* in packets * CUNIT */ 15311947Sjulian short s_swnd; /* == tcp snd_wnd, in packets */ 15411947Sjulian short s_smxw; /* == tcp max_sndwnd */ 15511947Sjulian /* difference of two spx_seq's can be 15611947Sjulian no bigger than a short */ 15711947Sjulian u_short s_swl1; /* == tcp snd_wl1 */ 15811947Sjulian u_short s_swl2; /* == tcp snd_wl2 */ 15911947Sjulian int s_cwmx; /* max allowable cwnd */ 16013765Smpp int s_ssthresh; /* s_cwnd size threshold for 16111947Sjulian * slow start exponential-to- 16211947Sjulian * linear switch */ 16311947Sjulian/* transmit timing stuff 16411947Sjulian * srtt and rttvar are stored as fixed point, for convenience in smoothing. 16511947Sjulian * srtt has 3 bits to the right of the binary point, rttvar has 2. 16611947Sjulian */ 16711947Sjulian short s_idle; /* time idle */ 16811947Sjulian#define SPXT_NTIMERS 4 16911947Sjulian short s_timer[SPXT_NTIMERS]; /* timers */ 17011947Sjulian short s_rxtshift; /* log(2) of rexmt exp. backoff */ 17111947Sjulian short s_rxtcur; /* current retransmit value */ 17211947Sjulian u_short s_rtseq; /* packet being timed */ 17311947Sjulian short s_rtt; /* timer for round trips */ 17411947Sjulian short s_srtt; /* averaged timer */ 17511947Sjulian short s_rttvar; /* variance in round trip time */ 17611947Sjulian char s_force; /* which timer expired */ 17711947Sjulian char s_dupacks; /* counter to intuit xmt loss */ 17811947Sjulian 17911947Sjulian/* out of band data */ 18011947Sjulian char s_oobflags; 18111947Sjulian#define SF_SOOB 0x08 /* sending out of band data */ 18211947Sjulian#define SF_IOOB 0x10 /* receiving out of band data */ 18311947Sjulian char s_iobc; /* input characters */ 18411947Sjulian/* debug stuff */ 18511947Sjulian u_short s_want; /* Last candidate for sending */ 18611947Sjulian char s_outx; /* exit taken from spx_output */ 18711947Sjulian char s_inx; /* exit taken from spx_input */ 18811947Sjulian u_short s_flags2; /* more flags for testing */ 18911947Sjulian#define SF_NEWCALL 0x100 /* for new_recvmsg */ 19011947Sjulian#define SO_NEWCALL 10 /* for new_recvmsg */ 19111947Sjulian}; 19211947Sjulian 19311947Sjulian#define ipxtospxpcb(np) ((struct spxpcb *)(np)->ipxp_pcb) 19411947Sjulian#define sotospxpcb(so) (ipxtospxpcb(sotoipxpcb(so))) 19511947Sjulian 19655205Speter#ifdef _KERNEL 19726965Sjhay 19824659Sjhayextern struct pr_usrreqs spx_usrreqs; 19924659Sjhayextern struct pr_usrreqs spx_usrreq_sps; 20024659Sjhay 20192745Salfredvoid spx_ctlinput(int cmd, struct sockaddr *arg_as_sa, void *dummy); 20292745Salfredint spx_ctloutput(struct socket *so, struct sockopt *sopt); 20392745Salfredvoid spx_fasttimo(void); 20492745Salfredvoid spx_init(void); 20592745Salfredvoid spx_input(struct mbuf *m, struct ipxpcb *ipxp); 20692745Salfredvoid spx_slowtimo(void); 20711947Sjulian 20855205Speter#endif /* _KERNEL */ 20911947Sjulian 21026965Sjhay#endif /* !_NETIPX_SPX_H_ */ 211