90
90
if (so->so_m != NULL)
91
91
m_free(pData, so->so_m);
92
92
#ifndef VBOX_WITH_SLIRP_MT
93
if(so->so_next && so->so_prev)
93
if (so->so_next && so->so_prev)
95
95
remque(pData, so); /* crashes if so is not in a queue */
481
484
nn = send(so->s, iov[0].iov_base, iov[0].iov_len, 0);
483
486
/* This should never happen, but people tell me it does *shrug* */
484
if (nn < 0 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
490
|| errno == EWOULDBLOCK))
486
492
SOCKET_UNLOCK(so);
487
493
STAM_PROFILE_STOP(&pData->StatIOwrite, a);
584
591
len = M_FREEROOM(m);
585
592
/* if (so->so_fport != htons(53)) */
587
ioctlsocket(so->s, FIONREAD, &n);
595
static int signaled = 0;
596
rc = ioctlsocket(so->s, FIONREAD, &n);
599
|| errno == EWOULDBLOCK
600
|| errno == EINPROGRESS
601
|| errno == ENOTCONN))
607
if (rc == -1 && signaled == 0)
609
LogRel(("NAT: can't fetch amount of bytes on socket %R[natsock], so message will be truncated.\n", so));
615
if (rc != -1 && n > len)
591
617
n = (m->m_data - m->m_dat) + m->m_len + n + 1;
597
m->m_len = recvfrom(so->s, m->m_data, len, 0,
623
ret = recvfrom(so->s, m->m_data, len, 0,
598
624
(struct sockaddr *)&addr, &addrlen);
599
625
Log2((" did recvfrom %d, errno = %d-%s\n",
600
626
m->m_len, errno, strerror(errno)));
603
630
u_char code = ICMP_UNREACH_PORT;
605
632
if (errno == EHOSTUNREACH)
606
633
code = ICMP_UNREACH_HOST;
607
else if(errno == ENETUNREACH)
634
else if (errno == ENETUNREACH)
608
635
code = ICMP_UNREACH_NET;
610
Log2((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
639
|| errno == EWOULDBLOCK
640
|| errno == EINPROGRESS
641
|| errno == ENOTCONN)
646
Log2((" rx error, tx icmp ICMP_UNREACH:%i\n", code));
611
647
icmp_error(pData, so->so_m, ICMP_UNREACH, code, 0, strerror(errno));
1151
1186
struct sockaddr_in addr;
1152
1187
socklen_t addrlen = sizeof(struct sockaddr_in);
1155
len = recvfrom(so->s, buff, 1500, 0,
1191
static int signalled = 0;
1192
rc = ioctlsocket(so->s, FIONREAD, &len);
1195
|| errno == EWOULDBLOCK
1196
|| errno == EINPROGRESS
1197
|| errno == ENOTCONN))
1201
if (rc == -1 && signalled == 0)
1204
LogRel(("NAT: fetching number of bits has been failed for ICMP socket (%d: %s)\n",
1205
errno, strerror(errno)));
1208
len = (len != 0 && rc != -1 ? len : 1500);
1209
buff = RTMemAlloc(len);
1210
len = recvfrom(so->s, buff, len, 0,
1156
1211
(struct sockaddr *)&addr, &addrlen);
1157
1212
/* XXX Check if reply is "correct"? */
1159
1214
if (len == -1 || len == 0)
1161
u_char code = ICMP_UNREACH_PORT;
1218
&& ( errno == EAGAIN
1219
|| errno == EWOULDBLOCK
1220
|| errno == EINPROGRESS
1221
|| errno == ENOTCONN))
1225
code = ICMP_UNREACH_PORT;
1163
1227
if (errno == EHOSTUNREACH)
1164
1228
code = ICMP_UNREACH_HOST;
1165
else if(errno == ENETUNREACH)
1229
else if (errno == ENETUNREACH)
1166
1230
code = ICMP_UNREACH_NET;
1168
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
1232
LogRel((" udp icmp rx errno = %d-%s\n",
1169
1233
errno, strerror(errno)));
1170
1234
icmp_error(pData, so->so_m, ICMP_UNREACH, code, 0, strerror(errno));
1171
1235
so->so_m = NULL;