-/* tcp_subr.c 4.28 82/06/26 */
+/* tcp_subr.c 4.40 83/02/10 */
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/socket.h"
#include "../h/socketvar.h"
#include "../h/protosw.h"
-#include "../net/in.h"
+#include "../h/errno.h"
+
#include "../net/route.h"
-#include "../net/in_pcb.h"
-#include "../net/in_systm.h"
#include "../net/if.h"
-#include "../net/ip.h"
-#include "../net/ip_var.h"
-#include "../net/ip_icmp.h"
-#include "../net/tcp.h"
-#include "../net/tcp_fsm.h"
-#include "../net/tcp_seq.h"
-#include "../net/tcp_timer.h"
-#include "../net/tcp_var.h"
-#include "../net/tcpip.h"
-#include <errno.h>
+
+#include "../netinet/in.h"
+#include "../netinet/in_pcb.h"
+#include "../netinet/in_systm.h"
+#include "../netinet/ip.h"
+#include "../netinet/ip_var.h"
+#include "../netinet/ip_icmp.h"
+#include "../netinet/tcp.h"
+#include "../netinet/tcp_fsm.h"
+#include "../netinet/tcp_seq.h"
+#include "../netinet/tcp_timer.h"
+#include "../netinet/tcp_var.h"
+#include "../netinet/tcpip.h"
/*
* Tcp initialization
register struct mbuf *m;
register struct tcpiphdr *n;
- m = m_get(M_WAIT);
- if (m == 0)
+ m = m_get(M_WAIT, MT_HEADER);
+ if (m == NULL)
return (0);
m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
m->m_len = sizeof (struct tcpiphdr);
ro = &tp->t_inpcb->inp_route;
}
if (flags == 0) {
- m = m_get(M_DONTWAIT);
- if (m == 0)
+ m = m_get(M_DONTWAIT, MT_HEADER);
+ if (m == NULL)
return;
- m->m_off = MMINOFF;
m->m_len = sizeof (struct tcpiphdr) + 1;
*mtod(m, struct tcpiphdr *) = *ti;
ti = mtod(m, struct tcpiphdr *);
}
ti->ti_next = ti->ti_prev = 0;
ti->ti_x1 = 0;
- ti->ti_len = sizeof (struct tcphdr) + tlen;
- ti->ti_seq = seq;
- ti->ti_ack = ack;
-#if vax
- ti->ti_len = htons((u_short)ti->ti_len);
- ti->ti_seq = htonl(ti->ti_seq);
- ti->ti_ack = htonl(ti->ti_ack);
-#endif
+ ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
+ ti->ti_seq = htonl(seq);
+ ti->ti_ack = htonl(ack);
ti->ti_x2 = 0;
ti->ti_off = sizeof (struct tcphdr) >> 2;
ti->ti_flags = flags;
- ti->ti_win = win;
-#if vax
- ti->ti_win = htons(ti->ti_win);
-#endif
+ ti->ti_win = htons((u_short)win);
ti->ti_urp = 0;
ti->ti_sum = in_cksum(m, sizeof (struct tcpiphdr) + tlen);
((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + tlen;
tcp_newtcpcb(inp)
struct inpcb *inp;
{
- struct mbuf *m = m_getclr(M_DONTWAIT);
+ struct mbuf *m = m_getclr(M_DONTWAIT, MT_PCB);
register struct tcpcb *tp;
- if (m == 0)
- return (0);
+ if (m == NULL)
+ return ((struct tcpcb *)0);
tp = mtod(m, struct tcpcb *);
tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
- tp->t_maxseg = 576; /* satisfy the rest of the world */
+ /*
+ * If the default maximum IP packet size is 576 bytes
+ * and a standard IP header is 20 bytes, with a TCP
+ * header of 20 bytes plus the options necessary to
+ * upgrade it to something higher, then initialize the
+ * maximum segment size to 576 - (20 + 20 + 8 + slop).
+ */
+ tp->t_maxseg = 512; /* satisfy the rest of the world */
tp->t_flags = 0; /* sends options! */
tp->t_inpcb = inp;
inp->inp_ppcb = (caddr_t)tp;
* the specified error. If connection is synchronized,
* then send a RST to peer.
*/
+struct tcpcb *
tcp_drop(tp, errno)
- struct tcpcb *tp;
+ register struct tcpcb *tp;
int errno;
{
struct socket *so = tp->t_inpcb->inp_socket;
if (TCPS_HAVERCVDSYN(tp->t_state)) {
tp->t_state = TCPS_CLOSED;
- tcp_output(tp);
+ (void) tcp_output(tp);
}
so->so_error = errno;
- tcp_close(tp);
+ return (tcp_close(tp));
}
tcp_abort(inp)
struct inpcb *inp;
{
- tcp_close(inp->inp_ppcb);
+
+ (void) tcp_close((struct tcpcb *)inp->inp_ppcb);
}
/*
* discard internet protocol block
* wake up any sleepers
*/
+struct tcpcb *
tcp_close(tp)
register struct tcpcb *tp;
{
inp->inp_ppcb = 0;
soisdisconnected(so);
in_pcbdetach(inp);
+ return ((struct tcpcb *)0);
}
tcp_drain()
default:
sin = &((struct icmp *)arg)->icmp_ip.ip_dst;
- in_pcbnotify(&tcb, sin, inetctlerrmap[cmd], tcp_abort);
+ in_pcbnotify(&tcb, sin, (int)inetctlerrmap[cmd], tcp_abort);
}
}