Changeset 26495 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Feb 14, 2010 7:59:48 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r26423 r26495 407 407 408 408 /* @todo: Here we should get mbuf instead temporal buffer */ 409 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 409 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 410 410 void *pvmBuf = slirp_ext_m_get(pThis->pNATState); 411 411 Assert(pvmBuf); -
trunk/src/VBox/Devices/Network/slirp/bootp.c
r26037 r26495 664 664 665 665 case DHCPRELEASE: 666 rc = dhcp_decode_release(pData, bp, buf, size); 666 rc = dhcp_decode_release(pData, bp, buf, size); 667 667 /* no reply required */ 668 668 break; -
trunk/src/VBox/Devices/Network/slirp/dnsproxy/dnsproxy.c
r26404 r26495 102 102 #else /* VBOX */ 103 103 static void 104 timeout(PNATState pData, struct socket *so, void *arg) 104 timeout(PNATState pData, struct socket *so, void *arg) 105 105 { 106 106 struct request *req = (struct request *)arg; … … 119 119 struct udphdr *udp; 120 120 int iphlen; 121 struct socket *so1 = socreate(); 121 struct socket *so1 = socreate(); 122 122 struct mbuf *m = NULL; 123 123 char *data; … … 146 146 /* mbuf initialization */ 147 147 m->m_data += if_maxlinkhdr; 148 ip = mtod(m, struct ip *); 148 ip = mtod(m, struct ip *); 149 149 udp = (struct udphdr *)&ip[1]; /* ip attributes */ 150 150 data = (char *)&udp[1]; … … 175 175 * queue and send it to the correct server. 176 176 * 177 * Slirp: this routine should be called from udp_input 177 * Slirp: this routine should be called from udp_input 178 178 * socket is Slirp's construction (here we should set expiration time for socket) 179 179 * mbuf points on ip header to easy fetch information about source and destination. … … 268 268 269 269 /* fill the request structure */ 270 if (so->so_timeout_arg == NULL) 270 if (so->so_timeout_arg == NULL) 271 271 { 272 272 req->id = QUERYID; … … 280 280 if (fail_counter == 0) 281 281 LogRel(("NAT/dnsproxy: Empty DNS entry (suppressed 100 times)\n")); 282 else 282 else 283 283 fail_counter = (fail_counter == 100 ? 0 : fail_counter + 1); 284 284 return; 285 285 286 286 } 287 287 retransmit = 0; … … 290 290 req->nbyte = byte; 291 291 memcpy(req->byte, buf, byte); /* copying original request */ 292 } 293 else 292 } 293 else 294 294 { 295 295 retransmit = 1; … … 383 383 * server. Find the corresponding query and send answer back to querying 384 384 * host. 385 * 385 * 386 386 * Slirp: we call this from the routine from socrecvfrom routine handling UDP responses. 387 387 * So at the moment of call response already has been readed and packed into the mbuf … … 430 430 if ((query = hash_find_request(pData, *((unsigned short *)buf))) == NULL) { 431 431 ++late_answers; 432 /* Probably, this request wasn't serviced by 432 /* Probably, this request wasn't serviced by 433 433 * dnsproxy so we won't care about it here*/ 434 434 so->so_expire = curtime + SO_EXPIREFAST; … … 632 632 } 633 633 #else 634 int 634 int 635 635 dnsproxy_init(PNATState pData) 636 636 { -
trunk/src/VBox/Devices/Network/slirp/dnsproxy/dnsproxy.h
r18815 r26495 78 78 struct request *next; 79 79 #ifdef VBOX 80 /* this field used for saving last attempt 81 * to connect server, timeout function should change 80 /* this field used for saving last attempt 81 * to connect server, timeout function should change 82 82 * it's value on next server. And dnsproxy_query should 83 83 * initializate with first server in the list 84 84 */ 85 struct dns_entry *dns_server; 85 struct dns_entry *dns_server; 86 86 int nbyte; /* length of dns request */ 87 87 char byte[1]; /* copy of original request */ -
trunk/src/VBox/Devices/Network/slirp/libalias/alias.c
r23154 r26495 759 759 ad.dport = &ud->uh_dport; 760 760 ad.maxpktsize = 0; 761 761 762 762 763 763 alias_address = GetAliasAddress(lnk); … … 766 766 ud->uh_dport = GetOriginalPort(lnk); 767 767 768 /* Walk out chain. */ 768 /* Walk out chain. */ 769 769 error = find_handler(IN, UDP, la, pip, &ad); 770 770 … … 815 815 struct in_addr alias_address; 816 816 struct alias_data ad; 817 ad.lnk = lnk; 817 ad.lnk = lnk; 818 818 ad.oaddr = NULL; 819 819 ad.aaddr = &alias_address; … … 826 826 alias_port = GetAliasPort(lnk); 827 827 828 /* Walk out chain. */ 828 /* Walk out chain. */ 829 829 error = find_handler(OUT, UDP, la, pip, &ad); 830 830 … … 876 876 int accumulate, error; 877 877 878 /* 879 * The init of MANY vars is a bit below, but aliashandlepptpin 878 /* 879 * The init of MANY vars is a bit below, but aliashandlepptpin 880 880 * seems to need the destination port that came within the 881 881 * packet and not the original one looks below [*]. … … 883 883 884 884 struct alias_data ad; 885 ad.lnk = lnk; 885 ad.lnk = lnk; 886 886 ad.oaddr = NULL; 887 887 ad.aaddr = NULL; … … 891 891 ad.maxpktsize = 0; 892 892 893 /* Walk out chain. */ 893 /* Walk out chain. */ 894 894 error = find_handler(IN, TCP, la, pip, &ad); 895 895 … … 901 901 proxy_port = GetProxyPort(lnk); 902 902 903 /* 904 * Look above, if anyone is going to add find_handler AFTER 903 /* 904 * Look above, if anyone is going to add find_handler AFTER 905 905 * this aliashandlepptpin/point, please redo alias_data too. 906 906 * Uncommenting the piece here below should be enough. … … 916 916 .maxpktsize = 0 917 917 }; 918 918 919 919 /* Walk out chain. */ 920 920 error = find_handler(la, pip, &ad); … … 1026 1026 int accumulate; 1027 1027 struct alias_data ad; 1028 ad.lnk = lnk; 1028 ad.lnk = lnk; 1029 1029 ad.oaddr = NULL; 1030 1030 ad.aaddr = &alias_address; … … 1049 1049 /* Monitor TCP connection state */ 1050 1050 TcpMonitorOut(pip, lnk); 1051 1052 /* Walk out chain. */ 1051 1052 /* Walk out chain. */ 1053 1053 error = find_handler(OUT, TCP, la, pip, &ad); 1054 1054 … … 1193 1193 SetFragmentPtr(lnk, NULL); 1194 1194 SetExpire(lnk, 0); /* Deletes link */ 1195 } else 1195 } else 1196 1196 fptr = NULL; 1197 1197 … … 1263 1263 if (ntohs(pip->ip_len) > maxpacketsize 1264 1264 || (pip->ip_hl << 2) > maxpacketsize) { 1265 iresult = PKT_ALIAS_IGNORED; 1265 iresult = PKT_ALIAS_IGNORED; 1266 1266 goto getout; 1267 1267 } … … 1283 1283 int error; 1284 1284 struct alias_data ad; 1285 ad.lnk = NULL, 1286 ad.oaddr = NULL, 1285 ad.lnk = NULL, 1286 ad.oaddr = NULL, 1287 1287 ad.aaddr = NULL, 1288 1288 ad.aport = NULL, 1289 1289 ad.sport = NULL, 1290 1290 ad.dport = NULL, 1291 ad.maxpktsize = 0 1292 1293 /* Walk out chain. */ 1291 ad.maxpktsize = 0 1292 1293 /* Walk out chain. */ 1294 1294 error = find_handler(IN, IP, la, pip, &ad); 1295 1295 if (error == 0) … … 1298 1298 iresult = ProtoAliasIn(la, pip); 1299 1299 } 1300 break; 1300 break; 1301 1301 #endif 1302 1302 default: … … 1426 1426 int error; 1427 1427 struct alias_data ad = { 1428 .lnk = NULL, 1429 .oaddr = NULL, 1428 .lnk = NULL, 1429 .oaddr = NULL, 1430 1430 .aaddr = NULL, 1431 1431 .aport = NULL, 1432 1432 .sport = NULL, 1433 1433 .dport = NULL, 1434 .maxpktsize = 0 1434 .maxpktsize = 0 1435 1435 }; 1436 /* Walk out chain. */ 1436 /* Walk out chain. */ 1437 1437 error = find_handler(OUT, IP, la, pip, &ad); 1438 1438 if (error == 0) … … 1583 1583 for (;;) { 1584 1584 fgets(buf, 256, fd); 1585 if feof(fd) 1585 if feof(fd) 1586 1586 break; 1587 1587 len = strlen(buf); … … 1653 1653 1654 1654 /* Unload all modules then reload everything. */ 1655 while ((p = first_handler()) != NULL) { 1655 while ((p = first_handler()) != NULL) { 1656 1656 detach_handler(p); 1657 1657 } 1658 while ((t = walk_dll_chain()) != NULL) { 1658 while ((t = walk_dll_chain()) != NULL) { 1659 1659 dlclose(t->handle); 1660 1660 free(t); … … 1681 1681 struct mbuf * 1682 1682 #ifndef VBOX 1683 m_megapullup(struct mbuf *m, int len) 1683 m_megapullup(struct mbuf *m, int len) 1684 1684 #else 1685 1685 m_megapullup(PNATState pData, struct mbuf *m, int len) … … 1687 1687 { 1688 1688 struct mbuf *mcl; 1689 1689 1690 1690 if (len > m->m_pkthdr.len) 1691 1691 goto bad; 1692 1692 1693 1693 /* Do not reallocate packet if it is sequentional, 1694 1694 * writable and has some extra space for expansion. … … 1723 1723 if (mcl == NULL) 1724 1724 goto bad; 1725 1725 1726 1726 m_move_pkthdr(mcl, m); 1727 1727 m_copydata(m, 0, len, mtod(mcl, caddr_t)); … … 1732 1732 m_freem(pData, m); 1733 1733 #endif 1734 1734 1735 1735 return (mcl); 1736 1736 bad: -
trunk/src/VBox/Devices/Network/slirp/libalias/alias.h
r23154 r26495 77 77 */ 78 78 struct libalias; 79 #if defined(VBOX) && !defined(VBOX_SLIRP_ALIAS) 79 #if defined(VBOX) && !defined(VBOX_SLIRP_ALIAS) 80 80 /* XXX: used only for browsing */ 81 81 struct libalias { -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_cuseeme.c
r20958 r26495 57 57 58 58 static void 59 AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, 59 AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, 60 60 struct alias_link *lnk); 61 61 62 62 static void 63 AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, 63 AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, 64 64 struct in_addr original_addr); 65 65 66 static int 66 static int 67 67 fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah) 68 68 { … … 75 75 } 76 76 77 static int 77 static int 78 78 protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah) 79 79 { 80 80 81 81 AliasHandleCUSeeMeIn(la, pip, *ah->oaddr); 82 82 return (0); 83 83 } 84 84 85 static int 85 static int 86 86 protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah) 87 87 { 88 88 89 89 AliasHandleCUSeeMeOut(la, pip, ah->lnk); 90 90 return (0); … … 93 93 /* Kernel module definition. */ 94 94 struct proto_handler handlers[] = { 95 { 96 .pri = 120, 97 .dir = OUT, 98 .proto = UDP, 99 .fingerprint = &fingerprint, 95 { 96 .pri = 120, 97 .dir = OUT, 98 .proto = UDP, 99 .fingerprint = &fingerprint, 100 100 .protohandler = &protohandlerout 101 }, 101 }, 102 102 { 103 .pri = 120, 104 .dir = IN, 105 .proto = UDP, 106 .fingerprint = &fingerprint, 103 .pri = 120, 104 .dir = IN, 105 .proto = UDP, 106 .fingerprint = &fingerprint, 107 107 .protohandler = &protohandlerin 108 }, 108 }, 109 109 { EOH } 110 110 }; … … 131 131 132 132 #ifdef _KERNEL 133 static 134 #endif 135 moduledata_t 133 static 134 #endif 135 moduledata_t 136 136 alias_mod = { 137 137 "alias_cuseeme", mod_handler, NULL -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_db.c
r25364 r26495 157 157 #include <sys/errno.h> 158 158 #include <sys/time.h> 159 #include <unistd.h> 159 #include <unistd.h> 160 160 #endif 161 161 … … 163 163 #include <netinet/tcp.h> 164 164 165 #ifdef _KERNEL 165 #ifdef _KERNEL 166 166 #include <netinet/libalias/alias.h> 167 167 #include <netinet/libalias/alias_local.h> … … 338 338 339 339 #ifndef NO_USE_SOCKETS 340 # ifndef VBOX 341 /* 342 * in VBox we do not use host's sockets here, which are managed 340 # ifndef VBOX 341 /* 342 * in VBox we do not use host's sockets here, which are managed 343 343 * inside slirp. yes we have to create new sockets here but latter 344 * managment and deletion are in repsponsible of Slirp. 344 * managment and deletion are in repsponsible of Slirp. 345 345 */ 346 346 int sockfd; /* socket descriptor */ … … 486 486 static void 487 487 AliasLog(char *str, const char *format, ...) 488 { 488 { 489 489 va_list ap; 490 490 491 491 va_start(ap, format); 492 492 vsnprintf(str, LIBALIAS_BUF_SIZE, format, ap); … … 499 499 # ifndef VBOX 500 500 va_list ap; 501 501 502 502 va_start(ap, format); 503 503 vfprintf(stream, format, ap); … … 525 525 /* Used for debugging */ 526 526 if (la->logDesc) { 527 int tot = la->icmpLinkCount + la->udpLinkCount + 527 int tot = la->icmpLinkCount + la->udpLinkCount + 528 528 la->tcpLinkCount + la->pptpLinkCount + 529 529 la->protoLinkCount + la->fragmentIdLinkCount + 530 530 la->fragmentPtrLinkCount; 531 531 532 532 AliasLog(la->logDesc, 533 533 "icmp=%u, udp=%u, tcp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", … … 540 540 la->fragmentPtrLinkCount, tot); 541 541 #ifndef _KERNEL 542 AliasLog(la->logDesc, " (sock=%u)\n", la->sockCount); 542 AliasLog(la->logDesc, " (sock=%u)\n", la->sockCount); 543 543 #endif 544 544 } … … 781 781 #ifdef VBOX 782 782 so->so_expire = la->curtime + SO_EXPIRE; 783 setsockopt(so->s, SOL_SOCKET, SO_BROADCAST, 783 setsockopt(so->s, SOL_SOCKET, SO_BROADCAST, 784 784 (const char *)&opt, sizeof(opt)); 785 785 status = getsockname(so->s, &sa_addr, &socklen); … … 791 791 } 792 792 so->so_hlport = ((struct sockaddr_in *)&sa_addr)->sin_port; 793 so->so_hladdr.s_addr = 793 so->so_hladdr.s_addr = 794 794 ((struct sockaddr_in *)&sa_addr)->sin_addr.s_addr; 795 795 NSOCK_INC_EX(la); 796 if (link_type == LINK_TCP) 796 if (link_type == LINK_TCP) 797 797 { 798 798 insque(la->pData, so, &la->tcb); 799 799 } 800 else if (link_type == LINK_UDP) 800 else if (link_type == LINK_UDP) 801 801 { 802 802 insque(la->pData, so, &la->udb); 803 803 } 804 else { 804 else { 805 805 Assert(!"Shouldn't be here"); 806 806 } 807 807 808 808 #else 809 809 *sockfd = sock; … … 812 812 } else { 813 813 #ifdef VBOX 814 if (sock >= 0) 814 if (sock >= 0) 815 815 closesocket(sock); 816 816 /* socket wasn't enqueued so we shouldn't use sofree */ … … 1528 1528 u_short ip_id) 1529 1529 { 1530 1530 1531 1531 LIBALIAS_LOCK_ASSERT(la); 1532 1532 return FindLinkIn(la, dst_addr, alias_addr, … … 2015 2015 GetDefaultAliasAddress(struct libalias *la) 2016 2016 { 2017 2017 2018 2018 LIBALIAS_LOCK_ASSERT(la); 2019 2019 return (la->aliasAddress); … … 2240 2240 ClearCheckNewLink(struct libalias *la) 2241 2241 { 2242 2242 2243 2243 LIBALIAS_LOCK_ASSERT(la); 2244 2244 la->newDefaultLink = 0; … … 2350 2350 if ((la->logDesc = malloc(LIBALIAS_BUF_SIZE))) 2351 2351 ; 2352 #else 2352 #else 2353 2353 if ((la->logDesc = fopen("/var/log/alias.log", "w"))) 2354 fprintf(la->logDesc, "PacketAlias/InitPacketAliasLog: Packet alias logging enabled.\n"); 2355 #endif 2356 else 2354 fprintf(la->logDesc, "PacketAlias/InitPacketAliasLog: Packet alias logging enabled.\n"); 2355 #endif 2356 else 2357 2357 return (ENOMEM); /* log initialization failed */ 2358 2358 #else 2359 Log2(("NAT: PacketAlias/InitPacketAliasLog: Packet alias logging enabled.\n")); 2359 Log2(("NAT: PacketAlias/InitPacketAliasLog: Packet alias logging enabled.\n")); 2360 2360 la->logDesc = (void *)1; /* XXX: in vbox we don't use this param */ 2361 2361 #endif -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_dns.c
r25353 r26495 71 71 static void QStr2CStr(const char *pcszQStr, char *pszStr, size_t cStr); 72 72 73 static int 73 static int 74 74 fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah) 75 75 { … … 78 78 return -1; 79 79 80 fprintf(stderr, "NAT:%s: ah(dport: %hd, sport: %hd) oaddr:%R[IP4] aaddr:%R[IP4]\n", 80 fprintf(stderr, "NAT:%s: ah(dport: %hd, sport: %hd) oaddr:%R[IP4] aaddr:%R[IP4]\n", 81 81 __FUNCTION__, ntohs(*ah->dport), ntohs(*ah->sport), 82 82 &ah->oaddr, &ah->aaddr); … … 100 100 hdr->X.rd = 1; 101 101 hdr->X.rcode = 3; 102 } 102 } 103 103 else 104 104 { … … 110 110 uint16_t packet_len = 0; 111 111 uint16_t addr_off = (uint16_t)~0; 112 112 113 113 #if 0 114 114 /* here is no compressed names+answers + new query */ … … 117 117 packet_len = (pip->ip_hl << 2) 118 118 + sizeof(struct udphdr) 119 + sizeof(union dnsmsg_header) 119 + sizeof(union dnsmsg_header) 120 120 + strlen(qname) 121 121 + 2 * sizeof(uint16_t); /* ip + udp + header + query */ … … 159 159 { 160 160 struct dnsmsg_answer *ans = (struct dnsmsg_answer *)answers; 161 161 162 162 ans->name = htons(off); 163 163 ans->type = htons(1); … … 180 180 } 181 181 } 182 static int 182 static int 183 183 protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 184 184 { … … 206 206 qw_qtype = (uint16_t *)(qw_qname + strlen(qw_qname) + 1); 207 207 qw_qclass = &qw_qtype[1]; 208 fprintf(stderr, "qname:%s qtype:%hd qclass:%hd\n", 208 fprintf(stderr, "qname:%s qtype:%hd qclass:%hd\n", 209 209 qw_qname, ntohs(*qw_qtype), ntohs(*qw_qclass)); 210 210 } … … 215 215 doanswer(la, hdr, qw_qname, pip, h); 216 216 217 /* 217 /* 218 218 * We have changed the size and the content of udp, to avoid double csum calculation 219 219 * will assign to zero … … 245 245 || *q == '_') 246 246 { 247 *c = *q; 247 *c = *q; 248 248 c++; 249 249 } … … 271 271 { 272 272 /* at the begining or at -dot- position */ 273 if (*c == '.' || (c == pcszStr && q == pszQStr)) 273 if (*c == '.' || (c == pcszStr && q == pszQStr)) 274 274 { 275 275 if (c != pcszStr) -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_dummy.c
r20958 r26495 28 28 __FBSDID("$FreeBSD: src/sys/netinet/libalias/alias_dummy.c,v 1.1.8.1 2009/04/15 03:14:26 kensmith Exp $"); 29 29 30 /* 30 /* 31 31 * Alias_dummy is just an empty skeleton used to demostrate how to write 32 32 * a module for libalias, that will run unalterated in userland or in … … 60 60 AliasHandleDummy(struct libalias *la, struct ip *ip, struct alias_data *ah); 61 61 62 static int 62 static int 63 63 fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah) 64 64 { 65 65 66 /* 67 * Check here all the data that will be used later, if any field 66 /* 67 * Check here all the data that will be used later, if any field 68 68 * is empy/NULL, return a -1 value. 69 69 */ 70 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || 70 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || 71 71 ah->maxpktsize == 0) 72 72 return (-1); 73 /* 74 * Fingerprint the incoming packet, if it matches any conditions 73 /* 74 * Fingerprint the incoming packet, if it matches any conditions 75 75 * return an OK value. 76 76 */ … … 81 81 } 82 82 83 /* 84 * Wrap in this general purpose function, the real function used to alias the 83 /* 84 * Wrap in this general purpose function, the real function used to alias the 85 85 * packets. 86 86 */ 87 87 88 static int 88 static int 89 89 protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 90 90 { 91 91 92 92 AliasHandleDummy(la, pip, ah); 93 93 return (0); 94 94 } 95 95 96 /* 97 * NOTA BENE: the next variable MUST NOT be renamed in any case if you want 98 * your module to work in userland, cause it's used to find and use all 96 /* 97 * NOTA BENE: the next variable MUST NOT be renamed in any case if you want 98 * your module to work in userland, cause it's used to find and use all 99 99 * the protocol handlers present in every module. 100 * So WATCH OUT, your module needs this variables and it needs it with 100 * So WATCH OUT, your module needs this variables and it needs it with 101 101 * ITS EXACT NAME: handlers. 102 102 */ 103 103 104 104 struct proto_handler handlers [] = { 105 { 106 .pri = 666, 107 .dir = IN|OUT, 108 .proto = UDP|TCP, 109 .fingerprint = &fingerprint, 105 { 106 .pri = 666, 107 .dir = IN|OUT, 108 .proto = UDP|TCP, 109 .fingerprint = &fingerprint, 110 110 .protohandler = &protohandler 111 }, 111 }, 112 112 { EOH } 113 113 }; … … 118 118 int error; 119 119 120 switch (type) { 120 switch (type) { 121 121 case MOD_LOAD: 122 122 error = 0; -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_ftp.c
r24233 r26495 109 109 110 110 static void 111 AliasHandleFtpOut(struct libalias *, struct ip *, struct alias_link *, 111 AliasHandleFtpOut(struct libalias *, struct ip *, struct alias_link *, 112 112 int maxpacketsize); 113 113 114 static int 114 static int 115 115 fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah) 116 116 { 117 117 118 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || 118 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || 119 119 ah->maxpktsize == 0) 120 120 return (-1); … … 125 125 } 126 126 127 static int 127 static int 128 128 protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 129 129 { 130 130 131 131 AliasHandleFtpOut(la, pip, ah->lnk, ah->maxpktsize); 132 132 return (0); … … 135 135 #ifndef VBOX 136 136 struct proto_handler handlers[] = { 137 { 138 .pri = 80, 139 .dir = OUT, 140 .proto = TCP, 141 .fingerprint = &fingerprint, 137 { 138 .pri = 80, 139 .dir = OUT, 140 .proto = TCP, 141 .fingerprint = &fingerprint, 142 142 .protohandler = &protohandler 143 }, 143 }, 144 144 { EOH } 145 145 }; … … 181 181 #endif /* VBOX */ 182 182 183 switch (type) { 183 switch (type) { 184 184 case MOD_LOAD: 185 185 error = 0; -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_irc.c
r20958 r26495 89 89 90 90 static void 91 AliasHandleIrcOut(struct libalias *, struct ip *, struct alias_link *, 91 AliasHandleIrcOut(struct libalias *, struct ip *, struct alias_link *, 92 92 int maxpacketsize); 93 93 94 static int 94 static int 95 95 fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah) 96 96 { 97 97 98 if (ah->dport == NULL || ah->dport == NULL || ah->lnk == NULL || 98 if (ah->dport == NULL || ah->dport == NULL || ah->lnk == NULL || 99 99 ah->maxpktsize == 0) 100 100 return (-1); … … 105 105 } 106 106 107 static int 107 static int 108 108 protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 109 109 { … … 118 118 119 119 struct proto_handler handlers[] = { 120 { 121 .pri = 90, 122 .dir = OUT, 123 .proto = TCP, 124 .fingerprint = &fingerprint, 120 { 121 .pri = 90, 122 .dir = OUT, 123 .proto = TCP, 124 .fingerprint = &fingerprint, 125 125 .protohandler = &protohandler 126 }, 126 }, 127 127 { EOH } 128 128 }; … … 149 149 150 150 #ifdef _KERNEL 151 static 151 static 152 152 #endif 153 153 moduledata_t alias_mod = { -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_local.h
r21671 r26495 121 121 int deleteAllLinks; /* If equal to zero, DeleteLink() */ 122 122 /* will not remove permanent links */ 123 124 /* log descriptor */ 123 124 /* log descriptor */ 125 125 #ifdef _KERNEL 126 char *logDesc; 127 #else 128 FILE *logDesc; 126 char *logDesc; 127 #else 128 FILE *logDesc; 129 129 #endif 130 130 /* statistics monitoring */ … … 157 157 u_short true_port; /* in host byte order. */ 158 158 #if defined(_KERNEL) && !defined(VBOX) 159 /* 159 /* 160 160 * avoid races in libalias: every public function has to use it. 161 161 */ … … 178 178 #else 179 179 #define LIBALIAS_LOCK_INIT(l) 180 #define LIBALIAS_LOCK_ASSERT(l) 180 #define LIBALIAS_LOCK_ASSERT(l) 181 181 #define LIBALIAS_LOCK(l) 182 182 #define LIBALIAS_UNLOCK(l) -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_mod.c
r21864 r26495 63 63 struct rwlock handler_rw; 64 64 #endif 65 SLIST_HEAD(dll_chain, dll) dll_chain = SLIST_HEAD_INITIALIZER(foo); 65 SLIST_HEAD(dll_chain, dll) dll_chain = SLIST_HEAD_INITIALIZER(foo); 66 66 67 67 #ifdef _KERNEL … … 123 123 #define _handler_chain_init() ; 124 124 #define _handler_chain_destroy() ; 125 #endif 125 #endif 126 126 127 127 void … … 146 146 struct proto_handler *b = NULL; 147 147 148 LIBALIAS_WLOCK_ASSERT(); 148 LIBALIAS_WLOCK_ASSERT(); 149 149 LIST_FOREACH(b, &handler_chain, entries) { 150 if ((b->pri == p->pri) && 150 if ((b->pri == p->pri) && 151 151 (b->dir == p->dir) && 152 152 (b->proto == p->proto)) … … 174 174 struct proto_handler *b, *b_tmp;; 175 175 176 LIBALIAS_WLOCK_ASSERT(); 176 LIBALIAS_WLOCK_ASSERT(); 177 177 LIST_FOREACH_SAFE(b, &handler_chain, entries, b_tmp) { 178 178 if (b == p) { … … 195 195 LIBALIAS_WLOCK(); 196 196 for (i=0; 1; i++) { 197 if (*((int *)&_p[i]) == EOH) 197 if (*((int *)&_p[i]) == EOH) 198 198 break; 199 199 #ifdef VBOX … … 202 202 error = _attach_handler(&_p[i]); 203 203 #endif 204 if (error != 0) 204 if (error != 0) 205 205 break; 206 206 } … … 220 220 LIBALIAS_WLOCK(); 221 221 for (i=0; 1; i++) { 222 if (*((int *)&_p[i]) == EOH) 222 if (*((int *)&_p[i]) == EOH) 223 223 break; 224 224 #ifdef VBOX … … 227 227 error = _detach_handler(&_p[i]); 228 228 #endif 229 if (error != 0) 229 if (error != 0) 230 230 break; 231 231 } … … 254 254 255 255 int 256 find_handler(int8_t dir, int8_t proto, struct libalias *la, struct ip *pip, 256 find_handler(int8_t dir, int8_t proto, struct libalias *la, struct ip *pip, 257 257 struct alias_data *ad) 258 258 { … … 264 264 265 265 LIBALIAS_RLOCK(); 266 266 267 267 LIST_FOREACH(p, &handler_chain, entries) { 268 268 if ((p->dir & dir) && (p->proto & proto)) … … 273 273 } 274 274 LIBALIAS_RUNLOCK(); 275 return (error); 275 return (error); 276 276 } 277 277 … … 283 283 #endif 284 284 { 285 286 return (LIST_FIRST(&handler_chain)); 285 286 return (LIST_FIRST(&handler_chain)); 287 287 } 288 288 … … 310 310 SLIST_FOREACH_SAFE(b, &dll_chain, next, b_tmp) 311 311 if (!strncmp(b->name, p, DLL_LEN)) { 312 SLIST_REMOVE(&dll_chain, b, dll, next); 312 SLIST_REMOVE(&dll_chain, b, dll, next); 313 313 error = b; 314 314 break; -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_mod.h
r21864 r26495 54 54 55 55 /* Packet flow direction. */ 56 #define IN 1 57 #define OUT 2 56 #define IN 1 57 #define OUT 2 58 58 59 59 /* Working protocol. */ … … 62 62 #define UDP 4 63 63 64 /* 64 /* 65 65 * Data passed to protocol handler module, it must be filled 66 66 * right before calling find_handler() to determine which … … 68 68 */ 69 69 70 struct alias_data { 71 struct alias_link *lnk; 70 struct alias_data { 71 struct alias_link *lnk; 72 72 struct in_addr *oaddr; /* Original address. */ 73 struct in_addr *aaddr; /* Alias address. */ 73 struct in_addr *aaddr; /* Alias address. */ 74 74 uint16_t *aport; /* Alias port. */ 75 75 uint16_t *sport, *dport; /* Source & destination port */ 76 76 uint16_t maxpktsize; /* Max packet size. */ 77 }; 77 }; 78 78 79 /* 79 /* 80 80 * This structure contains all the information necessary to make 81 81 * a protocol handler correctly work. … … 85 85 u_int pri; /* Handler priority. */ 86 86 int16_t dir; /* Flow direction. */ 87 uint8_t proto; /* Working protocol. */ 87 uint8_t proto; /* Working protocol. */ 88 88 int (*fingerprint)(struct libalias *la, /* Fingerprint * function. */ 89 89 struct ip *pip, struct alias_data *ah); 90 90 int (*protohandler)(struct libalias *la, /* Aliasing * function. */ 91 struct ip *pip, struct alias_data *ah); 91 struct ip *pip, struct alias_data *ah); 92 92 LIST_ENTRY(proto_handler) entries; 93 93 }; 94 94 95 95 96 /* 96 /* 97 97 * Used only in userland when libalias needs to keep track of all 98 98 * module loaded. In kernel land (kld mode) we don't need to care … … 101 101 102 102 #define DLL_LEN 32 103 struct dll { 103 struct dll { 104 104 char name[DLL_LEN]; /* Name of module. */ 105 void *handle; /* 105 void *handle; /* 106 106 * Ptr to shared obj obtained through 107 107 * dlopen() - use this ptr to get access 108 * to any symbols from a loaded module 109 * via dlsym(). 108 * to any symbols from a loaded module 109 * via dlsym(). 110 110 */ 111 111 SLIST_ENTRY(dll) next; … … 127 127 struct proto_handler *first_handler(void); 128 128 #endif 129 int find_handler(int8_t, int8_t, struct libalias *, 129 int find_handler(int8_t, int8_t, struct libalias *, 130 130 struct ip *, struct alias_data *); 131 131 … … 141 141 #define EOH -1 142 142 143 /* 143 /* 144 144 * Some defines borrowed from sys/module.h used to compile a kld 145 145 * in userland as a shared lib. … … 153 153 MOD_QUIESCE 154 154 } modeventtype_t; 155 155 156 156 typedef struct module *module_t; 157 157 typedef int (*modeventhand_t)(module_t, int /* modeventtype_t */, void *); -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_pptp.c
r20958 r26495 79 79 AliasHandlePptpGreIn(struct libalias *, struct ip *); 80 80 81 static int 81 static int 82 82 fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah) 83 83 { … … 91 91 } 92 92 93 static int 93 static int 94 94 fingerprintgre(struct libalias *la, struct ip *pip, struct alias_data *ah) 95 95 { … … 98 98 } 99 99 100 static int 100 static int 101 101 protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah) 102 102 { 103 103 104 104 AliasHandlePptpIn(la, pip, ah->lnk); 105 105 return (0); 106 106 } 107 107 108 static int 108 static int 109 109 protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah) 110 110 { 111 111 112 112 AliasHandlePptpOut(la, pip, ah->lnk); 113 113 return (0); 114 114 } 115 115 116 static int 116 static int 117 117 protohandlergrein(struct libalias *la, struct ip *pip, struct alias_data *ah) 118 118 { … … 124 124 } 125 125 126 static int 126 static int 127 127 protohandlergreout(struct libalias *la, struct ip *pip, struct alias_data *ah) 128 128 { … … 135 135 /* Kernel module definition. */ 136 136 struct proto_handler handlers[] = { 137 { 138 .pri = 200, 139 .dir = IN, 140 .proto = TCP, 141 .fingerprint = &fingerprint, 137 { 138 .pri = 200, 139 .dir = IN, 140 .proto = TCP, 141 .fingerprint = &fingerprint, 142 142 .protohandler = &protohandlerin 143 143 }, 144 { 145 .pri = 210, 146 .dir = OUT, 147 .proto = TCP, 148 .fingerprint = &fingerprint, 144 { 145 .pri = 210, 146 .dir = OUT, 147 .proto = TCP, 148 .fingerprint = &fingerprint, 149 149 .protohandler = &protohandlerout 150 150 }, 151 /* 152 * WATCH OUT!!! these 2 handlers NEED a priority of INT_MAX (highest possible) 151 /* 152 * WATCH OUT!!! these 2 handlers NEED a priority of INT_MAX (highest possible) 153 153 * cause they will ALWAYS process packets, so they must be the last one 154 154 * in chain: look fingerprintgre() above. 155 155 */ 156 { 157 .pri = INT_MAX, 158 .dir = IN, 159 .proto = IP, 160 .fingerprint = &fingerprintgre, 156 { 157 .pri = INT_MAX, 158 .dir = IN, 159 .proto = IP, 160 .fingerprint = &fingerprintgre, 161 161 .protohandler = &protohandlergrein 162 162 }, 163 { 164 .pri = INT_MAX, 165 .dir = OUT, 166 .proto = IP, 167 .fingerprint = &fingerprintgre, 163 { 164 .pri = INT_MAX, 165 .dir = OUT, 166 .proto = IP, 167 .fingerprint = &fingerprintgre, 168 168 .protohandler = &protohandlergreout 169 }, 169 }, 170 170 { EOH } 171 171 }; … … 191 191 192 192 #ifdef _KERNEL 193 static 193 static 194 194 #endif 195 195 moduledata_t alias_mod = { -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_skinny.c
r20958 r26495 57 57 AliasHandleSkinny(struct libalias *, struct ip *, struct alias_link *); 58 58 59 static int 59 static int 60 60 fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah) 61 61 { … … 69 69 } 70 70 71 static int 71 static int 72 72 protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 73 73 { 74 74 75 75 AliasHandleSkinny(la, pip, ah->lnk); 76 76 return (0); … … 78 78 79 79 struct proto_handler handlers[] = { 80 { 81 .pri = 110, 82 .dir = IN|OUT, 83 .proto = TCP, 84 .fingerprint = &fingerprint, 80 { 81 .pri = 110, 82 .dir = IN|OUT, 83 .proto = TCP, 84 .fingerprint = &fingerprint, 85 85 .protohandler = &protohandler 86 }, 86 }, 87 87 { EOH } 88 88 }; … … 109 109 110 110 #ifdef _KERNEL 111 static 111 static 112 112 #endif 113 113 moduledata_t alias_mod = { -
trunk/src/VBox/Devices/Network/slirp/libalias/alias_smedia.c
r20958 r26495 130 130 131 131 static void 132 AliasHandleRtspOut(struct libalias *, struct ip *, struct alias_link *, 132 AliasHandleRtspOut(struct libalias *, struct ip *, struct alias_link *, 133 133 int maxpacketsize); 134 static int 134 static int 135 135 fingerprint(struct libalias *la, struct ip *pip, struct alias_data *ah) 136 136 { … … 139 139 ntohs(*ah->dport) == TFTP_PORT_NUMBER) 140 140 return (0); 141 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || 141 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL || 142 142 ah->maxpktsize == 0) 143 143 return (-1); … … 150 150 } 151 151 152 static int 152 static int 153 153 protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 154 154 { 155 155 156 156 if (ntohs(*ah->dport) == TFTP_PORT_NUMBER) 157 157 FindRtspOut(la, pip->ip_src, pip->ip_dst, 158 158 *ah->sport, *ah->aport, IPPROTO_UDP); 159 else AliasHandleRtspOut(la, pip, ah->lnk, ah->maxpktsize); 159 else AliasHandleRtspOut(la, pip, ah->lnk, ah->maxpktsize); 160 160 return (0); 161 161 } 162 162 163 163 struct proto_handler handlers[] = { 164 { 165 .pri = 100, 166 .dir = OUT, 164 { 165 .pri = 100, 166 .dir = OUT, 167 167 .proto = TCP|UDP, 168 .fingerprint = &fingerprint, 168 .fingerprint = &fingerprint, 169 169 .protohandler = &protohandler 170 }, 170 }, 171 171 { EOH } 172 172 }; … … 193 193 194 194 #ifdef _KERNEL 195 static 195 static 196 196 #endif 197 197 moduledata_t alias_mod = { -
trunk/src/VBox/Devices/Network/slirp/mbuf.c
r26423 r26495 23 23 int i; 24 24 struct mbuf *m; 25 uint8_t *zone = RTMemAlloc(msize * MBUF_ZONE_SIZE); 25 uint8_t *zone = RTMemAlloc(msize * MBUF_ZONE_SIZE); 26 26 if (zone == NULL) 27 27 { … … 51 51 pData->mbuf_water_line_limit = pData->mbuf_zone_count * MBUF_ZONE_SIZE; 52 52 return 0; 53 } 53 } 54 54 55 55 void m_fini(PNATState pData) … … 66 66 { 67 67 m = (struct mbuf *)((char *)zone + i*msize); 68 if ( (m->m_flags & M_EXT) 68 if ( (m->m_flags & M_EXT) 69 69 && m->m_ext != NULL) 70 70 RTMemFree(m->m_ext); … … 125 125 126 126 DEBUG_CALL("m_get"); 127 127 128 128 rc = RTCritSectEnter(&pData->cs_mbuf_zone); 129 129 AssertRC(rc); … … 383 383 { 384 384 m_inc(m, cbBuf); 385 } 385 } 386 386 c = mtod(m, char *); 387 387 memcpy(c, pu8Buf, cbBuf); -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r26404 r26495 63 63 64 64 /* specific for Unix API */ 65 # define DO_UNIX_CHECK_FD_SET(so, events, fdset) DO_CHECK_FD_SET((so), (events), fdset) 65 # define DO_UNIX_CHECK_FD_SET(so, events, fdset) DO_CHECK_FD_SET((so), (events), fdset) 66 66 /* specific for Windows Winsock API */ 67 # define DO_WIN_CHECK_FD_SET(so, events, fdset) 0 67 # define DO_WIN_CHECK_FD_SET(so, events, fdset) 0 68 68 69 69 # ifndef RT_OS_LINUX -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r26423 r26495 150 150 int mbuf_water_line_limit; 151 151 int mbuf_zone_count; 152 int fmbuf_water_warn_sent; 152 int fmbuf_water_warn_sent; 153 153 uint32_t tsmbuf_water_warn_sent; 154 154 #endif -
trunk/src/VBox/Devices/Network/slirp/socket.c
r26404 r26495 628 628 (struct sockaddr *)&addr, &addrlen); 629 629 Log2(("NAT: %R[natsock] ioctlsocket after read " 630 "(rc:%d errno:%d, n:%d) ret:%d, len:%d\n", so, 630 "(rc:%d errno:%d, n:%d) ret:%d, len:%d\n", so, 631 631 rc, errno, n, ret, len)); 632 632 #else
Note:
See TracChangeset
for help on using the changeset viewer.