Commit 9634d9031c140b24c7ca0d8872632207f6ce7275

Authored by blueswir1
1 parent 31a60e22

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
slirp/bootp.c
... ... @@ -149,7 +149,7 @@ static void bootp_reply(struct bootp_t *bp)
149 149  
150 150 if ((m = m_get()) == NULL)
151 151 return;
152   - m->m_data += if_maxlinkhdr;
  152 + m->m_data += IF_MAXLINKHDR;
153 153 rbp = (struct bootp_t *)m->m_data;
154 154 m->m_data += sizeof(struct udpiphdr);
155 155 memset(rbp, 0, sizeof(struct bootp_t));
... ...
slirp/debug.c
... ... @@ -92,9 +92,9 @@ ttystats(ttyp)
92 92  
93 93 lprint(" \r\n");
94 94  
95   - if (if_comp & IF_COMPRESS)
  95 + if (IF_COMP & IF_COMPRESS)
96 96 strcpy(buff, "on");
97   - else if (if_comp & IF_NOCOMPRESS)
  97 + else if (IF_COMP & IF_NOCOMPRESS)
98 98 strcpy(buff, "off");
99 99 else
100 100 strcpy(buff, "off (for now)");
... ...
slirp/if.c
... ... @@ -7,9 +7,6 @@
7 7  
8 8 #include <slirp.h>
9 9  
10   -int if_mtu, if_mru;
11   -int if_comp;
12   -int if_maxlinkhdr;
13 10 int if_queued = 0; /* Number of packets queued so far */
14 11 int if_thresh = 10; /* Number of packets queued before we start sending
15 12 * (to prevent allocing too many mbufs) */
... ... @@ -41,23 +38,6 @@ ifs_remque(ifm)
41 38 void
42 39 if_init()
43 40 {
44   -#if 0
45   - /*
46   - * Set if_maxlinkhdr to 48 because it's 40 bytes for TCP/IP,
47   - * and 8 bytes for PPP, but need to have it on an 8byte boundary
48   - */
49   -#ifdef USE_PPP
50   - if_maxlinkhdr = 48;
51   -#else
52   - if_maxlinkhdr = 40;
53   -#endif
54   -#else
55   - /* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
56   - if_maxlinkhdr = 2 + 14 + 40;
57   -#endif
58   - if_mtu = 1500;
59   - if_mru = 1500;
60   - if_comp = IF_AUTOCOMP;
61 41 if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq;
62 42 if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq;
63 43 // sl_compress_init(&comp_s);
... ...
slirp/if.h
... ... @@ -13,12 +13,25 @@
13 13 #define IF_AUTOCOMP 0x04 /* Autodetect (default) */
14 14 #define IF_NOCIDCOMP 0x08 /* CID compression */
15 15  
16   -/* Needed for FreeBSD */
17   -#undef if_mtu
18   -extern int if_mtu;
19   -extern int if_mru; /* MTU and MRU */
20   -extern int if_comp; /* Flags for compression */
21   -extern int if_maxlinkhdr;
  16 +#define IF_MTU 1500
  17 +#define IF_MRU 1500
  18 +#define IF_COMP IF_AUTOCOMP /* Flags for compression */
  19 +
  20 +#if 0
  21 +/*
  22 + * Set if_maxlinkhdr to 48 because it's 40 bytes for TCP/IP,
  23 + * and 8 bytes for PPP, but need to have it on an 8byte boundary
  24 + */
  25 +#ifdef USE_PPP
  26 +#define IF_MAXLINKHDR 48
  27 +#else
  28 +#define IF_MAXLINKHDR 40
  29 +#endif
  30 +#else
  31 + /* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
  32 +#define IF_MAXLINKHDR (2 + 14 + 40)
  33 +#endif
  34 +
22 35 extern int if_queued; /* Number of packets queued so far */
23 36 extern int if_thresh; /* Number of packets queued before we start sending
24 37 * (to prevent allocing too many mbufs) */
... ...
slirp/ip.h
... ... @@ -312,6 +312,4 @@ extern struct ipstat ipstat;
312 312 extern struct ipq ipq; /* ip reass. queue */
313 313 extern u_int16_t ip_id; /* ip packet ctr, for ids */
314 314  
315   -extern int ip_defttl; /* default IP ttl */
316   -
317 315 #endif
... ...
slirp/ip_icmp.c
... ... @@ -46,7 +46,7 @@ struct icmpstat icmpstat;
46 46 char icmp_ping_msg[] = "This is a psuedo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
47 47  
48 48 /* list of actions for icmp_error() on RX of an icmp message */
49   -static int icmp_flush[19] = {
  49 +static const int icmp_flush[19] = {
50 50 /* ECHO REPLY (0) */ 0,
51 51 1,
52 52 1,
... ...
slirp/ip_input.c
... ... @@ -45,14 +45,19 @@
45 45 #include <slirp.h>
46 46 #include "ip_icmp.h"
47 47  
48   -int ip_defttl;
49   -
50 48 #ifdef LOG_ENABLED
51 49 struct ipstat ipstat;
52 50 #endif
53 51  
54 52 struct ipq ipq;
55 53  
  54 +static struct ip *ip_reass(register struct ipasfrag *ip,
  55 + register struct ipq *fp);
  56 +static void ip_freef(struct ipq *fp);
  57 +static void ip_enq(register struct ipasfrag *p,
  58 + register struct ipasfrag *prev);
  59 +static void ip_deq(register struct ipasfrag *p);
  60 +
56 61 /*
57 62 * IP initialization: fill in IP protocol switch table.
58 63 * All protocols not implemented in kernel go to raw IP protocol handler.
... ... @@ -64,7 +69,6 @@ ip_init()
64 69 ip_id = tt.tv_sec & 0xffff;
65 70 udp_init();
66 71 tcp_init();
67   - ip_defttl = IPDEFTTL;
68 72 }
69 73  
70 74 /*
... ... @@ -239,10 +243,8 @@ bad:
239 243 * reassembly of this datagram already exists, then it
240 244 * is given as fp; otherwise have to make a chain.
241 245 */
242   -struct ip *
243   -ip_reass(ip, fp)
244   - register struct ipasfrag *ip;
245   - register struct ipq *fp;
  246 +static struct ip *
  247 +ip_reass(register struct ipasfrag *ip, register struct ipq *fp)
246 248 {
247 249 register struct mbuf *m = dtom(ip);
248 250 register struct ipasfrag *q;
... ... @@ -398,9 +400,8 @@ dropfrag:
398 400 * Free a fragment reassembly header and all
399 401 * associated datagrams.
400 402 */
401   -void
402   -ip_freef(fp)
403   - struct ipq *fp;
  403 +static void
  404 +ip_freef(struct ipq *fp)
404 405 {
405 406 register struct ipasfrag *q, *p;
406 407  
... ... @@ -418,9 +419,8 @@ ip_freef(fp)
418 419 * Put an ip fragment on a reassembly chain.
419 420 * Like insque, but pointers in middle of structure.
420 421 */
421   -void
422   -ip_enq(p, prev)
423   - register struct ipasfrag *p, *prev;
  422 +static void
  423 +ip_enq(register struct ipasfrag *p, register struct ipasfrag *prev)
424 424 {
425 425 DEBUG_CALL("ip_enq");
426 426 DEBUG_ARG("prev = %lx", (long)prev);
... ... @@ -433,9 +433,8 @@ ip_enq(p, prev)
433 433 /*
434 434 * To ip_enq as remque is to insque.
435 435 */
436   -void
437   -ip_deq(p)
438   - register struct ipasfrag *p;
  436 +static void
  437 +ip_deq(register struct ipasfrag *p)
439 438 {
440 439 ((struct ipasfrag *)(p->ipf_prev))->ipf_next = p->ipf_next;
441 440 ((struct ipasfrag *)(p->ipf_next))->ipf_prev = p->ipf_prev;
... ...
slirp/ip_output.c
... ... @@ -96,7 +96,7 @@ ip_output(so, m0)
96 96 /*
97 97 * If small enough for interface, can just send directly.
98 98 */
99   - if ((u_int16_t)ip->ip_len <= if_mtu) {
  99 + if ((u_int16_t)ip->ip_len <= IF_MTU) {
100 100 ip->ip_len = htons((u_int16_t)ip->ip_len);
101 101 ip->ip_off = htons((u_int16_t)ip->ip_off);
102 102 ip->ip_sum = 0;
... ... @@ -116,7 +116,7 @@ ip_output(so, m0)
116 116 goto bad;
117 117 }
118 118  
119   - len = (if_mtu - hlen) &~ 7; /* ip databytes per packet */
  119 + len = (IF_MTU - hlen) &~ 7; /* ip databytes per packet */
120 120 if (len < 8) {
121 121 error = -1;
122 122 goto bad;
... ... @@ -140,7 +140,7 @@ ip_output(so, m0)
140 140 STAT(ipstat.ips_odropped++);
141 141 goto sendorfree;
142 142 }
143   - m->m_data += if_maxlinkhdr;
  143 + m->m_data += IF_MAXLINKHDR;
144 144 mhip = mtod(m, struct ip *);
145 145 *mhip = *ip;
146 146  
... ...
slirp/main.h
... ... @@ -42,7 +42,6 @@ extern char *username;
42 42 extern char *socket_path;
43 43 extern int towrite_max;
44 44 extern int ppp_exit;
45   -extern int so_options;
46 45 extern int tcp_keepintvl;
47 46 extern uint8_t client_ethaddr[6];
48 47  
... ...
slirp/mbuf.c
... ... @@ -21,27 +21,20 @@ struct mbuf *mbutl;
21 21 char *mclrefcnt;
22 22 int mbuf_alloced = 0;
23 23 struct mbuf m_freelist, m_usedlist;
24   -int mbuf_thresh = 30;
  24 +#define MBUF_THRESH 30
25 25 int mbuf_max = 0;
26   -int msize;
  26 +
  27 +/*
  28 + * Find a nice value for msize
  29 + * XXX if_maxlinkhdr already in mtu
  30 + */
  31 +#define MSIZE (IF_MTU + IF_MAXLINKHDR + sizeof(struct m_hdr ) + 6)
27 32  
28 33 void
29 34 m_init()
30 35 {
31 36 m_freelist.m_next = m_freelist.m_prev = &m_freelist;
32 37 m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
33   - msize_init();
34   -}
35   -
36   -void
37   -msize_init()
38   -{
39   - /*
40   - * Find a nice value for msize
41   - * XXX if_maxlinkhdr already in mtu
42   - */
43   - msize = (if_mtu>if_mru?if_mtu:if_mru) +
44   - if_maxlinkhdr + sizeof(struct m_hdr ) + 6;
45 38 }
46 39  
47 40 /*
... ... @@ -61,10 +54,10 @@ m_get()
61 54 DEBUG_CALL("m_get");
62 55  
63 56 if (m_freelist.m_next == &m_freelist) {
64   - m = (struct mbuf *)malloc(msize);
  57 + m = (struct mbuf *)malloc(MSIZE);
65 58 if (m == NULL) goto end_error;
66 59 mbuf_alloced++;
67   - if (mbuf_alloced > mbuf_thresh)
  60 + if (mbuf_alloced > MBUF_THRESH)
68 61 flags = M_DOFREE;
69 62 if (mbuf_alloced > mbuf_max)
70 63 mbuf_max = mbuf_alloced;
... ... @@ -78,7 +71,7 @@ m_get()
78 71 m->m_flags = (flags | M_USEDLIST);
79 72  
80 73 /* Initialise it */
81   - m->m_size = msize - sizeof(struct m_hdr);
  74 + m->m_size = MSIZE - sizeof(struct m_hdr);
82 75 m->m_data = m->m_dat;
83 76 m->m_len = 0;
84 77 m->m_nextpkt = 0;
... ...
slirp/mbuf.h
... ... @@ -135,7 +135,6 @@ extern struct mbuf m_freelist, m_usedlist;
135 135 extern int mbuf_max;
136 136  
137 137 void m_init _P((void));
138   -void msize_init _P((void));
139 138 struct mbuf * m_get _P((void));
140 139 void m_free _P((struct mbuf *));
141 140 void m_cat _P((register struct mbuf *, register struct mbuf *));
... ...
slirp/misc.c
... ... @@ -8,8 +8,7 @@
8 8 #define WANT_SYS_IOCTL_H
9 9 #include <slirp.h>
10 10  
11   -u_int curtime, time_fasttimo, last_slowtimo, detach_time;
12   -u_int detach_wait = 600000; /* 10 minutes */
  11 +u_int curtime, time_fasttimo, last_slowtimo;
13 12  
14 13 #if 0
15 14 int x_port = -1;
... ... @@ -214,10 +213,7 @@ strerror(error)
214 213 #ifdef _WIN32
215 214  
216 215 int
217   -fork_exec(so, ex, do_pty)
218   - struct socket *so;
219   - char *ex;
220   - int do_pty;
  216 +fork_exec(struct socket *so, const char *ex, int do_pty)
221 217 {
222 218 /* not implemented */
223 219 return 0;
... ... @@ -225,6 +221,7 @@ fork_exec(so, ex, do_pty)
225 221  
226 222 #else
227 223  
  224 +#ifndef CONFIG_QEMU
228 225 int
229 226 slirp_openpty(amaster, aslave)
230 227 int *amaster, *aslave;
... ... @@ -289,6 +286,7 @@ slirp_openpty(amaster, aslave)
289 286 return (-1);
290 287 #endif
291 288 }
  289 +#endif
292 290  
293 291 /*
294 292 * XXX This is ugly
... ... @@ -302,23 +300,20 @@ slirp_openpty(amaster, aslave)
302 300 * do_ptr = 2 Fork/exec using pty
303 301 */
304 302 int
305   -fork_exec(so, ex, do_pty)
306   - struct socket *so;
307   - char *ex;
308   - int do_pty;
  303 +fork_exec(struct socket *so, const char *ex, int do_pty)
309 304 {
310 305 int s;
311 306 struct sockaddr_in addr;
312 307 int addrlen = sizeof(addr);
313 308 int opt;
314   - int master;
  309 + int master = -1;
315 310 char *argv[256];
316 311 #if 0
317 312 char buff[256];
318 313 #endif
319 314 /* don't want to clobber the original */
320 315 char *bptr;
321   - char *curarg;
  316 + const char *curarg;
322 317 int c, i, ret;
323 318  
324 319 DEBUG_CALL("fork_exec");
... ... @@ -327,10 +322,12 @@ fork_exec(so, ex, do_pty)
327 322 DEBUG_ARG("do_pty = %lx", (long)do_pty);
328 323  
329 324 if (do_pty == 2) {
  325 +#if 0
330 326 if (slirp_openpty(&master, &s) == -1) {
331 327 lprint("Error: openpty failed: %s\n", strerror(errno));
332 328 return 0;
333 329 }
  330 +#endif
334 331 } else {
335 332 addr.sin_family = AF_INET;
336 333 addr.sin_port = 0;
... ... @@ -390,7 +387,7 @@ fork_exec(so, ex, do_pty)
390 387 dup2(s, 0);
391 388 dup2(s, 1);
392 389 dup2(s, 2);
393   - for (s = 3; s <= 255; s++)
  390 + for (s = getdtablesize() - 1; s >= 3; s--)
394 391 close(s);
395 392  
396 393 i = 0;
... ...
slirp/misc.h
... ... @@ -12,12 +12,12 @@ struct ex_list {
12 12 int ex_pty; /* Do we want a pty? */
13 13 int ex_addr; /* The last byte of the address */
14 14 int ex_fport; /* Port to telnet to */
15   - char *ex_exec; /* Command line of what to exec */
  15 + const char *ex_exec; /* Command line of what to exec */
16 16 struct ex_list *ex_next;
17 17 };
18 18  
19 19 extern struct ex_list *exec_list;
20   -extern u_int curtime, time_fasttimo, last_slowtimo, detach_time, detach_wait;
  20 +extern u_int curtime, time_fasttimo, last_slowtimo;
21 21  
22 22 extern int (*lprint_print) _P((void *, const char *, va_list));
23 23 extern char *lprint_ptr, *lprint_ptr2, **lprint_arg;
... ... @@ -74,7 +74,7 @@ inline void slirp_insque _P((void *, void *));
74 74 inline void slirp_remque _P((void *));
75 75 int add_exec _P((struct ex_list **, int, char *, int, int));
76 76 int slirp_openpty _P((int *, int *));
77   -int fork_exec _P((struct socket *, char *, int));
  77 +int fork_exec(struct socket *so, const char *ex, int do_pty);
78 78 void snooze_hup _P((int));
79 79 void snooze _P((void));
80 80 void relay _P((int));
... ...
slirp/sbuf.c
... ... @@ -7,6 +7,8 @@
7 7  
8 8 #include <slirp.h>
9 9  
  10 +static void sbappendsb(struct sbuf *sb, struct mbuf *m);
  11 +
10 12 /* Done as a macro in socket.h */
11 13 /* int
12 14 * sbspace(struct sockbuff *sb)
... ... @@ -133,10 +135,8 @@ sbappend(so, m)
133 135 * Copy the data from m into sb
134 136 * The caller is responsible to make sure there's enough room
135 137 */
136   -void
137   -sbappendsb(sb, m)
138   - struct sbuf *sb;
139   - struct mbuf *m;
  138 +static void
  139 +sbappendsb(struct sbuf *sb, struct mbuf *m)
140 140 {
141 141 int len, n, nn;
142 142  
... ...
slirp/sbuf.h
... ... @@ -25,7 +25,6 @@ void sbfree _P((struct sbuf *));
25 25 void sbdrop _P((struct sbuf *, int));
26 26 void sbreserve _P((struct sbuf *, int));
27 27 void sbappend _P((struct socket *, struct mbuf *));
28   -void sbappendsb _P((struct sbuf *, struct mbuf *));
29 28 void sbcopy _P((struct sbuf *, int, int, char *));
30 29  
31 30 #endif
... ...
slirp/slirp.c
... ... @@ -12,7 +12,7 @@ struct in_addr special_addr;
12 12 /* virtual address alias for host */
13 13 struct in_addr alias_addr;
14 14  
15   -const uint8_t special_ethaddr[6] = {
  15 +static const uint8_t special_ethaddr[6] = {
16 16 0x52, 0x54, 0x00, 0x12, 0x35, 0x00
17 17 };
18 18  
... ... @@ -130,7 +130,7 @@ static int get_dns_addr(struct in_addr *pdns_addr)
130 130 #endif
131 131  
132 132 #ifdef _WIN32
133   -void slirp_cleanup(void)
  133 +static void slirp_cleanup(void)
134 134 {
135 135 WSACleanup();
136 136 }
... ...
slirp/slirp.h
... ... @@ -280,6 +280,9 @@ extern int do_echo;
280 280  
281 281 #define DEFAULT_BAUD 115200
282 282  
  283 +#define SO_OPTIONS DO_KEEPALIVE
  284 +#define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)
  285 +
283 286 /* cksum.c */
284 287 int cksum(struct mbuf *m, int len);
285 288  
... ... @@ -290,10 +293,6 @@ void if_output _P((struct socket *, struct mbuf *));
290 293 /* ip_input.c */
291 294 void ip_init _P((void));
292 295 void ip_input _P((struct mbuf *));
293   -struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
294   -void ip_freef _P((struct ipq *));
295   -void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
296   -void ip_deq _P((register struct ipasfrag *));
297 296 void ip_slowtimo _P((void));
298 297 void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
299 298  
... ... @@ -301,10 +300,7 @@ void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
301 300 int ip_output _P((struct socket *, struct mbuf *));
302 301  
303 302 /* tcp_input.c */
304   -int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
305 303 void tcp_input _P((register struct mbuf *, int, struct socket *));
306   -void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
307   -void tcp_xmit_timer _P((register struct tcpcb *, int));
308 304 int tcp_mss _P((register struct tcpcb *, u_int));
309 305  
310 306 /* tcp_output.c */
... ... @@ -317,7 +313,6 @@ void tcp_template _P((struct tcpcb *));
317 313 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
318 314 struct tcpcb * tcp_newtcpcb _P((struct socket *));
319 315 struct tcpcb * tcp_close _P((register struct tcpcb *));
320   -void tcp_drain _P((void));
321 316 void tcp_sockclosed _P((struct tcpcb *));
322 317 int tcp_fconnect _P((struct socket *));
323 318 void tcp_connect _P((struct socket *));
... ...
slirp/socket.c
... ... @@ -13,12 +13,16 @@
13 13 #include <sys/filio.h>
14 14 #endif
15 15  
16   -void
  16 +static void sofcantrcvmore(struct socket *so);
  17 +static void sofcantsendmore(struct socket *so);
  18 +
  19 +#if 0
  20 +static void
17 21 so_init()
18 22 {
19 23 /* Nothing yet */
20 24 }
21   -
  25 +#endif
22 26  
23 27 struct socket *
24 28 solookup(head, laddr, lport, faddr, fport)
... ... @@ -421,7 +425,7 @@ sorecvfrom(so)
421 425 int len, n;
422 426  
423 427 if (!(m = m_get())) return;
424   - m->m_data += if_maxlinkhdr;
  428 + m->m_data += IF_MAXLINKHDR;
425 429  
426 430 /*
427 431 * XXX Shouldn't FIONREAD packets destined for port 53,
... ... @@ -604,12 +608,13 @@ solisten(port, laddr, lport, flags)
604 608 return so;
605 609 }
606 610  
  611 +#if 0
607 612 /*
608 613 * Data is available in so_rcv
609 614 * Just write() the data to the socket
610 615 * XXX not yet...
611 616 */
612   -void
  617 +static void
613 618 sorwakeup(so)
614 619 struct socket *so;
615 620 {
... ... @@ -622,12 +627,13 @@ sorwakeup(so)
622 627 * We have room for a read() if we want to
623 628 * For now, don't read, it'll be done in the main loop
624 629 */
625   -void
  630 +static void
626 631 sowwakeup(so)
627 632 struct socket *so;
628 633 {
629 634 /* Nothing, yet */
630 635 }
  636 +#endif
631 637  
632 638 /*
633 639 * Various session state calls
... ... @@ -652,9 +658,8 @@ soisfconnected(so)
652 658 so->so_state |= SS_ISFCONNECTED; /* Clobber other states */
653 659 }
654 660  
655   -void
656   -sofcantrcvmore(so)
657   - struct socket *so;
  661 +static void
  662 +sofcantrcvmore(struct socket *so)
658 663 {
659 664 if ((so->so_state & SS_NOFDREF) == 0) {
660 665 shutdown(so->s,0);
... ... @@ -669,9 +674,8 @@ sofcantrcvmore(so)
669 674 so->so_state |= SS_FCANTRCVMORE;
670 675 }
671 676  
672   -void
673   -sofcantsendmore(so)
674   - struct socket *so;
  677 +static void
  678 +sofcantsendmore(struct socket *so)
675 679 {
676 680 if ((so->so_state & SS_NOFDREF) == 0) {
677 681 shutdown(so->s,1); /* send FIN to fhost */
... ...
slirp/socket.h
... ... @@ -81,7 +81,6 @@ struct iovec {
81 81 };
82 82 #endif
83 83  
84   -void so_init _P((void));
85 84 struct socket * solookup _P((struct socket *, struct in_addr, u_int, struct in_addr, u_int));
86 85 struct socket * socreate _P((void));
87 86 void sofree _P((struct socket *));
... ... @@ -92,12 +91,8 @@ int sowrite _P((struct socket *));
92 91 void sorecvfrom _P((struct socket *));
93 92 int sosendto _P((struct socket *, struct mbuf *));
94 93 struct socket * solisten _P((u_int, u_int32_t, u_int, int));
95   -void sorwakeup _P((struct socket *));
96   -void sowwakeup _P((struct socket *));
97 94 void soisfconnecting _P((register struct socket *));
98 95 void soisfconnected _P((register struct socket *));
99   -void sofcantrcvmore _P((struct socket *));
100   -void sofcantsendmore _P((struct socket *));
101 96 void soisfdisconnected _P((struct socket *));
102 97 void sofwdrain _P((struct socket *));
103 98  
... ...
slirp/tcp.h
... ... @@ -42,8 +42,6 @@ typedef u_int32_t tcp_seq;
42 42 #define PR_SLOWHZ 2 /* 2 slow timeouts per second (approx) */
43 43 #define PR_FASTHZ 5 /* 5 fast timeouts per second (not important) */
44 44  
45   -extern int tcp_rcvspace;
46   -extern int tcp_sndspace;
47 45 extern struct socket *tcp_last_so;
48 46  
49 47 #define TCP_SNDSPACE 8192
... ... @@ -172,6 +170,6 @@ struct tcphdr {
172 170  
173 171 extern tcp_seq tcp_iss; /* tcp initial send seq # */
174 172  
175   -extern char *tcpstates[];
  173 +extern const char * const tcpstates[];
176 174  
177 175 #endif
... ...
slirp/tcp_input.c
... ... @@ -47,7 +47,7 @@
47 47  
48 48 struct socket tcb;
49 49  
50   -int tcprexmtthresh = 3;
  50 +#define TCPREXMTTHRESH 3
51 51 struct socket *tcp_last_so = &tcb;
52 52  
53 53 tcp_seq tcp_iss; /* tcp initial send seq # */
... ... @@ -112,12 +112,13 @@ tcp_seq tcp_iss; /* tcp initial send seq # */
112 112 } \
113 113 }
114 114 #endif
  115 +static void tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt,
  116 + struct tcpiphdr *ti);
  117 +static void tcp_xmit_timer(register struct tcpcb *tp, int rtt);
115 118  
116   -int
117   -tcp_reass(tp, ti, m)
118   - register struct tcpcb *tp;
119   - register struct tcpiphdr *ti;
120   - struct mbuf *m;
  119 +static int
  120 +tcp_reass(register struct tcpcb *tp, register struct tcpiphdr *ti,
  121 + struct mbuf *m)
121 122 {
122 123 register struct tcpiphdr *q;
123 124 struct socket *so = tp->t_socket;
... ... @@ -402,8 +403,8 @@ findso:
402 403 goto dropwithreset;
403 404 }
404 405  
405   - sbreserve(&so->so_snd, tcp_sndspace);
406   - sbreserve(&so->so_rcv, tcp_rcvspace);
  406 + sbreserve(&so->so_snd, TCP_SNDSPACE);
  407 + sbreserve(&so->so_rcv, TCP_RCVSPACE);
407 408  
408 409 /* tcp_last_so = so; */ /* XXX ? */
409 410 /* tp = sototcpcb(so); */
... ... @@ -448,10 +449,10 @@ findso:
448 449 * Reset idle time and keep-alive timer.
449 450 */
450 451 tp->t_idle = 0;
451   - if (so_options)
452   - tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
  452 + if (SO_OPTIONS)
  453 + tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL;
453 454 else
454   - tp->t_timer[TCPT_KEEP] = tcp_keepidle;
  455 + tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE;
455 456  
456 457 /*
457 458 * Process options if not in LISTEN state,
... ... @@ -1102,7 +1103,7 @@ trimthenstep6:
1102 1103 if (tp->t_timer[TCPT_REXMT] == 0 ||
1103 1104 ti->ti_ack != tp->snd_una)
1104 1105 tp->t_dupacks = 0;
1105   - else if (++tp->t_dupacks == tcprexmtthresh) {
  1106 + else if (++tp->t_dupacks == TCPREXMTTHRESH) {
1106 1107 tcp_seq onxt = tp->snd_nxt;
1107 1108 u_int win =
1108 1109 min(tp->snd_wnd, tp->snd_cwnd) / 2 /
... ... @@ -1121,7 +1122,7 @@ trimthenstep6:
1121 1122 if (SEQ_GT(onxt, tp->snd_nxt))
1122 1123 tp->snd_nxt = onxt;
1123 1124 goto drop;
1124   - } else if (tp->t_dupacks > tcprexmtthresh) {
  1125 + } else if (tp->t_dupacks > TCPREXMTTHRESH) {
1125 1126 tp->snd_cwnd += tp->t_maxseg;
1126 1127 (void) tcp_output(tp);
1127 1128 goto drop;
... ... @@ -1135,7 +1136,7 @@ trimthenstep6:
1135 1136 * If the congestion window was inflated to account
1136 1137 * for the other side's cached packets, retract it.
1137 1138 */
1138   - if (tp->t_dupacks > tcprexmtthresh &&
  1139 + if (tp->t_dupacks > TCPREXMTTHRESH &&
1139 1140 tp->snd_cwnd > tp->snd_ssthresh)
1140 1141 tp->snd_cwnd = tp->snd_ssthresh;
1141 1142 tp->t_dupacks = 0;
... ... @@ -1227,7 +1228,7 @@ trimthenstep6:
1227 1228 */
1228 1229 if (so->so_state & SS_FCANTRCVMORE) {
1229 1230 soisfdisconnected(so);
1230   - tp->t_timer[TCPT_2MSL] = tcp_maxidle;
  1231 + tp->t_timer[TCPT_2MSL] = TCP_MAXIDLE;
1231 1232 }
1232 1233 tp->t_state = TCPS_FIN_WAIT_2;
1233 1234 }
... ... @@ -1490,12 +1491,8 @@ drop:
1490 1491 /* int *ts_present;
1491 1492 * u_int32_t *ts_val, *ts_ecr;
1492 1493 */
1493   -void
1494   -tcp_dooptions(tp, cp, cnt, ti)
1495   - struct tcpcb *tp;
1496   - u_char *cp;
1497   - int cnt;
1498   - struct tcpiphdr *ti;
  1494 +static void
  1495 +tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
1499 1496 {
1500 1497 u_int16_t mss;
1501 1498 int opt, optlen;
... ... @@ -1605,10 +1602,8 @@ tcp_pulloutofband(so, ti, m)
1605 1602 * and update averages and current timeout.
1606 1603 */
1607 1604  
1608   -void
1609   -tcp_xmit_timer(tp, rtt)
1610   - register struct tcpcb *tp;
1611   - int rtt;
  1605 +static void
  1606 +tcp_xmit_timer(register struct tcpcb *tp, int rtt)
1612 1607 {
1613 1608 register short delta;
1614 1609  
... ... @@ -1707,7 +1702,7 @@ tcp_mss(tp, offer)
1707 1702 DEBUG_ARG("tp = %lx", (long)tp);
1708 1703 DEBUG_ARG("offer = %d", offer);
1709 1704  
1710   - mss = min(if_mtu, if_mru) - sizeof(struct tcpiphdr);
  1705 + mss = min(IF_MTU, IF_MRU) - sizeof(struct tcpiphdr);
1711 1706 if (offer)
1712 1707 mss = min(mss, offer);
1713 1708 mss = max(mss, 32);
... ... @@ -1716,8 +1711,12 @@ tcp_mss(tp, offer)
1716 1711  
1717 1712 tp->snd_cwnd = mss;
1718 1713  
1719   - sbreserve(&so->so_snd, tcp_sndspace+((tcp_sndspace%mss)?(mss-(tcp_sndspace%mss)):0));
1720   - sbreserve(&so->so_rcv, tcp_rcvspace+((tcp_rcvspace%mss)?(mss-(tcp_rcvspace%mss)):0));
  1714 + sbreserve(&so->so_snd, TCP_SNDSPACE + ((TCP_SNDSPACE % mss) ?
  1715 + (mss - (TCP_SNDSPACE % mss)) :
  1716 + 0));
  1717 + sbreserve(&so->so_rcv, TCP_RCVSPACE + ((TCP_RCVSPACE % mss) ?
  1718 + (mss - (TCP_RCVSPACE % mss)) :
  1719 + 0));
1721 1720  
1722 1721 DEBUG_MISC((dfd, " returning mss = %d\n", mss));
1723 1722  
... ...
slirp/tcp_output.c
... ... @@ -48,14 +48,14 @@
48 48 * Since this is only used in "stats socket", we give meaning
49 49 * names instead of the REAL names
50 50 */
51   -char *tcpstates[] = {
  51 +const char * const tcpstates[] = {
52 52 /* "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD", */
53 53 "REDIRECT", "LISTEN", "SYN_SENT", "SYN_RCVD",
54 54 "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING",
55 55 "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT",
56 56 };
57 57  
58   -u_char tcp_outflags[TCP_NSTATES] = {
  58 +static const u_char tcp_outflags[TCP_NSTATES] = {
59 59 TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK,
60 60 TH_ACK, TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK,
61 61 TH_FIN|TH_ACK, TH_ACK, TH_ACK,
... ... @@ -354,7 +354,7 @@ send:
354 354 error = 1;
355 355 goto out;
356 356 }
357   - m->m_data += if_maxlinkhdr;
  357 + m->m_data += IF_MAXLINKHDR;
358 358 m->m_len = hdrlen;
359 359  
360 360 /*
... ... @@ -396,7 +396,7 @@ send:
396 396 error = 1;
397 397 goto out;
398 398 }
399   - m->m_data += if_maxlinkhdr;
  399 + m->m_data += IF_MAXLINKHDR;
400 400 m->m_len = hdrlen;
401 401 }
402 402  
... ... @@ -536,7 +536,7 @@ send:
536 536  
537 537 ((struct ip *)ti)->ip_len = m->m_len;
538 538  
539   - ((struct ip *)ti)->ip_ttl = ip_defttl;
  539 + ((struct ip *)ti)->ip_ttl = IPDEFTTL;
540 540 ((struct ip *)ti)->ip_tos = so->so_iptos;
541 541  
542 542 /* #if BSD >= 43 */
... ...
slirp/tcp_subr.c
... ... @@ -46,11 +46,8 @@
46 46 #include <slirp.h>
47 47  
48 48 /* patchable/settable parameters for tcp */
49   -int tcp_mssdflt = TCP_MSS;
50   -int tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
51   -int tcp_do_rfc1323 = 0; /* Don't do rfc1323 performance enhancements */
52   -int tcp_rcvspace; /* You may want to change this */
53   -int tcp_sndspace; /* Keep small if you have an error prone link */
  49 +/* Don't do rfc1323 performance enhancements */
  50 +#define TCP_DO_RFC1323 0
54 51  
55 52 /*
56 53 * Tcp initialization
... ... @@ -60,14 +57,6 @@ tcp_init()
60 57 {
61 58 tcp_iss = 1; /* wrong */
62 59 tcb.so_next = tcb.so_prev = &tcb;
63   -
64   - /* tcp_rcvspace = our Window we advertise to the remote */
65   - tcp_rcvspace = TCP_RCVSPACE;
66   - tcp_sndspace = TCP_SNDSPACE;
67   -
68   - /* Make sure tcp_sndspace is at least 2*MSS */
69   - if (tcp_sndspace < 2*(min(if_mtu, if_mru) - sizeof(struct tcpiphdr)))
70   - tcp_sndspace = 2*(min(if_mtu, if_mru) - sizeof(struct tcpiphdr));
71 60 }
72 61  
73 62 /*
... ... @@ -145,7 +134,7 @@ tcp_respond(tp, ti, m, ack, seq, flags)
145 134 #else
146 135 tlen = 0;
147 136 #endif
148   - m->m_data += if_maxlinkhdr;
  137 + m->m_data += IF_MAXLINKHDR;
149 138 *mtod(m, struct tcpiphdr *) = *ti;
150 139 ti = mtod(m, struct tcpiphdr *);
151 140 flags = TH_ACK;
... ... @@ -186,7 +175,7 @@ tcp_respond(tp, ti, m, ack, seq, flags)
186 175 if(flags & TH_RST)
187 176 ((struct ip *)ti)->ip_ttl = MAXTTL;
188 177 else
189   - ((struct ip *)ti)->ip_ttl = ip_defttl;
  178 + ((struct ip *)ti)->ip_ttl = IPDEFTTL;
190 179  
191 180 (void) ip_output((struct socket *)0, m);
192 181 }
... ... @@ -208,9 +197,9 @@ tcp_newtcpcb(so)
208 197  
209 198 memset((char *) tp, 0, sizeof(struct tcpcb));
210 199 tp->seg_next = tp->seg_prev = (tcpiphdrp_32)tp;
211   - tp->t_maxseg = tcp_mssdflt;
  200 + tp->t_maxseg = TCP_MSS;
212 201  
213   - tp->t_flags = tcp_do_rfc1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
  202 + tp->t_flags = TCP_DO_RFC1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
214 203 tp->t_socket = so;
215 204  
216 205 /*
... ... @@ -219,7 +208,7 @@ tcp_newtcpcb(so)
219 208 * reasonable initial retransmit time.
220 209 */
221 210 tp->t_srtt = TCPTV_SRTTBASE;
222   - tp->t_rttvar = tcp_rttdflt * PR_SLOWHZ << 2;
  211 + tp->t_rttvar = TCPTV_SRTTDFLT << 2;
223 212 tp->t_rttmin = TCPTV_MIN;
224 213  
225 214 TCPT_RANGESET(tp->t_rxtcur,
... ... @@ -309,6 +298,7 @@ tcp_close(tp)
309 298 return ((struct tcpcb *)0);
310 299 }
311 300  
  301 +#ifdef notdef
312 302 void
313 303 tcp_drain()
314 304 {
... ... @@ -319,9 +309,6 @@ tcp_drain()
319 309 * When a source quench is received, close congestion window
320 310 * to one segment. We will gradually open it again as we proceed.
321 311 */
322   -
323   -#ifdef notdef
324   -
325 312 void
326 313 tcp_quench(i, errno)
327 314  
... ... @@ -556,7 +543,7 @@ tcp_attach(so)
556 543 /*
557 544 * Set the socket's type of service field
558 545 */
559   -struct tos_t tcptos[] = {
  546 +static const struct tos_t tcptos[] = {
560 547 {0, 20, IPTOS_THROUGHPUT, 0}, /* ftp data */
561 548 {21, 21, IPTOS_LOWDELAY, EMU_FTP}, /* ftp control */
562 549 {0, 23, IPTOS_LOWDELAY, 0}, /* telnet */
... ... @@ -572,7 +559,7 @@ struct tos_t tcptos[] = {
572 559 {0, 0, 0, 0}
573 560 };
574 561  
575   -struct emu_t *tcpemu = 0;
  562 +static struct emu_t *tcpemu = 0;
576 563  
577 564 /*
578 565 * Return TOS according to the above table
... ... @@ -665,7 +652,7 @@ tcp_emu(so, m)
665 652 so_rcv->sb_rptr += m->m_len;
666 653 m->m_data[m->m_len] = 0; /* NULL terminate */
667 654 if (strchr(m->m_data, '\r') || strchr(m->m_data, '\n')) {
668   - if (sscanf(so_rcv->sb_data, "%d%*[ ,]%d", &n1, &n2) == 2) {
  655 + if (sscanf(so_rcv->sb_data, "%u%*[ ,]%u", &n1, &n2) == 2) {
669 656 HTONS(n1);
670 657 HTONS(n2);
671 658 /* n2 is the one on our host */
... ... @@ -991,7 +978,7 @@ do_prompt:
991 978 /*
992 979 * Need to emulate the PORT command
993 980 */
994   - x = sscanf(bptr, "ORT %d,%d,%d,%d,%d,%d\r\n%256[^\177]",
  981 + x = sscanf(bptr, "ORT %u,%u,%u,%u,%u,%u\r\n%256[^\177]",
995 982 &n1, &n2, &n3, &n4, &n5, &n6, buff);
996 983 if (x < 6)
997 984 return 1;
... ... @@ -1022,7 +1009,7 @@ do_prompt:
1022 1009 /*
1023 1010 * Need to emulate the PASV response
1024 1011 */
1025   - x = sscanf(bptr, "27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n%256[^\177]",
  1012 + x = sscanf(bptr, "27 Entering Passive Mode (%u,%u,%u,%u,%u,%u)\r\n%256[^\177]",
1026 1013 &n1, &n2, &n3, &n4, &n5, &n6, buff);
1027 1014 if (x < 6)
1028 1015 return 1;
... ...
slirp/tcp_timer.c
... ... @@ -36,17 +36,14 @@
36 36  
37 37 #include <slirp.h>
38 38  
39   -int tcp_keepidle = TCPTV_KEEP_IDLE;
40   -int tcp_keepintvl = TCPTV_KEEPINTVL;
41   -int tcp_maxidle;
42   -int so_options = DO_KEEPALIVE;
43   -
44 39 #ifdef LOG_ENABLED
45 40 struct tcpstat tcpstat; /* tcp statistics */
46 41 #endif
47 42  
48 43 u_int32_t tcp_now; /* for RFC 1323 timestamps */
49 44  
  45 +static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer);
  46 +
50 47 /*
51 48 * Fast timeout routine for processing delayed acks
52 49 */
... ... @@ -84,7 +81,6 @@ tcp_slowtimo()
84 81  
85 82 DEBUG_CALL("tcp_slowtimo");
86 83  
87   - tcp_maxidle = TCPTV_KEEPCNT * tcp_keepintvl;
88 84 /*
89 85 * Search through tcb's and update active timers.
90 86 */
... ... @@ -130,16 +126,14 @@ tcp_canceltimers(tp)
130 126 tp->t_timer[i] = 0;
131 127 }
132 128  
133   -int tcp_backoff[TCP_MAXRXTSHIFT + 1] =
  129 +const int tcp_backoff[TCP_MAXRXTSHIFT + 1] =
134 130 { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
135 131  
136 132 /*
137 133 * TCP timer processing.
138 134 */
139   -struct tcpcb *
140   -tcp_timers(tp, timer)
141   - register struct tcpcb *tp;
142   - int timer;
  135 +static struct tcpcb *
  136 +tcp_timers(register struct tcpcb *tp, int timer)
143 137 {
144 138 register int rexmt;
145 139  
... ... @@ -155,8 +149,8 @@ tcp_timers(tp, timer)
155 149 */
156 150 case TCPT_2MSL:
157 151 if (tp->t_state != TCPS_TIME_WAIT &&
158   - tp->t_idle <= tcp_maxidle)
159   - tp->t_timer[TCPT_2MSL] = tcp_keepintvl;
  152 + tp->t_idle <= TCP_MAXIDLE)
  153 + tp->t_timer[TCPT_2MSL] = TCPTV_KEEPINTVL;
160 154 else
161 155 tp = tcp_close(tp);
162 156 break;
... ... @@ -287,8 +281,8 @@ tcp_timers(tp, timer)
287 281 goto dropit;
288 282  
289 283 /* if (tp->t_socket->so_options & SO_KEEPALIVE && */
290   - if ((so_options) && tp->t_state <= TCPS_CLOSE_WAIT) {
291   - if (tp->t_idle >= tcp_keepidle + tcp_maxidle)
  284 + if ((SO_OPTIONS) && tp->t_state <= TCPS_CLOSE_WAIT) {
  285 + if (tp->t_idle >= TCPTV_KEEP_IDLE + TCP_MAXIDLE)
292 286 goto dropit;
293 287 /*
294 288 * Send a packet designed to force a response
... ... @@ -314,9 +308,9 @@ tcp_timers(tp, timer)
314 308 tcp_respond(tp, &tp->t_template, (struct mbuf *)NULL,
315 309 tp->rcv_nxt, tp->snd_una - 1, 0);
316 310 #endif
317   - tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
  311 + tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL;
318 312 } else
319   - tp->t_timer[TCPT_KEEP] = tcp_keepidle;
  313 + tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE;
320 314 break;
321 315  
322 316 dropit:
... ...
slirp/tcp_timer.h
... ... @@ -126,17 +126,12 @@ char *tcptimers[] =
126 126 (tv) = (tvmax); \
127 127 }
128 128  
129   -extern int tcp_keepidle; /* time before keepalive probes begin */
130   -extern int tcp_keepintvl; /* time between keepalive probes */
131   -extern int tcp_maxidle; /* time to drop after starting probes */
132   -extern int tcp_ttl; /* time to live for TCP segs */
133   -extern int tcp_backoff[];
  129 +extern const int tcp_backoff[];
134 130  
135 131 struct tcpcb;
136 132  
137 133 void tcp_fasttimo _P((void));
138 134 void tcp_slowtimo _P((void));
139 135 void tcp_canceltimers _P((struct tcpcb *));
140   -struct tcpcb * tcp_timers _P((register struct tcpcb *, int));
141 136  
142 137 #endif
... ...
slirp/tftp.c
... ... @@ -34,7 +34,7 @@ struct tftp_session {
34 34 int timestamp;
35 35 };
36 36  
37   -struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
  37 +static struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
38 38  
39 39 const char *tftp_prefix;
40 40  
... ... @@ -143,7 +143,7 @@ static int tftp_send_oack(struct tftp_session *spt,
143 143  
144 144 memset(m->m_data, 0, m->m_size);
145 145  
146   - m->m_data += if_maxlinkhdr;
  146 + m->m_data += IF_MAXLINKHDR;
147 147 tp = (void *)m->m_data;
148 148 m->m_data += sizeof(struct udpiphdr);
149 149  
... ... @@ -183,7 +183,7 @@ static int tftp_send_error(struct tftp_session *spt,
183 183  
184 184 memset(m->m_data, 0, m->m_size);
185 185  
186   - m->m_data += if_maxlinkhdr;
  186 + m->m_data += IF_MAXLINKHDR;
187 187 tp = (void *)m->m_data;
188 188 m->m_data += sizeof(struct udpiphdr);
189 189  
... ... @@ -230,7 +230,7 @@ static int tftp_send_data(struct tftp_session *spt,
230 230  
231 231 memset(m->m_data, 0, m->m_size);
232 232  
233   - m->m_data += if_maxlinkhdr;
  233 + m->m_data += IF_MAXLINKHDR;
234 234 tp = (void *)m->m_data;
235 235 m->m_data += sizeof(struct udpiphdr);
236 236  
... ...
slirp/udp.c
... ... @@ -51,14 +51,17 @@ struct udpstat udpstat;
51 51  
52 52 struct socket udb;
53 53  
  54 +static u_int8_t udp_tos(struct socket *so);
  55 +static void udp_emu(struct socket *so, struct mbuf *m);
  56 +
54 57 /*
55 58 * UDP protocol implementation.
56 59 * Per RFC 768, August, 1980.
57 60 */
58 61 #ifndef COMPAT_42
59   -int udpcksum = 1;
  62 +#define UDPCKSUM 1
60 63 #else
61   -int udpcksum = 0; /* XXX */
  64 +#define UDPCKSUM 0 /* XXX */
62 65 #endif
63 66  
64 67 struct socket *udp_last_so = &udb;
... ... @@ -132,7 +135,7 @@ udp_input(m, iphlen)
132 135 /*
133 136 * Checksum extended UDP header and data.
134 137 */
135   - if (udpcksum && uh->uh_sum) {
  138 + if (UDPCKSUM && uh->uh_sum) {
136 139 ((struct ipovly *)ip)->ih_next = 0;
137 140 ((struct ipovly *)ip)->ih_prev = 0;
138 141 ((struct ipovly *)ip)->ih_x1 = 0;
... ... @@ -292,13 +295,13 @@ int udp_output2(struct socket *so, struct mbuf *m,
292 295 * Stuff checksum and output datagram.
293 296 */
294 297 ui->ui_sum = 0;
295   - if (udpcksum) {
  298 + if (UDPCKSUM) {
296 299 if ((ui->ui_sum = cksum(m, /* sizeof (struct udpiphdr) + */ m->m_len)) == 0)
297 300 ui->ui_sum = 0xffff;
298 301 }
299 302 ((struct ip *)ui)->ip_len = m->m_len;
300 303  
301   - ((struct ip *)ui)->ip_ttl = ip_defttl;
  304 + ((struct ip *)ui)->ip_ttl = IPDEFTTL;
302 305 ((struct ip *)ui)->ip_tos = iptos;
303 306  
304 307 STAT(udpstat.udps_opackets++);
... ... @@ -369,7 +372,7 @@ udp_detach(so)
369 372 sofree(so);
370 373 }
371 374  
372   -struct tos_t udptos[] = {
  375 +static const struct tos_t udptos[] = {
373 376 {0, 53, IPTOS_LOWDELAY, 0}, /* DNS */
374 377 {517, 517, IPTOS_LOWDELAY, EMU_TALK}, /* talk */
375 378 {518, 518, IPTOS_LOWDELAY, EMU_NTALK}, /* ntalk */
... ... @@ -377,9 +380,8 @@ struct tos_t udptos[] = {
377 380 {0, 0, 0, 0}
378 381 };
379 382  
380   -u_int8_t
381   -udp_tos(so)
382   - struct socket *so;
  383 +static u_int8_t
  384 +udp_tos(struct socket *so)
383 385 {
384 386 int i = 0;
385 387  
... ... @@ -402,10 +404,8 @@ udp_tos(so)
402 404 /*
403 405 * Here, talk/ytalk/ntalk requests must be emulated
404 406 */
405   -void
406   -udp_emu(so, m)
407   - struct socket *so;
408   - struct mbuf *m;
  407 +static void
  408 +udp_emu(struct socket *so, struct mbuf *m)
409 409 {
410 410 struct sockaddr_in addr;
411 411 int addrlen = sizeof(addr);
... ...
slirp/udp.h
... ... @@ -106,8 +106,6 @@ void udp_input _P((register struct mbuf *, int));
106 106 int udp_output _P((struct socket *, struct mbuf *, struct sockaddr_in *));
107 107 int udp_attach _P((struct socket *));
108 108 void udp_detach _P((struct socket *));
109   -u_int8_t udp_tos _P((struct socket *));
110   -void udp_emu _P((struct socket *, struct mbuf *));
111 109 struct socket * udp_listen _P((u_int, u_int32_t, u_int, int));
112 110 int udp_output2(struct socket *so, struct mbuf *m,
113 111 struct sockaddr_in *saddr, struct sockaddr_in *daddr,
... ...