Skip to content

Commit

Permalink
slirp: Drop dead code
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
jan-kiszka authored and Anthony Liguori committed Jun 29, 2009
1 parent 6dbe553 commit 0d62c4c
Show file tree
Hide file tree
Showing 26 changed files with 22 additions and 1,650 deletions.
185 changes: 0 additions & 185 deletions slirp/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 0 additions & 2 deletions slirp/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
80 changes: 0 additions & 80 deletions slirp/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 1 addition & 13 deletions slirp/if.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
4 changes: 0 additions & 4 deletions slirp/ip_icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 0 additions & 17 deletions slirp/ip_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -396,9 +386,6 @@ ip_reass(register struct ip *ip, register struct ipq *fp)
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++);
Expand Down
Loading

0 comments on commit 0d62c4c

Please sign in to comment.