guix-commits
[Top][All Lists]
Advanced

[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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]