Hello Charles,

I think there is an issue in the calculation of the pointer to the
next DHCP option. Could you please try the attached patch?

Greets
-- 
Christian Helmuth
Genode Labs

http://www.genode-labs.com/ · http://genode.org/
https://twitter.com/GenodeLabs · /ˈdʒiː.nəʊd/

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
 repos/os/include/net/dhcp.h | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/repos/os/include/net/dhcp.h b/repos/os/include/net/dhcp.h
index da492d0..c1ce3cc 100644
--- a/repos/os/include/net/dhcp.h
+++ b/repos/os/include/net/dhcp.h
@@ -122,6 +122,14 @@ class Net::Dhcp_packet
 				Genode::size_t  length() { return _len;   }
 				void*           value()  { return _value; }
 
+				Option *next()
+				{
+					if (_code == PAD)
+						return (Option *)&_len;
+					else
+						return (Option *)(_value + _len);
+				};
+
 				/**
 				 * Placement new.
 				 */
@@ -142,6 +150,7 @@ class Net::Dhcp_packet
 		};
 
 		enum Option_type {
+			PAD            = 0,
 			REQ_IP_ADDR    = 50,
 			IP_LEASE_TIME  = 51,
 			OPT_OVERLOAD   = 52,
@@ -212,16 +221,11 @@ class Net::Dhcp_packet
 
 		Option *option(Option_type op)
 		{
-			void *ptr = &_opts;
-			while (true) {
-				Option *ext = new (ptr) Option();
-				if (ext->code() == op)
-					return ext;
-				if (ext->code() == END || ext->code() == 0)
-					break;
-				ptr = ext + ext->length();
-			}
-			return 0;
+			for (Option *o = (Option *)&_opts; o->code() != END; o = o->next())
+				if (o->code() == op)
+					return o;
+
+			return nullptr;
 		}
 
 
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
genode-main mailing list
genode-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/genode-main

Reply via email to