Changeset 17599 in vbox for trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
- Timestamp:
- Mar 10, 2009 7:49:20 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r17442 r17599 204 204 int addConfig(VBoxNetDhcpCfg *pCfg); 205 205 bool handleDhcpMsg(uint8_t uMsgType, PCRTNETBOOTP pDhcpMsg, size_t cb); 206 bool handleDhcpReqDiscover(PCRTNETBOOTP pDhcpMsg, size_t cb); 207 bool handleDhcpReqRequest(PCRTNETBOOTP pDhcpMsg, size_t cb); 208 bool handleDhcpReqDecline(PCRTNETBOOTP pDhcpMsg, size_t cb); 209 bool handleDhcpReqRelease(PCRTNETBOOTP pDhcpMsg, size_t cb); 210 void handleDhcpReply(uint8_t uMsgType, VBoxNetDhcpLease *pLease, PCRTNETBOOTP pDhcpMsg, size_t cb); 206 211 207 212 inline void debugPrint( int32_t iMinLevel, bool fMsg, const char *pszFmt, ...) const; … … 635 640 } 636 641 else 637 debugPrint(1, true, "VBoxNetDHCP: Skipping invalid DHCP packet.\n"); 642 debugPrint(1, true, "VBoxNetDHCP: Skipping invalid DHCP packet.\n"); /** @todo handle pure bootp clients too? */ 638 643 639 644 m_pCurMsg = NULL; … … 660 665 bool VBoxNetDhcp::handleDhcpMsg(uint8_t uMsgType, PCRTNETBOOTP pDhcpMsg, size_t cb) 661 666 { 662 debugPrint(0, true, "todo"); 667 if (pDhcpMsg->bp_op == RTNETBOOTP_OP_REQUEST) 668 { 669 switch (uMsgType) 670 { 671 case RTNET_DHCP_MT_DISCOVER: 672 return handleDhcpReqDiscover(pDhcpMsg, cb); 673 674 case RTNET_DHCP_MT_REQUEST: 675 return handleDhcpReqRequest(pDhcpMsg, cb); 676 677 case RTNET_DHCP_MT_DECLINE: 678 return handleDhcpReqDecline(pDhcpMsg, cb); 679 680 case RTNET_DHCP_MT_RELEASE: 681 return handleDhcpReqRelease(pDhcpMsg, cb); 682 683 case RTNET_DHCP_MT_INFORM: 684 debugPrint(0, true, "Should we handle this?"); 685 break; 686 687 default: 688 debugPrint(0, true, "Unexpected."); 689 break; 690 } 691 } 663 692 return false; 664 693 } 694 695 696 /** 697 * The client is requesting an offer. 698 * 699 * @returns true. 700 * 701 * @param pDhcpMsg The message. 702 * @param cb The message size. 703 */ 704 bool VBoxNetDhcp::handleDhcpReqDiscover(PCRTNETBOOTP pDhcpMsg, size_t cb) 705 { 706 /* 707 * First, see if there is already a lease for this client. It may have rebooted, 708 * crashed or whatever that have caused it to forget its existing lease. 709 * If none was found, create a new lease for it and then construct a reply. 710 */ 711 712 /** @todo this code IS required. */ 713 return true; 714 } 715 716 717 /** 718 * The client is requesting an offer. 719 * 720 * @returns true. 721 * 722 * @param pDhcpMsg The message. 723 * @param cb The message size. 724 */ 725 bool VBoxNetDhcp::handleDhcpReqRequest(PCRTNETBOOTP pDhcpMsg, size_t cb) 726 { 727 /* 728 * Windows will reissue these requests when rejoining a network if it thinks it 729 * already has an address on the network. If we cannot find a valid lease, 730 * make a new one. 731 */ 732 /** @todo check how windows treats bp_xid here, it should match I think. If 733 * it doesn't we've no way of filtering out broadcast replies to other 734 * DHCP servers. */ 735 736 /** @todo this code IS required. */ 737 return true; 738 } 739 740 741 /** 742 * The client is declining an offer we've made. 743 * 744 * @returns true. 745 * 746 * @param pDhcpMsg The message. 747 * @param cb The message size. 748 */ 749 bool VBoxNetDhcp::handleDhcpReqDecline(PCRTNETBOOTP pDhcpMsg, size_t cb) 750 { 751 /* 752 * The client is supposed to pass us option 50, requested address, 753 * from the offer. We also match the lease state. Apparently the 754 * MAC address is not supposed to be checked here. 755 */ 756 757 /** @todo this is not required in the initial implementation, do it later. */ 758 return true; 759 } 760 761 762 /** 763 * The client is releasing its lease - good boy. 764 * 765 * @returns true. 766 * 767 * @param pDhcpMsg The message. 768 * @param cb The message size. 769 */ 770 bool VBoxNetDhcp::handleDhcpReqRelease(PCRTNETBOOTP pDhcpMsg, size_t cb) 771 { 772 /* 773 * The client may pass us option 61, client identifier, which we should 774 * use to find the lease by. 775 * 776 * We're matching MAC address and lease state as well. 777 */ 778 779 /* 780 * If no client identifier or if we couldn't find a lease by using it, 781 * we will try look it up by the client IP address. 782 */ 783 784 785 /* 786 * If found, release it. 787 */ 788 789 790 /** @todo this is not required in the initial implementation, do it later. */ 791 return true; 792 } 793 794 795 /** 796 * Constructs and sends a reply to a client. 797 * 798 * @returns 799 * @param uMsgType The DHCP message type. 800 * @param pLease The lease. This can be NULL for some replies. 801 * @param pDhcpMsg The client message. We will dig out the MAC address, 802 * transaction ID, and requested options from this. 803 * @param cb The size of the client message. 804 */ 805 void VBoxNetDhcp::handleDhcpReply(uint8_t uMsgType, VBoxNetDhcpLease *pLease, PCRTNETBOOTP pDhcpMsg, size_t cb) 806 { 807 /** @todo this is required. :-) */ 808 } 809 665 810 666 811
Note:
See TracChangeset
for help on using the changeset viewer.