Revision 3b46e624 slirp/socket.c
b/slirp/socket.c | ||
---|---|---|
251 | 251 |
/* We can send it directly */ |
252 | 252 |
n = send(so->s, sb->sb_rptr, so->so_urgc, (MSG_OOB)); /* |MSG_DONTWAIT)); */ |
253 | 253 |
so->so_urgc -= n; |
254 |
|
|
254 |
|
|
255 | 255 |
DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc)); |
256 | 256 |
} else { |
257 | 257 |
/* |
... | ... | |
274 | 274 |
#ifdef DEBUG |
275 | 275 |
if (n != len) |
276 | 276 |
DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n")); |
277 |
#endif
|
|
277 |
#endif |
|
278 | 278 |
DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc)); |
279 | 279 |
} |
280 | 280 |
|
... | ... | |
396 | 396 |
if (so->so_type == IPPROTO_ICMP) { /* This is a "ping" reply */ |
397 | 397 |
char buff[256]; |
398 | 398 |
int len; |
399 |
|
|
399 |
|
|
400 | 400 |
len = recvfrom(so->s, buff, 256, 0, |
401 | 401 |
(struct sockaddr *)&addr, &addrlen); |
402 | 402 |
/* XXX Check if reply is "correct"? */ |
403 |
|
|
403 |
|
|
404 | 404 |
if(len == -1 || len == 0) { |
405 | 405 |
u_char code=ICMP_UNREACH_PORT; |
406 | 406 |
|
407 | 407 |
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST; |
408 | 408 |
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET; |
409 |
|
|
409 |
|
|
410 | 410 |
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n", |
411 | 411 |
errno,strerror(errno))); |
412 | 412 |
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno)); |
... | ... | |
422 | 422 |
|
423 | 423 |
if (!(m = m_get())) return; |
424 | 424 |
m->m_data += if_maxlinkhdr; |
425 |
|
|
425 |
|
|
426 | 426 |
/* |
427 | 427 |
* XXX Shouldn't FIONREAD packets destined for port 53, |
428 | 428 |
* but I don't know the max packet size for DNS lookups |
... | ... | |
430 | 430 |
len = M_FREEROOM(m); |
431 | 431 |
/* if (so->so_fport != htons(53)) { */ |
432 | 432 |
ioctlsocket(so->s, FIONREAD, &n); |
433 |
|
|
433 |
|
|
434 | 434 |
if (n > len) { |
435 | 435 |
n = (m->m_data - m->m_dat) + m->m_len + n + 1; |
436 | 436 |
m_inc(m, n); |
437 | 437 |
len = M_FREEROOM(m); |
438 | 438 |
} |
439 | 439 |
/* } */ |
440 |
|
|
440 |
|
|
441 | 441 |
m->m_len = recvfrom(so->s, m->m_data, len, 0, |
442 | 442 |
(struct sockaddr *)&addr, &addrlen); |
443 | 443 |
DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n", |
... | ... | |
447 | 447 |
|
448 | 448 |
if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST; |
449 | 449 |
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET; |
450 |
|
|
450 |
|
|
451 | 451 |
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code)); |
452 | 452 |
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno)); |
453 | 453 |
m_free(m); |
... | ... | |
470 | 470 |
* m->m_len = 0; |
471 | 471 |
* } |
472 | 472 |
*/ |
473 |
|
|
473 |
|
|
474 | 474 |
/* |
475 | 475 |
* If this packet was destined for CTL_ADDR, |
476 | 476 |
* make it look like that's where it came from, done by udp_output |
... | ... | |
580 | 580 |
(bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) || |
581 | 581 |
(listen(s,1) < 0)) { |
582 | 582 |
int tmperrno = errno; /* Don't clobber the real reason we failed */ |
583 |
|
|
583 |
|
|
584 | 584 |
close(s); |
585 | 585 |
sofree(so); |
586 | 586 |
/* Restore the real errno */ |
Also available in: Unified diff