1 /* $OpenBSD: spx.h,v 1.8 2003/10/26 17:01:11 avsm Exp $ */ 2 3 /*- 4 * 5 * Copyright (c) 1996 Michael Shalayeff 6 * Copyright (c) 1995, Mike Mitchell 7 * Copyright (c) 1984, 1985, 1986, 1987, 1993 8 * The Regents of the University of California. All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. 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 * from FreeBSD Id: spx.h,v 1.7 1996/01/30 22:58:51 mpp Exp 37 */ 38 39 #ifndef _NETIPX_SPX_H_ 40 #define _NETIPX_SPX_H_ 41 42 #include <sys/queue.h> 43 44 /* 45 * Definitions for IPX style Sequenced Packet Protocol 46 */ 47 48 struct spxhdr { 49 u_int8_t spx_cc __packed; /* connection control */ 50 u_int8_t spx_dt __packed; /* datastream type */ 51 #define SPX_SP 0x80 /* system packet */ 52 #define SPX_SA 0x40 /* send acknowledgement */ 53 #define SPX_OB 0x20 /* attention (out of band data) */ 54 #define SPX_EM 0x10 /* end of message */ 55 u_int16_t spx_sid __packed; /* source connection identifier */ 56 u_int16_t spx_did __packed; /* destination connection identifier */ 57 u_int16_t spx_seq __packed; /* sequence number */ 58 u_int16_t spx_ack __packed; /* acknowledge number */ 59 u_int16_t spx_alo __packed; /* allocation number */ 60 }; 61 62 /* 63 * Definitions for NS(tm) Internet Datagram Protocol 64 * containing a Sequenced Packet Protocol packet. 65 */ 66 struct spx { 67 struct ipx si_i __packed; 68 struct spxhdr si_s __packed; 69 }; 70 71 #define SI(x) ((struct spx *)x) 72 #define si_sum si_i.ipx_sum 73 #define si_len si_i.ipx_len 74 #define si_tc si_i.ipx_tc 75 #define si_pt si_i.ipx_pt 76 #define si_dna si_i.ipx_dna 77 #define si_sna si_i.ipx_sna 78 #define si_sport si_i.ipx_sna.ipx_port 79 #define si_cc si_s.spx_cc 80 #define si_dt si_s.spx_dt 81 #define si_sid si_s.spx_sid 82 #define si_did si_s.spx_did 83 #define si_seq si_s.spx_seq 84 #define si_ack si_s.spx_ack 85 #define si_alo si_s.spx_alo 86 87 struct spx_q { 88 TAILQ_ENTRY(spx_q) list; 89 struct mbuf *m; 90 }; 91 92 /* 93 * SPX control block, one per connection 94 */ 95 struct spxpcb { 96 TAILQ_HEAD(, spx_q) spxp_queue; 97 struct ipxpcb *s_ipxpcb; /* backpointer to ipx pcb */ 98 u_char s_state; 99 u_char s_flags; 100 #define SF_ACKNOW 0x01 /* Ack peer immediately */ 101 #define SF_DELACK 0x02 /* Ack, but try to delay it */ 102 #define SF_HI 0x04 /* Show headers on input */ 103 #define SF_HO 0x08 /* Show headers on output */ 104 #define SF_PI 0x10 /* Packet (datagram) interface */ 105 #define SF_WIN 0x20 /* Window info changed */ 106 #define SF_RXT 0x40 /* Rxt info changed */ 107 #define SF_RVD 0x80 /* Calling from read usrreq routine */ 108 u_short s_mtu; /* Max packet size for this stream */ 109 /* use sequence fields in headers to store sequence numbers for this 110 connection */ 111 struct ipx *s_ipx; 112 struct spxhdr s_shdr; /* prototype header to transmit */ 113 #define s_cc s_shdr.spx_cc /* connection control (for EM bit) */ 114 #define s_dt s_shdr.spx_dt /* datastream type */ 115 #define s_sid s_shdr.spx_sid /* source connection identifier */ 116 #define s_did s_shdr.spx_did /* destination connection identifier */ 117 #define s_seq s_shdr.spx_seq /* sequence number */ 118 #define s_ack s_shdr.spx_ack /* acknowledge number */ 119 #define s_alo s_shdr.spx_alo /* allocation number */ 120 #define s_dport s_ipx->ipx_dna.ipx_port /* where we are sending */ 121 struct spxhdr s_rhdr; /* last received header (in effect!)*/ 122 u_short s_rack; /* their acknowledge number */ 123 u_short s_ralo; /* their allocation number */ 124 u_short s_smax; /* highest packet # we have sent */ 125 u_short s_snxt; /* which packet to send next */ 126 127 /* congestion control */ 128 #define CUNIT 1024 /* scaling for ... */ 129 int s_cwnd; /* Congestion-controlled window */ 130 /* in packets * CUNIT */ 131 short s_swnd; /* == tcp snd_wnd, in packets */ 132 short s_smxw; /* == tcp max_sndwnd */ 133 /* difference of two spx_seq's can be 134 no bigger than a short */ 135 u_short s_swl1; /* == tcp snd_wl1 */ 136 u_short s_swl2; /* == tcp snd_wl2 */ 137 int s_cwmx; /* max allowable cwnd */ 138 int s_ssthresh; /* s_cwnd size threshold for 139 * slow start exponential-to- 140 * linear switch */ 141 /* transmit timing stuff 142 * srtt and rttvar are stored as fixed point, for convenience in smoothing. 143 * srtt has 3 bits to the right of the binary point, rttvar has 2. 144 */ 145 short s_idle; /* time idle */ 146 #define SPXT_NTIMERS 4 147 short s_timer[SPXT_NTIMERS]; /* timers */ 148 short s_rxtshift; /* log(2) of rexmt exp. backoff */ 149 short s_rxtcur; /* current retransmit value */ 150 u_short s_rtseq; /* packet being timed */ 151 short s_rtt; /* timer for round trips */ 152 short s_srtt; /* averaged timer */ 153 short s_rttvar; /* variance in round trip time */ 154 char s_force; /* which timer expired */ 155 char s_dupacks; /* counter to intuit xmt loss */ 156 157 /* out of band data */ 158 char s_oobflags; 159 #define SF_SOOB 0x08 /* sending out of band data */ 160 #define SF_IOOB 0x10 /* receiving out of band data */ 161 char s_iobc; /* input characters */ 162 /* debug stuff */ 163 u_short s_want; /* Last candidate for sending */ 164 char s_outx; /* exit taken from spx_output */ 165 char s_inx; /* exit taken from spx_input */ 166 u_short s_flags2; /* more flags for testing */ 167 #define SF_NEWCALL 0x100 /* for new_recvmsg */ 168 #define SO_NEWCALL 10 /* for new_recvmsg */ 169 }; 170 171 #define ipxtospxpcb(np) ((struct spxpcb *)(np)->ipxp_ppcb) 172 #define sotospxpcb(so) (ipxtospxpcb(sotoipxpcb(so))) 173 174 #ifdef _KERNEL 175 176 void spx_abort(struct ipxpcb *ipxp); 177 struct spxpcb *spx_close(struct spxpcb *cb); 178 void *spx_ctlinput(int cmd, struct sockaddr *arg_as_sa, void *dummy); 179 int spx_ctloutput(int req, struct socket *so, int level, int name, 180 struct mbuf **value); 181 struct spxpcb *spx_disconnect(struct spxpcb *cb); 182 struct spxpcb *spx_drop(struct spxpcb *cb, int errno); 183 void spx_fasttimo(void); 184 void spx_init(void); 185 void spx_input(struct mbuf *m, ...); 186 int spx_output(struct spxpcb *cb, struct mbuf *m0); 187 void spx_quench(struct ipxpcb *ipxp); 188 int spx_reass(struct spxpcb *cb, struct mbuf *m0); 189 void spx_setpersist(struct spxpcb *cb); 190 void spx_slowtimo(void); 191 void spx_template(struct spxpcb *cb); 192 struct spxpcb *spx_timers(struct spxpcb *cb, int timer); 193 struct spxpcb *spx_usrclosed(struct spxpcb *cb); 194 int spx_usrreq(struct socket *so, int req, struct mbuf *m, 195 struct mbuf *nam, struct mbuf *controlp); 196 int spx_usrreq_sp(struct socket *so, int req, struct mbuf *m, 197 struct mbuf *nam, struct mbuf *controlp); 198 int spx_sysctl(int *, u_int, void *, size_t *, void *, size_t); 199 200 #endif /* _KERNEL */ 201 202 #endif /* !_NETIPX_SPX_H_ */ 203