Changeset 14951 in vbox
- Timestamp:
- Dec 3, 2008 3:27:57 PM (16 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/if.c
r14470 r14951 28 28 if_init(PNATState pData) 29 29 { 30 #if 031 /*32 * Set if_maxlinkhdr to 48 because it's 40 bytes for TCP/IP,33 * and 8 bytes for PPP, but need to have it on an 8byte boundary34 */35 #ifdef USE_PPP36 if_maxlinkhdr = 48;37 #else38 if_maxlinkhdr = 40;39 #endif40 #else41 30 /* 2 for alignment, 14 for ethernet, 40 for TCP/IP */ 42 31 if_maxlinkhdr = 2 + 14 + 40; 43 #endif44 32 if_queued = 0; 45 33 if_thresh = 10; -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r14882 r14951 15 15 }; 16 16 17 #ifdef _WIN3217 #ifdef RT_OS_WINDOWS 18 18 19 19 static int get_dns_addr_domain(PNATState pData, bool fVerbose, … … 230 230 pData->netmask = u32Netmask; 231 231 232 #ifdef _WIN32232 #ifdef RT_OS_WINDOWS 233 233 { 234 234 WSADATA Data; 235 235 WSAStartup(MAKEWORD(2,0), &Data); 236 236 } 237 # if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)237 # if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) 238 238 pData->phEvents[VBOX_SOCKET_EVENT_INDEX] = CreateEvent(NULL, FALSE, FALSE, NULL); 239 # endif239 # endif 240 240 #endif 241 241 … … 331 331 332 332 slirp_link_down(pData); 333 #ifdef WIN32333 #ifdef RT_OS_WINDOWS 334 334 WSACleanup(); 335 335 #endif … … 360 360 * curtime kept to an accuracy of 1ms 361 361 */ 362 #ifdef _WIN32362 #ifdef RT_OS_WINDOWS 363 363 static void updtime(PNATState pData) 364 364 { … … 416 416 * triggering of fragment expiration should be the same but use new macroses 417 417 */ 418 for (i = 0; i < IPREASS_NHASH; i++) 419 { 420 if (!TAILQ_EMPTY(&ipq[i])) 421 { 422 do_slowtimo = 1; 423 break; 424 } 425 } 426 do_slowtimo |= (tcb.so_next != &tcb); 418 do_slowtimo = (tcb.so_next != &tcb); 419 if (!do_slowtimo) 420 { 421 for (i = 0; i < IPREASS_NHASH; i++) 422 { 423 if (!TAILQ_EMPTY(&ipq[i])) 424 { 425 do_slowtimo = 1; 426 break; 427 } 428 } 429 } 427 430 #endif /* VBOX_WITH_BSD_REASS */ 428 431 … … 459 462 UPD_NFDS(so->s); 460 463 #else 461 rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB); 464 engage_event: 465 rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_ALL_EVENTS); 462 466 if (rc == SOCKET_ERROR) 463 467 { 464 socket_error: 468 /* This should not happen */ 465 469 error = WSAGetLastError(); 466 LogRel(("WSAEventSelector error %d (so=%x, socket=%s, event=%x)\n", error, so, so->s, VBOX_SOCKET_EVENT)); 470 LogRel(("WSAEventSelector (TCP) error %d (so=%x, socket=%s, event=%x)\n", 471 error, so, so->s, VBOX_SOCKET_EVENT)); 467 472 } 468 473 #endif … … 479 484 FD_SET(so->s, writefds); 480 485 UPD_NFDS(so->s); 481 #else482 rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB);483 if (rc == SOCKET_ERROR)484 goto socket_error;485 #endif486 486 continue; 487 #else 488 goto engage_event; 489 #endif 487 490 } 488 491 … … 498 501 UPD_NFDS(so->s); 499 502 #else 500 rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_OOB); 501 if (rc == SOCKET_ERROR) 502 goto socket_error; 503 continue; /* we're using the widest mask for event */ 503 goto engage_event; 504 504 #endif 505 505 } … … 517 517 UPD_NFDS(so->s); 518 518 #else 519 rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_OOB|FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT); 520 if (rc == SOCKET_ERROR) 521 goto socket_error; 522 continue; /* we're using the widest mask for event */ 523 #endif 524 } 525 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 526 rc = WSAEventSelect(so->s, NULL, 0); 527 if (rc == SOCKET_ERROR) 528 goto socket_error; 529 #endif 519 goto engage_event; 520 #endif 521 } 530 522 } 531 523 … … 573 565 UPD_NFDS(so->s); 574 566 #else 575 rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_ READ|FD_WRITE|FD_OOB|FD_ACCEPT);567 rc = WSAEventSelect(so->s, VBOX_SOCKET_EVENT, FD_ALL_EVENTS); 576 568 if (rc == SOCKET_ERROR) 577 goto socket_error; 578 continue; 579 #endif 580 } 581 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 582 else 583 { 584 rc = WSAEventSelect(so->s, NULL, 0); 585 if (rc != SOCKET_ERROR) 586 goto socket_error; 587 } 588 #endif 569 { 570 /* This should not happen */ 571 error = WSAGetLastError(); 572 LogRel(("WSAEventSelector (UDP) error %d (so=%x, socket=%s, event=%x)\n", 573 error, so, so->s, VBOX_SOCKET_EVENT)); 574 } 575 #endif 576 } 589 577 } 590 578 } … … 608 596 int error; 609 597 #endif 598 610 599 STAM_REL_PROFILE_START(&pData->StatPoll, a); 611 600 … … 698 687 { 699 688 tcp_connect(pData, so); 700 continue; 689 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 690 if (!NetworkEvents.lNetworkEvents & FD_CLOSE) 691 #endif 692 continue; 701 693 } 702 694 … … 706 698 tcp_output(pData, sototcpcb(so)); 707 699 } 700 701 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 702 /* 703 * Check for FD_CLOSE events. 704 */ 705 if (NetworkEvents.lNetworkEvents & FD_CLOSE) 706 { 707 /* 708 * drain the socket 709 */ 710 for (;;) 711 { 712 ret = soread(pData, so); 713 if (ret > 0) 714 tcp_output(pData, sototcpcb(so)); 715 else 716 break; 717 } 718 } 719 #endif 708 720 709 721 /* … … 752 764 tcp_input(pData, (struct mbuf *)NULL, sizeof(struct ip), so); 753 765 /* continue; */ 754 } else 766 } 767 else 755 768 ret = sowrite(pData, so); 756 769 /* 757 * XXXXX If we wrote something (a lot), there 758 * could be a need for a window update. 759 * In the worst case, the remote will send 760 * a window probe to get things going again 770 * XXX If we wrote something (a lot), there could be the need 771 * for a window update. In the worst case, the remote will send 772 * a window probe to get things going again. 761 773 */ 762 774 } … … 850 862 } 851 863 852 #define ETH_ALEN 6853 #define ETH_HLEN 14864 #define ETH_ALEN 6 865 #define ETH_HLEN 14 854 866 855 867 #define ETH_P_IP 0x0800 /* Internet Protocol packet */ … … 861 873 struct ethhdr 862 874 { 863 unsigned char h_dest[ETH_ALEN];/* destination eth addr */864 unsigned char h_source[ETH_ALEN];/* source ether addr */865 unsigned short h_proto;/* packet type ID field */875 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 876 unsigned char h_source[ETH_ALEN]; /* source ether addr */ 877 unsigned short h_proto; /* packet type ID field */ 866 878 }; 867 879 868 880 struct arphdr 869 881 { 870 unsigned short ar_hrd;/* format of hardware address */871 unsigned short ar_pro;/* format of protocol address */872 unsigned char ar_hln;/* length of hardware address */873 unsigned char ar_pln;/* length of protocol address */874 unsigned short ar_op;/* ARP opcode (command) */875 876 877 878 879 unsigned char ar_sha[ETH_ALEN];/* sender hardware address */880 unsigned char ar_sip[4];/* sender IP address */881 unsigned char ar_tha[ETH_ALEN];/* target hardware address */882 unsigned char ar_tip[4];/* target IP address */882 unsigned short ar_hrd; /* format of hardware address */ 883 unsigned short ar_pro; /* format of protocol address */ 884 unsigned char ar_hln; /* length of hardware address */ 885 unsigned char ar_pln; /* length of protocol address */ 886 unsigned short ar_op; /* ARP opcode (command) */ 887 888 /* 889 * Ethernet looks like this : This bit is variable sized however... 890 */ 891 unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ 892 unsigned char ar_sip[4]; /* sender IP address */ 893 unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ 894 unsigned char ar_tip[4]; /* target IP address */ 883 895 }; 884 896 -
trunk/src/VBox/Devices/Network/slirp/slirp.h
r14638 r14951 23 23 24 24 #ifndef CONFIG_QEMU 25 # include "version.h"25 # include "version.h" 26 26 #endif 27 27 #define LOG_GROUP LOG_GROUP_DRV_NAT 28 28 #include <VBox/log.h> 29 29 #ifdef VBOX_WITH_SLIRP_MEMORY_CHECK 30 # define RTMEM_WRAP_TO_EF_APIS30 # define RTMEM_WRAP_TO_EF_APIS 31 31 #endif /* VBOX_WITH_SLIRP_MEMORY_CHECK */ 32 32 #include <iprt/mem.h> … … 40 40 #include <VBox/types.h> 41 41 42 # 43 # 44 # 42 #define malloc(a) RTMemAlloc(a) 43 #define free(a) RTMemFree(a) 44 #define realloc(a,b) RTMemRealloc(a, b) 45 45 46 46 #include "slirp_config.h" 47 47 48 #ifdef _WIN3249 50 # ifndef _MSC_VER51 # include <inttypes.h>52 # endif48 #ifdef RT_OS_WINDOWS 49 50 # ifndef _MSC_VER 51 # include <inttypes.h> 52 # endif 53 53 54 54 typedef uint8_t u_int8_t; … … 67 67 # define ENETUNREACH WSAENETUNREACH 68 68 # define ECONNREFUSED WSAECONNREFUSED 69 #else 69 70 #else /* !RT_OS_WINDOWS */ 71 70 72 # define ioctlsocket ioctl 71 73 # define closesocket(s) close(s) 72 74 # define O_BINARY 0 73 #endif 75 76 #endif /* !RT_OS_WINDOWS */ 74 77 75 78 #include <sys/types.h> … … 79 82 80 83 #ifdef _MSC_VER 81 # include <time.h>84 # include <time.h> 82 85 #else /* !_MSC_VER */ 83 # include <sys/time.h>86 # include <sys/time.h> 84 87 #endif /* !_MSC_VER */ 85 88 … … 125 128 126 129 #ifndef HAVE_MEMMOVE 127 # define memmove(x, y, z) bcopy(y, x, z)130 # define memmove(x, y, z) bcopy(y, x, z) 128 131 #endif 129 132 … … 145 148 #endif 146 149 147 #ifndef _WIN32148 # include <sys/uio.h>150 #ifndef RT_OS_WINDOWS 151 # include <sys/uio.h> 149 152 #endif 150 153 … … 157 160 #endif 158 161 159 #ifndef _WIN32160 # include <netinet/in.h>161 # include <arpa/inet.h>162 #ifndef RT_OS_WINDOWS 163 # include <netinet/in.h> 164 # include <arpa/inet.h> 162 165 #endif 163 166 164 167 #ifdef GETTIMEOFDAY_ONE_ARG 165 # define gettimeofday(x, y) gettimeofday(x)168 # define gettimeofday(x, y) gettimeofday(x) 166 169 #endif 167 170 … … 183 186 #include <fcntl.h> 184 187 #ifndef NO_UNIX_SOCKETS 185 # include <sys/un.h>188 # include <sys/un.h> 186 189 #endif 187 190 #include <signal.h> … … 189 192 # include <sys/signal.h> 190 193 #endif 191 #ifndef _WIN32192 # include <sys/socket.h>194 #ifndef RT_OS_WINDOWS 195 # include <sys/socket.h> 193 196 #endif 194 197 … … 209 212 #endif 210 213 211 #ifdef USE_PPP212 #include <ppp/slirppp.h>213 #endif214 215 214 #if defined(__STDC__) || defined(_MSC_VER) 216 # include <stdarg.h>217 #else 218 # include <varargs.h>215 # include <stdarg.h> 216 #else 217 # include <varargs.h> 219 218 #endif 220 219 221 220 #include <sys/stat.h> 222 221 223 #if 1 /* ndef _MSC_VER */224 222 /* Avoid conflicting with the libc insque() and remque(), which 225 223 * have different prototypes. */ 226 224 #define insque slirp_insque 227 225 #define remque slirp_remque 228 #endif /* !_MSC_VER */229 226 230 227 #ifdef HAVE_SYS_STROPTS_H 231 # include <sys/stropts.h>228 # include <sys/stropts.h> 232 229 #endif 233 230 … … 250 247 #include "misc.h" 251 248 #include "ctl.h" 252 #ifdef USE_PPP253 #include "ppp/pppd.h"254 #include "ppp/ppp.h"255 #endif256 257 249 #include "bootp.h" 258 250 #include "tftp.h" … … 260 252 #include "slirp_state.h" 261 253 262 #undef PVM /* XXX Mac hack */254 #undef PVM /* XXX Mac OS X hack */ 263 255 264 256 #ifndef NULL 265 # define NULL (void *)0257 # define NULL (void *)0 266 258 #endif 267 259 … … 318 310 #endif 319 311 320 #ifndef _WIN32312 #ifndef RT_OS_WINDOWS 321 313 #include <netdb.h> 322 314 #endif … … 382 374 struct tcpcb *tcp_drop(PNATState, struct tcpcb *tp, int err); 383 375 384 #ifdef USE_PPP385 #define MIN_MRU MINMRU386 #define MAX_MRU MAXMRU387 #else388 376 #define MIN_MRU 128 389 377 #define MAX_MRU 16384 390 #endif 391 392 #ifndef _WIN32 393 #define min(x,y) ((x) < (y) ? (x) : (y)) 394 #define max(x,y) ((x) > (y) ? (x) : (y)) 395 #endif 396 397 #ifdef _WIN32 398 #undef errno 399 #define errno (WSAGetLastError()) 400 #endif 401 402 #endif 378 379 #ifndef RT_OS_WINDOWS 380 # define min(x,y) ((x) < (y) ? (x) : (y)) 381 # define max(x,y) ((x) > (y) ? (x) : (y)) 382 #endif 383 384 #ifdef RT_OS_WINDOWS 385 # undef errno 386 # define errno (WSAGetLastError()) 387 #endif 388 389 #endif -
trunk/src/VBox/Devices/Network/slirp/slirp_config.h
r3693 r14951 67 67 /* Define if you have sys/ioctl.h */ 68 68 #undef HAVE_SYS_IOCTL_H 69 #ifndef _WIN3270 # define HAVE_SYS_IOCTL_H69 #ifndef RT_OS_WINDOWS 70 # define HAVE_SYS_IOCTL_H 71 71 #endif 72 72 … … 101 101 /* Define if iovec needs to be declared */ 102 102 #undef DECLARE_IOVEC 103 #ifdef _WIN32104 # define DECLARE_IOVEC103 #ifdef RT_OS_WINDOWS 104 # define DECLARE_IOVEC 105 105 #endif 106 106 … … 113 113 /* Define if you have sys/select.h */ 114 114 #undef HAVE_SYS_SELECT_H 115 #ifndef _WIN32116 # define HAVE_SYS_SELECT_H115 #ifndef RT_OS_WINDOWS 116 # define HAVE_SYS_SELECT_H 117 117 #endif 118 118 … … 122 122 /* Define if you have arpa/inet.h */ 123 123 #undef HAVE_ARPA_INET_H 124 #ifndef _WIN32125 # define HAVE_ARPA_INET_H124 #ifndef RT_OS_WINDOWS 125 # define HAVE_ARPA_INET_H 126 126 #endif 127 127 … … 172 172 /* Define if you have inet_aton */ 173 173 #undef HAVE_INET_ATON 174 #ifndef _WIN32175 # define HAVE_INET_ATON174 #ifndef RT_OS_WINDOWS 175 # define HAVE_INET_ATON 176 176 #endif 177 177 … … 199 199 /* Define if you DON'T have unix-domain sockets */ 200 200 #undef NO_UNIX_SOCKETS 201 #ifdef _WIN32202 # define NO_UNIX_SOCKETS201 #ifdef RT_OS_WINDOWS 202 # define NO_UNIX_SOCKETS 203 203 #endif 204 204 -
trunk/src/VBox/Devices/Network/slirp/socket.c
r14925 r14951 160 160 #endif 161 161 if (nn <= 0) { 162 #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) 163 /* 164 * Special case for WSAEnumNetworkEvents: If we receive 0 bytes that 165 * _could_ mean that the connection is closed. But we will receive an 166 * FD_CLOSE event later if the connection was _really_ closed. With 167 * www.youtube.com I see this very often. Closing the socket too early 168 * would be dangerous. 169 */ 170 if (nn == 0) 171 return 0; 172 #endif 162 173 if (nn < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) 163 174 return 0; -
trunk/src/VBox/Devices/Network/slirp/udp.c
r14616 r14951 345 345 closesocket(so->s); 346 346 so->s=-1; 347 #ifdef _WIN32347 #ifdef RT_OS_WINDOWS 348 348 WSASetLastError(lasterrno); 349 349 #else
Note:
See TracChangeset
for help on using the changeset viewer.