tcp_subr.c revision 6de922ee8158732706074aacb20c2a5dc6d4d7a3
0N/A/*
2362N/A * Copyright (c) 1982, 1986, 1988, 1990, 1993
0N/A * The Regents of the University of California. All rights reserved.
0N/A *
0N/A * Redistribution and use in source and binary forms, with or without
0N/A * modification, are permitted provided that the following conditions
2362N/A * are met:
0N/A * 1. Redistributions of source code must retain the above copyright
2362N/A * notice, this list of conditions and the following disclaimer.
0N/A * 2. Redistributions in binary form must reproduce the above copyright
0N/A * notice, this list of conditions and the following disclaimer in the
0N/A * documentation and/or other materials provided with the distribution.
0N/A * 3. All advertising materials mentioning features or use of this software
0N/A * must display the following acknowledgement:
0N/A * This product includes software developed by the University of
0N/A * California, Berkeley and its contributors.
0N/A * 4. Neither the name of the University nor the names of its contributors
0N/A * may be used to endorse or promote products derived from this software
0N/A * without specific prior written permission.
0N/A *
2362N/A * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2362N/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2362N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0N/A * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
0N/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0N/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0N/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0N/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0N/A * SUCH DAMAGE.
0N/A *
0N/A * @(#)tcp_subr.c 8.1 (Berkeley) 6/10/93
0N/A * tcp_subr.c,v 1.5 1994/10/08 22:39:58 phk Exp
0N/A */
0N/A
0N/A/*
0N/A * Changes and additions relating to SLiRP
0N/A * Copyright (c) 1995 Danny Gasparovski.
0N/A *
0N/A * Please read the file COPYRIGHT for the
0N/A * terms and conditions of the copyright.
0N/A */
0N/A
0N/A#define WANT_SYS_IOCTL_H
0N/A#include <slirp.h>
0N/A
0N/A
0N/A/*
0N/A * Tcp initialization
0N/A */
0N/Avoid
0N/Atcp_init(PNATState pData)
0N/A{
0N/A tcp_iss = 1; /* wrong */
0N/A tcb.so_next = tcb.so_prev = &tcb;
0N/A tcp_last_so = &tcb;
0N/A tcp_reass_maxqlen = 48;
0N/A tcp_reass_maxseg = 256;
0N/A}
0N/A
0N/A/*
0N/A * Create template to be used to send tcp packets on a connection.
0N/A * Call after host entry created, fills
0N/A * in a skeletal tcp/ip header, minimizing the amount of work
0N/A * necessary when the connection is used.
0N/A */
0N/A/* struct tcpiphdr * */
0N/Avoid
0N/Atcp_template(struct tcpcb *tp)
0N/A{
0N/A struct socket *so = tp->t_socket;
0N/A register struct tcpiphdr *n = &tp->t_template;
0N/A
0N/A memset(n->ti_x1, 0, 9);
0N/A n->ti_pr = IPPROTO_TCP;
0N/A n->ti_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));
0N/A n->ti_src = so->so_faddr;
0N/A n->ti_dst = so->so_laddr;
0N/A n->ti_sport = so->so_fport;
0N/A n->ti_dport = so->so_lport;
0N/A
0N/A n->ti_seq = 0;
0N/A n->ti_ack = 0;
0N/A n->ti_x2 = 0;
0N/A n->ti_off = 5;
0N/A n->ti_flags = 0;
0N/A n->ti_win = 0;
0N/A n->ti_sum = 0;
0N/A n->ti_urp = 0;
0N/A}
0N/A
0N/A/*
0N/A * Send a single message to the TCP at address specified by
0N/A * the given TCP/IP header. If m == 0, then we make a copy
0N/A * of the tcpiphdr at ti and send directly to the addressed host.
0N/A * This is used to force keep alive messages out using the TCP
0N/A * template for a connection tp->t_template. If flags are given
0N/A * then we send a message back to the TCP which originated the
0N/A * segment ti, and discard the mbuf containing it and any other
0N/A * attached mbufs.
0N/A *
0N/A * In any case the ack and sequence number of the transmitted
0N/A * segment are as specified by the parameters.
0N/A */
0N/Avoid
0N/Atcp_respond(PNATState pData, struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m, tcp_seq ack, tcp_seq seq, int flags)
0N/A{
0N/A register int tlen;
0N/A int win = 0;
0N/A
0N/A DEBUG_CALL("tcp_respond");
0N/A DEBUG_ARG("tp = %lx", (long)tp);
0N/A DEBUG_ARG("ti = %lx", (long)ti);
0N/A DEBUG_ARG("m = %lx", (long)m);
0N/A DEBUG_ARG("ack = %u", ack);
0N/A DEBUG_ARG("seq = %u", seq);
0N/A DEBUG_ARG("flags = %x", flags);
0N/A
0N/A if (tp)
0N/A win = sbspace(&tp->t_socket->so_rcv);
0N/A if (m == 0)
0N/A {
0N/A#ifndef VBOX_WITH_SLIRP_BSD_MBUF
0N/A if ((m = m_get(pData)) == NULL)
0N/A#else
0N/A if ((m = m_gethdr(pData, M_DONTWAIT, MT_HEADER)) == NULL)
0N/A#endif
0N/A return;
0N/A#ifdef TCP_COMPAT_42
0N/A tlen = 1;
0N/A#else
0N/A tlen = 0;
0N/A#endif
0N/A m->m_data += if_maxlinkhdr;
0N/A *mtod(m, struct tcpiphdr *) = *ti;
0N/A ti = mtod(m, struct tcpiphdr *);
0N/A flags = TH_ACK;
0N/A }
0N/A else
0N/A {
0N/A /*
0N/A * ti points into m so the next line is just making
0N/A * the mbuf point to ti
0N/A */
0N/A m->m_data = (caddr_t)ti;
0N/A
0N/A m->m_len = sizeof (struct tcpiphdr);
0N/A tlen = 0;
0N/A#define xchg(a,b,type) { type t; t = a; a = b; b = t; }
28N/A xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, u_int32_t);
0N/A xchg(ti->ti_dport, ti->ti_sport, u_int16_t);
0N/A#undef xchg
0N/A }
0N/A ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
0N/A tlen += sizeof (struct tcpiphdr);
0N/A m->m_len = tlen;
0N/A
0N/A memset(ti->ti_x1, 0, 9);
0N/A ti->ti_seq = htonl(seq);
0N/A ti->ti_ack = htonl(ack);
0N/A ti->ti_x2 = 0;
0N/A ti->ti_off = sizeof (struct tcphdr) >> 2;
0N/A ti->ti_flags = flags;
0N/A if (tp)
0N/A ti->ti_win = htons((u_int16_t) (win >> tp->rcv_scale));
0N/A else
0N/A ti->ti_win = htons((u_int16_t)win);
0N/A ti->ti_urp = 0;
0N/A ti->ti_sum = 0;
0N/A ti->ti_sum = cksum(m, tlen);
0N/A ((struct ip *)ti)->ip_len = tlen;
0N/A
0N/A if(flags & TH_RST)
0N/A ((struct ip *)ti)->ip_ttl = MAXTTL;
0N/A else
0N/A ((struct ip *)ti)->ip_ttl = ip_defttl;
0N/A
0N/A (void) ip_output(pData, (struct socket *)0, m);
0N/A}
0N/A
0N/A/*
0N/A * Create a new TCP control block, making an
0N/A * empty reassembly queue and hooking it to the argument
0N/A * protocol control block.
0N/A */
0N/Astruct tcpcb *
0N/Atcp_newtcpcb(PNATState pData, struct socket *so)
0N/A{
0N/A register struct tcpcb *tp;
0N/A
0N/A tp = (struct tcpcb *)RTMemAllocZ(sizeof(*tp));
0N/A if (tp == NULL)
0N/A return ((struct tcpcb *)0);
0N/A
0N/A tp->t_maxseg = tcp_mssdflt;
0N/A
0N/A tp->t_flags = tcp_do_rfc1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
0N/A tp->t_socket = so;
0N/A
0N/A /*
0N/A * Init srtt to TCPTV_SRTTBASE (0), so we can tell that we have no
0N/A * rtt estimate. Set rttvar so that srtt + 2 * rttvar gives
0N/A * reasonable initial retransmit time.
0N/A */
0N/A tp->t_srtt = TCPTV_SRTTBASE;
0N/A tp->t_rttvar = tcp_rttdflt * PR_SLOWHZ << 2;
0N/A tp->t_rttmin = TCPTV_MIN;
0N/A
0N/A TCPT_RANGESET(tp->t_rxtcur,
0N/A ((TCPTV_SRTTBASE >> 2) + (TCPTV_SRTTDFLT << 2)) >> 1,
0N/A TCPTV_MIN, TCPTV_REXMTMAX);
0N/A
0N/A tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
0N/A tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
0N/A tp->t_state = TCPS_CLOSED;
0N/A
0N/A so->so_tcpcb = tp;
0N/A
0N/A return (tp);
0N/A}
0N/A
0N/A/*
0N/A * Drop a TCP connection, reporting
0N/A * the specified error. If connection is synchronized,
0N/A * then send a RST to peer.
0N/A */
0N/Astruct tcpcb *tcp_drop(PNATState pData, struct tcpcb *tp, int err)
0N/A{
0N/A/* tcp_drop(tp, errno)
0N/A register struct tcpcb *tp;
0N/A int errno;
0N/A{
0N/A*/
0N/A DEBUG_CALL("tcp_drop");
0N/A DEBUG_ARG("tp = %lx", (long)tp);
0N/A DEBUG_ARG("errno = %d", errno);
0N/A
0N/A if (TCPS_HAVERCVDSYN(tp->t_state))
0N/A {
0N/A tp->t_state = TCPS_CLOSED;
0N/A (void) tcp_output(pData, tp);
0N/A tcpstat.tcps_drops++;
0N/A }
0N/A else
0N/A tcpstat.tcps_conndrops++;
0N/A#if 0
0N/A if (errno == ETIMEDOUT && tp->t_softerror)
0N/A errno = tp->t_softerror;
0N/A
0N/A so->so_error = errno;
0N/A#endif
0N/A return (tcp_close(pData, tp));
0N/A}
0N/A
0N/A/*
0N/A * Close a TCP control block:
0N/A * discard all space held by the tcp
0N/A * discard internet protocol block
0N/A * wake up any sleepers
0N/A */
0N/Astruct tcpcb *
0N/Atcp_close(PNATState pData, register struct tcpcb *tp)
0N/A{
0N/A struct socket *so = tp->t_socket;
0N/A struct socket *so_next, *so_prev;
0N/A
0N/A struct tseg_qent *te = NULL;
0N/A DEBUG_CALL("tcp_close");
0N/A DEBUG_ARG("tp = %lx", (long )tp);
0N/A so_next = so_prev = NULL;
0N/A /*XXX: freeing the reassembly queue */
0N/A while (!LIST_EMPTY(&tp->t_segq))
0N/A {
0N/A te = LIST_FIRST(&tp->t_segq);
0N/A LIST_REMOVE(te, tqe_q);
0N/A m_freem(pData, te->tqe_m);
0N/A RTMemFree(te);
0N/A tcp_reass_qsize--;
0N/A }
0N/A RTMemFree(tp);
0N/A so->so_tcpcb = 0;
0N/A soisfdisconnected(so);
0N/A /* clobber input socket cache if we're closing the cached connection */
0N/A if (so == tcp_last_so)
0N/A tcp_last_so = &tcb;
0N/A closesocket(so->s);
0N/A sbfree(&so->so_rcv);
0N/A sbfree(&so->so_snd);
0N/A sofree(pData, so);
0N/A SOCKET_UNLOCK(so);
0N/A tcpstat.tcps_closed++;
0N/A return ((struct tcpcb *)0);
0N/A}
0N/A
0N/Avoid
0N/Atcp_drain()
0N/A{
0N/A /* XXX */
0N/A}
0N/A
0N/A/*
0N/A * When a source quench is received, close congestion window
0N/A * to one segment. We will gradually open it again as we proceed.
0N/A */
0N/A
0N/A#if 0
0N/A
0N/Avoid
0N/Atcp_quench(i, int errno)
0N/A{
0N/A struct tcpcb *tp = intotcpcb(inp);
0N/A
0N/A if (tp)
0N/A tp->snd_cwnd = tp->t_maxseg;
0N/A}
0N/A
0N/A#endif
0N/A
0N/A/*
0N/A * TCP protocol interface to socket abstraction.
0N/A */
0N/A
0N/A/*
0N/A * User issued close, and wish to trail through shutdown states:
0N/A * if never received SYN, just forget it. If got a SYN from peer,
0N/A * but haven't sent FIN, then go to FIN_WAIT_1 state to send peer a FIN.
0N/A * If already got a FIN from peer, then almost done; go to LAST_ACK
0N/A * state. In all other cases, have already sent FIN to peer (e.g.
0N/A * after PRU_SHUTDOWN), and just have to play tedious game waiting
0N/A * for peer to send FIN or not respond to keep-alives, etc.
0N/A * We can let the user exit from the close as soon as the FIN is acked.
0N/A */
0N/Avoid
0N/Atcp_sockclosed(PNATState pData, struct tcpcb *tp)
0N/A{
0N/A DEBUG_CALL("tcp_sockclosed");
0N/A DEBUG_ARG("tp = %lx", (long)tp);
0N/A
0N/A switch (tp->t_state)
0N/A {
0N/A case TCPS_CLOSED:
0N/A case TCPS_LISTEN:
0N/A case TCPS_SYN_SENT:
0N/A tp->t_state = TCPS_CLOSED;
0N/A tp = tcp_close(pData, tp);
0N/A break;
0N/A
0N/A case TCPS_SYN_RECEIVED:
0N/A case TCPS_ESTABLISHED:
0N/A tp->t_state = TCPS_FIN_WAIT_1;
0N/A break;
0N/A
0N/A case TCPS_CLOSE_WAIT:
0N/A tp->t_state = TCPS_LAST_ACK;
0N/A break;
0N/A }
0N/A/* soisfdisconnecting(tp->t_socket); */
0N/A if ( tp
0N/A && tp->t_state >= TCPS_FIN_WAIT_2)
0N/A soisfdisconnected(tp->t_socket);
0N/A if (tp)
0N/A tcp_output(pData, tp);
0N/A}
0N/A
0N/A/*
0N/A * Connect to a host on the Internet
0N/A * Called by tcp_input
0N/A * Only do a connect, the tcp fields will be set in tcp_input
0N/A * return 0 if there's a result of the connect,
0N/A * else return -1 means we're still connecting
0N/A * The return value is almost always -1 since the socket is
0N/A * nonblocking. Connect returns after the SYN is sent, and does
0N/A * not wait for ACK+SYN.
0N/A */
int tcp_fconnect(PNATState pData, struct socket *so)
{
int ret = 0;
DEBUG_CALL("tcp_fconnect");
DEBUG_ARG("so = %lx", (long )so);
if ((ret = so->s = socket(AF_INET, SOCK_STREAM, 0)) >= 0)
{
int opt, s = so->s;
struct sockaddr_in addr;
fd_nonblock(s);
opt = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt));
opt = 1;
setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(opt));
addr.sin_family = AF_INET;
if ((so->so_faddr.s_addr & htonl(pData->netmask)) == special_addr.s_addr)
{
/* It's an alias */
switch(ntohl(so->so_faddr.s_addr) & ~pData->netmask)
{
case CTL_DNS:
case CTL_ALIAS:
default:
addr.sin_addr = loopback_addr;
break;
}
}
else
addr.sin_addr = so->so_faddr;
addr.sin_port = so->so_fport;
DEBUG_MISC((dfd, " connect()ing, addr.sin_port=%d, "
"addr.sin_addr.s_addr=%.16s\n",
ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));
/* We don't care what port we get */
ret = connect(s,(struct sockaddr *)&addr,sizeof (addr));
/*
* If it's not in progress, it failed, so we just return 0,
* without clearing SS_NOFDREF
*/
soisfconnecting(so);
}
return(ret);
}
/*
* Accept the socket and connect to the local-host
*
* We have a problem. The correct thing to do would be
* to first connect to the local-host, and only if the
* connection is accepted, then do an accept() here.
* But, a) we need to know who's trying to connect
* to the socket to be able to SYN the local-host, and
* b) we are already connected to the foreign host by
* the time it gets to accept(), so... We simply accept
* here and SYN the local-host.
*/
void
tcp_connect(PNATState pData, struct socket *inso)
{
struct socket *so;
struct sockaddr_in addr;
socklen_t addrlen = sizeof(struct sockaddr_in);
struct tcpcb *tp;
int s, opt;
int status;
socklen_t optlen;
static int cVerbose = 1;
DEBUG_CALL("tcp_connect");
DEBUG_ARG("inso = %lx", (long)inso);
/*
* If it's an SS_ACCEPTONCE socket, no need to socreate()
* another socket, just use the accept() socket.
*/
if (inso->so_state & SS_FACCEPTONCE)
{
/* FACCEPTONCE already have a tcpcb */
so = inso;
}
else
{
if ((so = socreate()) == NULL)
{
/* If it failed, get rid of the pending connection */
closesocket(accept(inso->s,(struct sockaddr *)&addr,&addrlen));
return;
}
if (tcp_attach(pData, so) < 0)
{
RTMemFree(so); /* NOT sofree */
return;
}
so->so_laddr = inso->so_laddr;
so->so_lport = inso->so_lport;
so->so_la = inso->so_la;
}
(void) tcp_mss(pData, sototcpcb(so), 0);
fd_nonblock(inso->s);
if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0)
{
tcp_close(pData, sototcpcb(so)); /* This will sofree() as well */
return;
}
fd_nonblock(s);
opt = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR,(char *)&opt, sizeof(int));
opt = 1;
setsockopt(s, SOL_SOCKET, SO_OOBINLINE,(char *)&opt, sizeof(int));
#if 0
opt = 1;
setsockopt(s, IPPROTO_TCP, TCP_NODELAY,(char *)&opt, sizeof(int));
#endif
optlen = sizeof(int);
status = getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &optlen);
if (status < 0)
{
LogRel(("NAT: Error(%d) while getting RCV capacity\n", errno));
goto no_sockopt;
}
if (cVerbose > 0)
LogRel(("NAT: old socket rcv size: %dKB\n", opt / 1024));
/* @todo (r-vvl) make it configurable (via extra data) */
opt = pData->socket_rcv;
status = setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, sizeof(int));
if (status < 0)
{
LogRel(("NAT: Error(%d) while setting RCV capacity to (%d)\n", errno, opt));
goto no_sockopt;
}
optlen = sizeof(int);
status = getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&opt, &optlen);
if (status < 0)
{
LogRel(("NAT: Error(%d) while getting SND capacity\n", errno));
goto no_sockopt;
}
if (cVerbose > 0)
LogRel(("NAT: old socket snd size: %dKB\n", opt / 1024));
opt = pData->socket_rcv;
status = setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&opt, sizeof(int));
if (status < 0)
{
LogRel(("NAT: Error(%d) while setting SND capacity to (%d)\n", errno, opt));
goto no_sockopt;
}
if (cVerbose > 0)
cVerbose--;
no_sockopt:
so->so_fport = addr.sin_port;
so->so_faddr = addr.sin_addr;
/* Translate connections from localhost to the real hostname */
if (so->so_faddr.s_addr == 0 || so->so_faddr.s_addr == loopback_addr.s_addr)
so->so_faddr = alias_addr;
/* Close the accept() socket, set right state */
if (inso->so_state & SS_FACCEPTONCE)
{
closesocket(so->s); /* If we only accept once, close the accept() socket */
so->so_state = SS_NOFDREF; /* Don't select it yet, even though we have an FD */
/* if it's not FACCEPTONCE, it's already NOFDREF */
}
so->s = s;
so->so_iptos = tcp_tos(so);
tp = sototcpcb(so);
tcp_template(tp);
/* Compute window scaling to request. */
/* while (tp->request_r_scale < TCP_MAX_WINSHIFT
* && (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
* tp->request_r_scale++;
*/
/* soisconnecting(so); */ /* NOFDREF used instead */
tcpstat.tcps_connattempt++;
tp->t_state = TCPS_SYN_SENT;
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
tp->iss = tcp_iss;
tcp_iss += TCP_ISSINCR/2;
tcp_sendseqinit(tp);
tcp_output(pData, tp);
}
/*
* Attach a TCPCB to a socket.
*/
int
tcp_attach(PNATState pData, struct socket *so)
{
if ((so->so_tcpcb = tcp_newtcpcb(pData, so)) == NULL)
return -1;
SOCKET_LOCK_CREATE(so);
QSOCKET_LOCK(tcb);
insque(pData, so, &tcb);
NSOCK_INC();
QSOCKET_UNLOCK(tcb);
return 0;
}
/*
* Set the socket's type of service field
*/
static const struct tos_t tcptos[] =
{
{0, 20, IPTOS_THROUGHPUT, 0}, /* ftp data */
{21, 21, IPTOS_LOWDELAY, EMU_FTP}, /* ftp control */
{0, 23, IPTOS_LOWDELAY, 0}, /* telnet */
{0, 80, IPTOS_THROUGHPUT, 0}, /* WWW */
{0, 513, IPTOS_LOWDELAY, EMU_RLOGIN|EMU_NOCONNECT}, /* rlogin */
{0, 514, IPTOS_LOWDELAY, EMU_RSH|EMU_NOCONNECT}, /* shell */
{0, 544, IPTOS_LOWDELAY, EMU_KSH}, /* kshell */
{0, 543, IPTOS_LOWDELAY, 0}, /* klogin */
{0, 6667, IPTOS_THROUGHPUT, EMU_IRC}, /* IRC */
{0, 6668, IPTOS_THROUGHPUT, EMU_IRC}, /* IRC undernet */
{0, 7070, IPTOS_LOWDELAY, EMU_REALAUDIO }, /* RealAudio control */
{0, 113, IPTOS_LOWDELAY, EMU_IDENT }, /* identd protocol */
{0, 0, 0, 0}
};
/*
* Return TOS according to the above table
*/
u_int8_t
tcp_tos(struct socket *so)
{
return 0;
}
/*
* Emulate programs that try and connect to us. This includes ftp (the data
* connection is initiated by the server) and IRC (DCC CHAT and DCC SEND)
* for now
*
* NOTE: It's possible to crash SLiRP by sending it unstandard strings to
* emulate... if this is a problem, more checks are needed here.
*
* XXX Assumes the whole command cames in one packet
*
* XXX Some ftp clients will have their TOS set to LOWDELAY and so Nagel will
* kick in. Because of this, we'll get the first letter, followed by the
* rest, so we simply scan for ORT instead of PORT... DCC doesn't have this
* problem because there's other stuff in the packet before the DCC command.
*
* Return 1 if the mbuf m is still valid and should be sbappend()ed
*
* NOTE: if you return 0 you MUST m_free() the mbuf!
*/
int
tcp_emu(PNATState pData, struct socket *so, struct mbuf *m)
{
/*XXX: libalias should care about it */
so->so_emu = 0;
return 1;
}