Changeset 22024 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Aug 6, 2009 11:30:01 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r22019 r22024 41 41 bc->allocated = 1; 42 42 paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR)); 43 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER44 43 bc->addr.s_addr = paddr->s_addr; 45 #endif46 44 return bc; 47 45 } … … 130 128 } 131 129 132 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER133 static void bootp_reply(PNATState pData, struct bootp_t *bp)134 #else135 130 static void bootp_reply(PNATState pData, struct mbuf *m0) 136 #endif137 131 { 138 132 BOOTPClient *bc; 139 133 struct mbuf *m; /* XXX: @todo vasily - it'd be better to reuse this mbuf here */ 140 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER141 134 struct bootp_t *bp = mtod(m0, struct bootp_t *); 142 135 struct ethhdr *eh; 143 #endif144 136 struct bootp_t *rbp; 145 137 struct sockaddr_in saddr, daddr; … … 189 181 return; 190 182 191 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER192 /* XXX: this is a hack to get the client mac address */193 memcpy(client_ethaddr, bp->bp_hwaddr, 6);194 #endif195 196 183 if ((m = m_get(pData)) == NULL) 197 184 return; 198 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER199 185 eh = mtod(m, struct ethhdr *); 200 186 memcpy(eh->h_source, bp->bp_hwaddr, ETH_ALEN); /* XXX: if_encap just swap source with dest*/ 201 #endif202 187 m->m_data += if_maxlinkhdr; /*reserve ether header */ 203 188 rbp = mtod(m, struct bootp_t *); … … 218 203 return; 219 204 } 220 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER221 205 memcpy(bc->macaddr, bp->bp_hwaddr, 6); 222 #else223 memcpy(bc->macaddr, client_ethaddr, 6);224 #endif225 206 } 226 207 } … … 386 367 387 368 if (bp->bp_op == BOOTP_REQUEST) 388 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER389 bootp_reply(pData, bp);390 #else391 369 bootp_reply(pData, m); 392 #endif 393 } 370 } -
trunk/src/VBox/Devices/Network/slirp/ip_output.c
r22020 r22024 46 46 #include "alias.h" 47 47 48 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER49 48 static const uint8_t* rt_lookup_in_cache(PNATState pData, uint32_t dst) 50 49 { … … 67 66 return NULL; 68 67 } 69 #endif70 68 71 69 /* … … 82 80 register int hlen = sizeof(struct ip ); 83 81 int len, off, error = 0; 84 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER85 82 extern uint8_t zerro_ethaddr[ETH_ALEN]; 86 83 struct ethhdr *eh = NULL; 87 84 const uint8_t *eth_dst = NULL; 88 #endif 85 89 86 STAM_PROFILE_START(&pData->StatIP_output, a); 90 87 … … 126 123 } 127 124 #endif 128 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER129 125 /* Current TCP/IP stack hasn't routing information at 130 126 * all so we need to calculate destination ethernet address … … 133 129 if (memcmp(eh->h_source, zerro_ethaddr, ETH_ALEN) == 0) 134 130 eth_dst = rt_lookup_in_cache(pData, ip->ip_dst.s_addr); 135 #endif136 131 137 132 /* … … 144 139 ip->ip_sum = 0; 145 140 ip->ip_sum = cksum(m, hlen); 146 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER 147 if (eth_dst != NULL) { 141 if (eth_dst != NULL) 148 142 memcpy(eh->h_source, eth_dst, ETH_ALEN); 149 }150 #endif151 143 { 152 144 int rc; … … 203 195 mhip = mtod(m, struct ip *); 204 196 *mhip = *ip; 205 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER206 197 /* we've calculated eth_dst for first packet */ 207 198 eh = (struct ethhdr *)MBUF_HEAD(m); … … 209 200 memcpy(eh->h_source, eth_dst, ETH_ALEN); 210 201 } 211 #endif212 202 213 203 #if 0 /* No options */ -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r22021 r22024 528 528 special_addr.s_addr = u32NetAddr; 529 529 #endif 530 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER531 530 pData->slirp_ethaddr = &special_ethaddr[0]; 532 #endif533 531 alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS); 534 532 /* @todo: add ability to configure this staff */ … … 1297 1295 } 1298 1296 1299 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER1300 #define ETH_ALEN 61301 #define ETH_HLEN 141302 1303 #define ARPOP_REQUEST 1 /* ARP request */1304 #define ARPOP_REPLY 2 /* ARP reply */1305 1306 struct ethhdr1307 {1308 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */1309 unsigned char h_source[ETH_ALEN]; /* source ether addr */1310 unsigned short h_proto; /* packet type ID field */1311 };1312 AssertCompileSize(struct ethhdr, 14);1313 #endif1314 1297 1315 1298 struct arphdr … … 1348 1331 1349 1332 mr = m_get(pData); 1350 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER 1333 1351 1334 reh = mtod(mr, struct ethhdr *); 1352 1335 memcpy(reh->h_source, eh->h_source, ETH_ALEN); /* XXX: if_encap will swap src and dst*/ … … 1354 1337 reh->h_source, reh->h_dest)); 1355 1338 Log4(("NAT: arp: %R[IP4]\n", &tip)); 1356 #endif 1339 1357 1340 mr->m_data += if_maxlinkhdr; 1358 1341 mr->m_len = sizeof(struct arphdr); … … 1423 1406 } 1424 1407 Log4(("NAT: in:%R[ether]->%R[ether]\n", &eh->h_source, &eh->h_dest)); 1425 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER 1408 1426 1409 if (memcmp(eh->h_source, special_ethaddr, ETH_ALEN) == 0) 1427 1410 { … … 1431 1414 return; 1432 1415 } 1433 #endif1434 1416 1435 1417 m = m_get(pData); … … 1497 1479 } 1498 1480 1499 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER1500 memcpy(eh->h_dest, client_ethaddr, ETH_ALEN);1501 memcpy(eh->h_source, special_ethaddr, ETH_ALEN - 1);1502 /* XXX: not correct */1503 eh->h_source[5] = CTL_ALIAS;1504 #else1505 1481 if (memcmp(eh->h_source, special_ethaddr, ETH_ALEN) != 0) 1506 1482 { … … 1514 1490 } 1515 1491 } 1516 #endif 1492 1517 1493 eh->h_proto = htons(eth_proto); 1518 1494 memcpy(buf, mtod(m, uint8_t *), m->m_len); -
trunk/src/VBox/Devices/Network/slirp/slirp.h
r22014 r22024 326 326 #endif 327 327 328 # ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER 329 # define ETH_ALEN 6 330 # define ETH_HLEN 14 331 332 # define ARPOP_REQUEST 1 /* ARP request */ 333 # define ARPOP_REPLY 2 /* ARP reply */ 328 # define ETH_ALEN 6 329 # define ETH_HLEN 14 330 331 # define ARPOP_REQUEST 1 /* ARP request */ 332 # define ARPOP_REPLY 2 /* ARP reply */ 334 333 335 334 struct ethhdr … … 340 339 }; 341 340 AssertCompileSize(struct ethhdr, 14); 342 # endif343 341 #if defined(VBOX_SLIRP_ALIAS) 344 342 -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r22020 r22024 40 40 bool allocated; 41 41 uint8_t macaddr[6]; 42 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER43 42 struct in_addr addr; 44 #endif45 43 } BOOTPClient; 46 44 … … 142 140 struct in_addr loopback_addr; 143 141 uint32_t netmask; 144 #ifndef VBOX_WITH OUT_SLIRP_CLIENT_ETHER142 #ifndef VBOX_WITH_NAT_SERVICE 145 143 uint8_t client_ethaddr[6]; 146 #else 147 # ifndef VBOX_WITH_NAT_SERVICE 148 uint8_t client_ethaddr[6]; 149 # endif 144 #endif 150 145 const uint8_t *slirp_ethaddr; 151 #endif152 146 struct ex_list *exec_list; 153 147 char slirp_hostname[33];
Note:
See TracChangeset
for help on using the changeset viewer.