Re: [Toybox] [New Toy] : add udhcpd

2013-08-13 Thread Ashwini Sharma
HI Rob,

Need to include headers, which are added in toynet.h at my end.
The files reuired are

#include netinet/ip.h
#include netinet/udp.h
#include netpacket/packet.h
regards,
Ashwini

On Tue, Aug 13, 2013 at 5:26 PM, Rob Landley r...@landley.net wrote:

  On 08/12/2013 04:29:25 AM, Ashwini Sharma wrote:

 Hi Rob,

  In the continuation to DHCP client sent to you last week, attached here
 with is the DHCP server implementation.

 Have a look at the same and let me know for any comments.


 I'm trying to finish the cleanups for ifconfig and grep before tackling
 anything else. If anyone else wants to post cleanup patches in the
 meantime, I'm all for it.

 (Quick glance: 1500 lines and 1200 lines. Some sort of get_flag macros.
 Its own write_pid() instead of xpidfile()... There are todo items here.)

 I renamed udhcpc to dhcp and udhcpd to dhcpd, because the u versions
 were the micro prefix for the busybox implementations. (There's no
 standard name for this: the isc reference implementation is called
 dhclient, I've also used pump and dhcpcd. The objective here isn't to
 blindly copy busybox, and when I typed dhcp into ubuntu not only did it not
 have such a command but its auto-suggest didn't say there was one in any
 package in the repository...)

 Um, test compile:

 toys/pending/dhcp.c:167:16: error: field 'iph' has incomplete type
 toys/pending/dhcp.c:168:17: error: field 'udph' has incomplete type
 toys/pending/dhcp.c: In function 'mode_raw':
 toys/pending/dhcp.c:592:22: error: storage size of 'sock' isn't known
 toys/pending/dhcp.c:592:22: warning: unused variable 'sock'
 [-Wunused-variable]
 toys/pending/dhcp.c: In function 'read_raw':
 toys/pending/dhcp.c:683:67: error: 'IPVERSION' undeclared (first use in
 this function)
 toys/pending/dhcp.c:683:67: note: each undeclared identifier is reported
 only once for each function it appears in
 toys/pending/dhcp.c:697:56: error: dereferencing pointer to incomplete type
 toys/pending/dhcp.c: In function 'send_raw':
 toys/pending/dhcp.c:732:22: error: storage size of 'dest_sll' isn't known
 toys/pending/dhcp.c:762:21: error: invalid application of 'sizeof' to
 incomplete type 'struct iphdr'

 And so on for a while. Might try again in the morning.

 Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


[Toybox] [New Toy] : add udhcpd

2013-08-12 Thread Ashwini Sharma
Hi Rob,

 In the continuation to DHCP client sent to you last week, attached here
with is the DHCP server implementation.

Have a look at the same and let me know for any comments.

regards,
Ashwini


udhcpd.c.patch
Description: Binary data
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] [New Toy] : add udhcpd

2013-08-12 Thread Isaac
On Mon, Aug 12, 2013 at 06:29:25PM +0900, Ashwini Sharma wrote:
 Hi Rob,
 
  In the continuation to DHCP client sent to you last week, attached here
 with is the DHCP server implementation.
 
 Have a look at the same and let me know for any comments.
 
 regards,
 Ashwini

Note: these are my comments and not Rob's.

I note that not all of the uses of goto are neccessary.
Here's an example of what I refer to:

  if (buffer[0] == '#' || buffer[0] == '\n') goto free_buffer;
  //parse buffer here
free_buffer:
  free(buffer);

can readily become
  if (buffer[0] != '#'  buffer[0] != '\n') {
//parse buffer here
  }
  free(buffer);

Of course, for a buffer there's toybuf, which is not to be free()ed.

There will be places where you need to use goto if you don't check 
3 different variables, but for cases where you aren't jumping out of 
a loop, the if () {} approach makes it much clearer that the code
is conditionally executed.

Thanks,
Isaac Dunham
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net