Use const and static as needed, disable unused code

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3452 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1
2007-10-26 19:01:16 +00:00
parent 31a60e2275
commit 9634d9031c
28 changed files with 163 additions and 221 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ static void bootp_reply(struct bootp_t *bp)
if ((m = m_get()) == NULL)
return;
m->m_data += if_maxlinkhdr;
m->m_data += IF_MAXLINKHDR;
rbp = (struct bootp_t *)m->m_data;
m->m_data += sizeof(struct udpiphdr);
memset(rbp, 0, sizeof(struct bootp_t));
+2 -2
View File
@@ -92,9 +92,9 @@ ttystats(ttyp)
lprint(" \r\n");
if (if_comp & IF_COMPRESS)
if (IF_COMP & IF_COMPRESS)
strcpy(buff, "on");
else if (if_comp & IF_NOCOMPRESS)
else if (IF_COMP & IF_NOCOMPRESS)
strcpy(buff, "off");
else
strcpy(buff, "off (for now)");
-20
View File
@@ -7,9 +7,6 @@
#include <slirp.h>
int if_mtu, if_mru;
int if_comp;
int if_maxlinkhdr;
int if_queued = 0; /* Number of packets queued so far */
int if_thresh = 10; /* Number of packets queued before we start sending
* (to prevent allocing too many mbufs) */
@@ -41,23 +38,6 @@ ifs_remque(ifm)
void
if_init()
{
#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
if_maxlinkhdr = 48;
#else
if_maxlinkhdr = 40;
#endif
#else
/* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
if_maxlinkhdr = 2 + 14 + 40;
#endif
if_mtu = 1500;
if_mru = 1500;
if_comp = IF_AUTOCOMP;
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);
+19 -6
View File
@@ -13,12 +13,25 @@
#define IF_AUTOCOMP 0x04 /* Autodetect (default) */
#define IF_NOCIDCOMP 0x08 /* CID compression */
/* Needed for FreeBSD */
#undef if_mtu
extern int if_mtu;
extern int if_mru; /* MTU and MRU */
extern int if_comp; /* Flags for compression */
extern int if_maxlinkhdr;
#define IF_MTU 1500
#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 */
#define IF_MAXLINKHDR (2 + 14 + 40)
#endif
extern int if_queued; /* Number of packets queued so far */
extern int if_thresh; /* Number of packets queued before we start sending
* (to prevent allocing too many mbufs) */
-2
View File
@@ -312,6 +312,4 @@ extern struct ipstat ipstat;
extern struct ipq ipq; /* ip reass. queue */
extern u_int16_t ip_id; /* ip packet ctr, for ids */
extern int ip_defttl; /* default IP ttl */
#endif
+1 -1
View File
@@ -46,7 +46,7 @@ struct icmpstat icmpstat;
char icmp_ping_msg[] = "This is a psuedo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
/* list of actions for icmp_error() on RX of an icmp message */
static int icmp_flush[19] = {
static const int icmp_flush[19] = {
/* ECHO REPLY (0) */ 0,
1,
1,
+15 -16
View File
@@ -45,14 +45,19 @@
#include <slirp.h>
#include "ip_icmp.h"
int ip_defttl;
#ifdef LOG_ENABLED
struct ipstat ipstat;
#endif
struct ipq ipq;
static struct ip *ip_reass(register struct ipasfrag *ip,
register struct ipq *fp);
static void ip_freef(struct ipq *fp);
static void ip_enq(register struct ipasfrag *p,
register struct ipasfrag *prev);
static void ip_deq(register struct ipasfrag *p);
/*
* IP initialization: fill in IP protocol switch table.
* All protocols not implemented in kernel go to raw IP protocol handler.
@@ -64,7 +69,6 @@ ip_init()
ip_id = tt.tv_sec & 0xffff;
udp_init();
tcp_init();
ip_defttl = IPDEFTTL;
}
/*
@@ -239,10 +243,8 @@ bad:
* reassembly of this datagram already exists, then it
* is given as fp; otherwise have to make a chain.
*/
struct ip *
ip_reass(ip, fp)
register struct ipasfrag *ip;
register struct ipq *fp;
static struct ip *
ip_reass(register struct ipasfrag *ip, register struct ipq *fp)
{
register struct mbuf *m = dtom(ip);
register struct ipasfrag *q;
@@ -398,9 +400,8 @@ dropfrag:
* Free a fragment reassembly header and all
* associated datagrams.
*/
void
ip_freef(fp)
struct ipq *fp;
static void
ip_freef(struct ipq *fp)
{
register struct ipasfrag *q, *p;
@@ -418,9 +419,8 @@ ip_freef(fp)
* Put an ip fragment on a reassembly chain.
* Like insque, but pointers in middle of structure.
*/
void
ip_enq(p, prev)
register struct ipasfrag *p, *prev;
static void
ip_enq(register struct ipasfrag *p, register struct ipasfrag *prev)
{
DEBUG_CALL("ip_enq");
DEBUG_ARG("prev = %lx", (long)prev);
@@ -433,9 +433,8 @@ ip_enq(p, prev)
/*
* To ip_enq as remque is to insque.
*/
void
ip_deq(p)
register struct ipasfrag *p;
static void
ip_deq(register struct ipasfrag *p)
{
((struct ipasfrag *)(p->ipf_prev))->ipf_next = p->ipf_next;
((struct ipasfrag *)(p->ipf_next))->ipf_prev = p->ipf_prev;
+3 -3
View File
@@ -96,7 +96,7 @@ ip_output(so, m0)
/*
* If small enough for interface, can just send directly.
*/
if ((u_int16_t)ip->ip_len <= if_mtu) {
if ((u_int16_t)ip->ip_len <= IF_MTU) {
ip->ip_len = htons((u_int16_t)ip->ip_len);
ip->ip_off = htons((u_int16_t)ip->ip_off);
ip->ip_sum = 0;
@@ -116,7 +116,7 @@ ip_output(so, m0)
goto bad;
}
len = (if_mtu - hlen) &~ 7; /* ip databytes per packet */
len = (IF_MTU - hlen) &~ 7; /* ip databytes per packet */
if (len < 8) {
error = -1;
goto bad;
@@ -140,7 +140,7 @@ ip_output(so, m0)
STAT(ipstat.ips_odropped++);
goto sendorfree;
}
m->m_data += if_maxlinkhdr;
m->m_data += IF_MAXLINKHDR;
mhip = mtod(m, struct ip *);
*mhip = *ip;
-1
View File
@@ -42,7 +42,6 @@ extern char *username;
extern char *socket_path;
extern int towrite_max;
extern int ppp_exit;
extern int so_options;
extern int tcp_keepintvl;
extern uint8_t client_ethaddr[6];
+10 -17
View File
@@ -21,27 +21,20 @@ struct mbuf *mbutl;
char *mclrefcnt;
int mbuf_alloced = 0;
struct mbuf m_freelist, m_usedlist;
int mbuf_thresh = 30;
#define MBUF_THRESH 30
int mbuf_max = 0;
int msize;
/*
* Find a nice value for msize
* XXX if_maxlinkhdr already in mtu
*/
#define MSIZE (IF_MTU + IF_MAXLINKHDR + sizeof(struct m_hdr ) + 6)
void
m_init()
{
m_freelist.m_next = m_freelist.m_prev = &m_freelist;
m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
msize_init();
}
void
msize_init()
{
/*
* Find a nice value for msize
* XXX if_maxlinkhdr already in mtu
*/
msize = (if_mtu>if_mru?if_mtu:if_mru) +
if_maxlinkhdr + sizeof(struct m_hdr ) + 6;
}
/*
@@ -61,10 +54,10 @@ m_get()
DEBUG_CALL("m_get");
if (m_freelist.m_next == &m_freelist) {
m = (struct mbuf *)malloc(msize);
m = (struct mbuf *)malloc(MSIZE);
if (m == NULL) goto end_error;
mbuf_alloced++;
if (mbuf_alloced > mbuf_thresh)
if (mbuf_alloced > MBUF_THRESH)
flags = M_DOFREE;
if (mbuf_alloced > mbuf_max)
mbuf_max = mbuf_alloced;
@@ -78,7 +71,7 @@ m_get()
m->m_flags = (flags | M_USEDLIST);
/* Initialise it */
m->m_size = msize - sizeof(struct m_hdr);
m->m_size = MSIZE - sizeof(struct m_hdr);
m->m_data = m->m_dat;
m->m_len = 0;
m->m_nextpkt = 0;
-1
View File
@@ -135,7 +135,6 @@ extern struct mbuf m_freelist, m_usedlist;
extern int mbuf_max;
void m_init _P((void));
void msize_init _P((void));
struct mbuf * m_get _P((void));
void m_free _P((struct mbuf *));
void m_cat _P((register struct mbuf *, register struct mbuf *));
+10 -13
View File
@@ -8,8 +8,7 @@
#define WANT_SYS_IOCTL_H
#include <slirp.h>
u_int curtime, time_fasttimo, last_slowtimo, detach_time;
u_int detach_wait = 600000; /* 10 minutes */
u_int curtime, time_fasttimo, last_slowtimo;
#if 0
int x_port = -1;
@@ -214,10 +213,7 @@ strerror(error)
#ifdef _WIN32
int
fork_exec(so, ex, do_pty)
struct socket *so;
char *ex;
int do_pty;
fork_exec(struct socket *so, const char *ex, int do_pty)
{
/* not implemented */
return 0;
@@ -225,6 +221,7 @@ fork_exec(so, ex, do_pty)
#else
#ifndef CONFIG_QEMU
int
slirp_openpty(amaster, aslave)
int *amaster, *aslave;
@@ -289,6 +286,7 @@ slirp_openpty(amaster, aslave)
return (-1);
#endif
}
#endif
/*
* XXX This is ugly
@@ -302,23 +300,20 @@ slirp_openpty(amaster, aslave)
* do_ptr = 2 Fork/exec using pty
*/
int
fork_exec(so, ex, do_pty)
struct socket *so;
char *ex;
int do_pty;
fork_exec(struct socket *so, const char *ex, int do_pty)
{
int s;
struct sockaddr_in addr;
int addrlen = sizeof(addr);
int opt;
int master;
int master = -1;
char *argv[256];
#if 0
char buff[256];
#endif
/* don't want to clobber the original */
char *bptr;
char *curarg;
const char *curarg;
int c, i, ret;
DEBUG_CALL("fork_exec");
@@ -327,10 +322,12 @@ fork_exec(so, ex, do_pty)
DEBUG_ARG("do_pty = %lx", (long)do_pty);
if (do_pty == 2) {
#if 0
if (slirp_openpty(&master, &s) == -1) {
lprint("Error: openpty failed: %s\n", strerror(errno));
return 0;
}
#endif
} else {
addr.sin_family = AF_INET;
addr.sin_port = 0;
@@ -390,7 +387,7 @@ fork_exec(so, ex, do_pty)
dup2(s, 0);
dup2(s, 1);
dup2(s, 2);
for (s = 3; s <= 255; s++)
for (s = getdtablesize() - 1; s >= 3; s--)
close(s);
i = 0;
+3 -3
View File
@@ -12,12 +12,12 @@ struct ex_list {
int ex_pty; /* Do we want a pty? */
int ex_addr; /* The last byte of the address */
int ex_fport; /* Port to telnet to */
char *ex_exec; /* Command line of what to exec */
const char *ex_exec; /* Command line of what to exec */
struct ex_list *ex_next;
};
extern struct ex_list *exec_list;
extern u_int curtime, time_fasttimo, last_slowtimo, detach_time, detach_wait;
extern u_int curtime, time_fasttimo, last_slowtimo;
extern int (*lprint_print) _P((void *, const char *, va_list));
extern char *lprint_ptr, *lprint_ptr2, **lprint_arg;
@@ -74,7 +74,7 @@ inline void slirp_insque _P((void *, void *));
inline void slirp_remque _P((void *));
int add_exec _P((struct ex_list **, int, char *, int, int));
int slirp_openpty _P((int *, int *));
int fork_exec _P((struct socket *, char *, int));
int fork_exec(struct socket *so, const char *ex, int do_pty);
void snooze_hup _P((int));
void snooze _P((void));
void relay _P((int));
+4 -4
View File
@@ -7,6 +7,8 @@
#include <slirp.h>
static void sbappendsb(struct sbuf *sb, struct mbuf *m);
/* Done as a macro in socket.h */
/* int
* sbspace(struct sockbuff *sb)
@@ -133,10 +135,8 @@ sbappend(so, m)
* Copy the data from m into sb
* The caller is responsible to make sure there's enough room
*/
void
sbappendsb(sb, m)
struct sbuf *sb;
struct mbuf *m;
static void
sbappendsb(struct sbuf *sb, struct mbuf *m)
{
int len, n, nn;
-1
View File
@@ -25,7 +25,6 @@ void sbfree _P((struct sbuf *));
void sbdrop _P((struct sbuf *, int));
void sbreserve _P((struct sbuf *, int));
void sbappend _P((struct socket *, struct mbuf *));
void sbappendsb _P((struct sbuf *, struct mbuf *));
void sbcopy _P((struct sbuf *, int, int, char *));
#endif
+2 -2
View File
@@ -12,7 +12,7 @@ struct in_addr special_addr;
/* virtual address alias for host */
struct in_addr alias_addr;
const uint8_t special_ethaddr[6] = {
static const uint8_t special_ethaddr[6] = {
0x52, 0x54, 0x00, 0x12, 0x35, 0x00
};
@@ -130,7 +130,7 @@ static int get_dns_addr(struct in_addr *pdns_addr)
#endif
#ifdef _WIN32
void slirp_cleanup(void)
static void slirp_cleanup(void)
{
WSACleanup();
}
+3 -8
View File
@@ -280,6 +280,9 @@ extern int do_echo;
#define DEFAULT_BAUD 115200
#define SO_OPTIONS DO_KEEPALIVE
#define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)
/* cksum.c */
int cksum(struct mbuf *m, int len);
@@ -290,10 +293,6 @@ void if_output _P((struct socket *, struct mbuf *));
/* ip_input.c */
void ip_init _P((void));
void ip_input _P((struct mbuf *));
struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
void ip_freef _P((struct ipq *));
void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
void ip_deq _P((register struct ipasfrag *));
void ip_slowtimo _P((void));
void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
@@ -301,10 +300,7 @@ void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
int ip_output _P((struct socket *, struct mbuf *));
/* tcp_input.c */
int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
void tcp_input _P((register struct mbuf *, int, struct socket *));
void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
void tcp_xmit_timer _P((register struct tcpcb *, int));
int tcp_mss _P((register struct tcpcb *, u_int));
/* tcp_output.c */
@@ -317,7 +313,6 @@ void tcp_template _P((struct tcpcb *));
void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
struct tcpcb * tcp_newtcpcb _P((struct socket *));
struct tcpcb * tcp_close _P((register struct tcpcb *));
void tcp_drain _P((void));
void tcp_sockclosed _P((struct tcpcb *));
int tcp_fconnect _P((struct socket *));
void tcp_connect _P((struct socket *));
+15 -11
View File
@@ -13,12 +13,16 @@
#include <sys/filio.h>
#endif
void
static void sofcantrcvmore(struct socket *so);
static void sofcantsendmore(struct socket *so);
#if 0
static void
so_init()
{
/* Nothing yet */
}
#endif
struct socket *
solookup(head, laddr, lport, faddr, fport)
@@ -421,7 +425,7 @@ sorecvfrom(so)
int len, n;
if (!(m = m_get())) return;
m->m_data += if_maxlinkhdr;
m->m_data += IF_MAXLINKHDR;
/*
* XXX Shouldn't FIONREAD packets destined for port 53,
@@ -604,12 +608,13 @@ solisten(port, laddr, lport, flags)
return so;
}
#if 0
/*
* Data is available in so_rcv
* Just write() the data to the socket
* XXX not yet...
*/
void
static void
sorwakeup(so)
struct socket *so;
{
@@ -622,12 +627,13 @@ sorwakeup(so)
* We have room for a read() if we want to
* For now, don't read, it'll be done in the main loop
*/
void
static void
sowwakeup(so)
struct socket *so;
{
/* Nothing, yet */
}
#endif
/*
* Various session state calls
@@ -652,9 +658,8 @@ soisfconnected(so)
so->so_state |= SS_ISFCONNECTED; /* Clobber other states */
}
void
sofcantrcvmore(so)
struct socket *so;
static void
sofcantrcvmore(struct socket *so)
{
if ((so->so_state & SS_NOFDREF) == 0) {
shutdown(so->s,0);
@@ -669,9 +674,8 @@ sofcantrcvmore(so)
so->so_state |= SS_FCANTRCVMORE;
}
void
sofcantsendmore(so)
struct socket *so;
static void
sofcantsendmore(struct socket *so)
{
if ((so->so_state & SS_NOFDREF) == 0) {
shutdown(so->s,1); /* send FIN to fhost */
-5
View File
@@ -81,7 +81,6 @@ struct iovec {
};
#endif
void so_init _P((void));
struct socket * solookup _P((struct socket *, struct in_addr, u_int, struct in_addr, u_int));
struct socket * socreate _P((void));
void sofree _P((struct socket *));
@@ -92,12 +91,8 @@ int sowrite _P((struct socket *));
void sorecvfrom _P((struct socket *));
int sosendto _P((struct socket *, struct mbuf *));
struct socket * solisten _P((u_int, u_int32_t, u_int, int));
void sorwakeup _P((struct socket *));
void sowwakeup _P((struct socket *));
void soisfconnecting _P((register struct socket *));
void soisfconnected _P((register struct socket *));
void sofcantrcvmore _P((struct socket *));
void sofcantsendmore _P((struct socket *));
void soisfdisconnected _P((struct socket *));
void sofwdrain _P((struct socket *));
+1 -3
View File
@@ -42,8 +42,6 @@ typedef u_int32_t tcp_seq;
#define PR_SLOWHZ 2 /* 2 slow timeouts per second (approx) */
#define PR_FASTHZ 5 /* 5 fast timeouts per second (not important) */
extern int tcp_rcvspace;
extern int tcp_sndspace;
extern struct socket *tcp_last_so;
#define TCP_SNDSPACE 8192
@@ -172,6 +170,6 @@ struct tcphdr {
extern tcp_seq tcp_iss; /* tcp initial send seq # */
extern char *tcpstates[];
extern const char * const tcpstates[];
#endif

Some files were not shown because too many files have changed in this diff Show More