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
36 * $FreeBSD: src/sys/netipx/spx_usrreq.c,v 1.27.2.1 2001/02/22 09:44:18 bp Exp $
37 * $DragonFly: src/sys/netproto/ipx/spx_usrreq.c,v 1.15 2004/07/31 07:52:56 dillon Exp $
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
43 #include <sys/malloc.h>
46 #include <sys/protosw.h>
47 #include <sys/socket.h>
48 #include <sys/socketvar.h>
50 #include <net/route.h>
51 #include <netinet/tcp_fsm.h>
57 #include "spx_timer.h"
59 #include "spx_debug.h"
62 * SPX protocol implementation.
64 static u_short spx_iss;
65 static u_short spx_newchecks[50];
66 static int spx_hardnosed;
67 static int spx_use_delack = 0;
68 static int traceallspxs = 0;
69 static struct spx spx_savesi;
70 static struct spx_istat spx_istat;
72 /* Following was struct spxstat spxstat; */
74 #define spxstat spx_istat.newstats
77 static int spx_backoff[SPX_MAXRXTSHIFT+1] =
78 { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
80 static struct spxpcb *spx_close(struct spxpcb *cb);
81 static struct spxpcb *spx_disconnect(struct spxpcb *cb);
82 static struct spxpcb *spx_drop(struct spxpcb *cb, int errno);
83 static int spx_output(struct spxpcb *cb, struct mbuf *m0);
84 static int spx_reass(struct spxpcb *cb, struct spx *si, struct mbuf *si_m);
85 static void spx_setpersist(struct spxpcb *cb);
86 static void spx_template(struct spxpcb *cb);
87 static struct spxpcb *spx_timers(struct spxpcb *cb, int timer);
88 static struct spxpcb *spx_usrclosed(struct spxpcb *cb);
90 static int spx_usr_abort(struct socket *so);
91 static int spx_accept(struct socket *so, struct sockaddr **nam);
92 static int spx_attach(struct socket *so, int proto,
93 struct pru_attach_info *ai);
94 static int spx_bind(struct socket *so, struct sockaddr *nam,
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,
108 struct pru_attach_info *ai);
110 struct pr_usrreqs spx_usrreqs = {
111 spx_usr_abort, spx_accept, spx_attach, spx_bind,
112 spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
113 spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
114 spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
115 ipx_sockaddr, sosend, soreceive, sopoll
118 struct pr_usrreqs spx_usrreq_sps = {
119 spx_usr_abort, spx_accept, spx_sp_attach, spx_bind,
120 spx_connect, pru_connect2_notsupp, ipx_control, spx_detach,
121 spx_usr_disconnect, spx_listen, ipx_peeraddr, spx_rcvd,
122 spx_rcvoob, spx_send, pru_sense_null, spx_shutdown,
123 ipx_sockaddr, sosend, soreceive, sopoll
126 static MALLOC_DEFINE(M_SPX_Q, "ipx_spx_q", "IPX Packet Management");
132 spx_iss = 1; /* WRONG !! should fish it out of TODR */
136 spx_input(struct mbuf *m, struct ipxpcb *ipxp)
144 spxstat.spxs_rcvtotal++;
146 panic("No ipxpcb in spx_input\n");
150 cb = ipxtospxpcb(ipxp);
154 if (m->m_len < sizeof(struct spx)) {
155 if ((m = m_pullup(m, sizeof(*si))) == NULL) {
156 spxstat.spxs_rcvshort++;
160 si = mtod(m, struct spx *);
161 si->si_seq = ntohs(si->si_seq);
162 si->si_ack = ntohs(si->si_ack);
163 si->si_alo = ntohs(si->si_alo);
165 so = ipxp->ipxp_socket;
167 if (so->so_options & SO_DEBUG || traceallspxs) {
168 ostate = cb->s_state;
171 if (so->so_options & SO_ACCEPTCONN) {
172 struct spxpcb *ocb = cb;
174 so = sonewconn(so, 0);
179 * This is ugly, but ....
181 * Mark socket as temporary until we're
182 * committed to keeping it. The code at
183 * ``drop'' and ``dropwithreset'' check the
184 * flag dropsocket to see if the temporary
185 * socket created here should be discarded.
186 * We mark the socket as discardable until
187 * we're committed to it below in TCPS_LISTEN.
190 ipxp = (struct ipxpcb *)so->so_pcb;
191 ipxp->ipxp_laddr = si->si_dna;
192 cb = ipxtospxpcb(ipxp);
193 cb->s_mtu = ocb->s_mtu; /* preserve sockopts */
194 cb->s_flags = ocb->s_flags; /* preserve sockopts */
195 cb->s_flags2 = ocb->s_flags2; /* preserve sockopts */
196 cb->s_state = TCPS_LISTEN;
200 * Packet received on connection.
201 * reset idle time and keep-alive timer;
204 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
206 switch (cb->s_state) {
209 struct sockaddr_ipx *sipx, ssipx;
210 struct ipx_addr laddr;
213 * If somebody here was carying on a conversation
214 * and went away, and his pen pal thinks he can
215 * still talk, we get the misdirected packet.
217 if (spx_hardnosed && (si->si_did != 0 || si->si_seq != 0)) {
222 bzero(sipx, sizeof *sipx);
223 sipx->sipx_len = sizeof(*sipx);
224 sipx->sipx_family = AF_IPX;
225 sipx->sipx_addr = si->si_sna;
226 laddr = ipxp->ipxp_laddr;
227 if (ipx_nullhost(laddr))
228 ipxp->ipxp_laddr = si->si_dna;
229 if (ipx_pcbconnect(ipxp, (struct sockaddr *)sipx, &thread0)) {
230 ipxp->ipxp_laddr = laddr;
235 dropsocket = 0; /* committed to socket */
236 cb->s_did = si->si_sid;
237 cb->s_rack = si->si_ack;
238 cb->s_ralo = si->si_alo;
239 #define THREEWAYSHAKE
241 cb->s_state = TCPS_SYN_RECEIVED;
242 cb->s_force = 1 + SPXT_KEEP;
243 spxstat.spxs_accepts++;
244 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
248 * This state means that we have heard a response
249 * to our acceptance of their connection
250 * It is probably logically unnecessary in this
253 case TCPS_SYN_RECEIVED: {
254 if (si->si_did != cb->s_sid) {
259 ipxp->ipxp_fport = si->si_sport;
260 cb->s_timer[SPXT_REXMT] = 0;
261 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
263 cb->s_state = TCPS_ESTABLISHED;
264 spxstat.spxs_accepts++;
269 * This state means that we have gotten a response
270 * to our attempt to establish a connection.
271 * We fill in the data from the other side,
272 * telling us which port to respond to, instead of the well-
273 * known one we might have sent to in the first place.
274 * We also require that this is a response to our
278 if (si->si_did != cb->s_sid) {
282 spxstat.spxs_connects++;
283 cb->s_did = si->si_sid;
284 cb->s_rack = si->si_ack;
285 cb->s_ralo = si->si_alo;
286 cb->s_dport = ipxp->ipxp_fport = si->si_sport;
287 cb->s_timer[SPXT_REXMT] = 0;
288 cb->s_flags |= SF_ACKNOW;
290 cb->s_state = TCPS_ESTABLISHED;
291 /* Use roundtrip time of connection request for initial rtt */
293 cb->s_srtt = cb->s_rtt << 3;
294 cb->s_rttvar = cb->s_rtt << 1;
295 SPXT_RANGESET(cb->s_rxtcur,
296 ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
297 SPXTV_MIN, SPXTV_REXMTMAX);
301 if (so->so_options & SO_DEBUG || traceallspxs)
302 spx_trace(SA_INPUT, (u_char)ostate, cb, &spx_savesi, 0);
304 m->m_len -= sizeof(struct ipx);
305 m->m_pkthdr.len -= sizeof(struct ipx);
306 m->m_data += sizeof(struct ipx);
308 if (spx_reass(cb, si, m)) {
311 if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT)))
312 spx_output(cb, (struct mbuf *)NULL);
313 cb->s_flags &= ~(SF_WIN|SF_RXT);
319 si->si_seq = ntohs(si->si_seq);
320 si->si_ack = ntohs(si->si_ack);
321 si->si_alo = ntohs(si->si_alo);
323 if (cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG || traceallspxs)
324 spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0);
329 if (cb == 0 || cb->s_ipxpcb->ipxp_socket->so_options & SO_DEBUG ||
331 spx_trace(SA_DROP, (u_char)ostate, cb, &spx_savesi, 0);
335 static int spxrexmtthresh = 3;
338 * This is structurally similar to the tcp reassembly routine
339 * but its function is somewhat different: It merely queues
340 * packets up, and suppresses duplicates.
343 spx_reass(struct spxpcb *cb, struct spx *si, struct mbuf *si_m)
348 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) {
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 nq = malloc(sizeof(struct spx_q), M_SPX_Q, M_INTNOWAIT);
549 insque(nq, q->si_prev);
552 * If this packet is urgent, inform process
554 if (si->si_cc & SPX_OB) {
555 cb->s_iobc = ((char *)si)[1 + sizeof(*si)];
557 cb->s_oobflags |= SF_IOOB;
560 #define SPINC sizeof(struct spxhdr)
562 * Loop through all packets queued up to update acknowledge
563 * number, and present all acknowledged data to user;
564 * If in packet interface mode, show packet headers.
566 for (q = cb->s_q.si_next; q != &cb->s_q; q = q->si_next) {
567 if (SI(q)->si_seq == cb->s_ack) {
570 if (SI(q)->si_cc & SPX_OB) {
571 cb->s_oobflags &= ~SF_IOOB;
572 if (so->so_rcv.sb_cc)
573 so->so_oobmark = so->so_rcv.sb_cc;
575 so->so_state |= SS_RCVATMARK;
582 spxstat.spxs_rcvpack++;
584 if (cb->s_flags2 & SF_NEWCALL) {
585 struct spxhdr *sp = mtod(m, struct spxhdr *);
586 u_char dt = sp->spx_dt;
588 if (dt != cb->s_rhdr.spx_dt) {
590 m_getclr(MB_DONTWAIT, MT_CONTROL);
595 cb->s_rhdr.spx_dt = dt;
596 mm->m_len = 5; /*XXX*/
599 *(u_char *)(&s[2]) = dt;
600 sbappend(&so->so_rcv, mm);
603 if (sp->spx_cc & SPX_OB) {
604 m_chtype(m, MT_OOBDATA);
607 so->so_state &= ~SS_RCVATMARK;
612 m->m_pkthdr.len -= SPINC;
614 if ((sp->spx_cc & SPX_EM) || packetp) {
615 sbappendrecord(&so->so_rcv, m);
618 sbappend(&so->so_rcv, m);
622 sbappendrecord(&so->so_rcv, m);
624 cb->s_rhdr = *mtod(m, struct spxhdr *);
627 m->m_pkthdr.len -= SPINC;
628 sbappend(&so->so_rcv, m);
639 spx_ctlinput(int cmd, struct sockaddr *arg_as_sa, void *dummy)
641 caddr_t arg = (/* XXX */ caddr_t)arg_as_sa;
643 struct sockaddr_ipx *sipx;
645 if (cmd < 0 || cmd > PRC_NCMDS)
655 case PRC_HOSTUNREACH:
656 sipx = (struct sockaddr_ipx *)arg;
657 if (sipx->sipx_family != AF_IPX)
659 na = &sipx->sipx_addr;
669 spx_fixmtu(struct ipxpcb *ipxp)
671 struct spxpcb *cb = (struct spxpcb *)(ipxp->ipxp_pcb);
677 struct mbuf *firstbad, *m0;
681 * The notification that we have sent
682 * too much is bad news -- we will
683 * have to go through queued up so far
684 * splitting ones which are too big and
685 * reassigning sequence numbers and checksums.
686 * we should then retransmit all packets from
687 * one above the offending packet to the last one
688 * we had sent (or our allocation)
689 * then the offending one so that the any queued
690 * data at our destination will be discarded.
692 ep = (struct ipx_errp *)ipxp->ipxp_notify_param;
693 sb = &ipxp->ipxp_socket->so_snd;
694 cb->s_mtu = ep->ipx_err_param;
695 badseq = ep->ipx_err_ipx.si_seq;
696 for (m = sb->sb_mb; m != NULL; m = m->m_nextpkt) {
697 si = mtod(m, struct spx *);
698 if (si->si_seq == badseq)
705 /* calculate length */
706 for (m0 = m, len = 0; m != NULL; m = m->m_next)
708 if (len > cb->s_mtu) {
717 spx_output(struct spxpcb *cb, struct mbuf *m0)
719 struct socket *so = cb->s_ipxpcb->ipxp_socket;
720 struct mbuf *m = NULL;
721 struct spx *si = NULL;
722 struct sockbuf *sb = &so->so_snd;
723 int len = 0, win, rcv_win;
724 short span, off, recordp = 0;
726 int error = 0, sendalot;
736 * Make sure that packet isn't too big.
738 for (m = m0; m != NULL; m = m->m_next) {
741 if (m->m_flags & M_EOR)
744 datalen = (cb->s_flags & SF_HO) ?
745 len - sizeof(struct spxhdr) : len;
747 if (cb->s_flags & SF_PI) {
751 int oldEM = cb->s_cc & SPX_EM;
756 * Here we are only being called
757 * from usrreq(), so it is OK to
760 m = m_copym(m0, 0, mtu, MB_WAIT);
761 if (cb->s_flags & SF_NEWCALL) {
765 mm->m_flags &= ~M_EOR;
769 error = spx_output(cb, m);
782 * Force length even, by adding a "garbage byte" if
787 if (M_TRAILINGSPACE(m) >= 1)
790 struct mbuf *m1 = m_get(MB_DONTWAIT, MT_DATA);
797 *(mtod(m1, u_char *)) = 0;
801 m = m_gethdr(MB_DONTWAIT, MT_HEADER);
807 * Fill in mbuf with extended SP header
808 * and addresses and length put into network format.
810 MH_ALIGN(m, sizeof(struct spx));
811 m->m_len = sizeof(struct spx);
813 si = mtod(m, struct spx *);
814 si->si_i = *cb->s_ipx;
815 si->si_s = cb->s_shdr;
816 if ((cb->s_flags & SF_PI) && (cb->s_flags & SF_HO)) {
818 if (m0->m_len < sizeof(*sh)) {
819 if((m0 = m_pullup(m0, sizeof(*sh))) == NULL) {
826 sh = mtod(m0, struct spxhdr *);
827 si->si_dt = sh->spx_dt;
828 si->si_cc |= sh->spx_cc & SPX_EM;
829 m0->m_len -= sizeof(*sh);
830 m0->m_data += sizeof(*sh);
834 if ((cb->s_flags2 & SF_NEWCALL) && recordp) {
838 if (cb->s_oobflags & SF_SOOB) {
841 * make sure OB packets convey exactly 1 byte.
842 * If the packet is 1 byte or larger, we
843 * have already guaranted there to be at least
844 * one garbage byte for the checksum, and
845 * extra bytes shouldn't hurt!
847 if (len > sizeof(*si)) {
849 len = (1 + sizeof(*si));
852 si->si_len = htons((u_short)len);
853 m->m_pkthdr.len = ((len - 1) | 1) + 1;
855 * queue stuff up for output
857 sbappendrecord(sb, m);
861 idle = (cb->s_smax == (cb->s_rack - 1));
865 off = cb->s_snxt - cb->s_rack;
866 win = min(cb->s_swnd, (cb->s_cwnd / CUNIT));
869 * If in persist timeout with window of 0, send a probe.
870 * Otherwise, if window is small but nonzero
871 * and timer expired, send what we can and go into
874 if (cb->s_force == 1 + SPXT_PERSIST) {
876 cb->s_timer[SPXT_PERSIST] = 0;
880 span = cb->s_seq - cb->s_rack;
881 len = min(span, win) - off;
885 * Window shrank after we went into it.
886 * If window shrank to 0, cancel pending
887 * restransmission and pull s_snxt back
888 * to (closed) window. We will enter persist
889 * state below. If the widndow didn't close completely,
890 * just wait for an ACK.
894 cb->s_timer[SPXT_REXMT] = 0;
895 cb->s_snxt = cb->s_rack;
900 rcv_win = sbspace(&so->so_rcv);
903 * Send if we owe peer an ACK.
905 if (cb->s_oobflags & SF_SOOB) {
907 * must transmit this out of band packet
909 cb->s_oobflags &= ~ SF_SOOB;
911 spxstat.spxs_sndurg++;
914 if (cb->s_flags & SF_ACKNOW)
916 if (cb->s_state < TCPS_ESTABLISHED)
919 * Silly window can't happen in spx.
920 * Code from tcp deleted.
925 * Compare available window to amount of window
926 * known to peer (as advertised window less
927 * next expected input.) If the difference is at least two
928 * packets or at least 35% of the mximum possible window,
929 * then want to send a window update to peer.
932 u_short delta = 1 + cb->s_alo - cb->s_ack;
933 int adv = rcv_win - (delta * cb->s_mtu);
935 if ((so->so_rcv.sb_cc == 0 && adv >= (2 * cb->s_mtu)) ||
936 (100 * adv / so->so_rcv.sb_hiwat >= 35)) {
937 spxstat.spxs_sndwinup++;
938 cb->s_flags |= SF_ACKNOW;
944 * Many comments from tcp_output.c are appropriate here
946 * If send window is too small, there is data to transmit, and no
947 * retransmit or persist is pending, then go to persist state.
948 * If nothing happens soon, send when timer expires:
949 * if window is nonzero, transmit what we can,
950 * otherwise send a probe.
952 if (so->so_snd.sb_cc && cb->s_timer[SPXT_REXMT] == 0 &&
953 cb->s_timer[SPXT_PERSIST] == 0) {
958 * No reason to send a packet, just return.
965 * Find requested packet.
969 cb->s_want = cb->s_snxt;
970 for (m = sb->sb_mb; m != NULL; m = m->m_nextpkt) {
971 si = mtod(m, struct spx *);
972 if (SSEQ_LEQ(cb->s_snxt, si->si_seq))
977 if (si->si_seq == cb->s_snxt)
980 spxstat.spxs_sndvoid++, si = 0;
988 alo = cb->s_ack - 1 + (rcv_win / ((short)cb->s_mtu));
989 if (SSEQ_LT(alo, cb->s_alo))
994 * must make a copy of this packet for
995 * ipx_output to monkey with
997 m = m_copy(m, 0, (int)M_COPYALL);
1001 si = mtod(m, struct spx *);
1002 if (SSEQ_LT(si->si_seq, cb->s_smax))
1003 spxstat.spxs_sndrexmitpack++;
1005 spxstat.spxs_sndpack++;
1006 } else if (cb->s_force || cb->s_flags & SF_ACKNOW) {
1008 * Must send an acknowledgement or a probe
1011 spxstat.spxs_sndprobe++;
1012 if (cb->s_flags & SF_ACKNOW)
1013 spxstat.spxs_sndacks++;
1014 m = m_gethdr(MB_DONTWAIT, MT_HEADER);
1018 * Fill in mbuf with extended SP header
1019 * and addresses and length put into network format.
1021 MH_ALIGN(m, sizeof(struct spx));
1022 m->m_len = sizeof(*si);
1023 m->m_pkthdr.len = sizeof(*si);
1024 si = mtod(m, struct spx *);
1025 si->si_i = *cb->s_ipx;
1026 si->si_s = cb->s_shdr;
1027 si->si_seq = cb->s_smax + 1;
1028 si->si_len = htons(sizeof(*si));
1029 si->si_cc |= SPX_SP;
1032 if (so->so_options & SO_DEBUG || traceallspxs)
1033 spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
1037 * Stuff checksum and output datagram.
1039 if ((si->si_cc & SPX_SP) == 0) {
1040 if (cb->s_force != (1 + SPXT_PERSIST) ||
1041 cb->s_timer[SPXT_PERSIST] == 0) {
1043 * If this is a new packet and we are not currently
1044 * timing anything, time this one.
1046 if (SSEQ_LT(cb->s_smax, si->si_seq)) {
1047 cb->s_smax = si->si_seq;
1048 if (cb->s_rtt == 0) {
1049 spxstat.spxs_segstimed++;
1050 cb->s_rtseq = si->si_seq;
1055 * Set rexmt timer if not currently set,
1056 * Initial value for retransmit timer is smoothed
1057 * round-trip time + 2 * round-trip time variance.
1058 * Initialize shift counter which is used for backoff
1059 * of retransmit time.
1061 if (cb->s_timer[SPXT_REXMT] == 0 &&
1062 cb->s_snxt != cb->s_rack) {
1063 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1064 if (cb->s_timer[SPXT_PERSIST]) {
1065 cb->s_timer[SPXT_PERSIST] = 0;
1069 } else if (SSEQ_LT(cb->s_smax, si->si_seq)) {
1070 cb->s_smax = si->si_seq;
1072 } else if (cb->s_state < TCPS_ESTABLISHED) {
1074 cb->s_rtt = 1; /* Time initial handshake */
1075 if (cb->s_timer[SPXT_REXMT] == 0)
1076 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1080 * Do not request acks when we ack their data packets or
1081 * when we do a gratuitous window update.
1083 if (((si->si_cc & SPX_SP) == 0) || cb->s_force)
1084 si->si_cc |= SPX_SA;
1085 si->si_seq = htons(si->si_seq);
1086 si->si_alo = htons(alo);
1087 si->si_ack = htons(cb->s_ack);
1090 si->si_sum = ipx_cksum(m, ntohs(si->si_len));
1092 si->si_sum = 0xffff;
1095 if (so->so_options & SO_DEBUG || traceallspxs)
1096 spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
1098 if (so->so_options & SO_DONTROUTE)
1099 error = ipx_outputfl(m, (struct route *)NULL, IPX_ROUTETOIF);
1101 error = ipx_outputfl(m, &cb->s_ipxpcb->ipxp_route, 0);
1106 spxstat.spxs_sndtotal++;
1108 * Data sent (as far as we can tell).
1109 * If this advertises a larger window than any other segment,
1110 * then remember the size of the advertized window.
1111 * Any pending ACK has now been sent.
1114 cb->s_flags &= ~(SF_ACKNOW|SF_DELACK);
1115 if (SSEQ_GT(alo, cb->s_alo))
1123 static int spx_do_persist_panics = 0;
1126 spx_setpersist(struct spxpcb *cb)
1128 int t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
1130 if (cb->s_timer[SPXT_REXMT] && spx_do_persist_panics)
1131 panic("spx_output REXMT");
1133 * Start/restart persistance timer.
1135 SPXT_RANGESET(cb->s_timer[SPXT_PERSIST],
1136 t*spx_backoff[cb->s_rxtshift],
1137 SPXTV_PERSMIN, SPXTV_PERSMAX);
1138 if (cb->s_rxtshift < SPX_MAXRXTSHIFT)
1143 spx_ctloutput(struct socket *so, struct sockopt *sopt)
1145 struct ipxpcb *ipxp = sotoipxpcb(so);
1154 if (sopt->sopt_level != IPXPROTO_SPX) {
1155 /* This will have to be changed when we do more general
1156 stacking of protocols */
1157 return (ipx_ctloutput(so, sopt));
1162 cb = ipxtospxpcb(ipxp);
1164 switch (sopt->sopt_dir) {
1166 switch (sopt->sopt_name) {
1167 case SO_HEADERS_ON_INPUT:
1171 case SO_HEADERS_ON_OUTPUT:
1174 soptval = cb->s_flags & mask;
1175 error = sooptcopyout(sopt, &soptval, sizeof soptval);
1179 usoptval = cb->s_mtu;
1180 error = sooptcopyout(sopt, &usoptval, sizeof usoptval);
1183 case SO_LAST_HEADER:
1184 error = sooptcopyout(sopt, &cb->s_rhdr,
1188 case SO_DEFAULT_HEADERS:
1189 error = sooptcopyout(sopt, &cb->s_shdr,
1194 error = ENOPROTOOPT;
1199 switch (sopt->sopt_name) {
1200 /* XXX why are these shorts on get and ints on set?
1201 that doesn't make any sense... */
1202 case SO_HEADERS_ON_INPUT:
1206 case SO_HEADERS_ON_OUTPUT:
1209 error = sooptcopyin(sopt, &optval, sizeof optval,
1214 if (cb->s_flags & SF_PI) {
1216 cb->s_flags |= mask;
1218 cb->s_flags &= ~mask;
1219 } else error = EINVAL;
1223 error = sooptcopyin(sopt, &usoptval, sizeof usoptval,
1227 cb->s_mtu = usoptval;
1232 error = sooptcopyin(sopt, &optval, sizeof optval,
1237 cb->s_flags2 |= SF_NEWCALL;
1240 cb->s_flags2 &= ~SF_NEWCALL;
1246 case SO_DEFAULT_HEADERS:
1250 error = sooptcopyin(sopt, &sp, sizeof sp,
1254 cb->s_dt = sp.spx_dt;
1255 cb->s_cc = sp.spx_cc & SPX_EM;
1260 error = ENOPROTOOPT;
1268 spx_usr_abort(struct socket *so)
1271 struct ipxpcb *ipxp;
1274 ipxp = sotoipxpcb(so);
1275 cb = ipxtospxpcb(ipxp);
1278 spx_drop(cb, ECONNABORTED);
1284 * Accept a connection. Essentially all the work is
1285 * done at higher levels; just return the address
1286 * of the peer, storing through addr.
1289 spx_accept(struct socket *so, 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);
1305 spx_attach(struct socket *so, int proto, struct pru_attach_info *ai)
1309 struct ipxpcb *ipxp;
1314 ipxp = sotoipxpcb(so);
1315 cb = ipxtospxpcb(ipxp);
1320 error = ipx_pcballoc(so, &ipxpcb);
1322 goto spx_attach_end;
1323 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
1324 error = soreserve(so, (u_long) 3072, (u_long) 3072,
1327 goto spx_attach_end;
1329 ipxp = sotoipxpcb(so);
1331 MALLOC(cb, struct spxpcb *, sizeof *cb, M_PCB, M_INTWAIT | M_ZERO);
1334 mm = m_getclr(MB_DONTWAIT, MT_HEADER);
1338 goto spx_attach_end;
1341 cb->s_ipx = mtod(mm, struct ipx *);
1342 cb->s_state = TCPS_LISTEN;
1345 cb->s_q.si_next = cb->s_q.si_prev = &cb->s_q;
1346 cb->s_ipxpcb = ipxp;
1347 cb->s_mtu = 576 - sizeof(struct spx);
1348 cb->s_cwnd = sbspace(sb) * CUNIT / cb->s_mtu;
1349 cb->s_ssthresh = cb->s_cwnd;
1350 cb->s_cwmx = sbspace(sb) * CUNIT / (2 * sizeof(struct spx));
1351 /* Above is recomputed when connecting to account
1352 for changed buffering or mtu's */
1353 cb->s_rtt = SPXTV_SRTTBASE;
1354 cb->s_rttvar = SPXTV_SRTTDFLT << 2;
1355 SPXT_RANGESET(cb->s_rxtcur,
1356 ((SPXTV_SRTTBASE >> 2) + (SPXTV_SRTTDFLT << 2)) >> 1,
1357 SPXTV_MIN, SPXTV_REXMTMAX);
1358 ipxp->ipxp_pcb = (caddr_t)cb;
1365 spx_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
1367 struct ipxpcb *ipxp;
1369 ipxp = sotoipxpcb(so);
1371 return (ipx_pcbbind(ipxp, nam, td));
1375 * Initiate connection to peer.
1376 * Enter SYN_SENT state, and mark socket as connecting.
1377 * Start keep-alive timer, setup prototype header,
1378 * Send initial system packet requesting connection.
1381 spx_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
1385 struct ipxpcb *ipxp;
1388 ipxp = sotoipxpcb(so);
1389 cb = ipxtospxpcb(ipxp);
1392 if (ipxp->ipxp_lport == 0) {
1393 error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td);
1395 goto spx_connect_end;
1397 error = ipx_pcbconnect(ipxp, nam, td);
1399 goto spx_connect_end;
1401 spxstat.spxs_connattempt++;
1402 cb->s_state = TCPS_SYN_SENT;
1405 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
1406 cb->s_force = 1 + SPXTV_KEEP;
1408 * Other party is required to respond to
1409 * the port I send from, but he is not
1410 * required to answer from where I am sending to,
1411 * so allow wildcarding.
1412 * original port I am sending to is still saved in
1415 ipxp->ipxp_fport = 0;
1416 error = spx_output(cb, (struct mbuf *)NULL);
1423 spx_detach(struct socket *so)
1426 struct ipxpcb *ipxp;
1429 ipxp = sotoipxpcb(so);
1430 cb = ipxtospxpcb(ipxp);
1435 if (cb->s_state > TCPS_LISTEN)
1444 * We may decide later to implement connection closing
1445 * handshaking at the spx level optionally.
1446 * here is the hook to do it:
1449 spx_usr_disconnect(struct socket *so)
1452 struct ipxpcb *ipxp;
1455 ipxp = sotoipxpcb(so);
1456 cb = ipxtospxpcb(ipxp);
1465 spx_listen(struct socket *so, struct thread *td)
1468 struct ipxpcb *ipxp;
1472 ipxp = sotoipxpcb(so);
1473 cb = ipxtospxpcb(ipxp);
1475 if (ipxp->ipxp_lport == 0)
1476 error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td);
1478 cb->s_state = TCPS_LISTEN;
1483 * After a receive, possibly send acknowledgment
1484 * updating allocation.
1487 spx_rcvd(struct socket *so, int flags)
1490 struct ipxpcb *ipxp;
1493 ipxp = sotoipxpcb(so);
1494 cb = ipxtospxpcb(ipxp);
1497 cb->s_flags |= SF_RVD;
1498 spx_output(cb, (struct mbuf *)NULL);
1499 cb->s_flags &= ~SF_RVD;
1505 spx_rcvoob(struct socket *so, struct mbuf *m, int flags)
1507 struct ipxpcb *ipxp;
1510 ipxp = sotoipxpcb(so);
1511 cb = ipxtospxpcb(ipxp);
1513 if ((cb->s_oobflags & SF_IOOB) || so->so_oobmark ||
1514 (so->so_state & SS_RCVATMARK)) {
1516 *mtod(m, caddr_t) = cb->s_iobc;
1523 spx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
1524 struct mbuf *controlp, struct thread *td)
1528 struct ipxpcb *ipxp;
1532 ipxp = sotoipxpcb(so);
1533 cb = ipxtospxpcb(ipxp);
1536 if (flags & PRUS_OOB) {
1537 if (sbspace(&so->so_snd) < -512) {
1541 cb->s_oobflags |= SF_SOOB;
1543 if (controlp != NULL) {
1544 u_short *p = mtod(controlp, u_short *);
1546 if ((p[0] == 5) && (p[1] == 1)) { /* XXXX, for testing */
1547 cb->s_shdr.spx_dt = *(u_char *)(&p[2]);
1553 error = spx_output(cb, m);
1556 if (controlp != NULL)
1565 spx_shutdown(struct socket *so)
1569 struct ipxpcb *ipxp;
1573 ipxp = sotoipxpcb(so);
1574 cb = ipxtospxpcb(ipxp);
1578 cb = spx_usrclosed(cb);
1580 error = spx_output(cb, (struct mbuf *)NULL);
1586 spx_sp_attach(struct socket *so, int proto, struct pru_attach_info *ai)
1589 struct ipxpcb *ipxp;
1591 error = spx_attach(so, proto, ai);
1593 ipxp = sotoipxpcb(so);
1594 ((struct spxpcb *)ipxp->ipxp_pcb)->s_flags |=
1595 (SF_HI | SF_HO | SF_PI);
1601 * Create template to be used to send spx packets on a connection.
1602 * Called after host entry created, fills
1603 * in a skeletal spx header (choosing connection id),
1604 * minimizing the amount of work necessary when the connection is used.
1607 spx_template(struct spxpcb *cb)
1609 struct ipxpcb *ipxp = cb->s_ipxpcb;
1610 struct ipx *ipx = cb->s_ipx;
1611 struct sockbuf *sb = &(ipxp->ipxp_socket->so_snd);
1613 ipx->ipx_pt = IPXPROTO_SPX;
1614 ipx->ipx_sna = ipxp->ipxp_laddr;
1615 ipx->ipx_dna = ipxp->ipxp_faddr;
1616 cb->s_sid = htons(spx_iss);
1617 spx_iss += SPX_ISSINCR/2;
1619 cb->s_cwnd = (sbspace(sb) * CUNIT) / cb->s_mtu;
1620 cb->s_ssthresh = cb->s_cwnd; /* Try to expand fast to full complement
1622 cb->s_cwmx = (sbspace(sb) * CUNIT) / (2 * sizeof(struct spx));
1623 cb->s_cwmx = max(cb->s_cwmx, cb->s_cwnd);
1624 /* But allow for lots of little packets as well */
1628 * Close a SPIP control block:
1629 * discard spx control block itself
1630 * discard ipx protocol control block
1631 * wake up any sleepers
1633 static struct spxpcb *
1634 spx_close(struct spxpcb *cb)
1638 struct ipxpcb *ipxp = cb->s_ipxpcb;
1639 struct socket *so = ipxp->ipxp_socket;
1642 q = cb->s_q.si_next;
1643 while (q != &(cb->s_q)) {
1651 m_free(cb->s_ipx_m);
1654 soisdisconnected(so);
1655 ipx_pcbdetach(ipxp);
1656 spxstat.spxs_closed++;
1657 return ((struct spxpcb *)NULL);
1661 * Someday we may do level 3 handshaking
1662 * to close a connection or send a xerox style error.
1663 * For now, just close.
1665 static struct spxpcb *
1666 spx_usrclosed(struct spxpcb *cb)
1668 return (spx_close(cb));
1671 static struct spxpcb *
1672 spx_disconnect(struct spxpcb *cb)
1674 return (spx_close(cb));
1678 * Drop connection, reporting
1679 * the specified error.
1681 static struct spxpcb *
1682 spx_drop(struct spxpcb *cb, int errno)
1684 struct socket *so = cb->s_ipxpcb->ipxp_socket;
1687 * someday, in the xerox world
1688 * we will generate error protocol packets
1689 * announcing that the socket has gone away.
1691 if (TCPS_HAVERCVDSYN(cb->s_state)) {
1692 spxstat.spxs_drops++;
1693 cb->s_state = TCPS_CLOSED;
1696 spxstat.spxs_conndrops++;
1697 so->so_error = errno;
1698 return (spx_close(cb));
1702 * Fast timeout routine for processing delayed acks
1707 struct ipxpcb *ipxp;
1711 ipxp = ipxpcb.ipxp_next;
1713 for (; ipxp != &ipxpcb; ipxp = ipxp->ipxp_next) {
1714 if ((cb = (struct spxpcb *)ipxp->ipxp_pcb) != NULL &&
1715 (cb->s_flags & SF_DELACK)) {
1716 cb->s_flags &= ~SF_DELACK;
1717 cb->s_flags |= SF_ACKNOW;
1718 spxstat.spxs_delack++;
1719 spx_output(cb, (struct mbuf *)NULL);
1727 * spx protocol timeout routine called every 500 ms.
1728 * Updates the timers in all active pcb's and
1729 * causes finite state machine actions if timers expire.
1734 struct ipxpcb *ip, *ipnxt;
1740 * Search through tcb's and update active timers.
1742 ip = ipxpcb.ipxp_next;
1747 while (ip != &ipxpcb) {
1748 cb = ipxtospxpcb(ip);
1749 ipnxt = ip->ipxp_next;
1752 for (i = 0; i < SPXT_NTIMERS; i++) {
1753 if (cb->s_timer[i] && --cb->s_timer[i] == 0) {
1755 if (ipnxt->ipxp_prev != ip)
1765 spx_iss += SPX_ISSINCR/PR_SLOWHZ; /* increment iss */
1770 * SPX timer processing.
1772 static struct spxpcb *
1773 spx_timers(struct spxpcb *cb, int timer)
1778 cb->s_force = 1 + timer;
1782 * 2 MSL timeout in shutdown went off. TCP deletes connection
1786 printf("spx: SPXT_2MSL went off for no reason\n");
1787 cb->s_timer[timer] = 0;
1791 * Retransmission timer went off. Message has not
1792 * been acked within retransmit interval. Back off
1793 * to a longer retransmit interval and retransmit one packet.
1796 if (++cb->s_rxtshift > SPX_MAXRXTSHIFT) {
1797 cb->s_rxtshift = SPX_MAXRXTSHIFT;
1798 spxstat.spxs_timeoutdrop++;
1799 cb = spx_drop(cb, ETIMEDOUT);
1802 spxstat.spxs_rexmttimeo++;
1803 rexmt = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
1804 rexmt *= spx_backoff[cb->s_rxtshift];
1805 SPXT_RANGESET(cb->s_rxtcur, rexmt, SPXTV_MIN, SPXTV_REXMTMAX);
1806 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur;
1808 * If we have backed off fairly far, our srtt
1809 * estimate is probably bogus. Clobber it
1810 * so we'll take the next rtt measurement as our srtt;
1811 * move the current srtt into rttvar to keep the current
1812 * retransmit times until then.
1814 if (cb->s_rxtshift > SPX_MAXRXTSHIFT / 4 ) {
1815 cb->s_rttvar += (cb->s_srtt >> 2);
1818 cb->s_snxt = cb->s_rack;
1820 * If timing a packet, stop the timer.
1824 * See very long discussion in tcp_timer.c about congestion
1825 * window and sstrhesh
1827 win = min(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2;
1831 cb->s_ssthresh = win * CUNIT;
1832 spx_output(cb, (struct mbuf *)NULL);
1836 * Persistance timer into zero window.
1837 * Force a probe to be sent.
1840 spxstat.spxs_persisttimeo++;
1842 spx_output(cb, (struct mbuf *)NULL);
1846 * Keep-alive timer went off; send something
1847 * or drop connection if idle for too long.
1850 spxstat.spxs_keeptimeo++;
1851 if (cb->s_state < TCPS_ESTABLISHED)
1853 if (cb->s_ipxpcb->ipxp_socket->so_options & SO_KEEPALIVE) {
1854 if (cb->s_idle >= SPXTV_MAXIDLE)
1856 spxstat.spxs_keepprobe++;
1857 spx_output(cb, (struct mbuf *)NULL);
1860 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP;
1863 spxstat.spxs_keepdrops++;
1864 cb = spx_drop(cb, ETIMEDOUT);