Changeset 22159 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Aug 11, 2009 11:52:12 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r22117 r22159 362 362 uint8_t *req_ip; 363 363 uint8_t *server_ip; 364 uint32_t ui32; 364 365 enum DHCP_REQUEST_STATES dhcp_stat = NONE; 365 366 /*need to understand which type of request we get */ 366 367 req_ip = dhcp_find_option(&bp->bp_vend[0], RFC2132_REQ_ADDR); 367 368 server_ip = dhcp_find_option(&bp->bp_vend[0], RFC2132_SRV_ID); 368 369 369 bc = find_addr(pData, &daddr, bp->bp_hwaddr); 370 if (!bc) 371 { 372 LogRel(("NAT: DHCP no IP address left\n")); 373 Log(("no address left\n")); 374 return -1; 375 } 370 376 371 if (server_ip != NULL) 377 372 { 378 373 /*selecting*/ 374 if (!bc) 375 { 376 LogRel(("NAT: DHCP no IP wasn't allocated\n")); 377 return -1; 378 } 379 379 dhcp_stat = SELECTING; 380 380 Assert((bp->bp_ciaddr.s_addr == INADDR_ANY)); … … 401 401 } 402 402 /*?? renewing ??*/ 403 if(dhcp_stat == RENEWING){ 404 Assert(( server_ip == NULL 405 && req_ip == NULL 406 && bp->bp_ciaddr.s_addr != INADDR_ANY)); 407 if (bc != NULL) 408 { 409 Assert((bc->addr.s_addr == bp->bp_ciaddr.s_addr)); 410 /*if it already here well just do ack, we aren't aware of dhcp time expiration*/ 411 } 412 else 413 { 414 if ((bp->bp_ciaddr.s_addr & pData->netmask) != special_addr.s_addr) 415 { 416 off = dhcp_send_nack(pData, bp, bc, m); 417 return off; 418 } 419 bc = alloc_addr(pData); 420 if (bc == NULL) 421 { 422 LogRel(("NAT: can't alloc address. RENEW has been silently ignored\n")); 423 return -1; 424 } 425 Assert((bp->bp_hlen == ETH_ALEN)); 426 memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen); 427 bc->addr.s_addr = bp->bp_ciaddr.s_addr; 428 } 429 } 430 Assert((dhcp_stat != NONE)); 403 switch (dhcp_stat) 404 { 405 case RENEWING: 406 { 407 Assert(( server_ip == NULL 408 && req_ip == NULL 409 && bp->bp_ciaddr.s_addr != INADDR_ANY)); 410 if (bc != NULL) 411 { 412 Assert((bc->addr.s_addr == bp->bp_ciaddr.s_addr)); 413 /*if it already here well just do ack, we aren't aware of dhcp time expiration*/ 414 } 415 else 416 { 417 if ((bp->bp_ciaddr.s_addr & htonl(pData->netmask)) != special_addr.s_addr) 418 { 419 off = dhcp_send_nack(pData, bp, bc, m); 420 return off; 421 } 422 bc = alloc_addr(pData); 423 if (bc == NULL) 424 { 425 LogRel(("NAT: can't alloc address. RENEW has been silently ignored\n")); 426 return -1; 427 } 428 Assert((bp->bp_hlen == ETH_ALEN)); 429 memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen); 430 bc->addr.s_addr = bp->bp_ciaddr.s_addr; 431 } 432 } 433 case INIT_REBOOT: 434 Assert(server_ip == NULL); 435 Assert(req_ip != NULL); 436 ui32 = *(uint32_t *)(req_ip + 2); 437 if ((ui32 & htonl(pData->netmask)) != special_addr.s_addr) 438 { 439 LogRel(("NAT: address %R[IP4] has been req.\n", &ui32)); 440 off = dhcp_send_nack(pData, bp, bc, m); 441 return off; 442 } 443 bc = alloc_addr(pData); 444 if (bc == NULL) 445 { 446 LogRel(("NAT: can't alloc address. RENEW has been silently ignored\n")); 447 return -1; 448 } 449 Assert((bp->bp_hlen == ETH_ALEN)); 450 memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen); 451 bc->addr.s_addr = ui32; 452 break; 453 case NONE: 454 Assert((dhcp_stat != NONE)); 455 return -1; 456 default: 457 break; 458 } 431 459 off = dhcp_send_ack(pData, bp, bc, m, 1); 432 460 return off;
Note:
See TracChangeset
for help on using the changeset viewer.