Re: [Toybox] add dumpleases

2013-08-13 Thread Isaac
On Wed, Aug 14, 2013 at 12:37:18PM +0900, Ashwini Sharma wrote:
> Hi Rob,
> 
> Attached is the patch for dumpleases.
> 
> Utility to dump all the lease details onto STDOUT in a human readable
> format.
> This completes the package for DHCP client and server.

I note that in a pedantic sense, there's more to do: default.script 
needs to call either (ifconfig and route) or ((ip addr) and (ip route)).
This means sometime route needs to be written.

But thanks for writing the DHCP software.

> Have a look at the same and add to the tree, if found good and suitable.

I'm not an expert, but it seems good to me after a one-minute scan...


Thanks,
Isaac Dunham

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


Re: [Toybox] Build issue for OPTSTR_

2013-08-13 Thread Isaac
On Wed, Aug 14, 2013 at 12:06:42PM +0900, Ashwini Sharma wrote:
> Hi Rob,
> 
> The build fails for OPTSTR_ usage.
> 
> Testcase: select grep in config for build.
> 
> Error:
> In file included from main.c:16:0:
> generated/newtoys.h:27:1: error: 'OPTSTR_grep' undeclared here (not in a
> function)
> make: *** [toybox] Error 1
> 
> I guess you missed to include __generated/oldtoys.h__ in __toys.h__

+#include "generated/oldtoys.h"
#include "generated/newtoys.h"

in main.c works here.
> 
> Thanks,
> Ashwini

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

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


[Toybox] add dumpleases

2013-08-13 Thread Ashwini Sharma
Hi Rob,

Attached is the patch for dumpleases.

Utility to dump all the lease details onto STDOUT in a human readable
format.
This completes the package for DHCP client and server.

Have a look at the same and add to the tree, if found good and suitable.

Thanks,
Ashwini


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


[Toybox] Build issue for OPTSTR_

2013-08-13 Thread Ashwini Sharma
Hi Rob,

The build fails for OPTSTR_ usage.

Testcase: select grep in config for build.

Error:
In file included from main.c:16:0:
generated/newtoys.h:27:1: error: 'OPTSTR_grep' undeclared here (not in a
function)
make: *** [toybox] Error 1

I guess you missed to include __generated/oldtoys.h__ in __toys.h__

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


[Toybox] [patch] add install

2013-08-13 Thread Strake
>From f147c9618914a6dbfe41eea04329e7243629d1fe Mon Sep 17 00:00:00 2001
From: Strake 
Date: Wed, 14 Aug 2013 00:52:40 +
Subject: [PATCH] add install

---
 lib/lib.h  |  3 ++
 lib/pending.c  | 11 +++
 toys/pending/install.c | 86 ++
 3 files changed, 100 insertions(+)
 create mode 100644 toys/pending/install.c

diff --git a/lib/lib.h b/lib/lib.h
index f66a70c..12a8c98 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -202,3 +202,6 @@ unsigned long get_int_value(const char *numstr,
unsigned lowrange, unsigned high
 // grep helper functions
 char  *astrcat (char *, char *);
 char *xastrcat (char *, char *);
+
+// pending
+int xsspawnv (char **);
diff --git a/lib/pending.c b/lib/pending.c
index fad1c65..89ed260 100644
--- a/lib/pending.c
+++ b/lib/pending.c
@@ -102,3 +102,14 @@ char *xastrcat (char *x, char *y) {
   if (!x) error_exit ("xastrcat");
   return x;
 }
+
+int xsspawnv (char **argu) {
+  pid_t pid;
+  int c;
+
+  pid = fork ();
+  if (pid < 0) perror_exit ("failed to fork");
+  if (!pid) xexec (argu);
+  if (waitpid (pid, &c, 0) < 0) perror_exit ("failed to wait");
+  return c;
+}
diff --git a/toys/pending/install.c b/toys/pending/install.c
new file mode 100644
index 000..cde5bac
--- /dev/null
+++ b/toys/pending/install.c
@@ -0,0 +1,86 @@
+/* install.c - install files
+ *
+ * Copyright 2013 CE Strake 
+ *
+ * See 
http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/cmdbehav.html
+
+USE_INSTALL(NEWTOY(install, "Dcdg:m:o:t:[!dt]", TOYFLAG_BIN))
+
+config INSTALL
+  bool "install"
+  default n
+  help
+usage: install [-D] [-m mode] [-g grp] [-o usr] (src tgt | src...
dir | -t dir src... | -d dir...)
+
+forms:
+  install src tgt   install src as tgt
+  install -t dir src... install all srcs into dir
+  install -d dir... mk all dirs
+
+flags:
+  -D create all needed directories
+  -m modechmod mode
+  -g grp chgrp grp
+  -o usr chown usr
+*/
+
+#define FOR_install
+#include "toys.h"
+
+GLOBALS(
+  char *tArgu;
+  char *oArgu;
+  char *mArgu;
+  char *gArgu;
+)
+
+static void chxs (char *path) {
+  if (toys.optflags & FLAG_m) xsspawnv ((char *[]){ "chmod", "--",
TT.mArgu, path, 0 });
+  if (toys.optflags & FLAG_g) xsspawnv ((char *[]){ "chown", "--",
TT.gArgu, path, 0 });
+  if (toys.optflags & FLAG_o) xsspawnv ((char *[]){ "chgrp", "--",
TT.oArgu, path, 0 });
+}
+
+void install_main () {
+  int ii;
+
+  if (!(toys.optflags & (FLAG_t | FLAG_d))) {
+if (toys.optc < 2) error_exit ("too few arguments");
+if (toys.optc > 2) {
+  toys.optflags |= FLAG_t;
+  TT.tArgu = toys.optargs[toys.optc - 1];
+  toys.optargs[--toys.optc] = 0;
+}
+else {
+  if (toys.optflags & FLAG_D) {
+char *p;
+p = strrchr (toys.optargs[1], '/');
+if (p) p[0] = 0;
+xmkpath (toys.optargs[1], -1);
+p[0] = '/';
+  }
+  xexec ((char *[]){ "cp", "--", toys.optargs[0], toys.optargs[1], 0 });
+}
+  }
+
+  if (toys.optflags & FLAG_d) {
+for (ii = 0; ii < toys.optc; ii++) {
+  xmkpath (toys.optargs[ii], -1);
+  chxs (toys.optargs[ii]);
+}
+  }
+
+  if (toys.optflags & FLAG_t) {
+struct stat st;
+
+if (toys.optflags & FLAG_D) xmkpath (TT.tArgu, -1);
+xstat (TT.tArgu, &st);
+if (!S_ISDIR(st.st_mode)) error_exit ("not a directory: %s", TT.tArgu);
+for (ii = 0; ii < toys.optc; ii++) {
+  char *path;
+  path = xmsprintf ("%s/%s", TT.tArgu, basename (toys.optargs[ii]));
+  xsspawnv ((char *[]){ "cp", "--", toys.optargs[ii], path, 0 });
+  chxs (path);
+  free (path);
+}
+  }
+}
-- 
1.8.3.4
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


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 
#include 
#include 
regards,
Ashwini

On Tue, Aug 13, 2013 at 5:26 PM, Rob Landley  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


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

2013-08-13 Thread Rob Landley

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