Changeset 25747 in vbox
- Timestamp:
- Jan 12, 2010 10:26:46 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/slirp.c
r25402 r25747 18 18 #include <alias.h> 19 19 20 #if !defined(RT_OS_WINDOWS) 21 22 # define DO_ENGAGE_EVENT1(so, fdset, label) \ 23 do { \ 24 if ( so->so_poll_index != -1 \ 25 && so->s == polls[so->so_poll_index].fd) { \ 26 polls[so->so_poll_index].events |= N_(fdset ## _poll); \ 27 break; /* out of this loop */ \ 28 } \ 29 AssertRelease(poll_index < (nfds)); \ 30 AssertRelease(poll_index >= 0 && poll_index < (nfds)); \ 31 polls[poll_index].fd = (so)->s; \ 32 (so)->so_poll_index = poll_index; \ 33 polls[poll_index].events = N_(fdset ## _poll); \ 34 polls[poll_index].revents = 0; \ 35 poll_index++; \ 36 } while (0) 37 38 39 # define DO_ENGAGE_EVENT2(so, fdset1, fdset2, label) \ 40 do { \ 41 if ( so->so_poll_index != -1 \ 42 && so->s == polls[so->so_poll_index].fd) { \ 43 polls[so->so_poll_index].events |= \ 44 N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \ 45 break; /* out of this loop */ \ 46 } \ 47 AssertRelease(poll_index < (nfds)); \ 48 polls[poll_index].fd = (so)->s; \ 49 (so)->so_poll_index = poll_index; \ 50 polls[poll_index].events = \ 51 N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \ 52 poll_index++; \ 53 } while (0) 54 55 # define DO_POLL_EVENTS(rc, error, so, events, label) do {} while (0) 56 57 # define DO_CHECK_FD_SET(so, events, fdset) \ 58 ( ((so)->so_poll_index != -1) \ 59 && ((so)->so_poll_index <= ndfs) \ 60 && ((so)->s == polls[so->so_poll_index].fd) \ 61 && (polls[(so)->so_poll_index].revents & N_(fdset ## _poll))) 62 63 /* specific for Unix API */ 64 # define DO_UNIX_CHECK_FD_SET(so, events, fdset ) DO_CHECK_FD_SET((so), (events), fdset) 65 /* specific for Windows Winsock API */ 66 # define DO_WIN_CHECK_FD_SET(so, events, fdset ) 0 67 68 # ifndef RT_OS_WINDOWS 69 70 # ifndef RT_OS_LINUX 71 # define readfds_poll (POLLRDNORM) 72 # define writefds_poll (POLLWRNORM) 73 # define xfds_poll (POLLRDBAND|POLLWRBAND|POLLPRI) 74 # else 75 # define readfds_poll (POLLIN) 76 # define writefds_poll (POLLOUT) 77 # define xfds_poll (POLLPRI) 78 # endif 79 # define rderr_poll (POLLERR) 80 # define rdhup_poll (POLLHUP) 81 # define nval_poll (POLLNVAL) 82 83 # define ICMP_ENGAGE_EVENT(so, fdset) \ 84 do { \ 85 if (pData->icmp_socket.s != -1) \ 86 DO_ENGAGE_EVENT1((so), fdset, ICMP); \ 87 } while (0) 88 # else /* !RT_OS_WINDOWS */ 89 # define DO_WIN_CHECK_FD_SET(so, events, fdset ) DO_CHECK_FD_SET((so), (events), fdset) 90 # define ICMP_ENGAGE_EVENT(so, fdset) do {} while (0) 91 #endif /* RT_OS_WINDOWS */ 92 93 #else /* defined(RT_OS_WINDOWS) */ 20 #ifndef RT_OS_WINDOWS 21 22 # define DO_ENGAGE_EVENT1(so, fdset, label) \ 23 do { \ 24 if ( so->so_poll_index != -1 \ 25 && so->s == polls[so->so_poll_index].fd) \ 26 { \ 27 polls[so->so_poll_index].events |= N_(fdset ## _poll); \ 28 break; \ 29 } \ 30 AssertRelease(poll_index < (nfds)); \ 31 AssertRelease(poll_index >= 0 && poll_index < (nfds)); \ 32 polls[poll_index].fd = (so)->s; \ 33 (so)->so_poll_index = poll_index; \ 34 polls[poll_index].events = N_(fdset ## _poll); \ 35 polls[poll_index].revents = 0; \ 36 poll_index++; \ 37 } while (0) 38 39 # define DO_ENGAGE_EVENT2(so, fdset1, fdset2, label) \ 40 do { \ 41 if ( so->so_poll_index != -1 \ 42 && so->s == polls[so->so_poll_index].fd) \ 43 { \ 44 polls[so->so_poll_index].events |= \ 45 N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \ 46 break; \ 47 } \ 48 AssertRelease(poll_index < (nfds)); \ 49 polls[poll_index].fd = (so)->s; \ 50 (so)->so_poll_index = poll_index; \ 51 polls[poll_index].events = \ 52 N_(fdset1 ## _poll) | N_(fdset1 ## _poll); \ 53 poll_index++; \ 54 } while (0) 55 56 # define DO_POLL_EVENTS(rc, error, so, events, label) do {} while (0) 57 58 # define DO_CHECK_FD_SET(so, events, fdset) \ 59 ( ((so)->so_poll_index != -1) \ 60 && ((so)->so_poll_index <= ndfs) \ 61 && ((so)->s == polls[so->so_poll_index].fd) \ 62 && (polls[(so)->so_poll_index].revents & N_(fdset ## _poll))) 63 64 /* specific for Unix API */ 65 # define DO_UNIX_CHECK_FD_SET(so, events, fdset ) DO_CHECK_FD_SET((so), (events), fdset) 66 /* specific for Windows Winsock API */ 67 # define DO_WIN_CHECK_FD_SET(so, events, fdset ) 0 68 69 # ifndef RT_OS_LINUX 70 # define readfds_poll (POLLRDNORM) 71 # define writefds_poll (POLLWRNORM) 72 # define xfds_poll (POLLRDBAND|POLLWRBAND|POLLPRI) 73 # else 74 # define readfds_poll (POLLIN) 75 # define writefds_poll (POLLOUT) 76 # define xfds_poll (POLLPRI) 77 # endif 78 # define rderr_poll (POLLERR) 79 # define rdhup_poll (POLLHUP) 80 # define nval_poll (POLLNVAL) 81 82 # define ICMP_ENGAGE_EVENT(so, fdset) \ 83 do { \ 84 if (pData->icmp_socket.s != -1) \ 85 DO_ENGAGE_EVENT1((so), fdset, ICMP); \ 86 } while (0) 87 88 #else /* RT_OS_WINDOWS */ 94 89 95 90 /* … … 109 104 error, (so), (so)->s, VBOX_SOCKET_EVENT)); \ 110 105 } \ 111 } while (0); 106 } while (0); \ 112 107 CONTINUE(label) 113 108 … … 124 119 } 125 120 126 # define acceptds_win FD_ACCEPT 127 # define acceptds_win_bit FD_ACCEPT_BIT 128 129 # define readfds_win FD_READ 130 # define readfds_win_bit FD_READ_BIT 131 132 # define writefds_win FD_WRITE 133 # define writefds_win_bit FD_WRITE_BIT 134 135 # define xfds_win FD_OOB 136 # define xfds_win_bit FD_OOB_BIT 121 # define acceptds_win FD_ACCEPT 122 # define readfds_win FD_READ 123 # define writefds_win FD_WRITE 124 # define xfds_win FD_OOB 137 125 138 126 # define DO_CHECK_FD_SET(so, events, fdset) \ 139 (((events).lNetworkEvents & fdset ## _win) && ((events).iErrorCode[fdset ## _win _bit] == 0))127 (((events).lNetworkEvents & fdset ## _win) && ((events).iErrorCode[fdset ## _win ## _BIT] == 0)) 140 128 141 129 # define DO_WIN_CHECK_FD_SET(so, events, fdset ) DO_CHECK_FD_SET((so), (events), fdset) 142 130 # define DO_UNIX_CHECK_FD_SET(so, events, fdset ) 1 /*specific for Unix API */ 143 131 144 #endif /* defined(RT_OS_WINDOWS)*/132 #endif /* RT_OS_WINDOWS */ 145 133 146 134 #define TCP_ENGAGE_EVENT1(so, fdset) \ … … 159 147 DO_POLL_EVENTS((rc), (error), (so), (events), udp) 160 148 161 #define CHECK_FD_SET(so, events, set) 149 #define CHECK_FD_SET(so, events, set) \ 162 150 (DO_CHECK_FD_SET((so), (events), set)) 163 151 164 #define WIN_CHECK_FD_SET(so, events, set) 152 #define WIN_CHECK_FD_SET(so, events, set) \ 165 153 (DO_WIN_CHECK_FD_SET((so), (events), set)) 154 166 155 #define UNIX_CHECK_FD_SET(so, events, set) \ 167 156 (DO_UNIX_CHECK_FD_SET(so, events, set)) … … 176 165 LogRel((" " #proto " %R[natsock] %R[natwinnetevents]\n", (so), (winevent))); \ 177 166 } while (0) 178 # else /* RT_OS_WINDOWS */167 # else /* !RT_OS_WINDOWS */ 179 168 # define DO_LOG_NAT_SOCK(so, proto, winevent, r_fdset, w_fdset, x_fdset) \ 180 169 do { \ … … 188 177 } while (0) 189 178 # endif /* !RT_OS_WINDOWS */ 190 #else /* VBOX_WITH_DEBUG_NAT_SOCKETS */179 #else /* !VBOX_WITH_DEBUG_NAT_SOCKETS */ 191 180 # define DO_LOG_NAT_SOCK(so, proto, winevent, r_fdset, w_fdset, x_fdset) do {} while (0) 192 181 #endif /* !VBOX_WITH_DEBUG_NAT_SOCKETS */ 193 182 194 #define LOG_NAT_SOCK(so, proto, winevent, r_fdset, w_fdset, x_fdset) DO_LOG_NAT_SOCK((so), proto, (winevent), r_fdset, w_fdset, x_fdset) 183 #define LOG_NAT_SOCK(so, proto, winevent, r_fdset, w_fdset, x_fdset) \ 184 DO_LOG_NAT_SOCK((so), proto, (winevent), r_fdset, w_fdset, x_fdset) 195 185 196 186 static void activate_port_forwarding(PNATState, const uint8_t *pEther); … … 372 362 size_t bytes; 373 363 374 # ifdef RT_OS_OS2364 # ifdef RT_OS_OS2 375 365 /* Try various locations. */ 376 366 char *etc = getenv("ETC"); … … 390 380 rc = RTFileOpen(&f, buff, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 391 381 } 392 # else393 # ifndef DEBUG_vvl382 # else /* !RT_OS_OS2 */ 383 # ifndef DEBUG_vvl 394 384 rc = RTFileOpen(&f, "/etc/resolv.conf", RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 395 # else385 # else 396 386 char *home = getenv("HOME"); 397 387 RTStrPrintf(buff, sizeof(buff), "%s/resolv.conf", home); … … 406 396 Log(("NAT: DNS we're using %s\n", buff)); 407 397 } 408 # endif409 # endif398 # endif 399 # endif /* !RT_OS_OS2 */ 410 400 if (RT_FAILURE(rc)) 411 401 return -1; … … 477 467 } 478 468 479 #endif 469 #endif /* !RT_OS_WINDOWS */ 480 470 481 471 static int slirp_init_dns_list(PNATState pData) -
trunk/src/VBox/Devices/Network/slirp/udp.c
r25265 r25747 529 529 SOCKET_LOCK_CREATE(so); 530 530 QSOCKET_LOCK(udb); 531 insque(pData, so, &udb);531 insque(pData, so, &udb); 532 532 NSOCK_INC(); 533 533 QSOCKET_UNLOCK(udb);
Note:
See TracChangeset
for help on using the changeset viewer.