[Toybox] [PATCH] dhcpd add -6 option(ipv6 support)

Rob Landley rob at landley.net
Fri Jul 10 11:50:42 PDT 2015


On 07/07/2015 10:21 PM, Yeongdeok Suh wrote:
> I added dhcpd -6 option.
> 
> It's for supporting ipv6, and I referred to RFC 3315 Specification
> http://www.rfc-base.org/txt/rfc-3315.txt
> 
> There are some different kind of requests in dhcpd6,
> but I inplemented only a basic protocol. (Solicit - Advertise - Request
> - Reply)
> There's a sample packet as below. toybox dhcpd works in the same way.
> http://packetlife.net/captures/DHCPv6.cap
> 
> PFA for the patch.

The "default y" vs "default n" involves things being promoted out of
pending. (Nothing in the pending directory should be enabled in
defconfig. You can enable it if you want, but if it breaks you get to
keep the pieces. See http://landley.net/toybox/cleanup.html for details.)

     -f    Run in foreground
-    -i    Interface to use
+    -i Interface to use
     -S    Log to syslog too

Why?

+/*
+ * Things to do
+ *
+ * - Working as an relay agent
+ * - Rapid commit option support
+ * - Additional packet options (commented on the middle of sources)
+ * - Create common modules
+ */
+

I don't understand your todo list.

@@ -31,6 +42,7 @@ config DEBUG_DHCP

 // Todo: headers not in posix
 #include <netinet/ip.h>
+#include <netinet/ip6.h>
 #include <netinet/udp.h>
 #include <netpacket/packet.h>

Hmmm... I'm torn on wanting a config symbol for ipv6 support (something
not every build environment has/wants) and treating it like long file
support ("it's 2015, you don't ever _not_ do that")...

This is still two codepaths, so I learn towards the config symbol. Then
again I didn't do it for ifconfig, so... yeah, we can hardwire it in
these days.

Right, pages and pages of "oh boy this command needs cleanup". I guess
your patch isn't going to make it worse. Well...

toys/pending/dhcpd.c: In function 'send_packet6':
toys/pending/dhcpd.c:896:47: warning: argument to 'sizeof' in 'memcpy'
call is the same pointer type 'unsigned char *' as the destination;
expected 'unsigned char' or an explicit length [-Wsizeof-pointer-memaccess]
   memcpy(dest_sll.sll_addr, client_lla, sizeof(client_lla));
                                               ^
toys/pending/dhcpd.c: In function 'getip6_from_pool':
toys/pending/dhcpd.c:1562:3: warning: function returns address of local
variable [-Wreturn-local-addr]
   return nip6;
   ^
toys/pending/dhcpd.c: In function 'dhcpd_main':
toys/pending/dhcpd.c:1850:39: warning: initialization from incompatible
pointer type [enabled by default]
               uint8_t* ia_na_optptr = &(*ia_na_p).optval;
                                       ^
toys/pending/dhcpd.c:1964:39: warning: initialization from incompatible
pointer type [enabled by default]
               uint8_t* ia_na_optptr = &(*ia_na_p).optval;
                                       ^
toys/pending/dhcpd.c:1757:30: warning: unused variable 'server_ia_pd'
[-Wunused-variable]
              *client_ia_pd, *server_ia_pd;
                              ^
toys/pending/dhcpd.c:1636:12: warning: unused variable 'requested_nip6'
[-Wunused-variable]
   uint32_t requested_nip6[4] = {0,};
            ^
toys/pending/dhcpd.c:1644:11: warning: ignoring return value of
'daemon', declared with attribute warn_unused_result [-Wunused-result]
     daemon(0,0);
           ^
toys/pending/dhcpd.c: In function 'write_pid':
toys/pending/dhcpd.c:491:10: warning: ignoring return value of 'write',
declared with attribute warn_unused_result [-Wunused-result]
     write(pidfile, pidbuf, strlen(pidbuf));
          ^

But it already produced a screenful of warnings, so producing _two_
screens full of warnings isn't a huge difference. (It's in pending for a
reason.)

Applied. (I'm switching the default back to n, though.)

Rob

 1436554242.0


More information about the Toybox mailing list