Revision 9634d903 slirp/udp.c
b/slirp/udp.c | ||
---|---|---|
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 | 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 | 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 | 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 | 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 | 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); |
Also available in: Unified diff