-#endif
- t->ti_seq = htonl(tp->snd_nxt);
- t->ti_ackno = htonl(tp->rcv_nxt);
- t->ti_sum = 0; /* gratuitous? */
- CKSUM_TCPSET(m, t, r9, sizeof (struct tcpiphdr) + len);
- ip = (struct ip *)t;
- ip->ip_v = IPVERSION;
- ip->ip_hl = 5;
- ip->ip_tos = 0;
- ip->ip_len = len + sizeof(struct tcpiphdr);
- ip->ip_id = ip_id++;
- ip->ip_off = 0;
- ip->ip_ttl = MAXTTL;
- i = ip_send(ip);
- return (i);
+
+ /*
+ * Trace.
+ */
+ if (so->so_options & SO_DEBUG)
+ tcp_trace(TA_OUTPUT, tp->t_state, tp, ti, 0);
+
+ /*
+ * Fill in IP length and desired time to live and
+ * send to IP level.
+ */
+ ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + optlen + len;
+ ((struct ip *)ti)->ip_ttl = TCP_TTL;
+ if (so->so_options & SO_DONTROUTE)
+ error =
+ ip_output(m, tp->t_ipopt, (struct route *)0, IP_ROUTETOIF);
+ else
+ error = ip_output(m, tp->t_ipopt, &tp->t_inpcb->inp_route, 0);
+ if (error)
+ return (error);
+
+ /*
+ * Data sent (as far as we can tell).
+ * If this advertises a larger window than any other segment,
+ * then remember the size of the advertised window.
+ * Drop send for purpose of ACK requirements.
+ */
+ if (win > 0 && SEQ_GT(tp->rcv_nxt+win, tp->rcv_adv))
+ tp->rcv_adv = tp->rcv_nxt + win;
+ tp->t_flags &= ~(TF_ACKNOW|TF_DELACK);
+ if (sendalot && tp->t_force == 0)
+ goto again;
+ return (0);