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>
41 #include <sys/malloc.h>
43 #include <sys/mutex.h>
45 #include <sys/protosw.h>
46 #include <sys/signalvar.h>
47 #include <sys/socket.h>
48 #include <sys/socketvar.h>
50 #include <sys/systm.h>
52 #include <net/route.h>
53 #include <netinet/tcp_fsm.h>
55 #include <netipx/ipx.h>
56 #include <netipx/ipx_pcb.h>
57 #include <netipx/ipx_var.h>
58 #include <netipx/spx.h>
59 #include <netipx/spx_debug.h>
60 #include <netipx/spx_timer.h>
61 #include <netipx/spx_var.h>
64 * SPX protocol implementation.
66 static u_short spx_iss;
67 static u_short spx_newchecks[50];
68 static int spx_hardnosed;
69 static int spx_use_delack = 0;
70 static int traceallspxs = 0;
71 static struct spx spx_savesi;
72 static struct spx_istat spx_istat;
74 /* Following was struct spxstat spxstat; */
76 #define spxstat spx_istat.newstats
79 static int spx_backoff[SPX_MAXRXTSHIFT+1] =
80 { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
82 static struct spxpcb *spx_close(struct spxpcb *cb);
83 static struct spxpcb *spx_disconnect(struct spxpcb *cb);
84 static struct spxpcb *spx_drop(struct spxpcb *cb, int errno);
85 static int spx_output(struct spxpcb *cb, struct mbuf *m0);
86 static int spx_reass(struct spxpcb *cb, struct spx *si);
87 static void spx_setpersist(struct spxpcb *cb);
88 static void spx_template(struct spxpcb *cb);
89 static struct spxpcb *spx_timers(struct spxpcb *cb, int timer);
90 static struct spxpcb *spx_usrclosed(struct spxpcb *cb);
92 static int spx_usr_abort(struct socket *so);
93 static int spx_accept(struct socket *so, struct sockaddr **nam);
94 static int spx_attach(struct socket *so, int proto, struct thread *td);
95 static int spx_bind(struct socket *so, struct sockaddr *nam, struct thread *td);
96 static int spx_connect(struct socket *so, struct sockaddr *nam,
98 static int spx_detach(struct socket *so);
99 static int spx_usr_disconnect(struct socket *so);
100 static int spx_listen(struct socket *so, struct thread *td);
101 static int spx_rcvd(struct socket *so, int flags);
102 static int spx_rcvoob(struct socket *so, struct mbuf *m, int flags);
103 static int spx_send(struct socket *so, int flags, struct mbuf *m,
104 struct sockaddr *addr, struct mbuf *control,
106 static int spx_shutdown(struct socket *so);
107 static int spx_sp_attach(struct socket *so, int proto, struct thread *td);
109 struct pr_usrreqs spx_usrreqs = {
110 spx_usr_abort, spx_accept, spx_attach, spx_bind,
111 spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
112 spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
113 spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
114 ipx_sockaddr, sosend, soreceive, sopoll
117 struct pr_usrreqs spx_usrreq_sps = {
118 spx_usr_abort, spx_accept, spx_sp_attach, spx_bind,
119 spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
120 spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
121 spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
122 ipx_sockaddr, sosend, soreceive, sopoll
129 spx_iss = 1; /* WRONG !! should fish it out of TODR */
134 register struct mbuf *m;
135 register struct ipxpcb *ipxp;
137 register struct spxpcb *cb;
138 register struct spx *si = mtod(m, struct spx *);
139 register struct socket *so;
143 spxstat.spxs_rcvtotal++;
145 panic("No ipxpcb in spx_input\n");
149 cb = ipxtospxpcb(ipxp);
153 if (m->m_len < sizeof(*si)) {
154 if ((m = m_pullup(m, sizeof(*si))) == NULL) {
155 spxstat.spxs_rcvshort++;
158 si = mtod(m, struct spx *);
160 si->si_seq = ntohs(si->si_seq);
161 si->si_ack = ntohs(si->si_ack);
162 si->si_alo = ntohs(si->si_alo);
164 so = ipxp->ipxp_socket;
166 if (so->so_options & SO_DEBUG || traceallspxs) {
167 ostate = cb->s_state;
170 if (so->so_options & SO_ACCEPTCONN) {
171 struct spxpcb *ocb = cb;
173 so = sonewconn(so, 0);
178 * This is ugly, but ....
180 * Mark socket as temporary until we're
181 * committed to keeping it. The code at
182 * ``drop'' and ``dropwithreset'' check the
183 * flag dropsocket to see if the temporary
184 * socket created here should be discarded.
185 * We mark the socket as discardable until
186 * we're committed to it below in TCPS_LISTEN.
189 ipxp = (struct ipxpcb *)so->so_pcb;
190 ipxp->ipxp_laddr = si->si_dna;
191 cb = ipxtospxpcb(ipxp);
192 cb->s_mtu = ocb->s_mtu; /* preserve sockopts */
193 cb->s_flags = ocb->s_flags; /* preserve sockopts */
194 cb->s_flags2 = ocb->s_flags2; /* preserve sockopts */
195 cb->s_state = TCPS_LISTEN;
199 * Packet received on connection.
200 * reset idle time and keep-alive timer;
203 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
205 switch (cb->s_state) {
208 struct sockaddr_ipx *sipx, ssipx;
209 struct ipx_addr laddr;
212 * If somebody here was carying on a conversation
213 * and went away, and his pen pal thinks he can
214 * still talk, we get the misdirected packet.
216 if (spx_hardnosed && (si->si_did != 0 || si->si_seq != 0)) {
221 bzero(sipx, sizeof *sipx);
222 sipx->sipx_len = sizeof(*sipx);
223 sipx->sipx_family = AF_IPX;
224 sipx->sipx_addr = si->si_sna;
225 laddr = ipxp->ipxp_laddr;
226 if (ipx_nullhost(laddr))
227 ipxp->ipxp_laddr = si->si_dna;
228 if (ipx_pcbconnect(ipxp, (struct sockaddr *)sipx, &thread0)) {
229 ipxp->ipxp_laddr = laddr;
234 dropsocket = 0; /* committed to socket */
235 cb->s_did = si->si_sid;
236 cb->s_rack = si->si_ack;
237 cb->s_ralo = si->si_alo;
238 #define THREEWAYSHAKE
240 cb->s_state = TCPS_SYN_RECEIVED;
241 cb->s_force = 1 + SPXT_KEEP;
242 spxstat.spxs_accepts++;
243 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
247 * This state means that we have heard a response
248 * to our acceptance of their connection
249 * It is probably logically unnecessary in this
252 case TCPS_SYN_RECEIVED: {
253 if (si->si_did != cb->s_sid) {
258 ipxp->ipxp_fport = si->si_sport;
259 cb->s_timer[SPXT_REXMT] = 0;
260 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
262 cb->s_state = TCPS_ESTABLISHED;
263 spxstat.spxs_accepts++;
268 * This state means that we have gotten a response
269 * to our attempt to establish a connection.
270 * We fill in the data from the other side,
271 * telling us which port to respond to, instead of the well-
272 * known one we might have sent to in the first place.
273 * We also require that this is a response to our
277 if (si->si_did != cb->s_sid) {
281 spxstat.spxs_connects++;
282 cb->s_did = si->si_sid;
283 cb->s_rack = si->si_ack;
284 cb->s_ralo = si->si_alo;
285 cb->s_dport = ipxp->ipxp_fport = si->si_sport;
286 cb->s_timer[SPXT_REXMT] = 0;
287 cb->s_flags |= SF_ACKNOW;
289 cb->s_state = TCPS_ESTABLISHED;
290 /* Use roundtrip time of connection request for initial rtt */
292 cb->s_srtt = cb->s_rtt << 3;
293 cb->s_rttvar = cb->s_rtt << 1;
294 SPXT_RANGESET(cb->s_rxtcur,
295 ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
296 SPXTV_MIN, SPXTV_REXMTMAX);
300 if (so->so_options & SO_DEBUG || traceallspxs)
301 spx_trace(SA_INPUT, (u_char)ostate, cb, &spx_savesi, 0);
303 m->m_len -= sizeof(struct ipx);
304 m->m_pkthdr.len -= sizeof(struct ipx);
305 m->m_data += sizeof(struct ipx);
307 if (spx_reass(cb, si)) {
310 if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT)))
311 spx_output(cb, (struct mbuf *)NULL);
312 cb->s_flags &= ~(SF_WIN|SF_RXT);
318 si->si_seq = ntohs(si->si_seq);
319 si->si_ack = ntohs(si->si_ack);
320 si->si_alo = ntohs(si->si_alo);
322 if (cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG || traceallspxs)
323 spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0);
328 if (cb == 0 || cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG ||
330 spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0);
334 static int spxrexmtthresh = 3;
337 * This is structurally similar to the tcp reassembly routine
338 * but its function is somewhat different: It merely queues
339 * packets up, and suppresses duplicates.
343 register struct spxpcb *cb;
344 register struct spx *si;
346 register struct spx_q *q;
347 register struct mbuf *m;
348 register struct socket *so = cb->s_ipxpcb->ipxp_socket;
349 char packetp = cb->s_flags & SF_HI;
356 * Update our news from them.
358 if (si->si_cc & SPX_SA)
359 cb->s_flags |= (spx_use_delack ? SF_DELACK : SF_ACKNOW);
360 if (SSEQ_GT(si->si_alo, cb->s_ralo))
361 cb->s_flags |= SF_WIN;
362 if (SSEQ_LEQ(si->si_ack, cb->s_rack)) {
363 if ((si->si_cc & SPX_SP) && cb->s_rack != (cb->s_smax + 1)) {
364 spxstat.spxs_rcvdupack++;
366 * If this is a completely duplicate ack
367 * and other conditions hold, we assume
368 * a packet has been dropped and retransmit
369 * it exactly as in tcp_input().
371 if (si->si_ack != cb->s_rack ||
372 si->si_alo != cb->s_ralo)
374 else if (++cb->s_dupacks == spxrexmtthresh) {
375 u_short onxt = cb->s_snxt;
376 int cwnd = cb->s_cwnd;
378 cb->s_snxt = si->si_ack;
380 cb->s_force = 1 + SPXT_REXMT;
381 spx_output(cb, (struct mbuf *)NULL);
382 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
384 if (cwnd >= 4 * CUNIT)
385 cb->s_cwnd = cwnd / 2;
386 if (SSEQ_GT(onxt, cb->s_snxt))
396 * If our correspondent acknowledges data we haven't sent
397 * TCP would drop the packet after acking. We'll be a little
400 if (SSEQ_GT(si->si_ack, (cb->s_smax + 1))) {
401 spxstat.spxs_rcvacktoomuch++;
402 si->si_ack = cb->s_smax + 1;
404 spxstat.spxs_rcvackpack++;
406 * If transmit timer is running and timed sequence
407 * number was acked, update smoothed round trip time.
408 * See discussion of algorithm in tcp_input.c
410 if (cb->s_rtt && SSEQ_GT(si->si_ack, cb->s_rtseq)) {
411 spxstat.spxs_rttupdated++;
412 if (cb->s_srtt != 0) {
413 register short delta;
414 delta = cb->s_rtt - (cb->s_srtt >> 3);
415 if ((cb->s_srtt += delta) <= 0)
419 delta -= (cb->s_rttvar >> 2);
420 if ((cb->s_rttvar += delta) <= 0)
424 * No rtt measurement yet
426 cb->s_srtt = cb->s_rtt << 3;
427 cb->s_rttvar = cb->s_rtt << 1;
431 SPXT_RANGESET(cb->s_rxtcur,
432 ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
433 SPXTV_MIN, SPXTV_REXMTMAX);
436 * If all outstanding data is acked, stop retransmit
437 * timer and remember to restart (more output or persist).
438 * If there is more data to be acked, restart retransmit
439 * timer, using current (possibly backed-off) value;
441 if (si->si_ack == cb->s_smax + 1) {
442 cb->s_timer[SPXT_REXMT] = 0;
443 cb->s_flags |= SF_RXT;
444 } else if (cb->s_timer[SPXT_PERSIST] == 0)
445 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
447 * When new data is acked, open the congestion window.
448 * If the window gives us less than ssthresh packets
449 * in flight, open exponentially (maxseg at a time).
450 * Otherwise open linearly (maxseg^2 / cwnd at a time).
453 if (cb->s_cwnd > cb->s_ssthresh)
454 incr = max(incr * incr / cb->s_cwnd, 1);
455 cb->s_cwnd = min(cb->s_cwnd + incr, cb->s_cwmx);
457 * Trim Acked data from output queue.
459 while ((m = so->so_snd.sb_mb) != NULL) {
460 if (SSEQ_LT((mtod(m, struct spx *))->si_seq, si->si_ack))
461 sbdroprecord(&so->so_snd);
466 cb->s_rack = si->si_ack;
468 if (SSEQ_LT(cb->s_snxt, cb->s_rack))
469 cb->s_snxt = cb->s_rack;
470 if (SSEQ_LT(cb->s_swl1, si->si_seq) || ((cb->s_swl1 == si->si_seq &&
471 (SSEQ_LT(cb->s_swl2, si->si_ack))) ||
472 (cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo)))) {
473 /* keep track of pure window updates */
474 if ((si->si_cc & SPX_SP) && cb->s_swl2 == si->si_ack
475 && SSEQ_LT(cb->s_ralo, si->si_alo)) {
476 spxstat.spxs_rcvwinupd++;
477 spxstat.spxs_rcvdupack--;
479 cb->s_ralo = si->si_alo;
480 cb->s_swl1 = si->si_seq;
481 cb->s_swl2 = si->si_ack;
482 cb->s_swnd = (1 + si->si_alo - si->si_ack);
483 if (cb->s_swnd > cb->s_smxw)
484 cb->s_smxw = cb->s_swnd;
485 cb->s_flags |= SF_WIN;
488 * If this packet number is higher than that which
489 * we have allocated refuse it, unless urgent
491 if (SSEQ_GT(si->si_seq, cb->s_alo)) {
492 if (si->si_cc & SPX_SP) {
493 spxstat.spxs_rcvwinprobe++;
496 spxstat.spxs_rcvpackafterwin++;
497 if (si->si_cc & SPX_OB) {
498 if (SSEQ_GT(si->si_seq, cb->s_alo + 60)) {
501 } /* else queue this packet; */
503 /*register struct socket *so = cb->s_ipxpcb->ipxp_socket;
504 if (so->so_state && SS_NOFDREF) {
514 * If this is a system packet, we don't need to
515 * queue it up, and won't update acknowledge #
517 if (si->si_cc & SPX_SP) {
521 * We have already seen this packet, so drop.
523 if (SSEQ_LT(si->si_seq, cb->s_ack)) {
525 spxstat.spxs_rcvduppack++;
526 if (si->si_seq == cb->s_ack - 1)
531 * Loop through all packets queued up to insert in
532 * appropriate sequence.
534 for (q = cb->s_q.si_next; q != &cb->s_q; q = q->si_next) {
535 if (si->si_seq == SI(q)->si_seq) {
536 spxstat.spxs_rcvduppack++;
539 if (SSEQ_LT(si->si_seq, SI(q)->si_seq)) {
540 spxstat.spxs_rcvoopack++;
544 insque(si, q->si_prev);
546 * If this packet is urgent, inform process
548 if (si->si_cc & SPX_OB) {
549 cb->s_iobc = ((char *)si)[1 + sizeof(*si)];
551 cb->s_oobflags |= SF_IOOB;
554 #define SPINC sizeof(struct spxhdr)
556 * Loop through all packets queued up to update acknowledge
557 * number, and present all acknowledged data to user;
558 * If in packet interface mode, show packet headers.
560 for (q = cb->s_q.si_next; q != &cb->s_q; q = q->si_next) {
561 if (SI(q)->si_seq == cb->s_ack) {
564 if (SI(q)->si_cc & SPX_OB) {
565 cb->s_oobflags &= ~SF_IOOB;
566 if (so->so_rcv.sb_cc)
567 so->so_oobmark = so->so_rcv.sb_cc;
569 so->so_state |= SS_RCVATMARK;
574 spxstat.spxs_rcvpack++;
576 if (cb->s_flags2 & SF_NEWCALL) {
577 struct spxhdr *sp = mtod(m, struct spxhdr *);
578 u_char dt = sp->spx_dt;
580 if (dt != cb->s_rhdr.spx_dt) {
582 m_getclr(M_DONTWAIT, MT_CONTROL);
587 cb->s_rhdr.spx_dt = dt;
588 mm->m_len = 5; /*XXX*/
591 *(u_char *)(&s[2]) = dt;
592 sbappend(&so->so_rcv, mm);
595 if (sp->spx_cc & SPX_OB) {
596 MCHTYPE(m, MT_OOBDATA);
599 so->so_state &= ~SS_RCVATMARK;
604 m->m_pkthdr.len -= SPINC;
606 if ((sp->spx_cc & SPX_EM) || packetp) {
607 sbappendrecord(&so->so_rcv, m);
610 sbappend(&so->so_rcv, m);
614 sbappendrecord(&so->so_rcv, m);
616 cb->s_rhdr = *mtod(m, struct spxhdr *);
619 m->m_pkthdr.len -= SPINC;
620 sbappend(&so->so_rcv, m);
631 spx_ctlinput(cmd, arg_as_sa, dummy)
633 struct sockaddr *arg_as_sa; /* XXX should be swapped with dummy */
636 caddr_t arg = (/* XXX */ caddr_t)arg_as_sa;
638 struct sockaddr_ipx *sipx;
640 if (cmd < 0 || cmd > PRC_NCMDS)
650 case PRC_HOSTUNREACH:
651 sipx = (struct sockaddr_ipx *)arg;
652 if (sipx->sipx_family != AF_IPX)
654 na = &sipx->sipx_addr;
665 register struct ipxpcb *ipxp;
667 register struct spxpcb *cb = (struct spxpcb *)(ipxp->ipxp_pcb);
668 register struct mbuf *m;
669 register struct spx *si;
673 struct mbuf *firstbad, *m0;
677 * The notification that we have sent
678 * too much is bad news -- we will
679 * have to go through queued up so far
680 * splitting ones which are too big and
681 * reassigning sequence numbers and checksums.
682 * we should then retransmit all packets from
683 * one above the offending packet to the last one
684 * we had sent (or our allocation)
685 * then the offending one so that the any queued
686 * data at our destination will be discarded.
688 ep = (struct ipx_errp *)ipxp->ipxp_notify_param;
689 sb = &ipxp->ipxp_socket->so_snd;
690 cb->s_mtu = ep->ipx_err_param;
691 badseq = SI(&ep->ipx_err_ipx)->si_seq;
692 for (m = sb->sb_mb; m != NULL; m = m->m_act) {
693 si = mtod(m, struct spx *);
694 if (si->si_seq == badseq)
701 /* calculate length */
702 for (m0 = m, len = 0; m != NULL; m = m->m_next)
704 if (len > cb->s_mtu) {
714 register struct spxpcb *cb;
717 struct socket *so = cb->s_ipxpcb->ipxp_socket;
718 register struct mbuf *m;
719 register struct spx *si = (struct spx *)NULL;
720 register struct sockbuf *sb = &so->so_snd;
721 int len = 0, win, rcv_win;
722 short span, off, recordp = 0;
724 int error = 0, sendalot;
734 * Make sure that packet isn't too big.
736 for (m = m0; m != NULL; m = m->m_next) {
739 if (m->m_flags & M_EOR)
742 datalen = (cb->s_flags & SF_HO) ?
743 len - sizeof(struct spxhdr) : len;
745 if (cb->s_flags & SF_PI) {
749 int oldEM = cb->s_cc & SPX_EM;
754 * Here we are only being called
755 * from usrreq(), so it is OK to
758 m = m_copym(m0, 0, mtu, M_TRYWAIT);
759 if (cb->s_flags & SF_NEWCALL) {
763 mm->m_flags &= ~M_EOR;
767 error = spx_output(cb, m);
780 * Force length even, by adding a "garbage byte" if
785 if (M_TRAILINGSPACE(m) >= 1)
788 struct mbuf *m1 = m_get(M_DONTWAIT, MT_DATA);
795 *(mtod(m1, u_char *)) = 0;
799 m = m_gethdr(M_DONTWAIT, MT_HEADER);
805 * Fill in mbuf with extended SP header
806 * and addresses and length put into network format.
808 MH_ALIGN(m, sizeof(struct spx));
809 m->m_len = sizeof(struct spx);
811 si = mtod(m, struct spx *);
812 si->si_i = *cb->s_ipx;
813 si->si_s = cb->s_shdr;
814 if ((cb->s_flags & SF_PI) && (cb->s_flags & SF_HO)) {
815 register struct spxhdr *sh;
816 if (m0->m_len < sizeof(*sh)) {
817 if((m0 = m_pullup(m0, sizeof(*sh))) == NULL) {
824 sh = mtod(m0, struct spxhdr *);
825 si->si_dt = sh->spx_dt;
826 si->si_cc |= sh->spx_cc & SPX_EM;
827 m0->m_len -= sizeof(*sh);
828 m0->m_data += sizeof(*sh);
832 if ((cb->s_flags2 & SF_NEWCALL) && recordp) {
836 if (cb->s_oobflags & SF_SOOB) {
839 * make sure OB packets convey exactly 1 byte.
840 * If the packet is 1 byte or larger, we
841 * have already guaranted there to be at least
842 * one garbage byte for the checksum, and
843 * extra bytes shouldn't hurt!
845 if (len > sizeof(*si)) {
847 len = (1 + sizeof(*si));
850 si->si_len = htons((u_short)len);
851 m->m_pkthdr.len = ((len - 1) | 1) + 1;
853 * queue stuff up for output
855 sbappendrecord(sb, m);
859 idle = (cb->s_smax == (cb->s_rack - 1));
863 off = cb->s_snxt - cb->s_rack;
864 win = min(cb->s_swnd, (cb->s_cwnd / CUNIT));
867 * If in persist timeout with window of 0, send a probe.
868 * Otherwise, if window is small but nonzero
869 * and timer expired, send what we can and go into
872 if (cb->s_force == 1 + SPXT_PERSIST) {
874 cb->s_timer[SPXT_PERSIST] = 0;
878 span = cb->s_seq - cb->s_rack;
879 len = min(span, win) - off;
883 * Window shrank after we went into it.
884 * If window shrank to 0, cancel pending
885 * restransmission and pull s_snxt back
886 * to (closed) window. We will enter persist
887 * state below. If the widndow didn't close completely,
888 * just wait for an ACK.
892 cb->s_timer[SPXT_REXMT] = 0;
893 cb->s_snxt = cb->s_rack;
898 rcv_win = sbspace(&so->so_rcv);
901 * Send if we owe peer an ACK.
903 if (cb->s_oobflags & SF_SOOB) {
905 * must transmit this out of band packet
907 cb->s_oobflags &= ~ SF_SOOB;
909 spxstat.spxs_sndurg++;
912 if (cb->s_flags & SF_ACKNOW)
914 if (cb->s_state < TCPS_ESTABLISHED)
917 * Silly window can't happen in spx.
918 * Code from tcp deleted.
923 * Compare available window to amount of window
924 * known to peer (as advertised window less
925 * next expected input.) If the difference is at least two
926 * packets or at least 35% of the mximum possible window,
927 * then want to send a window update to peer.
930 u_short delta = 1 + cb->s_alo - cb->s_ack;
931 int adv = rcv_win - (delta * cb->s_mtu);
933 if ((so->so_rcv.sb_cc == 0 && adv >= (2 * cb->s_mtu)) ||
934 (100 * adv / so->so_rcv.sb_hiwat >= 35)) {
935 spxstat.spxs_sndwinup++;
936 cb->s_flags |= SF_ACKNOW;
942 * Many comments from tcp_output.c are appropriate here
944 * If send window is too small, there is data to transmit, and no
945 * retransmit or persist is pending, then go to persist state.
946 * If nothing happens soon, send when timer expires:
947 * if window is nonzero, transmit what we can,
948 * otherwise send a probe.
950 if (so->so_snd.sb_cc && cb->s_timer[SPXT_REXMT] == 0 &&
951 cb->s_timer[SPXT_PERSIST] == 0) {
956 * No reason to send a packet, just return.
963 * Find requested packet.
967 cb->s_want = cb->s_snxt;
968 for (m = sb->sb_mb; m != NULL; m = m->m_act) {
969 si = mtod(m, struct spx *);
970 if (SSEQ_LEQ(cb->s_snxt, si->si_seq))
975 if (si->si_seq == cb->s_snxt)
978 spxstat.spxs_sndvoid++, si = 0;
986 alo = cb->s_ack - 1 + (rcv_win / ((short)cb->s_mtu));
987 if (SSEQ_LT(alo, cb->s_alo))
992 * must make a copy of this packet for
993 * ipx_output to monkey with
995 m = m_copy(dtom(si), 0, (int)M_COPYALL);
999 si = mtod(m, struct spx *);
1000 if (SSEQ_LT(si->si_seq, cb->s_smax))
1001 spxstat.spxs_sndrexmitpack++;
1003 spxstat.spxs_sndpack++;
1004 } else if (cb->s_force || cb->s_flags & SF_ACKNOW) {
1006 * Must send an acknowledgement or a probe
1009 spxstat.spxs_sndprobe++;
1010 if (cb->s_flags & SF_ACKNOW)
1011 spxstat.spxs_sndacks++;
1012 m = m_gethdr(M_DONTWAIT, MT_HEADER);
1016 * Fill in mbuf with extended SP header
1017 * and addresses and length put into network format.
1019 MH_ALIGN(m, sizeof(struct spx));
1020 m->m_len = sizeof(*si);
1021 m->m_pkthdr.len = sizeof(*si);
1022 si = mtod(m, struct spx *);
1023 si->si_i = *cb->s_ipx;
1024 si->si_s = cb->s_shdr;
1025 si->si_seq = cb->s_smax + 1;
1026 si->si_len = htons(sizeof(*si));
1027 si->si_cc |= SPX_SP;
1030 if (so->so_options & SO_DEBUG || traceallspxs)
1031 spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
1035 * Stuff checksum and output datagram.
1037 if ((si->si_cc & SPX_SP) == 0) {
1038 if (cb->s_force != (1 + SPXT_PERSIST) ||
1039 cb->s_timer[SPXT_PERSIST] == 0) {
1041 * If this is a new packet and we are not currently
1042 * timing anything, time this one.
1044 if (SSEQ_LT(cb->s_smax, si->si_seq)) {
1045 cb->s_smax = si->si_seq;
1046 if (cb->s_rtt == 0) {
1047 spxstat.spxs_segstimed++;
1048 cb->s_rtseq = si->si_seq;
1053 * Set rexmt timer if not currently set,
1054 * Initial value for retransmit timer is smoothed
1055 * round-trip time + 2 * round-trip time variance.
1056 * Initialize shift counter which is used for backoff
1057 * of retransmit time.
1059 if (cb->s_timer[SPXT_REXMT] == 0 &&
1060 cb->s_snxt != cb->s_rack) {
1061 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1062 if (cb->s_timer[SPXT_PERSIST]) {
1063 cb->s_timer[SPXT_PERSIST] = 0;
1067 } else if (SSEQ_LT(cb->s_smax, si->si_seq)) {
1068 cb->s_smax = si->si_seq;
1070 } else if (cb->s_state < TCPS_ESTABLISHED) {
1072 cb->s_rtt = 1; /* Time initial handshake */
1073 if (cb->s_timer[SPXT_REXMT] == 0)
1074 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1078 * Do not request acks when we ack their data packets or
1079 * when we do a gratuitous window update.
1081 if (((si->si_cc & SPX_SP) == 0) || cb->s_force)
1082 si->si_cc |= SPX_SA;
1083 si->si_seq = htons(si->si_seq);
1084 si->si_alo = htons(alo);
1085 si->si_ack = htons(cb->s_ack);
1088 si->si_sum = ipx_cksum(m, ntohs(si->si_len));
1090 si->si_sum = 0xffff;
1093 if (so->so_options & SO_DEBUG || traceallspxs)
1094 spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
1096 if (so->so_options & SO_DONTROUTE)
1097 error = ipx_outputfl(m, (struct route *)NULL, IPX_ROUTETOIF);
1099 error = ipx_outputfl(m, &cb->s_ipxpcb->ipxp_route, 0);
1104 spxstat.spxs_sndtotal++;
1106 * Data sent (as far as we can tell).
1107 * If this advertises a larger window than any other segment,
1108 * then remember the size of the advertized window.
1109 * Any pending ACK has now been sent.
1112 cb->s_flags &= ~(SF_ACKNOW|SF_DELACK);
1113 if (SSEQ_GT(alo, cb->s_alo))
1121 static int spx_do_persist_panics = 0;
1125 register struct spxpcb *cb;
1127 register int t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
1129 if (cb->s_timer[SPXT_REXMT] && spx_do_persist_panics)
1130 panic("spx_output REXMT");
1132 * Start/restart persistance timer.
1134 SPXT_RANGESET(cb->s_timer[SPXT_PERSIST],
1135 t*spx_backoff[cb->s_rxtshift],
1136 SPXTV_PERSMIN, SPXTV_PERSMAX);
1137 if (cb->s_rxtshift < SPX_MAXRXTSHIFT)
1142 spx_ctloutput(so, sopt)
1144 struct sockopt *sopt;
1146 struct ipxpcb *ipxp = sotoipxpcb(so);
1147 register struct spxpcb *cb;
1155 if (sopt->sopt_level != IPXPROTO_SPX) {
1156 /* This will have to be changed when we do more general
1157 stacking of protocols */
1158 return (ipx_ctloutput(so, sopt));
1163 cb = ipxtospxpcb(ipxp);
1165 switch (sopt->sopt_dir) {
1167 switch (sopt->sopt_name) {
1168 case SO_HEADERS_ON_INPUT:
1172 case SO_HEADERS_ON_OUTPUT:
1175 soptval = cb->s_flags & mask;
1176 error = sooptcopyout(sopt, &soptval, sizeof soptval);
1180 usoptval = cb->s_mtu;
1181 error = sooptcopyout(sopt, &usoptval, sizeof usoptval);
1184 case SO_LAST_HEADER:
1185 error = sooptcopyout(sopt, &cb->s_rhdr,
1189 case SO_DEFAULT_HEADERS:
1190 error = sooptcopyout(sopt, &cb->s_shdr,
1195 error = ENOPROTOOPT;
1200 switch (sopt->sopt_name) {
1201 /* XXX why are these shorts on get and ints on set?
1202 that doesn't make any sense... */
1203 case SO_HEADERS_ON_INPUT:
1207 case SO_HEADERS_ON_OUTPUT:
1210 error = sooptcopyin(sopt, &optval, sizeof optval,
1215 if (cb->s_flags & SF_PI) {
1217 cb->s_flags |= mask;
1219 cb->s_flags &= ~mask;
1220 } else error = EINVAL;
1224 error = sooptcopyin(sopt, &usoptval, sizeof usoptval,
1228 cb->s_mtu = usoptval;
1233 error = sooptcopyin(sopt, &optval, sizeof optval,
1238 cb->s_flags2 |= SF_NEWCALL;
1241 cb->s_flags2 &= ~SF_NEWCALL;
1247 case SO_DEFAULT_HEADERS:
1251 error = sooptcopyin(sopt, &sp, sizeof sp,
1255 cb->s_dt = sp.spx_dt;
1256 cb->s_cc = sp.spx_cc & SPX_EM;
1261 error = ENOPROTOOPT;
1273 struct ipxpcb *ipxp;
1276 ipxp = sotoipxpcb(so);
1277 cb = ipxtospxpcb(ipxp);
1280 spx_drop(cb, ECONNABORTED);
1286 * Accept a connection. Essentially all the work is
1287 * done at higher levels; just return the address
1288 * of the peer, storing through addr.
1293 struct sockaddr **nam;
1295 struct ipxpcb *ipxp;
1296 struct sockaddr_ipx *sipx, ssipx;
1298 ipxp = sotoipxpcb(so);
1300 bzero(sipx, sizeof *sipx);
1301 sipx->sipx_len = sizeof *sipx;
1302 sipx->sipx_family = AF_IPX;
1303 sipx->sipx_addr = ipxp->ipxp_faddr;
1304 *nam = dup_sockaddr((struct sockaddr *)sipx, 0);
1309 spx_attach(so, proto, td)
1316 struct ipxpcb *ipxp;
1321 ipxp = sotoipxpcb(so);
1322 cb = ipxtospxpcb(ipxp);
1327 error = ipx_pcballoc(so, &ipxpcb, td);
1329 goto spx_attach_end;
1330 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
1331 error = soreserve(so, (u_long) 3072, (u_long) 3072);
1333 goto spx_attach_end;
1335 ipxp = sotoipxpcb(so);
1337 MALLOC(cb, struct spxpcb *, sizeof *cb, M_PCB, M_NOWAIT | M_ZERO);
1341 goto spx_attach_end;
1345 mm = m_getclr(M_DONTWAIT, MT_HEADER);
1349 goto spx_attach_end;
1351 cb->s_ipx = mtod(mm, struct ipx *);
1352 cb->s_state = TCPS_LISTEN;
1355 cb->s_q.si_next = cb->s_q.si_prev = &cb->s_q;
1356 cb->s_ipxpcb = ipxp;
1357 cb->s_mtu = 576 - sizeof(struct spx);
1358 cb->s_cwnd = sbspace(sb) * CUNIT / cb->s_mtu;
1359 cb->s_ssthresh = cb->s_cwnd;
1360 cb->s_cwmx = sbspace(sb) * CUNIT / (2 * sizeof(struct spx));
1361 /* Above is recomputed when connecting to account
1362 for changed buffering or mtu's */
1363 cb->s_rtt = SPXTV_SRTTBASE;
1364 cb->s_rttvar = SPXTV_SRTTDFLT << 2;
1365 SPXT_RANGESET(cb->s_rxtcur,
1366 ((SPXTV_SRTTBASE >> 2) + (SPXTV_SRTTDFLT << 2)) >> 1,
1367 SPXTV_MIN, SPXTV_REXMTMAX);
1368 ipxp->ipxp_pcb = (caddr_t)cb;
1375 spx_bind(so, nam, td)
1377 struct sockaddr *nam;
1380 struct ipxpcb *ipxp;
1382 ipxp = sotoipxpcb(so);
1384 return (ipx_pcbbind(ipxp, nam, td));
1388 * Initiate connection to peer.
1389 * Enter SYN_SENT state, and mark socket as connecting.
1390 * Start keep-alive timer, setup prototype header,
1391 * Send initial system packet requesting connection.
1394 spx_connect(so, nam, td)
1396 struct sockaddr *nam;
1401 struct ipxpcb *ipxp;
1404 ipxp = sotoipxpcb(so);
1405 cb = ipxtospxpcb(ipxp);
1408 if (ipxp->ipxp_lport == 0) {
1409 error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td);
1411 goto spx_connect_end;
1413 error = ipx_pcbconnect(ipxp, nam, td);
1415 goto spx_connect_end;
1417 spxstat.spxs_connattempt++;
1418 cb->s_state = TCPS_SYN_SENT;
1421 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
1422 cb->s_force = 1 + SPXTV_KEEP;
1424 * Other party is required to respond to
1425 * the port I send from, but he is not
1426 * required to answer from where I am sending to,
1427 * so allow wildcarding.
1428 * original port I am sending to is still saved in
1431 ipxp->ipxp_fport = 0;
1432 error = spx_output(cb, (struct mbuf *)NULL);
1443 struct ipxpcb *ipxp;
1446 ipxp = sotoipxpcb(so);
1447 cb = ipxtospxpcb(ipxp);
1452 if (cb->s_state > TCPS_LISTEN)
1461 * We may decide later to implement connection closing
1462 * handshaking at the spx level optionally.
1463 * here is the hook to do it:
1466 spx_usr_disconnect(so)
1470 struct ipxpcb *ipxp;
1473 ipxp = sotoipxpcb(so);
1474 cb = ipxtospxpcb(ipxp);
1488 struct ipxpcb *ipxp;
1492 ipxp = sotoipxpcb(so);
1493 cb = ipxtospxpcb(ipxp);
1495 if (ipxp->ipxp_lport == 0)
1496 error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td);
1498 cb->s_state = TCPS_LISTEN;
1503 * After a receive, possibly send acknowledgment
1504 * updating allocation.
1512 struct ipxpcb *ipxp;
1515 ipxp = sotoipxpcb(so);
1516 cb = ipxtospxpcb(ipxp);
1519 cb->s_flags |= SF_RVD;
1520 spx_output(cb, (struct mbuf *)NULL);
1521 cb->s_flags &= ~SF_RVD;
1527 spx_rcvoob(so, m, flags)
1532 struct ipxpcb *ipxp;
1535 ipxp = sotoipxpcb(so);
1536 cb = ipxtospxpcb(ipxp);
1538 if ((cb->s_oobflags & SF_IOOB) || so->so_oobmark ||
1539 (so->so_state & SS_RCVATMARK)) {
1541 *mtod(m, caddr_t) = cb->s_iobc;
1548 spx_send(so, flags, m, addr, controlp, td)
1552 struct sockaddr *addr;
1553 struct mbuf *controlp;
1558 struct ipxpcb *ipxp;
1562 ipxp = sotoipxpcb(so);
1563 cb = ipxtospxpcb(ipxp);
1566 if (flags & PRUS_OOB) {
1567 if (sbspace(&so->so_snd) < -512) {
1571 cb->s_oobflags |= SF_SOOB;
1573 if (controlp != NULL) {
1574 u_short *p = mtod(controlp, u_short *);
1576 if ((p[0] == 5) && (p[1] == 1)) { /* XXXX, for testing */
1577 cb->s_shdr.spx_dt = *(u_char *)(&p[2]);
1583 error = spx_output(cb, m);
1586 if (controlp != NULL)
1600 struct ipxpcb *ipxp;
1604 ipxp = sotoipxpcb(so);
1605 cb = ipxtospxpcb(ipxp);
1609 cb = spx_usrclosed(cb);
1611 error = spx_output(cb, (struct mbuf *)NULL);
1617 spx_sp_attach(so, proto, td)
1623 struct ipxpcb *ipxp;
1625 error = spx_attach(so, proto, td);
1627 ipxp = sotoipxpcb(so);
1628 ((struct spxpcb *)ipxp->ipxp_pcb)->s_flags |=
1629 (SF_HI | SF_HO | SF_PI);
1635 * Create template to be used to send spx packets on a connection.
1636 * Called after host entry created, fills
1637 * in a skeletal spx header (choosing connection id),
1638 * minimizing the amount of work necessary when the connection is used.
1642 register struct spxpcb *cb;
1644 register struct ipxpcb *ipxp = cb->s_ipxpcb;
1645 register struct ipx *ipx = cb->s_ipx;
1646 register struct sockbuf *sb = &(ipxp->ipxp_socket->so_snd);
1648 ipx->ipx_pt = IPXPROTO_SPX;
1649 ipx->ipx_sna = ipxp->ipxp_laddr;
1650 ipx->ipx_dna = ipxp->ipxp_faddr;
1651 cb->s_sid = htons(spx_iss);
1652 spx_iss += SPX_ISSINCR/2;
1654 cb->s_cwnd = (sbspace(sb) * CUNIT) / cb->s_mtu;
1655 cb->s_ssthresh = cb->s_cwnd; /* Try to expand fast to full complement
1657 cb->s_cwmx = (sbspace(sb) * CUNIT) / (2 * sizeof(struct spx));
1658 cb->s_cwmx = max(cb->s_cwmx, cb->s_cwnd);
1659 /* But allow for lots of little packets as well */
1663 * Close a SPIP control block:
1664 * discard spx control block itself
1665 * discard ipx protocol control block
1666 * wake up any sleepers
1668 static struct spxpcb *
1670 register struct spxpcb *cb;
1672 register struct spx_q *s;
1673 struct ipxpcb *ipxp = cb->s_ipxpcb;
1674 struct socket *so = ipxp->ipxp_socket;
1675 register struct mbuf *m;
1677 s = cb->s_q.si_next;
1678 while (s != &(cb->s_q)) {
1680 m = dtom(s->si_prev);
1684 m_free(dtom(cb->s_ipx));
1687 soisdisconnected(so);
1688 ipx_pcbdetach(ipxp);
1689 spxstat.spxs_closed++;
1690 return ((struct spxpcb *)NULL);
1694 * Someday we may do level 3 handshaking
1695 * to close a connection or send a xerox style error.
1696 * For now, just close.
1698 static struct spxpcb *
1700 register struct spxpcb *cb;
1702 return (spx_close(cb));
1705 static struct spxpcb *
1707 register struct spxpcb *cb;
1709 return (spx_close(cb));
1713 * Drop connection, reporting
1714 * the specified error.
1716 static struct spxpcb *
1718 register struct spxpcb *cb;
1721 struct socket *so = cb->s_ipxpcb->ipxp_socket;
1724 * someday, in the xerox world
1725 * we will generate error protocol packets
1726 * announcing that the socket has gone away.
1728 if (TCPS_HAVERCVDSYN(cb->s_state)) {
1729 spxstat.spxs_drops++;
1730 cb->s_state = TCPS_CLOSED;
1733 spxstat.spxs_conndrops++;
1734 so->so_error = errno;
1735 return (spx_close(cb));
1739 * Fast timeout routine for processing delayed acks
1744 register struct ipxpcb *ipxp;
1745 register struct spxpcb *cb;
1748 ipxp = ipxpcb.ipxp_next;
1750 for (; ipxp != &ipxpcb; ipxp = ipxp->ipxp_next)
1751 if ((cb = (struct spxpcb *)ipxp->ipxp_pcb) != NULL &&
1752 (cb->s_flags & SF_DELACK)) {
1753 cb->s_flags &= ~SF_DELACK;
1754 cb->s_flags |= SF_ACKNOW;
1755 spxstat.spxs_delack++;
1756 spx_output(cb, (struct mbuf *)NULL);
1762 * spx protocol timeout routine called every 500 ms.
1763 * Updates the timers in all active pcb's and
1764 * causes finite state machine actions if timers expire.
1769 register struct ipxpcb *ip, *ipnxt;
1770 register struct spxpcb *cb;
1775 * Search through tcb's and update active timers.
1777 ip = ipxpcb.ipxp_next;
1782 while (ip != &ipxpcb) {
1783 cb = ipxtospxpcb(ip);
1784 ipnxt = ip->ipxp_next;
1787 for (i = 0; i < SPXT_NTIMERS; i++) {
1788 if (cb->s_timer[i] && --cb->s_timer[i] == 0) {
1790 if (ipnxt->ipxp_prev != ip)
1800 spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */
1805 * SPX timer processing.
1807 static struct spxpcb *
1808 spx_timers(cb, timer)
1809 register struct spxpcb *cb;
1815 cb->s_force = 1 + timer;
1819 * 2 MSL timeout in shutdown went off. TCP deletes connection
1823 printf("spx: SPXT_2MSL went off for no reason\n");
1824 cb->s_timer[timer] = 0;
1828 * Retransmission timer went off. Message has not
1829 * been acked within retransmit interval. Back off
1830 * to a longer retransmit interval and retransmit one packet.
1833 if (++cb->s_rxtshift > SPX_MAXRXTSHIFT) {
1834 cb->s_rxtshift = SPX_MAXRXTSHIFT;
1835 spxstat.spxs_timeoutdrop++;
1836 cb = spx_drop(cb, ETIMEDOUT);
1839 spxstat.spxs_rexmttimeo++;
1840 rexmt = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
1841 rexmt *= spx_backoff[cb->s_rxtshift];
1842 SPXT_RANGESET(cb->s_rxtcur, rexmt, SPXTV_MIN, SPXTV_REXMTMAX);
1843 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1845 * If we have backed off fairly far, our srtt
1846 * estimate is probably bogus. Clobber it
1847 * so we'll take the next rtt measurement as our srtt;
1848 * move the current srtt into rttvar to keep the current
1849 * retransmit times until then.
1851 if (cb->s_rxtshift > SPX_MAXRXTSHIFT / 4 ) {
1852 cb->s_rttvar += (cb->s_srtt >> 2);
1855 cb->s_snxt = cb->s_rack;
1857 * If timing a packet, stop the timer.
1861 * See very long discussion in tcp_timer.c about congestion
1862 * window and sstrhesh
1864 win = min(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2;
1868 cb->s_ssthresh = win * CUNIT;
1869 spx_output(cb, (struct mbuf *)NULL);
1873 * Persistance timer into zero window.
1874 * Force a probe to be sent.
1877 spxstat.spxs_persisttimeo++;
1879 spx_output(cb, (struct mbuf *)NULL);
1883 * Keep-alive timer went off; send something
1884 * or drop connection if idle for too long.
1887 spxstat.spxs_keeptimeo++;
1888 if (cb->s_state < TCPS_ESTABLISHED)
1890 if (cb->s_ipxpcb->ipxp_socket->so_options & SO_KEEPALIVE) {
1891 if (cb->s_idle >= SPXTV_MAXIDLE)
1893 spxstat.spxs_keepprobe++;
1894 spx_output(cb, (struct mbuf *)NULL);
1897 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
1900 spxstat.spxs_keepdrops++;
1901 cb = spx_drop(cb, ETIMEDOUT);