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.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/malloc.h>
44 #include <sys/protosw.h>
45 #include <sys/socket.h>
46 #include <sys/socketvar.h>
48 #include <net/route.h>
49 #include <netinet/tcp_fsm.h>
51 #include <netipx/ipx.h>
52 #include <netipx/ipx_pcb.h>
53 #include <netipx/ipx_var.h>
54 #include <netipx/spx.h>
55 #include <netipx/spx_timer.h>
56 #include <netipx/spx_var.h>
57 #include <netipx/spx_debug.h>
60 * SPX protocol implementation.
62 static u_short spx_iss;
63 static u_short spx_newchecks[50];
64 static int spx_hardnosed;
65 static int spx_use_delack = 0;
66 static int traceallspxs = 0;
67 static struct spx spx_savesi;
68 static struct spx_istat spx_istat;
70 /* Following was struct spxstat spxstat; */
72 #define spxstat spx_istat.newstats
75 static int spx_backoff[SPX_MAXRXTSHIFT+1] =
76 { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
78 static struct spxpcb *spx_close(struct spxpcb *cb);
79 static struct spxpcb *spx_disconnect(struct spxpcb *cb);
80 static struct spxpcb *spx_drop(struct spxpcb *cb, int errno);
81 static int spx_output(struct spxpcb *cb, struct mbuf *m0);
82 static int spx_reass(struct spxpcb *cb, struct spx *si);
83 static void spx_setpersist(struct spxpcb *cb);
84 static void spx_template(struct spxpcb *cb);
85 static struct spxpcb *spx_timers(struct spxpcb *cb, int timer);
86 static struct spxpcb *spx_usrclosed(struct spxpcb *cb);
88 static int spx_usr_abort(struct socket *so);
89 static int spx_accept(struct socket *so, struct sockaddr **nam);
90 static int spx_attach(struct socket *so, int proto, struct proc *p);
91 static int spx_bind(struct socket *so, struct sockaddr *nam, struct proc *p);
92 static int spx_connect(struct socket *so, struct sockaddr *nam,
94 static int spx_detach(struct socket *so);
95 static int spx_usr_disconnect(struct socket *so);
96 static int spx_listen(struct socket *so, struct proc *p);
97 static int spx_rcvd(struct socket *so, int flags);
98 static int spx_rcvoob(struct socket *so, struct mbuf *m, int flags);
99 static int spx_send(struct socket *so, int flags, struct mbuf *m,
100 struct sockaddr *addr, struct mbuf *control,
102 static int spx_shutdown(struct socket *so);
103 static int spx_sp_attach(struct socket *so, int proto, struct proc *p);
105 struct pr_usrreqs spx_usrreqs = {
106 spx_usr_abort, spx_accept, spx_attach, spx_bind,
107 spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
108 spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
109 spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
110 ipx_sockaddr, sosend, soreceive, sopoll
113 struct pr_usrreqs spx_usrreq_sps = {
114 spx_usr_abort, spx_accept, spx_sp_attach, spx_bind,
115 spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
116 spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
117 spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
118 ipx_sockaddr, sosend, soreceive, sopoll
125 spx_iss = 1; /* WRONG !! should fish it out of TODR */
130 register struct mbuf *m;
131 register struct ipxpcb *ipxp;
133 register struct spxpcb *cb;
134 register struct spx *si = mtod(m, struct spx *);
135 register struct socket *so;
139 spxstat.spxs_rcvtotal++;
141 panic("No ipxpcb in spx_input\n");
145 cb = ipxtospxpcb(ipxp);
149 if (m->m_len < sizeof(*si)) {
150 if ((m = m_pullup(m, sizeof(*si))) == NULL) {
151 spxstat.spxs_rcvshort++;
154 si = mtod(m, struct spx *);
156 si->si_seq = ntohs(si->si_seq);
157 si->si_ack = ntohs(si->si_ack);
158 si->si_alo = ntohs(si->si_alo);
160 so = ipxp->ipxp_socket;
162 if (so->so_options & SO_DEBUG || traceallspxs) {
163 ostate = cb->s_state;
166 if (so->so_options & SO_ACCEPTCONN) {
167 struct spxpcb *ocb = cb;
169 so = sonewconn(so, 0);
174 * This is ugly, but ....
176 * Mark socket as temporary until we're
177 * committed to keeping it. The code at
178 * ``drop'' and ``dropwithreset'' check the
179 * flag dropsocket to see if the temporary
180 * socket created here should be discarded.
181 * We mark the socket as discardable until
182 * we're committed to it below in TCPS_LISTEN.
185 ipxp = (struct ipxpcb *)so->so_pcb;
186 ipxp->ipxp_laddr = si->si_dna;
187 cb = ipxtospxpcb(ipxp);
188 cb->s_mtu = ocb->s_mtu; /* preserve sockopts */
189 cb->s_flags = ocb->s_flags; /* preserve sockopts */
190 cb->s_flags2 = ocb->s_flags2; /* preserve sockopts */
191 cb->s_state = TCPS_LISTEN;
195 * Packet received on connection.
196 * reset idle time and keep-alive timer;
199 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
201 switch (cb->s_state) {
204 struct sockaddr_ipx *sipx, ssipx;
205 struct ipx_addr laddr;
208 * If somebody here was carying on a conversation
209 * and went away, and his pen pal thinks he can
210 * still talk, we get the misdirected packet.
212 if (spx_hardnosed && (si->si_did != 0 || si->si_seq != 0)) {
217 bzero(sipx, sizeof *sipx);
218 sipx->sipx_len = sizeof(*sipx);
219 sipx->sipx_family = AF_IPX;
220 sipx->sipx_addr = si->si_sna;
221 laddr = ipxp->ipxp_laddr;
222 if (ipx_nullhost(laddr))
223 ipxp->ipxp_laddr = si->si_dna;
224 if (ipx_pcbconnect(ipxp, (struct sockaddr *)sipx, &proc0)) {
225 ipxp->ipxp_laddr = laddr;
230 dropsocket = 0; /* committed to socket */
231 cb->s_did = si->si_sid;
232 cb->s_rack = si->si_ack;
233 cb->s_ralo = si->si_alo;
234 #define THREEWAYSHAKE
236 cb->s_state = TCPS_SYN_RECEIVED;
237 cb->s_force = 1 + SPXT_KEEP;
238 spxstat.spxs_accepts++;
239 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
243 * This state means that we have heard a response
244 * to our acceptance of their connection
245 * It is probably logically unnecessary in this
248 case TCPS_SYN_RECEIVED: {
249 if (si->si_did != cb->s_sid) {
254 ipxp->ipxp_fport = si->si_sport;
255 cb->s_timer[SPXT_REXMT] = 0;
256 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
258 cb->s_state = TCPS_ESTABLISHED;
259 spxstat.spxs_accepts++;
264 * This state means that we have gotten a response
265 * to our attempt to establish a connection.
266 * We fill in the data from the other side,
267 * telling us which port to respond to, instead of the well-
268 * known one we might have sent to in the first place.
269 * We also require that this is a response to our
273 if (si->si_did != cb->s_sid) {
277 spxstat.spxs_connects++;
278 cb->s_did = si->si_sid;
279 cb->s_rack = si->si_ack;
280 cb->s_ralo = si->si_alo;
281 cb->s_dport = ipxp->ipxp_fport = si->si_sport;
282 cb->s_timer[SPXT_REXMT] = 0;
283 cb->s_flags |= SF_ACKNOW;
285 cb->s_state = TCPS_ESTABLISHED;
286 /* Use roundtrip time of connection request for initial rtt */
288 cb->s_srtt = cb->s_rtt << 3;
289 cb->s_rttvar = cb->s_rtt << 1;
290 SPXT_RANGESET(cb->s_rxtcur,
291 ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
292 SPXTV_MIN, SPXTV_REXMTMAX);
296 if (so->so_options & SO_DEBUG || traceallspxs)
297 spx_trace(SA_INPUT, (u_char)ostate, cb, &spx_savesi, 0);
299 m->m_len -= sizeof(struct ipx);
300 m->m_pkthdr.len -= sizeof(struct ipx);
301 m->m_data += sizeof(struct ipx);
303 if (spx_reass(cb, si)) {
306 if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT)))
307 spx_output(cb, (struct mbuf *)NULL);
308 cb->s_flags &= ~(SF_WIN|SF_RXT);
314 si->si_seq = ntohs(si->si_seq);
315 si->si_ack = ntohs(si->si_ack);
316 si->si_alo = ntohs(si->si_alo);
318 if (cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG || traceallspxs)
319 spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0);
324 if (cb == 0 || cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG ||
326 spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0);
330 static int spxrexmtthresh = 3;
333 * This is structurally similar to the tcp reassembly routine
334 * but its function is somewhat different: It merely queues
335 * packets up, and suppresses duplicates.
339 register struct spxpcb *cb;
340 register struct spx *si;
342 register struct spx_q *q;
343 register struct mbuf *m;
344 register struct socket *so = cb->s_ipxpcb->ipxp_socket;
345 char packetp = cb->s_flags & SF_HI;
352 * Update our news from them.
354 if (si->si_cc & SPX_SA)
355 cb->s_flags |= (spx_use_delack ? SF_DELACK : SF_ACKNOW);
356 if (SSEQ_GT(si->si_alo, cb->s_ralo))
357 cb->s_flags |= SF_WIN;
358 if (SSEQ_LEQ(si->si_ack, cb->s_rack)) {
359 if ((si->si_cc & SPX_SP) && cb->s_rack != (cb->s_smax + 1)) {
360 spxstat.spxs_rcvdupack++;
362 * If this is a completely duplicate ack
363 * and other conditions hold, we assume
364 * a packet has been dropped and retransmit
365 * it exactly as in tcp_input().
367 if (si->si_ack != cb->s_rack ||
368 si->si_alo != cb->s_ralo)
370 else if (++cb->s_dupacks == spxrexmtthresh) {
371 u_short onxt = cb->s_snxt;
372 int cwnd = cb->s_cwnd;
374 cb->s_snxt = si->si_ack;
376 cb->s_force = 1 + SPXT_REXMT;
377 spx_output(cb, (struct mbuf *)NULL);
378 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
380 if (cwnd >= 4 * CUNIT)
381 cb->s_cwnd = cwnd / 2;
382 if (SSEQ_GT(onxt, cb->s_snxt))
392 * If our correspondent acknowledges data we haven't sent
393 * TCP would drop the packet after acking. We'll be a little
396 if (SSEQ_GT(si->si_ack, (cb->s_smax + 1))) {
397 spxstat.spxs_rcvacktoomuch++;
398 si->si_ack = cb->s_smax + 1;
400 spxstat.spxs_rcvackpack++;
402 * If transmit timer is running and timed sequence
403 * number was acked, update smoothed round trip time.
404 * See discussion of algorithm in tcp_input.c
406 if (cb->s_rtt && SSEQ_GT(si->si_ack, cb->s_rtseq)) {
407 spxstat.spxs_rttupdated++;
408 if (cb->s_srtt != 0) {
409 register short delta;
410 delta = cb->s_rtt - (cb->s_srtt >> 3);
411 if ((cb->s_srtt += delta) <= 0)
415 delta -= (cb->s_rttvar >> 2);
416 if ((cb->s_rttvar += delta) <= 0)
420 * No rtt measurement yet
422 cb->s_srtt = cb->s_rtt << 3;
423 cb->s_rttvar = cb->s_rtt << 1;
427 SPXT_RANGESET(cb->s_rxtcur,
428 ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
429 SPXTV_MIN, SPXTV_REXMTMAX);
432 * If all outstanding data is acked, stop retransmit
433 * timer and remember to restart (more output or persist).
434 * If there is more data to be acked, restart retransmit
435 * timer, using current (possibly backed-off) value;
437 if (si->si_ack == cb->s_smax + 1) {
438 cb->s_timer[SPXT_REXMT] = 0;
439 cb->s_flags |= SF_RXT;
440 } else if (cb->s_timer[SPXT_PERSIST] == 0)
441 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
443 * When new data is acked, open the congestion window.
444 * If the window gives us less than ssthresh packets
445 * in flight, open exponentially (maxseg at a time).
446 * Otherwise open linearly (maxseg^2 / cwnd at a time).
449 if (cb->s_cwnd > cb->s_ssthresh)
450 incr = max(incr * incr / cb->s_cwnd, 1);
451 cb->s_cwnd = min(cb->s_cwnd + incr, cb->s_cwmx);
453 * Trim Acked data from output queue.
455 while ((m = so->so_snd.sb_mb) != NULL) {
456 if (SSEQ_LT((mtod(m, struct spx *))->si_seq, si->si_ack))
457 sbdroprecord(&so->so_snd);
462 cb->s_rack = si->si_ack;
464 if (SSEQ_LT(cb->s_snxt, cb->s_rack))
465 cb->s_snxt = cb->s_rack;
466 if (SSEQ_LT(cb->s_swl1, si->si_seq) || ((cb->s_swl1 == si->si_seq &&
467 (SSEQ_LT(cb->s_swl2, si->si_ack))) ||
468 (cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo)))) {
469 /* keep track of pure window updates */
470 if ((si->si_cc & SPX_SP) && cb->s_swl2 == si->si_ack
471 && SSEQ_LT(cb->s_ralo, si->si_alo)) {
472 spxstat.spxs_rcvwinupd++;
473 spxstat.spxs_rcvdupack--;
475 cb->s_ralo = si->si_alo;
476 cb->s_swl1 = si->si_seq;
477 cb->s_swl2 = si->si_ack;
478 cb->s_swnd = (1 + si->si_alo - si->si_ack);
479 if (cb->s_swnd > cb->s_smxw)
480 cb->s_smxw = cb->s_swnd;
481 cb->s_flags |= SF_WIN;
484 * If this packet number is higher than that which
485 * we have allocated refuse it, unless urgent
487 if (SSEQ_GT(si->si_seq, cb->s_alo)) {
488 if (si->si_cc & SPX_SP) {
489 spxstat.spxs_rcvwinprobe++;
492 spxstat.spxs_rcvpackafterwin++;
493 if (si->si_cc & SPX_OB) {
494 if (SSEQ_GT(si->si_seq, cb->s_alo + 60)) {
497 } /* else queue this packet; */
499 /*register struct socket *so = cb->s_ipxpcb->ipxp_socket;
500 if (so->so_state && SS_NOFDREF) {
510 * If this is a system packet, we don't need to
511 * queue it up, and won't update acknowledge #
513 if (si->si_cc & SPX_SP) {
517 * We have already seen this packet, so drop.
519 if (SSEQ_LT(si->si_seq, cb->s_ack)) {
521 spxstat.spxs_rcvduppack++;
522 if (si->si_seq == cb->s_ack - 1)
527 * Loop through all packets queued up to insert in
528 * appropriate sequence.
530 for (q = cb->s_q.si_next; q != &cb->s_q; q = q->si_next) {
531 if (si->si_seq == SI(q)->si_seq) {
532 spxstat.spxs_rcvduppack++;
535 if (SSEQ_LT(si->si_seq, SI(q)->si_seq)) {
536 spxstat.spxs_rcvoopack++;
540 insque(si, q->si_prev);
542 * If this packet is urgent, inform process
544 if (si->si_cc & SPX_OB) {
545 cb->s_iobc = ((char *)si)[1 + sizeof(*si)];
547 cb->s_oobflags |= SF_IOOB;
550 #define SPINC sizeof(struct spxhdr)
552 * Loop through all packets queued up to update acknowledge
553 * number, and present all acknowledged data to user;
554 * If in packet interface mode, show packet headers.
556 for (q = cb->s_q.si_next; q != &cb->s_q; q = q->si_next) {
557 if (SI(q)->si_seq == cb->s_ack) {
560 if (SI(q)->si_cc & SPX_OB) {
561 cb->s_oobflags &= ~SF_IOOB;
562 if (so->so_rcv.sb_cc)
563 so->so_oobmark = so->so_rcv.sb_cc;
565 so->so_state |= SS_RCVATMARK;
570 spxstat.spxs_rcvpack++;
572 if (cb->s_flags2 & SF_NEWCALL) {
573 struct spxhdr *sp = mtod(m, struct spxhdr *);
574 u_char dt = sp->spx_dt;
576 if (dt != cb->s_rhdr.spx_dt) {
578 m_getclr(M_DONTWAIT, MT_CONTROL);
583 cb->s_rhdr.spx_dt = dt;
584 mm->m_len = 5; /*XXX*/
587 *(u_char *)(&s[2]) = dt;
588 sbappend(&so->so_rcv, mm);
591 if (sp->spx_cc & SPX_OB) {
592 MCHTYPE(m, MT_OOBDATA);
595 so->so_state &= ~SS_RCVATMARK;
600 m->m_pkthdr.len -= SPINC;
602 if ((sp->spx_cc & SPX_EM) || packetp) {
603 sbappendrecord(&so->so_rcv, m);
606 sbappend(&so->so_rcv, m);
610 sbappendrecord(&so->so_rcv, m);
612 cb->s_rhdr = *mtod(m, struct spxhdr *);
615 m->m_pkthdr.len -= SPINC;
616 sbappend(&so->so_rcv, m);
627 spx_ctlinput(cmd, arg_as_sa, dummy)
629 struct sockaddr *arg_as_sa; /* XXX should be swapped with dummy */
632 caddr_t arg = (/* XXX */ caddr_t)arg_as_sa;
634 struct sockaddr_ipx *sipx;
636 if (cmd < 0 || cmd > PRC_NCMDS)
646 case PRC_HOSTUNREACH:
647 sipx = (struct sockaddr_ipx *)arg;
648 if (sipx->sipx_family != AF_IPX)
650 na = &sipx->sipx_addr;
661 register struct ipxpcb *ipxp;
663 register struct spxpcb *cb = (struct spxpcb *)(ipxp->ipxp_pcb);
664 register struct mbuf *m;
665 register struct spx *si;
669 struct mbuf *firstbad, *m0;
673 * The notification that we have sent
674 * too much is bad news -- we will
675 * have to go through queued up so far
676 * splitting ones which are too big and
677 * reassigning sequence numbers and checksums.
678 * we should then retransmit all packets from
679 * one above the offending packet to the last one
680 * we had sent (or our allocation)
681 * then the offending one so that the any queued
682 * data at our destination will be discarded.
684 ep = (struct ipx_errp *)ipxp->ipxp_notify_param;
685 sb = &ipxp->ipxp_socket->so_snd;
686 cb->s_mtu = ep->ipx_err_param;
687 badseq = SI(&ep->ipx_err_ipx)->si_seq;
688 for (m = sb->sb_mb; m != NULL; m = m->m_act) {
689 si = mtod(m, struct spx *);
690 if (si->si_seq == badseq)
697 /* calculate length */
698 for (m0 = m, len = 0; m != NULL; m = m->m_next)
700 if (len > cb->s_mtu) {
710 register struct spxpcb *cb;
713 struct socket *so = cb->s_ipxpcb->ipxp_socket;
714 register struct mbuf *m;
715 register struct spx *si = (struct spx *)NULL;
716 register struct sockbuf *sb = &so->so_snd;
717 int len = 0, win, rcv_win;
718 short span, off, recordp = 0;
720 int error = 0, sendalot;
730 * Make sure that packet isn't too big.
732 for (m = m0; m != NULL; m = m->m_next) {
735 if (m->m_flags & M_EOR)
738 datalen = (cb->s_flags & SF_HO) ?
739 len - sizeof(struct spxhdr) : len;
741 if (cb->s_flags & SF_PI) {
745 int oldEM = cb->s_cc & SPX_EM;
750 * Here we are only being called
751 * from usrreq(), so it is OK to
754 m = m_copym(m0, 0, mtu, M_WAIT);
755 if (cb->s_flags & SF_NEWCALL) {
759 mm->m_flags &= ~M_EOR;
763 error = spx_output(cb, m);
776 * Force length even, by adding a "garbage byte" if
781 if (M_TRAILINGSPACE(m) >= 1)
784 struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);
791 *(mtod(m1, u_char *)) = 0;
795 m = m_gethdr(M_DONTWAIT, MT_HEADER);
801 * Fill in mbuf with extended SP header
802 * and addresses and length put into network format.
804 MH_ALIGN(m, sizeof(struct spx));
805 m->m_len = sizeof(struct spx);
807 si = mtod(m, struct spx *);
808 si->si_i = *cb->s_ipx;
809 si->si_s = cb->s_shdr;
810 if ((cb->s_flags & SF_PI) && (cb->s_flags & SF_HO)) {
811 register struct spxhdr *sh;
812 if (m0->m_len < sizeof(*sh)) {
813 if((m0 = m_pullup(m0, sizeof(*sh))) == NULL) {
820 sh = mtod(m0, struct spxhdr *);
821 si->si_dt = sh->spx_dt;
822 si->si_cc |= sh->spx_cc & SPX_EM;
823 m0->m_len -= sizeof(*sh);
824 m0->m_data += sizeof(*sh);
828 if ((cb->s_flags2 & SF_NEWCALL) && recordp) {
832 if (cb->s_oobflags & SF_SOOB) {
835 * make sure OB packets convey exactly 1 byte.
836 * If the packet is 1 byte or larger, we
837 * have already guaranted there to be at least
838 * one garbage byte for the checksum, and
839 * extra bytes shouldn't hurt!
841 if (len > sizeof(*si)) {
843 len = (1 + sizeof(*si));
846 si->si_len = htons((u_short)len);
847 m->m_pkthdr.len = ((len - 1) | 1) + 1;
849 * queue stuff up for output
851 sbappendrecord(sb, m);
855 idle = (cb->s_smax == (cb->s_rack - 1));
859 off = cb->s_snxt - cb->s_rack;
860 win = min(cb->s_swnd, (cb->s_cwnd / CUNIT));
863 * If in persist timeout with window of 0, send a probe.
864 * Otherwise, if window is small but nonzero
865 * and timer expired, send what we can and go into
868 if (cb->s_force == 1 + SPXT_PERSIST) {
870 cb->s_timer[SPXT_PERSIST] = 0;
874 span = cb->s_seq - cb->s_rack;
875 len = min(span, win) - off;
879 * Window shrank after we went into it.
880 * If window shrank to 0, cancel pending
881 * restransmission and pull s_snxt back
882 * to (closed) window. We will enter persist
883 * state below. If the widndow didn't close completely,
884 * just wait for an ACK.
888 cb->s_timer[SPXT_REXMT] = 0;
889 cb->s_snxt = cb->s_rack;
894 rcv_win = sbspace(&so->so_rcv);
897 * Send if we owe peer an ACK.
899 if (cb->s_oobflags & SF_SOOB) {
901 * must transmit this out of band packet
903 cb->s_oobflags &= ~ SF_SOOB;
905 spxstat.spxs_sndurg++;
908 if (cb->s_flags & SF_ACKNOW)
910 if (cb->s_state < TCPS_ESTABLISHED)
913 * Silly window can't happen in spx.
914 * Code from tcp deleted.
919 * Compare available window to amount of window
920 * known to peer (as advertised window less
921 * next expected input.) If the difference is at least two
922 * packets or at least 35% of the mximum possible window,
923 * then want to send a window update to peer.
926 u_short delta = 1 + cb->s_alo - cb->s_ack;
927 int adv = rcv_win - (delta * cb->s_mtu);
929 if ((so->so_rcv.sb_cc == 0 && adv >= (2 * cb->s_mtu)) ||
930 (100 * adv / so->so_rcv.sb_hiwat >= 35)) {
931 spxstat.spxs_sndwinup++;
932 cb->s_flags |= SF_ACKNOW;
938 * Many comments from tcp_output.c are appropriate here
940 * If send window is too small, there is data to transmit, and no
941 * retransmit or persist is pending, then go to persist state.
942 * If nothing happens soon, send when timer expires:
943 * if window is nonzero, transmit what we can,
944 * otherwise send a probe.
946 if (so->so_snd.sb_cc && cb->s_timer[SPXT_REXMT] == 0 &&
947 cb->s_timer[SPXT_PERSIST] == 0) {
952 * No reason to send a packet, just return.
959 * Find requested packet.
963 cb->s_want = cb->s_snxt;
964 for (m = sb->sb_mb; m != NULL; m = m->m_act) {
965 si = mtod(m, struct spx *);
966 if (SSEQ_LEQ(cb->s_snxt, si->si_seq))
971 if (si->si_seq == cb->s_snxt)
974 spxstat.spxs_sndvoid++, si = 0;
982 alo = cb->s_ack - 1 + (rcv_win / ((short)cb->s_mtu));
983 if (SSEQ_LT(alo, cb->s_alo))
988 * must make a copy of this packet for
989 * ipx_output to monkey with
991 m = m_copy(dtom(si), 0, (int)M_COPYALL);
995 si = mtod(m, struct spx *);
996 if (SSEQ_LT(si->si_seq, cb->s_smax))
997 spxstat.spxs_sndrexmitpack++;
999 spxstat.spxs_sndpack++;
1000 } else if (cb->s_force || cb->s_flags & SF_ACKNOW) {
1002 * Must send an acknowledgement or a probe
1005 spxstat.spxs_sndprobe++;
1006 if (cb->s_flags & SF_ACKNOW)
1007 spxstat.spxs_sndacks++;
1008 m = m_gethdr(M_DONTWAIT, MT_HEADER);
1012 * Fill in mbuf with extended SP header
1013 * and addresses and length put into network format.
1015 MH_ALIGN(m, sizeof(struct spx));
1016 m->m_len = sizeof(*si);
1017 m->m_pkthdr.len = sizeof(*si);
1018 si = mtod(m, struct spx *);
1019 si->si_i = *cb->s_ipx;
1020 si->si_s = cb->s_shdr;
1021 si->si_seq = cb->s_smax + 1;
1022 si->si_len = htons(sizeof(*si));
1023 si->si_cc |= SPX_SP;
1026 if (so->so_options & SO_DEBUG || traceallspxs)
1027 spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
1031 * Stuff checksum and output datagram.
1033 if ((si->si_cc & SPX_SP) == 0) {
1034 if (cb->s_force != (1 + SPXT_PERSIST) ||
1035 cb->s_timer[SPXT_PERSIST] == 0) {
1037 * If this is a new packet and we are not currently
1038 * timing anything, time this one.
1040 if (SSEQ_LT(cb->s_smax, si->si_seq)) {
1041 cb->s_smax = si->si_seq;
1042 if (cb->s_rtt == 0) {
1043 spxstat.spxs_segstimed++;
1044 cb->s_rtseq = si->si_seq;
1049 * Set rexmt timer if not currently set,
1050 * Initial value for retransmit timer is smoothed
1051 * round-trip time + 2 * round-trip time variance.
1052 * Initialize shift counter which is used for backoff
1053 * of retransmit time.
1055 if (cb->s_timer[SPXT_REXMT] == 0 &&
1056 cb->s_snxt != cb->s_rack) {
1057 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1058 if (cb->s_timer[SPXT_PERSIST]) {
1059 cb->s_timer[SPXT_PERSIST] = 0;
1063 } else if (SSEQ_LT(cb->s_smax, si->si_seq)) {
1064 cb->s_smax = si->si_seq;
1066 } else if (cb->s_state < TCPS_ESTABLISHED) {
1068 cb->s_rtt = 1; /* Time initial handshake */
1069 if (cb->s_timer[SPXT_REXMT] == 0)
1070 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1074 * Do not request acks when we ack their data packets or
1075 * when we do a gratuitous window update.
1077 if (((si->si_cc & SPX_SP) == 0) || cb->s_force)
1078 si->si_cc |= SPX_SA;
1079 si->si_seq = htons(si->si_seq);
1080 si->si_alo = htons(alo);
1081 si->si_ack = htons(cb->s_ack);
1084 si->si_sum = ipx_cksum(m, ntohs(si->si_len));
1086 si->si_sum = 0xffff;
1089 if (so->so_options & SO_DEBUG || traceallspxs)
1090 spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
1092 if (so->so_options & SO_DONTROUTE)
1093 error = ipx_outputfl(m, (struct route *)NULL, IPX_ROUTETOIF);
1095 error = ipx_outputfl(m, &cb->s_ipxpcb->ipxp_route, 0);
1100 spxstat.spxs_sndtotal++;
1102 * Data sent (as far as we can tell).
1103 * If this advertises a larger window than any other segment,
1104 * then remember the size of the advertized window.
1105 * Any pending ACK has now been sent.
1108 cb->s_flags &= ~(SF_ACKNOW|SF_DELACK);
1109 if (SSEQ_GT(alo, cb->s_alo))
1117 static int spx_do_persist_panics = 0;
1121 register struct spxpcb *cb;
1123 register int t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
1125 if (cb->s_timer[SPXT_REXMT] && spx_do_persist_panics)
1126 panic("spx_output REXMT");
1128 * Start/restart persistance timer.
1130 SPXT_RANGESET(cb->s_timer[SPXT_PERSIST],
1131 t*spx_backoff[cb->s_rxtshift],
1132 SPXTV_PERSMIN, SPXTV_PERSMAX);
1133 if (cb->s_rxtshift < SPX_MAXRXTSHIFT)
1138 spx_ctloutput(so, sopt)
1140 struct sockopt *sopt;
1142 struct ipxpcb *ipxp = sotoipxpcb(so);
1143 register struct spxpcb *cb;
1151 if (sopt->sopt_level != IPXPROTO_SPX) {
1152 /* This will have to be changed when we do more general
1153 stacking of protocols */
1154 return (ipx_ctloutput(so, sopt));
1159 cb = ipxtospxpcb(ipxp);
1161 switch (sopt->sopt_dir) {
1163 switch (sopt->sopt_name) {
1164 case SO_HEADERS_ON_INPUT:
1168 case SO_HEADERS_ON_OUTPUT:
1171 soptval = cb->s_flags & mask;
1172 error = sooptcopyout(sopt, &soptval, sizeof soptval);
1176 usoptval = cb->s_mtu;
1177 error = sooptcopyout(sopt, &usoptval, sizeof usoptval);
1180 case SO_LAST_HEADER:
1181 error = sooptcopyout(sopt, &cb->s_rhdr,
1185 case SO_DEFAULT_HEADERS:
1186 error = sooptcopyout(sopt, &cb->s_shdr,
1191 error = ENOPROTOOPT;
1196 switch (sopt->sopt_name) {
1197 /* XXX why are these shorts on get and ints on set?
1198 that doesn't make any sense... */
1199 case SO_HEADERS_ON_INPUT:
1203 case SO_HEADERS_ON_OUTPUT:
1206 error = sooptcopyin(sopt, &optval, sizeof optval,
1211 if (cb->s_flags & SF_PI) {
1213 cb->s_flags |= mask;
1215 cb->s_flags &= ~mask;
1216 } else error = EINVAL;
1220 error = sooptcopyin(sopt, &usoptval, sizeof usoptval,
1224 cb->s_mtu = usoptval;
1229 error = sooptcopyin(sopt, &optval, sizeof optval,
1234 cb->s_flags2 |= SF_NEWCALL;
1237 cb->s_flags2 &= ~SF_NEWCALL;
1243 case SO_DEFAULT_HEADERS:
1247 error = sooptcopyin(sopt, &sp, sizeof sp,
1251 cb->s_dt = sp.spx_dt;
1252 cb->s_cc = sp.spx_cc & SPX_EM;
1257 error = ENOPROTOOPT;
1269 struct ipxpcb *ipxp;
1272 ipxp = sotoipxpcb(so);
1273 cb = ipxtospxpcb(ipxp);
1276 spx_drop(cb, ECONNABORTED);
1282 * Accept a connection. Essentially all the work is
1283 * done at higher levels; just return the address
1284 * of the peer, storing through addr.
1289 struct sockaddr **nam;
1291 struct ipxpcb *ipxp;
1292 struct sockaddr_ipx *sipx, ssipx;
1294 ipxp = sotoipxpcb(so);
1296 bzero(sipx, sizeof *sipx);
1297 sipx->sipx_len = sizeof *sipx;
1298 sipx->sipx_family = AF_IPX;
1299 sipx->sipx_addr = ipxp->ipxp_faddr;
1300 *nam = dup_sockaddr((struct sockaddr *)sipx, 0);
1305 spx_attach(so, proto, p)
1312 struct ipxpcb *ipxp;
1317 ipxp = sotoipxpcb(so);
1318 cb = ipxtospxpcb(ipxp);
1323 error = ipx_pcballoc(so, &ipxpcb, p);
1325 goto spx_attach_end;
1326 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
1327 error = soreserve(so, (u_long) 3072, (u_long) 3072);
1329 goto spx_attach_end;
1331 ipxp = sotoipxpcb(so);
1333 MALLOC(cb, struct spxpcb *, sizeof *cb, M_PCB, M_NOWAIT);
1337 goto spx_attach_end;
1339 bzero(cb, sizeof *cb);
1342 mm = m_getclr(M_DONTWAIT, MT_HEADER);
1346 goto spx_attach_end;
1348 cb->s_ipx = mtod(mm, struct ipx *);
1349 cb->s_state = TCPS_LISTEN;
1352 cb->s_q.si_next = cb->s_q.si_prev = &cb->s_q;
1353 cb->s_ipxpcb = ipxp;
1354 cb->s_mtu = 576 - sizeof(struct spx);
1355 cb->s_cwnd = sbspace(sb) * CUNIT / cb->s_mtu;
1356 cb->s_ssthresh = cb->s_cwnd;
1357 cb->s_cwmx = sbspace(sb) * CUNIT / (2 * sizeof(struct spx));
1358 /* Above is recomputed when connecting to account
1359 for changed buffering or mtu's */
1360 cb->s_rtt = SPXTV_SRTTBASE;
1361 cb->s_rttvar = SPXTV_SRTTDFLT << 2;
1362 SPXT_RANGESET(cb->s_rxtcur,
1363 ((SPXTV_SRTTBASE >> 2) + (SPXTV_SRTTDFLT << 2)) >> 1,
1364 SPXTV_MIN, SPXTV_REXMTMAX);
1365 ipxp->ipxp_pcb = (caddr_t)cb;
1372 spx_bind(so, nam, p)
1374 struct sockaddr *nam;
1377 struct ipxpcb *ipxp;
1379 ipxp = sotoipxpcb(so);
1381 return (ipx_pcbbind(ipxp, nam, p));
1385 * Initiate connection to peer.
1386 * Enter SYN_SENT state, and mark socket as connecting.
1387 * Start keep-alive timer, setup prototype header,
1388 * Send initial system packet requesting connection.
1391 spx_connect(so, nam, p)
1393 struct sockaddr *nam;
1398 struct ipxpcb *ipxp;
1401 ipxp = sotoipxpcb(so);
1402 cb = ipxtospxpcb(ipxp);
1405 if (ipxp->ipxp_lport == 0) {
1406 error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, p);
1408 goto spx_connect_end;
1410 error = ipx_pcbconnect(ipxp, nam, p);
1412 goto spx_connect_end;
1414 spxstat.spxs_connattempt++;
1415 cb->s_state = TCPS_SYN_SENT;
1418 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
1419 cb->s_force = 1 + SPXTV_KEEP;
1421 * Other party is required to respond to
1422 * the port I send from, but he is not
1423 * required to answer from where I am sending to,
1424 * so allow wildcarding.
1425 * original port I am sending to is still saved in
1428 ipxp->ipxp_fport = 0;
1429 error = spx_output(cb, (struct mbuf *)NULL);
1440 struct ipxpcb *ipxp;
1443 ipxp = sotoipxpcb(so);
1444 cb = ipxtospxpcb(ipxp);
1449 if (cb->s_state > TCPS_LISTEN)
1458 * We may decide later to implement connection closing
1459 * handshaking at the spx level optionally.
1460 * here is the hook to do it:
1463 spx_usr_disconnect(so)
1467 struct ipxpcb *ipxp;
1470 ipxp = sotoipxpcb(so);
1471 cb = ipxtospxpcb(ipxp);
1485 struct ipxpcb *ipxp;
1489 ipxp = sotoipxpcb(so);
1490 cb = ipxtospxpcb(ipxp);
1492 if (ipxp->ipxp_lport == 0)
1493 error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, p);
1495 cb->s_state = TCPS_LISTEN;
1500 * After a receive, possibly send acknowledgment
1501 * updating allocation.
1509 struct ipxpcb *ipxp;
1512 ipxp = sotoipxpcb(so);
1513 cb = ipxtospxpcb(ipxp);
1516 cb->s_flags |= SF_RVD;
1517 spx_output(cb, (struct mbuf *)NULL);
1518 cb->s_flags &= ~SF_RVD;
1524 spx_rcvoob(so, m, flags)
1529 struct ipxpcb *ipxp;
1532 ipxp = sotoipxpcb(so);
1533 cb = ipxtospxpcb(ipxp);
1535 if ((cb->s_oobflags & SF_IOOB) || so->so_oobmark ||
1536 (so->so_state & SS_RCVATMARK)) {
1538 *mtod(m, caddr_t) = cb->s_iobc;
1545 spx_send(so, flags, m, addr, controlp, p)
1549 struct sockaddr *addr;
1550 struct mbuf *controlp;
1555 struct ipxpcb *ipxp;
1559 ipxp = sotoipxpcb(so);
1560 cb = ipxtospxpcb(ipxp);
1563 if (flags & PRUS_OOB) {
1564 if (sbspace(&so->so_snd) < -512) {
1568 cb->s_oobflags |= SF_SOOB;
1570 if (controlp != NULL) {
1571 u_short *p = mtod(controlp, u_short *);
1573 if ((p[0] == 5) && (p[1] == 1)) { /* XXXX, for testing */
1574 cb->s_shdr.spx_dt = *(u_char *)(&p[2]);
1580 error = spx_output(cb, m);
1583 if (controlp != NULL)
1597 struct ipxpcb *ipxp;
1601 ipxp = sotoipxpcb(so);
1602 cb = ipxtospxpcb(ipxp);
1606 cb = spx_usrclosed(cb);
1608 error = spx_output(cb, (struct mbuf *)NULL);
1614 spx_sp_attach(so, proto, p)
1620 struct ipxpcb *ipxp;
1622 error = spx_attach(so, proto, p);
1624 ipxp = sotoipxpcb(so);
1625 ((struct spxpcb *)ipxp->ipxp_pcb)->s_flags |=
1626 (SF_HI | SF_HO | SF_PI);
1632 * Create template to be used to send spx packets on a connection.
1633 * Called after host entry created, fills
1634 * in a skeletal spx header (choosing connection id),
1635 * minimizing the amount of work necessary when the connection is used.
1639 register struct spxpcb *cb;
1641 register struct ipxpcb *ipxp = cb->s_ipxpcb;
1642 register struct ipx *ipx = cb->s_ipx;
1643 register struct sockbuf *sb = &(ipxp->ipxp_socket->so_snd);
1645 ipx->ipx_pt = IPXPROTO_SPX;
1646 ipx->ipx_sna = ipxp->ipxp_laddr;
1647 ipx->ipx_dna = ipxp->ipxp_faddr;
1648 cb->s_sid = htons(spx_iss);
1649 spx_iss += SPX_ISSINCR/2;
1651 cb->s_cwnd = (sbspace(sb) * CUNIT) / cb->s_mtu;
1652 cb->s_ssthresh = cb->s_cwnd; /* Try to expand fast to full complement
1654 cb->s_cwmx = (sbspace(sb) * CUNIT) / (2 * sizeof(struct spx));
1655 cb->s_cwmx = max(cb->s_cwmx, cb->s_cwnd);
1656 /* But allow for lots of little packets as well */
1660 * Close a SPIP control block:
1661 * discard spx control block itself
1662 * discard ipx protocol control block
1663 * wake up any sleepers
1665 static struct spxpcb *
1667 register struct spxpcb *cb;
1669 register struct spx_q *s;
1670 struct ipxpcb *ipxp = cb->s_ipxpcb;
1671 struct socket *so = ipxp->ipxp_socket;
1672 register struct mbuf *m;
1674 s = cb->s_q.si_next;
1675 while (s != &(cb->s_q)) {
1677 m = dtom(s->si_prev);
1681 m_free(dtom(cb->s_ipx));
1684 soisdisconnected(so);
1685 ipx_pcbdetach(ipxp);
1686 spxstat.spxs_closed++;
1687 return ((struct spxpcb *)NULL);
1691 * Someday we may do level 3 handshaking
1692 * to close a connection or send a xerox style error.
1693 * For now, just close.
1695 static struct spxpcb *
1697 register struct spxpcb *cb;
1699 return (spx_close(cb));
1702 static struct spxpcb *
1704 register struct spxpcb *cb;
1706 return (spx_close(cb));
1710 * Drop connection, reporting
1711 * the specified error.
1713 static struct spxpcb *
1715 register struct spxpcb *cb;
1718 struct socket *so = cb->s_ipxpcb->ipxp_socket;
1721 * someday, in the xerox world
1722 * we will generate error protocol packets
1723 * announcing that the socket has gone away.
1725 if (TCPS_HAVERCVDSYN(cb->s_state)) {
1726 spxstat.spxs_drops++;
1727 cb->s_state = TCPS_CLOSED;
1730 spxstat.spxs_conndrops++;
1731 so->so_error = errno;
1732 return (spx_close(cb));
1736 * Fast timeout routine for processing delayed acks
1741 register struct ipxpcb *ipxp;
1742 register struct spxpcb *cb;
1745 ipxp = ipxpcb.ipxp_next;
1747 for (; ipxp != &ipxpcb; ipxp = ipxp->ipxp_next)
1748 if ((cb = (struct spxpcb *)ipxp->ipxp_pcb) != NULL &&
1749 (cb->s_flags & SF_DELACK)) {
1750 cb->s_flags &= ~SF_DELACK;
1751 cb->s_flags |= SF_ACKNOW;
1752 spxstat.spxs_delack++;
1753 spx_output(cb, (struct mbuf *)NULL);
1759 * spx protocol timeout routine called every 500 ms.
1760 * Updates the timers in all active pcb's and
1761 * causes finite state machine actions if timers expire.
1766 register struct ipxpcb *ip, *ipnxt;
1767 register struct spxpcb *cb;
1772 * Search through tcb's and update active timers.
1774 ip = ipxpcb.ipxp_next;
1779 while (ip != &ipxpcb) {
1780 cb = ipxtospxpcb(ip);
1781 ipnxt = ip->ipxp_next;
1784 for (i = 0; i < SPXT_NTIMERS; i++) {
1785 if (cb->s_timer[i] && --cb->s_timer[i] == 0) {
1787 if (ipnxt->ipxp_prev != ip)
1797 spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */
1802 * SPX timer processing.
1804 static struct spxpcb *
1805 spx_timers(cb, timer)
1806 register struct spxpcb *cb;
1812 cb->s_force = 1 + timer;
1816 * 2 MSL timeout in shutdown went off. TCP deletes connection
1820 printf("spx: SPXT_2MSL went off for no reason\n");
1821 cb->s_timer[timer] = 0;
1825 * Retransmission timer went off. Message has not
1826 * been acked within retransmit interval. Back off
1827 * to a longer retransmit interval and retransmit one packet.
1830 if (++cb->s_rxtshift > SPX_MAXRXTSHIFT) {
1831 cb->s_rxtshift = SPX_MAXRXTSHIFT;
1832 spxstat.spxs_timeoutdrop++;
1833 cb = spx_drop(cb, ETIMEDOUT);
1836 spxstat.spxs_rexmttimeo++;
1837 rexmt = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
1838 rexmt *= spx_backoff[cb->s_rxtshift];
1839 SPXT_RANGESET(cb->s_rxtcur, rexmt, SPXTV_MIN, SPXTV_REXMTMAX);
1840 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1842 * If we have backed off fairly far, our srtt
1843 * estimate is probably bogus. Clobber it
1844 * so we'll take the next rtt measurement as our srtt;
1845 * move the current srtt into rttvar to keep the current
1846 * retransmit times until then.
1848 if (cb->s_rxtshift > SPX_MAXRXTSHIFT / 4 ) {
1849 cb->s_rttvar += (cb->s_srtt >> 2);
1852 cb->s_snxt = cb->s_rack;
1854 * If timing a packet, stop the timer.
1858 * See very long discussion in tcp_timer.c about congestion
1859 * window and sstrhesh
1861 win = min(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2;
1865 cb->s_ssthresh = win * CUNIT;
1866 spx_output(cb, (struct mbuf *)NULL);
1870 * Persistance timer into zero window.
1871 * Force a probe to be sent.
1874 spxstat.spxs_persisttimeo++;
1876 spx_output(cb, (struct mbuf *)NULL);
1880 * Keep-alive timer went off; send something
1881 * or drop connection if idle for too long.
1884 spxstat.spxs_keeptimeo++;
1885 if (cb->s_state < TCPS_ESTABLISHED)
1887 if (cb->s_ipxpcb->ipxp_socket->so_options & SO_KEEPALIVE) {
1888 if (cb->s_idle >= SPXTV_MAXIDLE)
1890 spxstat.spxs_keepprobe++;
1891 spx_output(cb, (struct mbuf *)NULL);
1894 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
1897 spxstat.spxs_keepdrops++;
1898 cb = spx_drop(cb, ETIMEDOUT);