- Timestamp:
- Aug 9, 2009 7:20:36 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r22103 r22110 380 380 Assert((bp->bp_ciaddr.s_addr == INADDR_ANY)); 381 381 Assert((*(uint32_t *)(req_ip + 2) == bc->addr.s_addr)); /*the same address as in offer*/ 382 #if 0 383 /* DSL xid in request differ from offer */ 382 384 Assert((bp->bp_xid == bc->xid)); 385 #endif 383 386 } 384 387 else … … 608 611 static void bootp_reply(PNATState pData, struct mbuf *m, int off, uint16_t flags) 609 612 { 610 #if 0611 BOOTPClient *bc;612 struct mbuf *m; /* XXX: @todo vasily - it'd be better to reuse this mbuf here */613 struct bootp_t *bp = mtod(m0, struct bootp_t *);614 struct bootp_t *rbp;615 struct sockaddr_in saddr, daddr;616 int dhcp_msg_type, val;617 uint8_t *q;618 struct in_addr requested_ip; /* the requested IP in DHCPREQUEST */619 int send_nak = 0;620 621 /* extract exact DHCP msg type */622 requested_ip.s_addr = 0xffffffff;623 dhcp_decode(bp, bp->bp_vend, DHCP_OPT_LEN, &dhcp_msg_type, &requested_ip);624 Log(("bootp packet op=%d msgtype=%d\n", bp->bp_op, dhcp_msg_type));625 626 if (dhcp_msg_type == 0)627 dhcp_msg_type = DHCPREQUEST; /* Force reply for old BOOTP clients */628 629 if (dhcp_msg_type == DHCPRELEASE)630 {631 int rc;632 rc = release_addr(pData, &bp->bp_ciaddr);633 LogRel(("NAT: %s %R[IP4]\n",634 rc ? "DHCP released IP address" : "Ignored DHCP release for IP address",635 &bp->bp_ciaddr));636 /* This message is not to be answered in any way. */637 return;638 }639 if ( dhcp_msg_type != DHCPDISCOVER640 && dhcp_msg_type != DHCPREQUEST)641 return;642 643 644 if (dhcp_msg_type == DHCPDISCOVER)645 {646 /* Do not allocate a new lease for clients that forgot that they had a lease. */647 }648 else if (dhcp_msg_type == DHCPREQUEST)649 {650 *q++ = RFC2132_MSG_TYPE;651 *q++ = 1;652 if (requested_ip.s_addr != daddr.sin_addr.s_addr)653 {654 /* network changed */655 *q++ = DHCPNAK;656 send_nak = 1;657 }658 else659 *q++ = DHCPACK;660 }661 662 if (send_nak)663 LogRel(("NAT: Client requested IP address %R[IP4] -- sending NAK\n",664 &requested_ip));665 else666 LogRel(("NAT: DHCP offered IP address %R[IP4]\n",667 &daddr.sin_addr));668 if ( dhcp_msg_type == DHCPDISCOVER669 || dhcp_msg_type == DHCPREQUEST)670 {671 FILL_BOOTP_EXT(q, RFC2132_SRV_ID, 4, &saddr.sin_addr);672 }673 674 if (!send_nak &&675 ( dhcp_msg_type == DHCPDISCOVER676 || dhcp_msg_type == DHCPREQUEST))677 #endif678 613 struct sockaddr_in saddr, daddr; 679 614 struct bootp_t *rbp = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.