[haiku-commits] r41275 - haiku/trunk/src/servers/net

  • From: philippe.houdoin@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 22 Apr 2011 23:52:15 +0200 (CEST)

Author: phoudoin
Date: 2011-04-22 23:52:15 +0200 (Fri, 22 Apr 2011)
New Revision: 41275
Changeset: https://dev.haiku-os.org/changeset/41275

Modified:
   haiku/trunk/src/servers/net/DHCPClient.cpp
Log:
Add dhcp_message::FindOption(), to retrieve a specific option.


Modified: haiku/trunk/src/servers/net/DHCPClient.cpp
===================================================================
--- haiku/trunk/src/servers/net/DHCPClient.cpp  2011-04-22 21:33:43 UTC (rev 
41274)
+++ haiku/trunk/src/servers/net/DHCPClient.cpp  2011-04-22 21:52:15 UTC (rev 
41275)
@@ -132,8 +132,9 @@
        bool HasOptions() const;
        bool NextOption(dhcp_option_cookie& cookie, message_option& option,
                const uint8*& data, size_t& size) const;
+       const uint8* FindOption(message_option which) const;
+       const uint8* LastOption() const;
        message_type Type() const;
-       const uint8* LastOption() const;
 
        uint8* PrepareMessage(uint8 type);
        uint8* PutOption(uint8* options, message_option option);
@@ -272,8 +273,8 @@
 }
 
 
-message_type
-dhcp_message::Type() const
+const uint8*
+dhcp_message::FindOption(message_option which) const
 {
        dhcp_option_cookie cookie;
        message_option option;
@@ -281,11 +282,11 @@
        size_t size;
        while (NextOption(cookie, option, data, size)) {
                // iterate through all options
-               if (option == OPTION_MESSAGE_TYPE)
-                       return (message_type)data[0];
+               if (option == which)
+                       return data;
        }
 
-       return DHCP_NONE;
+       return NULL;
 }
 
 
@@ -304,6 +305,17 @@
 }
 
 
+message_type
+dhcp_message::Type() const
+{
+       const uint8* data = FindOption(OPTION_MESSAGE_TYPE);
+       if (data)
+               return (message_type)data[0];
+
+       return DHCP_NONE;
+}
+
+
 size_t
 dhcp_message::Size() const
 {


Other related posts:

  • » [haiku-commits] r41275 - haiku/trunk/src/servers/net - philippe . houdoin