mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
slirp: Drop dead code
After all its years inside the qemu tree, there is no point in keeping the dead code paths of slirp. This patch is a first round of removing usually commented out code parts. More cleanups need to follow (and maybe finally a proper reindention). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
committed by
Anthony Liguori
parent
6dbe553fe9
commit
0d62c4cfe2
-185
@@ -9,127 +9,9 @@
|
||||
#include <slirp.h>
|
||||
|
||||
FILE *dfd = NULL;
|
||||
#ifdef DEBUG
|
||||
int dostats = 1;
|
||||
#else
|
||||
int dostats = 0;
|
||||
#endif
|
||||
int slirp_debug = 0;
|
||||
|
||||
/* Carry over one item from main.c so that the tty's restored.
|
||||
* Only done when the tty being used is /dev/tty --RedWolf */
|
||||
#ifndef CONFIG_QEMU
|
||||
extern struct termios slirp_tty_settings;
|
||||
extern int slirp_tty_restore;
|
||||
|
||||
|
||||
void
|
||||
debug_init(file, dbg)
|
||||
char *file;
|
||||
int dbg;
|
||||
{
|
||||
/* Close the old debugging file */
|
||||
if (dfd)
|
||||
fclose(dfd);
|
||||
|
||||
dfd = fopen(file,"w");
|
||||
if (dfd != NULL) {
|
||||
#if 0
|
||||
fprintf(dfd,"Slirp %s - Debugging Started.\n", SLIRP_VERSION);
|
||||
#endif
|
||||
fprintf(dfd,"Debugging Started level %i.\r\n",dbg);
|
||||
fflush(dfd);
|
||||
slirp_debug = dbg;
|
||||
} else {
|
||||
lprint("Error: Debugging file \"%s\" could not be opened: %s\r\n",
|
||||
file, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump a packet in the same format as tcpdump -x
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
void
|
||||
dump_packet(dat, n)
|
||||
void *dat;
|
||||
int n;
|
||||
{
|
||||
u_char *pptr = (u_char *)dat;
|
||||
int j,k;
|
||||
|
||||
n /= 16;
|
||||
n++;
|
||||
DEBUG_MISC((dfd, "PACKET DUMPED: \n"));
|
||||
for(j = 0; j < n; j++) {
|
||||
for(k = 0; k < 6; k++)
|
||||
DEBUG_MISC((dfd, "%02x ", *pptr++));
|
||||
DEBUG_MISC((dfd, "\n"));
|
||||
fflush(dfd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LOG_ENABLED
|
||||
#if 0
|
||||
/*
|
||||
* Statistic routines
|
||||
*
|
||||
* These will print statistics to the screen, the debug file (dfd), or
|
||||
* a buffer, depending on "type", so that the stats can be sent over
|
||||
* the link as well.
|
||||
*/
|
||||
|
||||
static void
|
||||
ttystats(ttyp)
|
||||
struct ttys *ttyp;
|
||||
{
|
||||
struct slirp_ifstats *is = &ttyp->ifstats;
|
||||
char buff[512];
|
||||
|
||||
lprint(" \r\n");
|
||||
|
||||
if (IF_COMP & IF_COMPRESS)
|
||||
strcpy(buff, "on");
|
||||
else if (IF_COMP & IF_NOCOMPRESS)
|
||||
strcpy(buff, "off");
|
||||
else
|
||||
strcpy(buff, "off (for now)");
|
||||
lprint("Unit %d:\r\n", ttyp->unit);
|
||||
lprint(" using %s encapsulation (VJ compression is %s)\r\n", (
|
||||
#ifdef USE_PPP
|
||||
ttyp->proto==PROTO_PPP?"PPP":
|
||||
#endif
|
||||
"SLIP"), buff);
|
||||
lprint(" %d baudrate\r\n", ttyp->baud);
|
||||
lprint(" interface is %s\r\n", ttyp->up?"up":"down");
|
||||
lprint(" using fd %d, guardian pid is %d\r\n", ttyp->fd, ttyp->pid);
|
||||
#ifndef FULL_BOLT
|
||||
lprint(" towrite is %d bytes\r\n", ttyp->towrite);
|
||||
#endif
|
||||
if (ttyp->zeros)
|
||||
lprint(" %d zeros have been typed\r\n", ttyp->zeros);
|
||||
else if (ttyp->ones)
|
||||
lprint(" %d ones have been typed\r\n", ttyp->ones);
|
||||
lprint("Interface stats:\r\n");
|
||||
lprint(" %6d output packets sent (%d bytes)\r\n", is->out_pkts, is->out_bytes);
|
||||
lprint(" %6d output packets dropped (%d bytes)\r\n", is->out_errpkts, is->out_errbytes);
|
||||
lprint(" %6d input packets received (%d bytes)\r\n", is->in_pkts, is->in_bytes);
|
||||
lprint(" %6d input packets dropped (%d bytes)\r\n", is->in_errpkts, is->in_errbytes);
|
||||
lprint(" %6d bad input packets\r\n", is->in_mbad);
|
||||
}
|
||||
|
||||
static void
|
||||
allttystats(void)
|
||||
{
|
||||
struct ttys *ttyp;
|
||||
|
||||
for (ttyp = ttys; ttyp; ttyp = ttyp->next)
|
||||
ttystats(ttyp);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
ipstats(void)
|
||||
{
|
||||
@@ -154,25 +36,6 @@ ipstats(void)
|
||||
lprint(" %6d total packets delivered\r\n", ipstat.ips_delivered);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_QEMU
|
||||
static void
|
||||
vjstats(void)
|
||||
{
|
||||
lprint(" \r\n");
|
||||
|
||||
lprint("VJ compression stats:\r\n");
|
||||
|
||||
lprint(" %6d outbound packets (%d compressed)\r\n",
|
||||
comp_s.sls_packets, comp_s.sls_compressed);
|
||||
lprint(" %6d searches for connection stats (%d misses)\r\n",
|
||||
comp_s.sls_searches, comp_s.sls_misses);
|
||||
lprint(" %6d inbound uncompressed packets\r\n", comp_s.sls_uncompressedin);
|
||||
lprint(" %6d inbound compressed packets\r\n", comp_s.sls_compressedin);
|
||||
lprint(" %6d inbound unknown type packets\r\n", comp_s.sls_errorin);
|
||||
lprint(" %6d inbound packets tossed due to error\r\n", comp_s.sls_tossed);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
tcpstats(void)
|
||||
{
|
||||
@@ -234,11 +97,6 @@ tcpstats(void)
|
||||
lprint(" %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
|
||||
lprint(" %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
|
||||
lprint(" %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
|
||||
|
||||
|
||||
/* lprint(" Packets received too short: %d\r\n", tcpstat.tcps_rcvshort); */
|
||||
/* lprint(" Segments dropped due to PAWS: %d\r\n", tcpstat.tcps_pawsdrop); */
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -293,49 +151,6 @@ mbufstats(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_QEMU
|
||||
void
|
||||
slirp_exit(exit_status)
|
||||
int exit_status;
|
||||
{
|
||||
struct ttys *ttyp;
|
||||
|
||||
DEBUG_CALL("slirp_exit");
|
||||
DEBUG_ARG("exit_status = %d", exit_status);
|
||||
|
||||
if (dostats) {
|
||||
lprint_print = (int (*) _P((void *, const char *, va_list)))vfprintf;
|
||||
if (!dfd)
|
||||
debug_init("slirp_stats", 0xf);
|
||||
lprint_arg = (char **)&dfd;
|
||||
|
||||
ipstats();
|
||||
tcpstats();
|
||||
udpstats();
|
||||
icmpstats();
|
||||
mbufstats();
|
||||
sockstats();
|
||||
allttystats();
|
||||
vjstats();
|
||||
}
|
||||
|
||||
for (ttyp = ttys; ttyp; ttyp = ttyp->next)
|
||||
tty_detached(ttyp, 1);
|
||||
|
||||
if (slirp_forked) {
|
||||
/* Menendez time */
|
||||
if (kill(getppid(), SIGQUIT) < 0)
|
||||
lprint("Couldn't kill parent process %ld!\n",
|
||||
(long) getppid());
|
||||
}
|
||||
|
||||
/* Restore the terminal if we gotta */
|
||||
if(slirp_tty_restore)
|
||||
tcsetattr(0,TCSANOW, &slirp_tty_settings); /* NOW DAMMIT! */
|
||||
exit(exit_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
slirp_stats(void)
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#define PRN_SPRINTF 2
|
||||
|
||||
extern FILE *dfd;
|
||||
extern FILE *lfd;
|
||||
extern int dostats;
|
||||
extern int slirp_debug;
|
||||
|
||||
#define DBG_CALL 0x1
|
||||
|
||||
-80
@@ -36,89 +36,9 @@ if_init(void)
|
||||
{
|
||||
if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq;
|
||||
if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq;
|
||||
// sl_compress_init(&comp_s);
|
||||
next_m = &if_batchq;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* This shouldn't be needed since the modem is blocking and
|
||||
* we don't expect any signals, but what the hell..
|
||||
*/
|
||||
inline int
|
||||
writen(fd, bptr, n)
|
||||
int fd;
|
||||
char *bptr;
|
||||
int n;
|
||||
{
|
||||
int ret;
|
||||
int total;
|
||||
|
||||
/* This should succeed most of the time */
|
||||
ret = send(fd, bptr, n,0);
|
||||
if (ret == n || ret <= 0)
|
||||
return ret;
|
||||
|
||||
/* Didn't write everything, go into the loop */
|
||||
total = ret;
|
||||
while (n > total) {
|
||||
ret = send(fd, bptr+total, n-total,0);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
total += ret;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/*
|
||||
* if_input - read() the tty, do "top level" processing (ie: check for any escapes),
|
||||
* and pass onto (*ttyp->if_input)
|
||||
*
|
||||
* XXXXX Any zeros arriving by themselves are NOT placed into the arriving packet.
|
||||
*/
|
||||
#define INBUFF_SIZE 2048 /* XXX */
|
||||
void
|
||||
if_input(ttyp)
|
||||
struct ttys *ttyp;
|
||||
{
|
||||
u_char if_inbuff[INBUFF_SIZE];
|
||||
int if_n;
|
||||
|
||||
DEBUG_CALL("if_input");
|
||||
DEBUG_ARG("ttyp = %lx", (long)ttyp);
|
||||
|
||||
if_n = recv(ttyp->fd, (char *)if_inbuff, INBUFF_SIZE,0);
|
||||
|
||||
DEBUG_MISC((dfd, " read %d bytes\n", if_n));
|
||||
|
||||
if (if_n <= 0) {
|
||||
if (if_n == 0 || (errno != EINTR && errno != EAGAIN)) {
|
||||
if (ttyp->up)
|
||||
link_up--;
|
||||
tty_detached(ttyp, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (if_n == 1) {
|
||||
if (*if_inbuff == '0') {
|
||||
ttyp->ones = 0;
|
||||
if (++ttyp->zeros >= 5)
|
||||
slirp_exit(0);
|
||||
return;
|
||||
}
|
||||
if (*if_inbuff == '1') {
|
||||
ttyp->zeros = 0;
|
||||
if (++ttyp->ones >= 5)
|
||||
tty_detached(ttyp, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ttyp->ones = ttyp->zeros = 0;
|
||||
|
||||
(*ttyp->if_input)(ttyp, if_inbuff, if_n);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* if_output: Queue packet into an output queue.
|
||||
* There are 2 output queue's, if_fastq and if_batchq.
|
||||
|
||||
+1
-13
@@ -17,20 +17,8 @@
|
||||
#define IF_MRU 1500
|
||||
#define IF_COMP IF_AUTOCOMP /* Flags for compression */
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Set if_maxlinkhdr to 48 because it's 40 bytes for TCP/IP,
|
||||
* and 8 bytes for PPP, but need to have it on an 8byte boundary
|
||||
*/
|
||||
#ifdef USE_PPP
|
||||
#define IF_MAXLINKHDR 48
|
||||
#else
|
||||
#define IF_MAXLINKHDR 40
|
||||
#endif
|
||||
#else
|
||||
/* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
|
||||
/* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
|
||||
#define IF_MAXLINKHDR (2 + 14 + 40)
|
||||
#endif
|
||||
|
||||
extern int if_queued; /* Number of packets queued so far */
|
||||
|
||||
|
||||
@@ -73,7 +73,6 @@ icmp_input(struct mbuf *m, int hlen)
|
||||
register struct icmp *icp;
|
||||
register struct ip *ip=mtod(m, struct ip *);
|
||||
int icmplen=ip->ip_len;
|
||||
/* int code; */
|
||||
|
||||
DEBUG_CALL("icmp_input");
|
||||
DEBUG_ARG("m = %lx", (long )m);
|
||||
@@ -102,9 +101,6 @@ icmp_input(struct mbuf *m, int hlen)
|
||||
m->m_len += hlen;
|
||||
m->m_data -= hlen;
|
||||
|
||||
/* icmpstat.icps_inhist[icp->icmp_type]++; */
|
||||
/* code = icp->icmp_code; */
|
||||
|
||||
DEBUG_ARG("icmp_type = %d", icp->icmp_type);
|
||||
switch (icp->icmp_type) {
|
||||
case ICMP_ECHO:
|
||||
|
||||
@@ -164,16 +164,6 @@ ip_input(struct mbuf *m)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/*
|
||||
* Process options and, if not destined for us,
|
||||
* ship it on. ip_dooptions returns 1 when an
|
||||
* error was detected (causing an icmp message
|
||||
* to be sent and the original packet to be freed).
|
||||
*/
|
||||
/* We do no IP options */
|
||||
/* if (hlen > sizeof (struct ip) && ip_dooptions(m))
|
||||
* goto next;
|
||||
*/
|
||||
/*
|
||||
* If offset or IP_MF are set, must reassemble.
|
||||
* Otherwise, nothing need be done.
|
||||
@@ -396,9 +386,6 @@ insert:
|
||||
q = (struct ipasfrag *)(m->m_ext + delta);
|
||||
}
|
||||
|
||||
/* DEBUG_ARG("ip = %lx", (long)ip);
|
||||
* ip=(struct ipasfrag *)m->m_data; */
|
||||
|
||||
ip = fragtoip(q);
|
||||
ip->ip_len = next;
|
||||
ip->ip_tos &= ~1;
|
||||
@@ -505,7 +492,6 @@ ip_dooptions(m)
|
||||
register u_char *cp;
|
||||
register struct ip_timestamp *ipt;
|
||||
register struct in_ifaddr *ia;
|
||||
/* int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0; */
|
||||
int opt, optlen, cnt, off, code, type, forward = 0;
|
||||
struct in_addr *sin, dst;
|
||||
typedef u_int32_t n_time;
|
||||
@@ -683,9 +669,6 @@ typedef u_int32_t n_time;
|
||||
}
|
||||
return (0);
|
||||
bad:
|
||||
/* ip->ip_len -= ip->ip_hl << 2; XXX icmp_error adds in hdr length */
|
||||
|
||||
/* Not yet */
|
||||
icmp_error(m, type, code, 0, 0);
|
||||
|
||||
STAT(ipstat.ips_badoptions++);
|
||||
|
||||
@@ -64,12 +64,6 @@ ip_output(struct socket *so, struct mbuf *m0)
|
||||
DEBUG_ARG("so = %lx", (long)so);
|
||||
DEBUG_ARG("m0 = %lx", (long)m0);
|
||||
|
||||
/* We do no options */
|
||||
/* if (opt) {
|
||||
* m = ip_insertoptions(m, opt, &len);
|
||||
* hlen = len;
|
||||
* }
|
||||
*/
|
||||
ip = mtod(m, struct ip *);
|
||||
/*
|
||||
* Fill in IP header.
|
||||
@@ -80,17 +74,6 @@ ip_output(struct socket *so, struct mbuf *m0)
|
||||
ip->ip_hl = hlen >> 2;
|
||||
STAT(ipstat.ips_localout++);
|
||||
|
||||
/*
|
||||
* Verify that we have any chance at all of being able to queue
|
||||
* the packet or packet fragments
|
||||
*/
|
||||
/* XXX Hmmm... */
|
||||
/* if (if_queued > IF_THRESH && towrite <= 0) {
|
||||
* error = ENOBUFS;
|
||||
* goto bad;
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* If small enough for interface, can just send directly.
|
||||
*/
|
||||
@@ -142,12 +125,6 @@ ip_output(struct socket *so, struct mbuf *m0)
|
||||
mhip = mtod(m, struct ip *);
|
||||
*mhip = *ip;
|
||||
|
||||
/* No options */
|
||||
/* if (hlen > sizeof (struct ip)) {
|
||||
* mhlen = ip_optcopy(ip, mhip) + sizeof (struct ip);
|
||||
* mhip->ip_hl = mhlen >> 2;
|
||||
* }
|
||||
*/
|
||||
m->m_len = mhlen;
|
||||
mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF);
|
||||
if (ip->ip_off & IP_MF)
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#ifndef _LIBSLIRP_H
|
||||
#define _LIBSLIRP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <qemu-common.h>
|
||||
|
||||
void slirp_init(int restricted, struct in_addr vnetwork,
|
||||
@@ -37,8 +33,4 @@ void slirp_socket_recv(struct in_addr guest_addr, int guest_port,
|
||||
const uint8_t *buf, int size);
|
||||
size_t slirp_socket_can_recv(struct in_addr guest_addr, int guest_port);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -141,17 +141,11 @@ m_inc(struct mbuf *m, int size)
|
||||
if (m->m_flags & M_EXT) {
|
||||
datasize = m->m_data - m->m_ext;
|
||||
m->m_ext = (char *)realloc(m->m_ext,size);
|
||||
/* if (m->m_ext == NULL)
|
||||
* return (struct mbuf *)NULL;
|
||||
*/
|
||||
m->m_data = m->m_ext + datasize;
|
||||
} else {
|
||||
char *dat;
|
||||
datasize = m->m_data - m->m_dat;
|
||||
dat = (char *)malloc(size);
|
||||
/* if (dat == NULL)
|
||||
* return (struct mbuf *)NULL;
|
||||
*/
|
||||
memcpy(dat, m->m_dat, m->m_size);
|
||||
|
||||
m->m_ext = dat;
|
||||
|
||||
@@ -41,10 +41,8 @@
|
||||
/*
|
||||
* Macros for type conversion
|
||||
* mtod(m,t) - convert mbuf pointer to data pointer of correct type
|
||||
* dtom(x) - convert data pointer within mbuf to mbuf pointer (XXX)
|
||||
*/
|
||||
#define mtod(m,t) ((t)(m)->m_data)
|
||||
/* #define dtom(x) ((struct mbuf *)((int)(x) & ~(M_SIZE-1))) */
|
||||
|
||||
/* XXX About mbufs for slirp:
|
||||
* Only one mbuf is ever used in a chain, for each "cell" of data.
|
||||
|
||||
-525
File diff suppressed because it is too large
Load Diff
@@ -19,10 +19,6 @@ struct ex_list {
|
||||
extern struct ex_list *exec_list;
|
||||
extern u_int time_fasttimo, last_slowtimo;
|
||||
|
||||
extern int (*lprint_print) _P((void *, const char *, va_list));
|
||||
extern char *lprint_ptr, *lprint_ptr2, **lprint_arg;
|
||||
extern struct sbuf *lprint_sb;
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *strdup _P((const char *));
|
||||
#endif
|
||||
@@ -63,10 +59,6 @@ struct emu_t {
|
||||
struct emu_t *next;
|
||||
};
|
||||
|
||||
#ifndef CONFIG_QEMU
|
||||
extern struct emu_t *tcpemu;
|
||||
#endif
|
||||
|
||||
extern int x_port, x_server, x_display;
|
||||
|
||||
int show_x _P((char *, struct socket *));
|
||||
|
||||
@@ -9,14 +9,6 @@
|
||||
|
||||
static void sbappendsb(struct sbuf *sb, struct mbuf *m);
|
||||
|
||||
/* Done as a macro in socket.h */
|
||||
/* int
|
||||
* sbspace(struct sockbuff *sb)
|
||||
* {
|
||||
* return SB_DATALEN - sb->sb_cc;
|
||||
* }
|
||||
*/
|
||||
|
||||
void
|
||||
sbfree(struct sbuf *sb)
|
||||
{
|
||||
|
||||
@@ -55,7 +55,6 @@ int slirp_restrict;
|
||||
static int do_slowtimo;
|
||||
int link_up;
|
||||
struct timeval tt;
|
||||
FILE *lfd;
|
||||
struct ex_list *exec_list;
|
||||
|
||||
/* XXX: suppress those select globals */
|
||||
@@ -96,16 +95,6 @@ static int get_dns_addr(struct in_addr *pdns_addr)
|
||||
pIPAddr = &(FixedInfo->DnsServerList);
|
||||
inet_aton(pIPAddr->IpAddress.String, &tmp_addr);
|
||||
*pdns_addr = tmp_addr;
|
||||
#if 0
|
||||
printf( "DNS Servers:\n" );
|
||||
printf( "DNS Addr:%s\n", pIPAddr->IpAddress.String );
|
||||
|
||||
pIPAddr = FixedInfo -> DnsServerList.Next;
|
||||
while ( pIPAddr ) {
|
||||
printf( "DNS Addr:%s\n", pIPAddr ->IpAddress.String );
|
||||
pIPAddr = pIPAddr ->Next;
|
||||
}
|
||||
#endif
|
||||
if (FixedInfo) {
|
||||
GlobalFree(FixedInfo);
|
||||
FixedInfo = NULL;
|
||||
@@ -179,8 +168,6 @@ void slirp_init(int restricted, struct in_addr vnetwork,
|
||||
const char *bootfile, struct in_addr vdhcp_start,
|
||||
struct in_addr vnameserver)
|
||||
{
|
||||
// debug_init("/tmp/slirp.log", DEBUG_DEFAULT);
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA Data;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
|
||||
#define CONFIG_QEMU
|
||||
|
||||
//#define DEBUG 1
|
||||
|
||||
// Uncomment the following line to enable SLIRP statistics printing in Qemu
|
||||
@@ -14,9 +12,6 @@
|
||||
#define STAT(expr) do { } while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_QEMU
|
||||
#include "version.h"
|
||||
#endif
|
||||
#include "config-host.h"
|
||||
#include "slirp_config.h"
|
||||
|
||||
@@ -223,8 +218,6 @@ int inet_aton _P((const char *cp, struct in_addr *ia));
|
||||
#include "tftp.h"
|
||||
#include "libslirp.h"
|
||||
|
||||
extern struct ttys *ttys_unit[MAX_INTERFACES];
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
|
||||
@@ -15,14 +15,6 @@
|
||||
static void sofcantrcvmore(struct socket *so);
|
||||
static void sofcantsendmore(struct socket *so);
|
||||
|
||||
#if 0
|
||||
static void
|
||||
so_init()
|
||||
{
|
||||
/* Nothing yet */
|
||||
}
|
||||
#endif
|
||||
|
||||
struct socket *
|
||||
solookup(struct socket *head, struct in_addr laddr, u_int lport,
|
||||
struct in_addr faddr, u_int fport)
|
||||
@@ -526,12 +518,6 @@ sorecvfrom(struct socket *so)
|
||||
so->so_expire = curtime + SO_EXPIRE;
|
||||
}
|
||||
|
||||
/* if (m->m_len == len) {
|
||||
* m_inc(m, MINCSIZE);
|
||||
* m->m_len = 0;
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* If this packet was destined for CTL_ADDR,
|
||||
* make it look like that's where it came from, done by udp_output
|
||||
@@ -604,7 +590,6 @@ tcp_listen(u_int32_t haddr, u_int hport, u_int32_t laddr, u_int lport, int flags
|
||||
DEBUG_ARG("flags = %x", flags);
|
||||
|
||||
if ((so = socreate()) == NULL) {
|
||||
/* free(so); Not sofree() ??? free(NULL) == NOP */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -659,33 +644,6 @@ tcp_listen(u_int32_t haddr, u_int hport, u_int32_t laddr, u_int lport, int flags
|
||||
return so;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Data is available in so_rcv
|
||||
* Just write() the data to the socket
|
||||
* XXX not yet...
|
||||
*/
|
||||
static void
|
||||
sorwakeup(so)
|
||||
struct socket *so;
|
||||
{
|
||||
/* sowrite(so); */
|
||||
/* FD_CLR(so->s,&writefds); */
|
||||
}
|
||||
|
||||
/*
|
||||
* Data has been freed in so_snd
|
||||
* We have room for a read() if we want to
|
||||
* For now, don't read, it'll be done in the main loop
|
||||
*/
|
||||
static void
|
||||
sowwakeup(so)
|
||||
struct socket *so;
|
||||
{
|
||||
/* Nothing, yet */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Various session state calls
|
||||
* XXX Should be #define's
|
||||
@@ -746,17 +704,6 @@ sofcantsendmore(struct socket *so)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
soisfdisconnected(struct socket *so)
|
||||
{
|
||||
/* so->so_state &= ~(SS_ISFCONNECTING|SS_ISFCONNECTED); */
|
||||
/* close(so->s); */
|
||||
/* so->so_state = SS_ISFDISCONNECTED; */
|
||||
/*
|
||||
* XXX Do nothing ... ?
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Set write drain mode
|
||||
* Set CANTSENDMORE once all data has been write()n
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
* terms and conditions of the copyright.
|
||||
*/
|
||||
|
||||
/* MINE */
|
||||
|
||||
#ifndef _SLIRP_SOCKET_H_
|
||||
#define _SLIRP_SOCKET_H_
|
||||
|
||||
@@ -64,7 +62,6 @@ struct socket {
|
||||
#define SS_ISFCONNECTED 0x004 /* Socket is connected to peer */
|
||||
#define SS_FCANTRCVMORE 0x008 /* Socket can't receive more from peer (for half-closes) */
|
||||
#define SS_FCANTSENDMORE 0x010 /* Socket can't send more to peer (for half-closes) */
|
||||
/* #define SS_ISFDISCONNECTED 0x020*/ /* Socket has disconnected from peer, in 2MSL state */
|
||||
#define SS_FWDRAIN 0x040 /* We received a FIN, drain data and set SS_FCANTSENDMORE */
|
||||
|
||||
#define SS_CTL 0x080
|
||||
@@ -89,7 +86,6 @@ int sosendto _P((struct socket *, struct mbuf *));
|
||||
struct socket * tcp_listen _P((u_int32_t, u_int, u_int32_t, u_int, int));
|
||||
void soisfconnecting _P((register struct socket *));
|
||||
void soisfconnected _P((register struct socket *));
|
||||
void soisfdisconnected _P((struct socket *));
|
||||
void sofwdrain _P((struct socket *));
|
||||
struct iovec; /* For win32 */
|
||||
size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np);
|
||||
|
||||
@@ -113,7 +113,6 @@ struct tcphdr {
|
||||
#undef TCP_NODELAY
|
||||
#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
|
||||
#undef TCP_MAXSEG
|
||||
/* #define TCP_MAXSEG 0x02 */ /* set maximum segment size */
|
||||
|
||||
/*
|
||||
* TCP FSM state definitions.
|
||||
|
||||
+9
-201
@@ -81,7 +81,6 @@ tcp_seq tcp_iss; /* tcp initial send seq # */
|
||||
if (tcp_emu((so),(m))) sbappend((so), (m)); \
|
||||
} else \
|
||||
sbappend((so), (m)); \
|
||||
/* sorwakeup(so); */ \
|
||||
} else {\
|
||||
(flags) = tcp_reass((tp), (ti), (m)); \
|
||||
tp->t_flags |= TF_ACKNOW; \
|
||||
@@ -101,7 +100,6 @@ tcp_seq tcp_iss; /* tcp initial send seq # */
|
||||
if (tcp_emu((so),(m))) sbappend(so, (m)); \
|
||||
} else \
|
||||
sbappend((so), (m)); \
|
||||
/* sorwakeup(so); */ \
|
||||
} else { \
|
||||
(flags) = tcp_reass((tp), (ti), (m)); \
|
||||
tp->t_flags |= TF_ACKNOW; \
|
||||
@@ -211,7 +209,6 @@ present:
|
||||
remque(tcpiphdr2qlink(ti));
|
||||
m = ti->ti_mbuf;
|
||||
ti = tcpiphdr_next(ti);
|
||||
/* if (so->so_state & SS_FCANTRCVMORE) */
|
||||
if (so->so_state & SS_FCANTSENDMORE)
|
||||
m_freem(m);
|
||||
else {
|
||||
@@ -221,7 +218,6 @@ present:
|
||||
sbappend(so, m);
|
||||
}
|
||||
} while (ti != (struct tcpiphdr *)tp && ti->ti_seq == tp->rcv_nxt);
|
||||
/* sorwakeup(so); */
|
||||
return (flags);
|
||||
}
|
||||
|
||||
@@ -241,11 +237,9 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
|
||||
register int tiflags;
|
||||
struct socket *so = NULL;
|
||||
int todrop, acked, ourfinisacked, needoutput = 0;
|
||||
/* int dropsocket = 0; */
|
||||
int iss = 0;
|
||||
u_long tiwin;
|
||||
int ret;
|
||||
/* int ts_present = 0; */
|
||||
struct ex_list *ex_ptr;
|
||||
|
||||
DEBUG_CALL("tcp_input");
|
||||
@@ -300,9 +294,6 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
|
||||
ti->ti_x1 = 0;
|
||||
ti->ti_len = htons((u_int16_t)tlen);
|
||||
len = sizeof(struct ip ) + tlen;
|
||||
/* keep checksum for ICMP reply
|
||||
* ti->ti_sum = cksum(m, len);
|
||||
* if (ti->ti_sum) { */
|
||||
if(cksum(m, len)) {
|
||||
STAT(tcpstat.tcps_rcvbadsum++);
|
||||
goto drop;
|
||||
@@ -322,25 +313,6 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
|
||||
if (off > sizeof (struct tcphdr)) {
|
||||
optlen = off - sizeof (struct tcphdr);
|
||||
optp = mtod(m, caddr_t) + sizeof (struct tcpiphdr);
|
||||
|
||||
/*
|
||||
* Do quick retrieval of timestamp options ("options
|
||||
* prediction?"). If timestamp is the only option and it's
|
||||
* formatted as recommended in RFC 1323 appendix A, we
|
||||
* quickly get the values now and not bother calling
|
||||
* tcp_dooptions(), etc.
|
||||
*/
|
||||
/* if ((optlen == TCPOLEN_TSTAMP_APPA ||
|
||||
* (optlen > TCPOLEN_TSTAMP_APPA &&
|
||||
* optp[TCPOLEN_TSTAMP_APPA] == TCPOPT_EOL)) &&
|
||||
* *(u_int32_t *)optp == htonl(TCPOPT_TSTAMP_HDR) &&
|
||||
* (ti->ti_flags & TH_SYN) == 0) {
|
||||
* ts_present = 1;
|
||||
* ts_val = ntohl(*(u_int32_t *)(optp + 4));
|
||||
* ts_ecr = ntohl(*(u_int32_t *)(optp + 8));
|
||||
* optp = NULL; / * we've parsed the options * /
|
||||
* }
|
||||
*/
|
||||
}
|
||||
tiflags = ti->ti_flags;
|
||||
|
||||
@@ -411,9 +383,6 @@ findso:
|
||||
sbreserve(&so->so_snd, TCP_SNDSPACE);
|
||||
sbreserve(&so->so_rcv, TCP_RCVSPACE);
|
||||
|
||||
/* tcp_last_so = so; */ /* XXX ? */
|
||||
/* tp = sototcpcb(so); */
|
||||
|
||||
so->so_laddr = ti->ti_src;
|
||||
so->so_lport = ti->ti_sport;
|
||||
so->so_faddr = ti->ti_dst;
|
||||
@@ -442,12 +411,7 @@ findso:
|
||||
if (tp->t_state == TCPS_CLOSED)
|
||||
goto drop;
|
||||
|
||||
/* Unscale the window into a 32-bit value. */
|
||||
/* if ((tiflags & TH_SYN) == 0)
|
||||
* tiwin = ti->ti_win << tp->snd_scale;
|
||||
* else
|
||||
*/
|
||||
tiwin = ti->ti_win;
|
||||
tiwin = ti->ti_win;
|
||||
|
||||
/*
|
||||
* Segment received on connection.
|
||||
@@ -465,8 +429,6 @@ findso:
|
||||
*/
|
||||
if (optp && tp->t_state != TCPS_LISTEN)
|
||||
tcp_dooptions(tp, (u_char *)optp, optlen, ti);
|
||||
/* , */
|
||||
/* &ts_present, &ts_val, &ts_ecr); */
|
||||
|
||||
/*
|
||||
* Header prediction: check for the two common cases
|
||||
@@ -488,20 +450,9 @@ findso:
|
||||
*/
|
||||
if (tp->t_state == TCPS_ESTABLISHED &&
|
||||
(tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK &&
|
||||
/* (!ts_present || TSTMP_GEQ(ts_val, tp->ts_recent)) && */
|
||||
ti->ti_seq == tp->rcv_nxt &&
|
||||
tiwin && tiwin == tp->snd_wnd &&
|
||||
tp->snd_nxt == tp->snd_max) {
|
||||
/*
|
||||
* If last ACK falls within this segment's sequence numbers,
|
||||
* record the timestamp.
|
||||
*/
|
||||
/* if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
|
||||
* SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len)) {
|
||||
* tp->ts_recent_age = tcp_now;
|
||||
* tp->ts_recent = ts_val;
|
||||
* }
|
||||
*/
|
||||
if (ti->ti_len == 0) {
|
||||
if (SEQ_GT(ti->ti_ack, tp->snd_una) &&
|
||||
SEQ_LEQ(ti->ti_ack, tp->snd_max) &&
|
||||
@@ -510,11 +461,8 @@ findso:
|
||||
* this is a pure ack for outstanding data.
|
||||
*/
|
||||
STAT(tcpstat.tcps_predack++);
|
||||
/* if (ts_present)
|
||||
* tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
|
||||
* else
|
||||
*/ if (tp->t_rtt &&
|
||||
SEQ_GT(ti->ti_ack, tp->t_rtseq))
|
||||
if (tp->t_rtt &&
|
||||
SEQ_GT(ti->ti_ack, tp->t_rtseq))
|
||||
tcp_xmit_timer(tp, tp->t_rtt);
|
||||
acked = ti->ti_ack - tp->snd_una;
|
||||
STAT(tcpstat.tcps_rcvackpack++);
|
||||
@@ -537,13 +485,6 @@ findso:
|
||||
else if (tp->t_timer[TCPT_PERSIST] == 0)
|
||||
tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
|
||||
|
||||
/*
|
||||
* There's room in so_snd, sowwakup will read()
|
||||
* from the socket if we can
|
||||
*/
|
||||
/* if (so->so_snd.sb_flags & SB_NOTIFY)
|
||||
* sowwakeup(so);
|
||||
*/
|
||||
/*
|
||||
* This is called because sowwakeup might have
|
||||
* put data into so_snd. Since we don't so sowwakeup,
|
||||
@@ -574,13 +515,6 @@ findso:
|
||||
} else
|
||||
sbappend(so, m);
|
||||
|
||||
/*
|
||||
* XXX This is called when data arrives. Later, check
|
||||
* if we can actually write() to the socket
|
||||
* XXX Need to check? It's be NON_BLOCKING
|
||||
*/
|
||||
/* sorwakeup(so); */
|
||||
|
||||
/*
|
||||
* If this is a short packet, then ACK now - with Nagel
|
||||
* congestion avoidance sender won't send more until
|
||||
@@ -644,13 +578,6 @@ findso:
|
||||
vnetwork_addr.s_addr) {
|
||||
if (so->so_faddr.s_addr != vhost_addr.s_addr &&
|
||||
so->so_faddr.s_addr != vnameserver_addr.s_addr) {
|
||||
#if 0
|
||||
if(lastbyte==CTL_CMD || lastbyte==CTL_EXEC) {
|
||||
/* Command or exec adress */
|
||||
so->so_state |= SS_CTL;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* May be an add exec */
|
||||
for(ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
|
||||
if(ex_ptr->ex_fport == so->so_fport &&
|
||||
@@ -659,8 +586,9 @@ findso:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(so->so_state & SS_CTL) goto cont_input;
|
||||
if (so->so_state & SS_CTL) {
|
||||
goto cont_input;
|
||||
}
|
||||
}
|
||||
/* CTL_ALIAS: Do nothing, tcp_fconnect will be called on it */
|
||||
}
|
||||
@@ -718,8 +646,6 @@ findso:
|
||||
|
||||
if (optp)
|
||||
tcp_dooptions(tp, (u_char *)optp, optlen, ti);
|
||||
/* , */
|
||||
/* &ts_present, &ts_val, &ts_ecr); */
|
||||
|
||||
if (iss)
|
||||
tp->iss = iss;
|
||||
@@ -777,13 +703,6 @@ findso:
|
||||
soisfconnected(so);
|
||||
tp->t_state = TCPS_ESTABLISHED;
|
||||
|
||||
/* Do window scaling on this connection? */
|
||||
/* if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
|
||||
* (TF_RCVD_SCALE|TF_REQ_SCALE)) {
|
||||
* tp->snd_scale = tp->requested_s_scale;
|
||||
* tp->rcv_scale = tp->request_r_scale;
|
||||
* }
|
||||
*/
|
||||
(void) tcp_reass(tp, (struct tcpiphdr *)0,
|
||||
(struct mbuf *)0);
|
||||
/*
|
||||
@@ -816,40 +735,10 @@ trimthenstep6:
|
||||
} /* switch tp->t_state */
|
||||
/*
|
||||
* States other than LISTEN or SYN_SENT.
|
||||
* First check timestamp, if present.
|
||||
* Then check that at least some bytes of segment are within
|
||||
* Check that at least some bytes of segment are within
|
||||
* receive window. If segment begins before rcv_nxt,
|
||||
* drop leading data (and SYN); if nothing left, just ack.
|
||||
*
|
||||
* RFC 1323 PAWS: If we have a timestamp reply on this segment
|
||||
* and it's less than ts_recent, drop it.
|
||||
*/
|
||||
/* if (ts_present && (tiflags & TH_RST) == 0 && tp->ts_recent &&
|
||||
* TSTMP_LT(ts_val, tp->ts_recent)) {
|
||||
*
|
||||
*/ /* Check to see if ts_recent is over 24 days old. */
|
||||
/* if ((int)(tcp_now - tp->ts_recent_age) > TCP_PAWS_IDLE) {
|
||||
*/ /*
|
||||
* * Invalidate ts_recent. If this segment updates
|
||||
* * ts_recent, the age will be reset later and ts_recent
|
||||
* * will get a valid value. If it does not, setting
|
||||
* * ts_recent to zero will at least satisfy the
|
||||
* * requirement that zero be placed in the timestamp
|
||||
* * echo reply when ts_recent isn't valid. The
|
||||
* * age isn't reset until we get a valid ts_recent
|
||||
* * because we don't want out-of-order segments to be
|
||||
* * dropped when ts_recent is old.
|
||||
* */
|
||||
/* tp->ts_recent = 0;
|
||||
* } else {
|
||||
* tcpstat.tcps_rcvduppack++;
|
||||
* tcpstat.tcps_rcvdupbyte += ti->ti_len;
|
||||
* tcpstat.tcps_pawsdrop++;
|
||||
* goto dropafterack;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
todrop = tp->rcv_nxt - ti->ti_seq;
|
||||
if (todrop > 0) {
|
||||
if (tiflags & TH_SYN) {
|
||||
@@ -947,18 +836,6 @@ trimthenstep6:
|
||||
tiflags &= ~(TH_PUSH|TH_FIN);
|
||||
}
|
||||
|
||||
/*
|
||||
* If last ACK falls within this segment's sequence numbers,
|
||||
* record its timestamp.
|
||||
*/
|
||||
/* if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
|
||||
* SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len +
|
||||
* ((tiflags & (TH_SYN|TH_FIN)) != 0))) {
|
||||
* tp->ts_recent_age = tcp_now;
|
||||
* tp->ts_recent = ts_val;
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* If the RST bit is set examine the state:
|
||||
* SYN_RECEIVED STATE:
|
||||
@@ -972,15 +849,10 @@ trimthenstep6:
|
||||
if (tiflags&TH_RST) switch (tp->t_state) {
|
||||
|
||||
case TCPS_SYN_RECEIVED:
|
||||
/* so->so_error = ECONNREFUSED; */
|
||||
goto close;
|
||||
|
||||
case TCPS_ESTABLISHED:
|
||||
case TCPS_FIN_WAIT_1:
|
||||
case TCPS_FIN_WAIT_2:
|
||||
case TCPS_CLOSE_WAIT:
|
||||
/* so->so_error = ECONNRESET; */
|
||||
close:
|
||||
tp->t_state = TCPS_CLOSED;
|
||||
STAT(tcpstat.tcps_drops++);
|
||||
tp = tcp_close(tp);
|
||||
@@ -1048,13 +920,6 @@ trimthenstep6:
|
||||
soisfconnected(so);
|
||||
}
|
||||
|
||||
/* Do window scaling? */
|
||||
/* if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
|
||||
* (TF_RCVD_SCALE|TF_REQ_SCALE)) {
|
||||
* tp->snd_scale = tp->requested_s_scale;
|
||||
* tp->rcv_scale = tp->request_r_scale;
|
||||
* }
|
||||
*/
|
||||
(void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0);
|
||||
tp->snd_wl1 = ti->ti_seq - 1;
|
||||
/* Avoid ack processing; snd_una==ti_ack => dup ack */
|
||||
@@ -1155,19 +1020,13 @@ trimthenstep6:
|
||||
STAT(tcpstat.tcps_rcvackbyte += acked);
|
||||
|
||||
/*
|
||||
* If we have a timestamp reply, update smoothed
|
||||
* round trip time. If no timestamp is present but
|
||||
* transmit timer is running and timed sequence
|
||||
* If transmit timer is running and timed sequence
|
||||
* number was acked, update smoothed round trip time.
|
||||
* Since we now have an rtt measurement, cancel the
|
||||
* timer backoff (cf., Phil Karn's retransmit alg.).
|
||||
* Recompute the initial retransmit timer.
|
||||
*/
|
||||
/* if (ts_present)
|
||||
* tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
|
||||
* else
|
||||
*/
|
||||
if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
|
||||
if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
|
||||
tcp_xmit_timer(tp,tp->t_rtt);
|
||||
|
||||
/*
|
||||
@@ -1205,13 +1064,6 @@ trimthenstep6:
|
||||
tp->snd_wnd -= acked;
|
||||
ourfinisacked = 0;
|
||||
}
|
||||
/*
|
||||
* XXX sowwakup is called when data is acked and there's room for
|
||||
* for more data... it should read() the socket
|
||||
*/
|
||||
/* if (so->so_snd.sb_flags & SB_NOTIFY)
|
||||
* sowwakeup(so);
|
||||
*/
|
||||
tp->snd_una = ti->ti_ack;
|
||||
if (SEQ_LT(tp->snd_nxt, tp->snd_una))
|
||||
tp->snd_nxt = tp->snd_una;
|
||||
@@ -1233,7 +1085,6 @@ trimthenstep6:
|
||||
* we'll hang forever.
|
||||
*/
|
||||
if (so->so_state & SS_FCANTRCVMORE) {
|
||||
soisfdisconnected(so);
|
||||
tp->t_timer[TCPT_2MSL] = TCP_MAXIDLE;
|
||||
}
|
||||
tp->t_state = TCPS_FIN_WAIT_2;
|
||||
@@ -1251,7 +1102,6 @@ trimthenstep6:
|
||||
tp->t_state = TCPS_TIME_WAIT;
|
||||
tcp_canceltimers(tp);
|
||||
tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
|
||||
soisfdisconnected(so);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1384,7 +1234,6 @@ dodata:
|
||||
* will got to TCPS_LAST_ACK, and use tcp_output()
|
||||
* to send the FIN.
|
||||
*/
|
||||
/* sofcantrcvmore(so); */
|
||||
sofwdrain(so);
|
||||
|
||||
tp->t_flags |= TF_ACKNOW;
|
||||
@@ -1421,7 +1270,6 @@ dodata:
|
||||
tp->t_state = TCPS_TIME_WAIT;
|
||||
tcp_canceltimers(tp);
|
||||
tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
|
||||
soisfdisconnected(so);
|
||||
break;
|
||||
|
||||
/*
|
||||
@@ -1440,13 +1288,6 @@ dodata:
|
||||
*
|
||||
* See above.
|
||||
*/
|
||||
/* if (ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg) {
|
||||
*/
|
||||
/* if ((ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg &&
|
||||
* (so->so_iptos & IPTOS_LOWDELAY) == 0) ||
|
||||
* ((so->so_iptos & IPTOS_LOWDELAY) &&
|
||||
* ((struct tcpiphdr_2 *)ti)->first_char == (char)27)) {
|
||||
*/
|
||||
if (ti->ti_len && (unsigned)ti->ti_len <= 5 &&
|
||||
((struct tcpiphdr_2 *)ti)->first_char == (char)27) {
|
||||
tp->t_flags |= TF_ACKNOW;
|
||||
@@ -1493,10 +1334,6 @@ drop:
|
||||
return;
|
||||
}
|
||||
|
||||
/* , ts_present, ts_val, ts_ecr) */
|
||||
/* int *ts_present;
|
||||
* u_int32_t *ts_val, *ts_ecr;
|
||||
*/
|
||||
static void
|
||||
tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
|
||||
{
|
||||
@@ -1531,35 +1368,6 @@ tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
|
||||
NTOHS(mss);
|
||||
(void) tcp_mss(tp, mss); /* sets t_maxseg */
|
||||
break;
|
||||
|
||||
/* case TCPOPT_WINDOW:
|
||||
* if (optlen != TCPOLEN_WINDOW)
|
||||
* continue;
|
||||
* if (!(ti->ti_flags & TH_SYN))
|
||||
* continue;
|
||||
* tp->t_flags |= TF_RCVD_SCALE;
|
||||
* tp->requested_s_scale = min(cp[2], TCP_MAX_WINSHIFT);
|
||||
* break;
|
||||
*/
|
||||
/* case TCPOPT_TIMESTAMP:
|
||||
* if (optlen != TCPOLEN_TIMESTAMP)
|
||||
* continue;
|
||||
* *ts_present = 1;
|
||||
* memcpy((char *) ts_val, (char *)cp + 2, sizeof(*ts_val));
|
||||
* NTOHL(*ts_val);
|
||||
* memcpy((char *) ts_ecr, (char *)cp + 6, sizeof(*ts_ecr));
|
||||
* NTOHL(*ts_ecr);
|
||||
*
|
||||
*/ /*
|
||||
* * A timestamp received in a SYN makes
|
||||
* * it ok to send timestamp requests and replies.
|
||||
* */
|
||||
/* if (ti->ti_flags & TH_SYN) {
|
||||
* tp->t_flags |= TF_RCVD_TSTMP;
|
||||
* tp->ts_recent = *ts_val;
|
||||
* tp->ts_recent_age = tcp_now;
|
||||
* }
|
||||
*/ break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-75
@@ -272,39 +272,9 @@ send:
|
||||
mss = htons((u_int16_t) tcp_mss(tp, 0));
|
||||
memcpy((caddr_t)(opt + 2), (caddr_t)&mss, sizeof(mss));
|
||||
optlen = 4;
|
||||
|
||||
/* if ((tp->t_flags & TF_REQ_SCALE) &&
|
||||
* ((flags & TH_ACK) == 0 ||
|
||||
* (tp->t_flags & TF_RCVD_SCALE))) {
|
||||
* *((u_int32_t *) (opt + optlen)) = htonl(
|
||||
* TCPOPT_NOP << 24 |
|
||||
* TCPOPT_WINDOW << 16 |
|
||||
* TCPOLEN_WINDOW << 8 |
|
||||
* tp->request_r_scale);
|
||||
* optlen += 4;
|
||||
* }
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a timestamp and echo-reply if this is a SYN and our side
|
||||
* wants to use timestamps (TF_REQ_TSTMP is set) or both our side
|
||||
* and our peer have sent timestamps in our SYN's.
|
||||
*/
|
||||
/* if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
|
||||
* (flags & TH_RST) == 0 &&
|
||||
* ((flags & (TH_SYN|TH_ACK)) == TH_SYN ||
|
||||
* (tp->t_flags & TF_RCVD_TSTMP))) {
|
||||
* u_int32_t *lp = (u_int32_t *)(opt + optlen);
|
||||
*
|
||||
* / * Form timestamp option as shown in appendix A of RFC 1323. * /
|
||||
* *lp++ = htonl(TCPOPT_TSTAMP_HDR);
|
||||
* *lp++ = htonl(tcp_now);
|
||||
* *lp = htonl(tp->ts_recent);
|
||||
* optlen += TCPOLEN_TSTAMP_APPA;
|
||||
* }
|
||||
*/
|
||||
hdrlen += optlen;
|
||||
|
||||
/*
|
||||
@@ -334,28 +304,15 @@ send:
|
||||
|
||||
m = m_get();
|
||||
if (m == NULL) {
|
||||
/* error = ENOBUFS; */
|
||||
error = 1;
|
||||
goto out;
|
||||
}
|
||||
m->m_data += IF_MAXLINKHDR;
|
||||
m->m_len = hdrlen;
|
||||
|
||||
/*
|
||||
* This will always succeed, since we make sure our mbufs
|
||||
* are big enough to hold one MSS packet + header + ... etc.
|
||||
*/
|
||||
/* if (len <= MHLEN - hdrlen - max_linkhdr) { */
|
||||
sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
|
||||
m->m_len += len;
|
||||
|
||||
sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
|
||||
m->m_len += len;
|
||||
|
||||
/* } else {
|
||||
* m->m_next = m_copy(so->so_snd.sb_mb, off, (int) len);
|
||||
* if (m->m_next == 0)
|
||||
* len = 0;
|
||||
* }
|
||||
*/
|
||||
/*
|
||||
* If we're sending everything we've got, set PUSH.
|
||||
* (This will keep happy those implementations which only
|
||||
@@ -376,7 +333,6 @@ send:
|
||||
|
||||
m = m_get();
|
||||
if (m == NULL) {
|
||||
/* error = ENOBUFS; */
|
||||
error = 1;
|
||||
goto out;
|
||||
}
|
||||
@@ -433,10 +389,6 @@ send:
|
||||
|
||||
if (SEQ_GT(tp->snd_up, tp->snd_una)) {
|
||||
ti->ti_urp = htons((u_int16_t)(tp->snd_up - ntohl(ti->ti_seq)));
|
||||
#ifdef notdef
|
||||
if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
|
||||
ti->ti_urp = htons((u_int16_t)(tp->snd_up - tp->snd_nxt));
|
||||
#endif
|
||||
ti->ti_flags |= TH_URG;
|
||||
} else
|
||||
/*
|
||||
@@ -523,32 +475,10 @@ send:
|
||||
((struct ip *)ti)->ip_ttl = IPDEFTTL;
|
||||
((struct ip *)ti)->ip_tos = so->so_iptos;
|
||||
|
||||
/* #if BSD >= 43 */
|
||||
/* Don't do IP options... */
|
||||
/* error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
|
||||
* so->so_options & SO_DONTROUTE, 0);
|
||||
*/
|
||||
error = ip_output(so, m);
|
||||
|
||||
/* #else
|
||||
* error = ip_output(m, (struct mbuf *)0, &tp->t_inpcb->inp_route,
|
||||
* so->so_options & SO_DONTROUTE);
|
||||
* #endif
|
||||
*/
|
||||
}
|
||||
if (error) {
|
||||
out:
|
||||
/* if (error == ENOBUFS) {
|
||||
* tcp_quench(tp->t_inpcb, 0);
|
||||
* return (0);
|
||||
* }
|
||||
*/
|
||||
/* if ((error == EHOSTUNREACH || error == ENETDOWN)
|
||||
* && TCPS_HAVERCVDSYN(tp->t_state)) {
|
||||
* tp->t_softerror = error;
|
||||
* return (0);
|
||||
* }
|
||||
*/
|
||||
return (error);
|
||||
}
|
||||
STAT(tcpstat.tcps_sndtotal++);
|
||||
@@ -574,9 +504,6 @@ tcp_setpersist(struct tcpcb *tp)
|
||||
{
|
||||
int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1;
|
||||
|
||||
/* if (tp->t_timer[TCPT_REXMT])
|
||||
* panic("tcp_output REXMT");
|
||||
*/
|
||||
/*
|
||||
* Start/restart persistence timer.
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user