spx.h revision 13765
1/* 2 * Copyright (c) 1995, Mike Mitchell 3 * Copyright (c) 1984, 1985, 1986, 1987, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by the University of 17 * California, Berkeley and its contributors. 18 * 4. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)spx.h 35 * 36 * $Id: spx.h,v 1.6 1995/12/16 02:14:34 bde Exp $ 37 */ 38 39#ifndef _NETIPX_SPX_H_ 40#define _NETIPX_SPX_H_ 41 42/* 43 * Definitions for IPX style Sequenced Packet Protocol 44 */ 45 46struct spxhdr { 47 u_char spx_cc; /* connection control */ 48 u_char spx_dt; /* datastream type */ 49#define SPX_SP 0x80 /* system packet */ 50#define SPX_SA 0x40 /* send acknowledgement */ 51#define SPX_OB 0x20 /* attention (out of band data) */ 52#define SPX_EM 0x10 /* end of message */ 53 u_short spx_sid; /* source connection identifier */ 54 u_short spx_did; /* destination connection identifier */ 55 u_short spx_seq; /* sequence number */ 56 u_short spx_ack; /* acknowledge number */ 57 u_short spx_alo; /* allocation number */ 58}; 59 60/* 61 * Definitions for NS(tm) Internet Datagram Protocol 62 * containing a Sequenced Packet Protocol packet. 63 */ 64struct spx { 65 struct ipx si_i; 66 struct spxhdr si_s; 67}; 68struct spx_q { 69 struct spx_q *si_next; 70 struct spx_q *si_prev; 71}; 72#define SI(x) ((struct spx *)x) 73#define si_sum si_i.ipx_sum 74#define si_len si_i.ipx_len 75#define si_tc si_i.ipx_tc 76#define si_pt si_i.ipx_pt 77#define si_dna si_i.ipx_dna 78#define si_sna si_i.ipx_sna 79#define si_sport si_i.ipx_sna.x_port 80#define si_cc si_s.spx_cc 81#define si_dt si_s.spx_dt 82#define si_sid si_s.spx_sid 83#define si_did si_s.spx_did 84#define si_seq si_s.spx_seq 85#define si_ack si_s.spx_ack 86#define si_alo si_s.spx_alo 87 88/* 89 * SPX control block, one per connection 90 */ 91struct spxpcb { 92 struct spx_q s_q; /* queue for out-of-order receipt */ 93 struct ipxpcb *s_ipxpcb; /* backpointer to internet pcb */ 94 u_char s_state; 95 u_char s_flags; 96#define SF_ACKNOW 0x01 /* Ack peer immediately */ 97#define SF_DELACK 0x02 /* Ack, but try to delay it */ 98#define SF_HI 0x04 /* Show headers on input */ 99#define SF_HO 0x08 /* Show headers on output */ 100#define SF_PI 0x10 /* Packet (datagram) interface */ 101#define SF_WIN 0x20 /* Window info changed */ 102#define SF_RXT 0x40 /* Rxt info changed */ 103#define SF_RVD 0x80 /* Calling from read usrreq routine */ 104 u_short s_mtu; /* Max packet size for this stream */ 105/* use sequence fields in headers to store sequence numbers for this 106 connection */ 107 struct ipx *s_ipx; 108 struct spxhdr s_shdr; /* prototype header to transmit */ 109#define s_cc s_shdr.spx_cc /* connection control (for EM bit) */ 110#define s_dt s_shdr.spx_dt /* datastream type */ 111#define s_sid s_shdr.spx_sid /* source connection identifier */ 112#define s_did s_shdr.spx_did /* destination connection identifier */ 113#define s_seq s_shdr.spx_seq /* sequence number */ 114#define s_ack s_shdr.spx_ack /* acknowledge number */ 115#define s_alo s_shdr.spx_alo /* allocation number */ 116#define s_dport s_ipx->ipx_dna.x_port /* where we are sending */ 117 struct spxhdr s_rhdr; /* last received header (in effect!)*/ 118 u_short s_rack; /* their acknowledge number */ 119 u_short s_ralo; /* their allocation number */ 120 u_short s_smax; /* highest packet # we have sent */ 121 u_short s_snxt; /* which packet to send next */ 122 123/* congestion control */ 124#define CUNIT 1024 /* scaling for ... */ 125 int s_cwnd; /* Congestion-controlled window */ 126 /* in packets * CUNIT */ 127 short s_swnd; /* == tcp snd_wnd, in packets */ 128 short s_smxw; /* == tcp max_sndwnd */ 129 /* difference of two spx_seq's can be 130 no bigger than a short */ 131 u_short s_swl1; /* == tcp snd_wl1 */ 132 u_short s_swl2; /* == tcp snd_wl2 */ 133 int s_cwmx; /* max allowable cwnd */ 134 int s_ssthresh; /* s_cwnd size threshold for 135 * slow start exponential-to- 136 * linear switch */ 137/* transmit timing stuff 138 * srtt and rttvar are stored as fixed point, for convenience in smoothing. 139 * srtt has 3 bits to the right of the binary point, rttvar has 2. 140 */ 141 short s_idle; /* time idle */ 142#define SPXT_NTIMERS 4 143 short s_timer[SPXT_NTIMERS]; /* timers */ 144 short s_rxtshift; /* log(2) of rexmt exp. backoff */ 145 short s_rxtcur; /* current retransmit value */ 146 u_short s_rtseq; /* packet being timed */ 147 short s_rtt; /* timer for round trips */ 148 short s_srtt; /* averaged timer */ 149 short s_rttvar; /* variance in round trip time */ 150 char s_force; /* which timer expired */ 151 char s_dupacks; /* counter to intuit xmt loss */ 152 153/* out of band data */ 154 char s_oobflags; 155#define SF_SOOB 0x08 /* sending out of band data */ 156#define SF_IOOB 0x10 /* receiving out of band data */ 157 char s_iobc; /* input characters */ 158/* debug stuff */ 159 u_short s_want; /* Last candidate for sending */ 160 char s_outx; /* exit taken from spx_output */ 161 char s_inx; /* exit taken from spx_input */ 162 u_short s_flags2; /* more flags for testing */ 163#define SF_NEWCALL 0x100 /* for new_recvmsg */ 164#define SO_NEWCALL 10 /* for new_recvmsg */ 165}; 166 167#define ipxtospxpcb(np) ((struct spxpcb *)(np)->ipxp_pcb) 168#define sotospxpcb(so) (ipxtospxpcb(sotoipxpcb(so))) 169 170#ifdef KERNEL 171 172void spx_abort __P((struct ipxpcb *ipxp)); 173struct spxpcb * 174 spx_close __P((struct spxpcb *cb)); 175void spx_ctlinput __P((int cmd, struct sockaddr *arg_as_sa, void *dummy)); 176int spx_ctloutput __P((int req, struct socket *so, int level, int name, 177 struct mbuf **value)); 178struct spxpcb * 179 spx_disconnect __P((struct spxpcb *cb)); 180struct spxpcb * 181 spx_drop __P((struct spxpcb *cb, int errno)); 182void spx_fasttimo __P((void)); 183void spx_init __P((void)); 184void spx_input __P((struct mbuf *m, struct ipxpcb *ipxp)); 185int spx_output __P((struct spxpcb *cb, struct mbuf *m0)); 186void spx_quench __P((struct ipxpcb *ipxp)); 187int spx_reass __P((struct spxpcb *cb, struct spx *si)); 188void spx_setpersist __P((struct spxpcb *cb)); 189void spx_slowtimo __P((void)); 190void spx_template __P((struct spxpcb *cb)); 191struct spxpcb * 192 spx_timers __P((struct spxpcb *cb, int timer)); 193struct spxpcb * 194 spx_usrclosed __P((struct spxpcb *cb)); 195int spx_usrreq __P((struct socket *so, int req, struct mbuf *m, 196 struct mbuf *nam, struct mbuf *controlp)); 197int spx_usrreq_sp __P((struct socket *so, int req, struct mbuf *m, 198 struct mbuf *nam, struct mbuf *controlp)); 199 200#endif /* KERNEL */ 201 202#endif /* !_NETIPX_SPX_H_ */ 203