[BusyBox-cvs] busybox/networking/udhcp dhcpc.c, 1.13, 1.14 dumpleases.c, 1.5, 1.6 libbb_udhcp.h, 1.3, 1.4

Russ Dill russ at busybox.net
Tue Dec 16 02:28:22 UTC 2003


Update of /var/cvs/busybox/networking/udhcp
In directory nail:/tmp/cvs-serv7848

Modified Files:
	dhcpc.c dumpleases.c libbb_udhcp.h 
Log Message:
start attempting to bring udhcp in busybox back to the state where it is (ideally) an exact copy of udhcp outside of busybox so that its easy to merge back and forth

Index: dhcpc.c
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/dhcpc.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- dhcpc.c	1 Sep 2003 04:08:36 -0000	1.13
+++ dhcpc.c	16 Dec 2003 02:28:20 -0000	1.14
@@ -75,6 +75,35 @@
 	arp: "\0\0\0\0\0\0",		/* appease gcc-3.0 */
 };
 
+#ifndef IN_BUSYBOX
+static void __attribute__ ((noreturn)) show_usage(void)
+{
+        printf(
+"Usage: udhcpc [OPTIONS]\n\n"
+"  -c, --clientid=CLIENTID         Client identifier\n"
+"  -H, --hostname=HOSTNAME         Client hostname\n"
+"  -h                              Alias for -H\n"
+"  -f, --foreground                Do not fork after getting lease\n"
+"  -b, --background                Fork to background if lease cannot be\n"
+"                                  immediately negotiated.\n"
+"  -i, --interface=INTERFACE       Interface to use (default: eth0)\n"
+"  -n, --now                       Exit with failure if lease cannot be\n"
+"                                  immediately negotiated.\n"
+"  -p, --pidfile=file              Store process ID of daemon in file\n"
+"  -q, --quit                      Quit after obtaining lease\n"
+"  -r, --request=IP                IP address to request (default: none)\n"
+"  -s, --script=file               Run file at dhcp events (default:\n"
+"                                  " DEFAULT_SCRIPT ")\n"
+"  -v, --version                   Display version\n"
+        );
+        exit(0);
+}
+#else
+#define show_usage bb_show_usage
+extern void show_usage(void) __attribute__ ((noreturn));
+#endif
+
+
 /* just a little helper */
 static void change_mode(int new_mode)
 {
@@ -233,7 +262,7 @@
 			return(0);
 			break;
 		default:
-			bb_show_usage();
+			show_usage();
 		}
 	}
 

Index: dumpleases.c
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/dumpleases.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dumpleases.c	10 Jun 2003 17:22:49 -0000	1.5
+++ dumpleases.c	16 Dec 2003 02:28:20 -0000	1.6
@@ -1,6 +1,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <sys/wait.h>
 #include <arpa/inet.h>
 #include <netdb.h>
@@ -12,12 +13,32 @@
 #include <time.h>
 
 #include "leases.h"
-#include "busybox.h"
+#include "libbb_udhcp.h"
 
 #define REMAINING 0
 #define ABSOLUTE 1
 
+
+#ifndef IN_BUSYBOX
+static void __attribute__ ((noreturn)) show_usage(void)
+{
+	printf(
+"Usage: dumpleases -f <file> -[r|a]\n\n"
+"  -f, --file=FILENAME             Leases file to load\n"
+"  -r, --remaining                 Interepret lease times as time remaing\n"
+"  -a, --absolute                  Interepret lease times as expire time\n");
+	exit(0);
+}
+#else
+#define show_usage bb_show_usage
+#endif
+
+
+#ifdef IN_BUSYBOX
 int dumpleases_main(int argc, char *argv[])
+#else
+int main(int argc, char *argv[])
+#endif
 {
 	FILE *fp;
 	int i, c, mode = REMAINING;
@@ -42,14 +63,14 @@
 		case 'a': mode = ABSOLUTE; break;
 		case 'r': mode = REMAINING; break;
 		case 'f':
-			file =  optarg;
+			file = optarg;
 			break;
 		default:
-			bb_show_usage();
+			show_usage();
 		}
 	}
 			
-	fp = bb_xfopen(file, "r");
+	fp = xfopen(file, "r");
 
 	printf("Mac Address       IP-Address      Expires %s\n", mode == REMAINING ? "in" : "at");  
 	/*     "00:00:00:00:00:00 255.255.255.255 Wed Jun 30 21:49:08 1993" */

Index: libbb_udhcp.h
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/libbb_udhcp.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- libbb_udhcp.h	11 Dec 2002 22:43:37 -0000	1.3
+++ libbb_udhcp.h	16 Dec 2003 02:28:20 -0000	1.4
@@ -4,7 +4,7 @@
 #define _LIBBB_UDHCP_H
 
 #ifdef IN_BUSYBOX
-#include "libbb.h"
+#include "busybox.h"
 
 #ifdef CONFIG_FEATURE_UDHCP_SYSLOG
 #define SYSLOG
@@ -17,12 +17,36 @@
 #define COMBINED_BINARY
 #include "version.h"
 
+#ifdef CONFIG_INSTALL_NO_USR
+#define DEFAULT_SCRIPT  "/share/udhcpc/default.script"
+#else
+#define DEFAULT_SCRIPT  "/usr/share/udhcpc/default.script"
+#endif
+
+#define xfopen bb_xfopen
+
 #else /* ! BB_VER */
 
+#include <stdlib.h>
+#include <stdio.h>
+
 #define TRUE			1
 #define FALSE			0
 
 #define xmalloc malloc
+#define xcalloc calloc
+
+#define DEFAULT_SCRIPT  "/usr/share/udhcpc/default.script"
+
+static inline FILE *xfopen(const char *file, const char *mode)
+{
+	FILE *fp;
+	if (!(fp = fopen(file, mode))) {
+		perror("could not open input file");
+		exit(0);
+	}
+	return fp;
+}
 
 #endif /* BB_VER */
 




More information about the busybox-cvs mailing list