[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dhcp] 12/12: dhcp: client code, incomplete
From: |
Rohan Prinja |
Subject: |
[dhcp] 12/12: dhcp: client code, incomplete |
Date: |
Sat, 06 Jun 2015 18:16:59 +0000 |
wenderen pushed a commit to branch master
in repository dhcp.
commit d6b11ddb00a599ccd9c0c9a3f3240e6f4a3e4e9f
Author: Rohan Prinja <address@hidden>
Date: Sat Jun 6 23:46:47 2015 +0530
dhcp: client code, incomplete
---
dhcp/client.scm | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/dhcp/client.scm b/dhcp/client.scm
new file mode 100644
index 0000000..be613e2
--- /dev/null
+++ b/dhcp/client.scm
@@ -0,0 +1,56 @@
+#!/usr/local/bin/guile \
+-e main -s
+coding: utf-8
+!#
+
+(add-to-load-path (string-append (dirname (current-filename))
+ "/.."))
+
+; DHCP client module
+(define-module (dhcp client))
+
+(use-modules (dhcp dhcp)
+ (ice-9 getopt-long)
+ (dhcp messages))
+
+(define *help-message* "\
+dhcp-client [options]
+ -v, --version Display version
+ -h, --help Display this help
+")
+
+(define (main args)
+ "Process command-line arguments and run the client"
+ (let* ((option-spec '((version (value #f))
+ (help (single-char #\h))
+ (four (single-char #\4) (value #t))
+ (six (single-char #\6))
+ (verbose)
+ (release)
+ (foreground (single-char #\d))
+ (continue-running (single-char #\w))
+ (no-wait)
+ (stop (single-char #\x))
+ (port (single-char #\p) (value #t))
+ (server-addr (single-char #\s) (value #t))))
+ (options (getopt-long args option-spec))
+ (help-wanted (option-ref options 'help #f))
+ (version-wanted (option-ref options 'version #f)))
+ (if (or version-wanted help-wanted)
+ (begin
+ (if version-wanted
+ (display "dhcp-client version 0.1\n"))
+ (if help-wanted
+ (display *help-message*)))
+ (begin
+ (display "Hello, World!") (newline)))))
+
+; Seed the random state.
+(set! *random-state* (random-state-from-platform))
+
+(define (generate-xid)
+ "Generate a random 32-bit number to be used as a transaction id."
+ (random (expt 2 32)))
+
+; Generate initial transaction id.
+(define xid (generate-xid))
- [dhcp] 02/12: dhcp: tell git to ignore log files, (continued)
- [dhcp] 02/12: dhcp: tell git to ignore log files, Rohan Prinja, 2015/06/06
- [dhcp] 05/12: dhcp: add in deprecated time-offset option, Rohan Prinja, 2015/06/06
- [dhcp] 01/12: dhcp: arp hardware address identifiers, Rohan Prinja, 2015/06/06
- [dhcp] 04/12: dhcp: change module names to reflect directory structure, Rohan Prinja, 2015/06/06
- [dhcp] 08/12: dhcp: code for sending packets, incomplete, untested, Rohan Prinja, 2015/06/06
- [dhcp] 10/12: dhcp: source for .so, used by some now-redundant functions in interfaces.scm, Rohan Prinja, 2015/06/06
- [dhcp] 06/12: dhcp: packet objects, untested, Rohan Prinja, 2015/06/06
- [dhcp] 03/12: dhcp: add unused and private-use options, fix some other mistakes, Rohan Prinja, 2015/06/06
- [dhcp] 09/12: dhcp: dhcp configuration objects, Rohan Prinja, 2015/06/06
- [dhcp] 07/12: dhcp: code to read info about network interfaces, untested, Rohan Prinja, 2015/06/06
- [dhcp] 12/12: dhcp: client code, incomplete,
Rohan Prinja <=
- [dhcp] 11/12: dhcp: tests for the (dhcp *) modules, incomplete, Rohan Prinja, 2015/06/06