Blame SOURCES/0007-Dhcpd-revert-Dhcpd-module-to-1.1.0-compatible-add-Dh.patch

c55e75
From c93dc5ca4c87f38772c98e3134ddc6662a98bc02 Mon Sep 17 00:00:00 2001
c2e930
From: Dominic Cleal <dcleal@redhat.com>
c2e930
Date: Fri, 12 Jun 2015 11:09:09 +0100
c2e930
Subject: [PATCH] Dhcpd: revert Dhcpd module to 1.1.0-compatible, add Dhcpd_140
c2e930
c2e930
In order to keep the default sshd config lens compatible with 1.1.0,
c2e930
the lens from 1.4.0 has been kept in the Dhcpd_140 module and is not
c2e930
loaded by default.  Use aug_transform, augtool --transform etc. to use
c2e930
it instead of Dhcpd.
c2e930
---
c2e930
 lenses/dhcpd.aug                | 182 +++---------
c2e930
 lenses/dhcpd_140.aug            | 512 +++++++++++++++++++++++++++++++++
c2e930
 lenses/tests/test_dhcpd.aug     | 214 +-------------
c2e930
 lenses/tests/test_dhcpd_140.aug | 606 ++++++++++++++++++++++++++++++++++++++++
c2e930
 tests/Makefile.am               |   1 +
c2e930
 5 files changed, 1152 insertions(+), 363 deletions(-)
c2e930
 create mode 100644 lenses/dhcpd_140.aug
c2e930
 create mode 100644 lenses/tests/test_dhcpd_140.aug
c2e930
c2e930
diff --git a/lenses/dhcpd.aug b/lenses/dhcpd.aug
c55e75
index f84a409c..21a5ce60 100644
c2e930
--- a/lenses/dhcpd.aug
c2e930
+++ b/lenses/dhcpd.aug
c2e930
@@ -65,12 +65,12 @@ let eos               = comment?
c2e930
 let sep_spc           = del /[ \t]+/ " "
c2e930
 let sep_osp           = del /[ \t]*/ ""
c2e930
 let sep_scl           = del /[ \t]*;([ \t]*\n)*/ ";\n"
c2e930
-let sep_obr           = del /[ \t\n]*\{([ \t]*\n)*/ " {\n"
c2e930
+let sep_obr           = del /[ \t]*\{([ \t]*\n)*/ " {\n"
c2e930
 let sep_cbr           = del /[ \t]*\}([ \t]*\n)*/ "}\n"
c2e930
 let sep_com           = del /[ \t\n]*,[ \t\n]*/ ", "
c2e930
 let sep_slh           = del "\/" "/"
c2e930
 let sep_col           = del ":" ":"
c2e930
-let sep_eq            = del /[ \t\n]*=[ \t\n]*/ "="
c2e930
+let sep_eq            = del /[ \t]*=[ \t]*/ "="
c2e930
 let scl               = del ";" ";"
c2e930
 
c2e930
 (* Define basic types *)
c2e930
@@ -94,11 +94,6 @@ let ip                = Rx.ipv4
c2e930
   let bare = del qchar? "" . store (bchar+) . del qchar? ""
c2e930
   let quote = Quote.do_quote (store (bchar* . /[ \t'\/]/ . bchar*)+)
c2e930
   let dquote = Quote.do_dquote (store (bchar+))
c2e930
-  (* these two are for special cases.  bare_to_scl is for any bareword that is
c2e930
-   * space or semicolon terminated.  dquote_any allows almost any character in
c2e930
-   * between the quotes. *)
c2e930
-  let bare_to_scl = Quote.do_dquote_opt (store /[^" \t\n;]+/)
c2e930
-  let dquote_any = Quote.do_dquote (store /[^"\n]*[ \t]+[^"\n]*/)
c2e930
 
c2e930
 let sto_to_spc        = store /[^\\#,;\{\}" \t\n]+|"[^\\#"\n]+"/
c2e930
 let sto_to_scl        = store /[^ \t;][^;\n=]+[^ \t;]|[^ \t;=]+/
c2e930
@@ -197,7 +192,6 @@ let stmt_string_re    = "ddns-update-style"
c2e930
                       | "use-lease-addr-for-default-route"
c2e930
                       | "vendor-option-space"
c2e930
                       | "primary"
c2e930
-                      | "omapi-key"
c2e930
 
c2e930
 let stmt_string_tpl (kw:regexp) (l:lens) = [ indent
c2e930
                         . key kw
c2e930
@@ -230,51 +224,26 @@ let stmt_range        = [ indent
c2e930
 let stmt_hardware     = [ indent
c2e930
                         . key "hardware"
c2e930
                         . sep_spc
c2e930
-                        . [ label "type" . store /ethernet|tokenring|fddi/ ]
c2e930
+                        . [ label "type" . store /ethernet|tokenring/ ]
c2e930
                         . sep_spc
c2e930
                         . [ label "address" . store /[a-fA-F0-9:-]+/ ]
c2e930
                         . sep_scl
c2e930
                         . eos ]
c2e930
 
f375a7
-(************************************************************************
c2e930
- *                         SET STATEMENTS
c2e930
- *************************************************************************)
c2e930
-let stmt_set          = [ indent
c2e930
-                        . key "set"
c2e930
-                        . sep_spc
c2e930
-                        . store word
c2e930
-                        . sep_spc
c2e930
-                        . Sep.equal
c2e930
-                        . sep_spc
c2e930
-                        . [ label "value" . sto_to_scl ]
c2e930
-                        . sep_scl
c2e930
-                        . eos ]
c2e930
-
f375a7
 (************************************************************************
c2e930
  *                         OPTION STATEMENTS
c2e930
  *************************************************************************)
c2e930
 (* The general case is considering options as a list *)
c2e930
 
c2e930
+let stmt_option_code  = [ label "label" . store word . sep_spc ]
c2e930
+                        . [ key "code" . sep_spc . store word ]
c2e930
+                        . sep_eq
c2e930
+                        . [ label "type" . store word ]
c2e930
 
c2e930
-let stmt_option_value = /((array of[ \t]+)?(((un)?signed[ \t]+)?integer (8|16|32)|string|ip6?-address|boolean|domain-list|text)|encapsulate [A-Za-z0-9_.-]+)/
c2e930
 
c2e930
 let stmt_option_list  = ([ label "arg" . bare ] | [ label "arg" . quote ])
c2e930
                         . ( sep_com . ([ label "arg" . bare ] | [ label "arg" . quote ]))*
c2e930
 
c2e930
-let del_trail_spc = del /[ \t\n]*/ ""
c2e930
-
c2e930
-let stmt_record = counter "record" . Util.del_str "{"
c2e930
-                . sep_spc
c2e930
-                . ([seq "record" . store stmt_option_value . sep_com]*
c2e930
-                .  [seq "record" . store stmt_option_value . del_trail_spc])?
c2e930
-                . Util.del_str "}"
c2e930
-
c2e930
-let stmt_option_code  = [ label "label" . store word . sep_spc ]
c2e930
-                        . [ key "code" . sep_spc . store word ]
c2e930
-                        . sep_eq
c2e930
-                        . ([ label "type" . store stmt_option_value ]
c2e930
-                          |[ label "record" . stmt_record ]) 
c2e930
-
c2e930
 let stmt_option_basic = [ key word . sep_spc . stmt_option_list ]
c2e930
 let stmt_option_extra = [ key word . sep_spc . store /true|false/ . sep_spc . stmt_option_list ]
c2e930
 
c2e930
@@ -302,13 +271,10 @@ let stmt_option = stmt_option1 | stmt_option2
c2e930
 (* this statement is not well documented in the manual dhcpd.conf
c2e930
    we support basic use case *)
c2e930
 
c2e930
-let stmt_subclass = [ indent . key "subclass" . sep_spc 
c2e930
-                      . ( [ label "name" .  bare_to_scl ]|[ label "name" .  dquote_any ] )
c2e930
-                      . sep_spc 
c2e930
-                      . ( [ label "value" . bare_to_scl ]|[ label "value" . dquote_any ] ) 
c2e930
-                      . sep_scl 
c2e930
-                      . eos ]
c2e930
-
c2e930
+let stmt_subclass = [ indent . key "subclass" . sep_spc .
c2e930
+                      ([ label "name" . quote ]|
c2e930
+                       [ label "name" . bare ]) . sep_spc .
c2e930
+                       [ label "value" . bare ] . sep_scl . eos ]
c2e930
 
c2e930
 (************************************************************************
c2e930
  *                         ALLOW/DENY STATEMENTS
c2e930
@@ -316,18 +282,10 @@ let stmt_subclass = [ indent . key "subclass" . sep_spc
c2e930
 (* We have to use special key for allow/deny members of
c2e930
   to avoid ambiguity in the put direction *)
c2e930
 
c2e930
-let allow_deny_re     = /unknown(-|[ ]+)clients/
c2e930
-                      | /known(-|[ ]+)clients/
c2e930
-                      | /all[ ]+clients/
c2e930
+let allow_deny_re     = "unknown-clients"
c2e930
                       | /dynamic[ ]+bootp[ ]+clients/
c2e930
                       | /authenticated[ ]+clients/
c2e930
                       | /unauthenticated[ ]+clients/
c2e930
-                      | "bootp"
c2e930
-                      | "booting"
c2e930
-                      | "duplicates"
c2e930
-                      | "declines"
c2e930
-                      | "client-updates"
c2e930
-                      | "leasequery"
c2e930
 
c2e930
 let stmt_secu_re      = "allow"
c2e930
                       | "deny"
c2e930
@@ -335,17 +293,9 @@ let stmt_secu_re      = "allow"
c2e930
 let del_allow = del /allow[ ]+members[ ]+of/ "allow members of"
c2e930
 let del_deny  = del /deny[ \t]+members[ \t]+of/ "deny members of"
c2e930
 
c2e930
-(* bare is anything but whitespace, quote marks or semicolon.
c2e930
- * technically this should be locked down to mostly alphanumerics, but the
c2e930
- * idea right now is just to make things work.  Also ideally I would use
c2e930
- * dquote_space but I had a whale of a time with it.  It doesn't like
c2e930
- * semicolon termination and my attempts to fix that led me to 3 hours of
c2e930
- * frustration and back to this :)
c2e930
- *)
c2e930
 let stmt_secu_tpl (l:lens) (s:string) =
c2e930
-                  [ indent . l . sep_spc . label s . bare_to_scl . sep_scl . eos ] |
c2e930
-                  [ indent . l . sep_spc . label s . dquote_any . sep_scl . eos ]
c2e930
-
c2e930
+                  [ indent . l . sep_spc . label s . bare . sep_scl . eos ] |
c2e930
+                  [ indent . l . sep_spc . label s . quote . sep_scl . eos ]
c2e930
 
c2e930
 let stmt_secu         = [ indent . key stmt_secu_re . sep_spc .
c2e930
                           store allow_deny_re . sep_scl . eos ] |
c2e930
@@ -356,62 +306,17 @@ let stmt_secu         = [ indent . key stmt_secu_re . sep_spc .
c2e930
  *                         MATCH STATEMENTS
c2e930
  *************************************************************************)
c2e930
 
c2e930
+let sto_fct = store (word . /[ \t]*\([^)]*\)/)
c2e930
+let sto_option = store (/option[ ]+/ . word)
c2e930
 let sto_com = /[^ \t\n,\(\)][^,\(\)]*[^ \t\n,\(\)]|[^ \t\n,\(\)]+/ | word . /[ \t]*\([^)]*\)/
c2e930
-(* this is already the most complicated part of this module and it's about to
c2e930
- * get worse.  match statements can be way more complicated than this
c2e930
- *
c2e930
- * examples:
c2e930
- *      using or:
c2e930
- *      match if ((option vendor-class-identifier="Banana Bready") or (option vendor-class-identifier="Cherry Sunfire"));
c2e930
- *      unneeded parenthesis:
c2e930
- *      match if (option vendor-class-identifier="Hello");
c2e930
- *
c2e930
- *      and of course the fact that the above two rules used one of infinately
c2e930
- *      many potential options instead of a builtin function.
c2e930
- *)
c2e930
-(* sto_com doesn't support quoted strings as arguments.  It also doesn't
c2e930
-   support single arguments (needs to match a comma) It will need to be
c2e930
-   updated for lcase, ucase and log to be workable.
c2e930
-
c2e930
-   it also doesn't support no arguments, so gethostbyname() doesn't work.
c2e930
-
c2e930
-   option and config-option are considered operators.  They should be matched
c2e930
-   in stmt_entry but also available under "match if" and "if" conditionals
c2e930
-   leased-address, host-decl-name, both take no args and return a value.  We
c2e930
-   might need to treat them as variable names in the parser.
c2e930
-
c2e930
-   things like this may be near-impossible to parse even with recursion
c2e930
-   because we have no way of knowing when or if a subfunction takes arguments
c2e930
-   set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
c2e930
-
c2e930
-   even if we could parse it, they could get arbitrarily complicated like:
c2e930
-   binary-to-ascii(16, 8, ":", substring(hardware, 1, 6) and substring(hardware, 2, 3));
c2e930
-
c2e930
-   so at some point we may need to programmatically knock it off and tell
c2e930
-   people to put weird stuff in an include file that augeas doesn't parse.
c2e930
-
c2e930
-   the other option is to change the API to not parse the if statement at all,
c2e930
-   just pull in the conditional as a string.
c2e930
- *)
c2e930
-
c2e930
-let fct_re = "substring" | "binary-to-ascii" | "suffix" | "lcase" | "ucase"
c2e930
-             | "gethostbyname" | "packet"
c2e930
-             | "concat" | "reverse" | "encode-int"
c2e930
-             | "extract-int" | "lease-time" | "client-state" | "exists" | "known" | "static"
c2e930
-             | "pick-first-value" | "log" | "execute"
c2e930
-
c2e930
-(* not needs to be different because it's a negation of whatever happens next *)
c2e930
-let op_re = "~="|"="|"~~"|"and"|"or"
c2e930
+let fct_re = "substring" | "binary-to-ascii"
c2e930
 
c2e930
 let fct_args = [ label "args" . dels "(" . sep_osp .
c2e930
                  ([ label "arg" . store sto_com ] . [ label "arg" . sep_com . store sto_com ]+) .
c2e930
                         sep_osp . dels ")" ]
c2e930
 
c2e930
-let stmt_match_ifopt = [ dels "if" . sep_spc . key "option" . sep_spc . store word .
c2e930
-                      sep_eq . ([ label "value" . bare_to_scl ]|[ label "value" . dquote_any ]) ]
c2e930
-
c2e930
-let stmt_match_func = [ store fct_re . sep_osp . label "function" . fct_args ] .
c2e930
-                      sep_eq . ([ label "value" . bare_to_scl ]|[ label "value" . dquote_any ])
c2e930
+let stmt_match_if = [ dels "if" . sep_spc . store fct_re . sep_osp . label "function" . fct_args ] .
c2e930
+                      sep_eq . ([ label "value" . bare ]|[ label "value" . quote ])
c2e930
 
c2e930
 let stmt_match_pfv = [ label "function" . store "pick-first-value" . sep_spc .
c2e930
                        dels "(" . sep_osp .
c2e930
@@ -422,7 +327,7 @@ let stmt_match_pfv = [ label "function" . store "pick-first-value" . sep_spc .
c2e930
 
c2e930
 let stmt_match_tpl (l:lens) = [ indent . key "match" . sep_spc . l . sep_scl . eos ]
c2e930
 
c2e930
-let stmt_match = stmt_match_tpl (dels "if" . sep_spc . stmt_match_func | stmt_match_pfv | stmt_match_ifopt)
c2e930
+let stmt_match = stmt_match_tpl (stmt_match_if | stmt_match_pfv )
c2e930
 
c2e930
 (************************************************************************
c2e930
  *                         BLOCK STATEMENTS
c2e930
@@ -438,11 +343,12 @@ let stmt_entry        =   stmt_secu
c2e930
                         | stmt_noarg
c2e930
                         | stmt_match
c2e930
                         | stmt_subclass
c2e930
-                        | stmt_set
c2e930
                         | empty
c2e930
                         | comment
c2e930
 
c2e930
-let stmt_block_noarg_re = "pool" | "group"
c2e930
+let stmt_block_noarg_re = "pool"
c2e930
+                        | "group"
c2e930
+                        | "allow-update"
c2e930
 
c2e930
 let stmt_block_noarg (body:lens)
c2e930
                         = [ indent
c2e930
@@ -456,14 +362,16 @@ let stmt_block_arg_re = "host"
c2e930
                       | "shared-network"
c2e930
                       | /failover[ ]+peer/
c2e930
                       | "zone"
c2e930
-                      | "group"
c2e930
-                      | "on"
c2e930
+                      | "key"
c2e930
 
c2e930
 let stmt_block_arg (body:lens)
c2e930
-                      = ([ indent . key stmt_block_arg_re . sep_spc . dquote_any . sep_obr . body* . sep_cbr ]
c2e930
-                         |[ indent . key stmt_block_arg_re . sep_spc . bare_to_scl . sep_obr . body* . sep_cbr ]
c2e930
-                         |[ indent . del /key/ "key" . label "key_block" . sep_spc . dquote_any . sep_obr . body* . sep_cbr . del /(;([ \t]*\n)*)?/ ""  ]
c2e930
-                         |[ indent . del /key/ "key" . label "key_block" . sep_spc . bare_to_scl . sep_obr . body* . sep_cbr . del /(;([ \t]*\n)*)?/ "" ])
c2e930
+                      = [ indent
c2e930
+                        . key stmt_block_arg_re
c2e930
+                        . sep_spc
c2e930
+                        . sto_to_spc
c2e930
+                        . sep_obr
c2e930
+                        . body*
c2e930
+                        . sep_cbr ]
c2e930
 
c2e930
 let stmt_block_subnet (body:lens)
c2e930
                       = [ indent
c2e930
@@ -476,37 +384,11 @@ let stmt_block_subnet (body:lens)
c2e930
                         . body*
c2e930
                         . sep_cbr ]
c2e930
 
c2e930
-let conditional (body:lens) =
c2e930
-     let condition         = /[^{ \r\t\n][^{\n]*[^{ \r\t\n]|[^{ \t\n\r]/
c2e930
-  in let elsif = [ indent
c2e930
-                 . Build.xchgs "elsif" "@elsif"
c2e930
-                 . sep_spc
c2e930
-                 . store condition
c2e930
-                 . sep_obr
c2e930
-                 . body*
c2e930
-                 . sep_cbr ]
c2e930
-  in let else = [  indent
c2e930
-                 . Build.xchgs "else" "@else"
c2e930
-                 . sep_obr
c2e930
-                 . body*
c2e930
-                 . sep_cbr ]
c2e930
-  in [ indent
c2e930
-     . Build.xchgs "if" "@if"
c2e930
-     . sep_spc
c2e930
-     . store condition
c2e930
-     . sep_obr
c2e930
-     . body*
c2e930
-     . sep_cbr
c2e930
-     . elsif*
c2e930
-     . else? ]
c2e930
-
c2e930
-
c2e930
 let all_block (body:lens) =
c2e930
     let lns1 = stmt_block_subnet body in
c2e930
     let lns2 = stmt_block_arg body in
c2e930
     let lns3 = stmt_block_noarg body in
c2e930
-    let lns4 = conditional body in
c2e930
-    (lns1 | lns2 | lns3 | lns4 | stmt_entry)
c2e930
+    (lns1 | lns2 | lns3 | stmt_entry)
c2e930
 
c2e930
 let rec lns_staging = stmt_entry|all_block lns_staging
c2e930
 let lns = (lns_staging)*
c2e930
diff --git a/lenses/dhcpd_140.aug b/lenses/dhcpd_140.aug
c2e930
new file mode 100644
c55e75
index 00000000..c9072990
c2e930
--- /dev/null
c2e930
+++ b/lenses/dhcpd_140.aug
c2e930
@@ -0,0 +1,512 @@
c2e930
+(*
c2e930
+Module: Dhcpd_140
c2e930
+  BIND dhcp 3 server configuration module for Augeas
c2e930
+
c2e930
+  This module is compatible with Augeas 1.4.0, but is not loaded by default.
c2e930
+
c2e930
+Author: Francis Giraldeau <francis.giraldeau@usherbrooke.ca>
c2e930
+
c2e930
+About: Reference
c2e930
+  Reference: manual of dhcpd.conf and dhcp-eval
c2e930
+  Follow dhclient module for tree structure
c2e930
+
c2e930
+About: License
c2e930
+    This file is licensed under the GPL.
c2e930
+
c2e930
+About: Lens Usage
c2e930
+  Sample usage of this lens in augtool
c2e930
+
c2e930
+  Directive without argument.
c2e930
+  Set this dhcpd server authoritative on the domain.
c2e930
+  > clear /files/etc/dhcp3/dhcpd.conf/authoritative
c2e930
+
c2e930
+  Directives with integer or string argument.
c2e930
+  Set max-lease-time to one hour:
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/max-lease-time 3600
c2e930
+
c2e930
+  Options are declared as a list, even for single values.
c2e930
+  Set the domain of the network:
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name/arg example.org
c2e930
+  Set two name server:
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name-servers/arg[1] foo.example.org
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/option/domain-name-servers/arg[2] bar.example.org
c2e930
+
c2e930
+  Create the subnet 172.16.0.1 with 10 addresses:
c2e930
+  > clear /files/etc/dhcp3/dhcpd.conf/subnet[last() + 1]
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/network 172.16.0.0
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/netmask 255.255.255.0
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/range/from 172.16.0.10
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[last()]/range/to 172.16.0.20
c2e930
+
c2e930
+  Create a new group "foo" with one static host. Nodes type and address are ordered.
c2e930
+  > ins group after /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/*[last()]
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[last()]/host foo
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/hardware/type "ethernet"
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/hardware/address "00:00:00:aa:bb:cc"
c2e930
+  > set /files/etc/dhcp3/dhcpd.conf/subnet[network='172.16.0.0']/group[host='foo']/host/fixed-address 172.16.0.100
c2e930
+
c2e930
+About: Configuration files
c2e930
+  This lens applies to /etc/dhcpd3/dhcpd.conf. See <filter>.
c2e930
+*)
c2e930
+
c2e930
+module Dhcpd_140 =
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                           USEFUL PRIMITIVES
c2e930
+ *************************************************************************)
c2e930
+let dels (s:string)   = del s s
c2e930
+let eol               = Util.eol
c2e930
+let comment           = Util.comment
c2e930
+let empty             = Util.empty
c2e930
+let indent            = Util.indent
c2e930
+let eos               = comment?
c2e930
+
c2e930
+(* Define separators *)
c2e930
+let sep_spc           = del /[ \t]+/ " "
c2e930
+let sep_osp           = del /[ \t]*/ ""
c2e930
+let sep_scl           = del /[ \t]*;([ \t]*\n)*/ ";\n"
c2e930
+let sep_obr           = del /[ \t\n]*\{([ \t]*\n)*/ " {\n"
c2e930
+let sep_cbr           = del /[ \t]*\}([ \t]*\n)*/ "}\n"
c2e930
+let sep_com           = del /[ \t\n]*,[ \t\n]*/ ", "
c2e930
+let sep_slh           = del "\/" "/"
c2e930
+let sep_col           = del ":" ":"
c2e930
+let sep_eq            = del /[ \t\n]*=[ \t\n]*/ "="
c2e930
+let scl               = del ";" ";"
c2e930
+
c2e930
+(* Define basic types *)
c2e930
+let word              = /[A-Za-z0-9_.-]+(\[[0-9]+\])?/
c2e930
+let ip                = Rx.ipv4
c2e930
+
c2e930
+(* Define fields *)
c2e930
+
c2e930
+(* adapted from sysconfig.aug *)
c2e930
+  (* Chars allowed in a bare string *)
c2e930
+  let bchar = /[^ \t\n"'\\{}#,()\/]|\\\\./
c2e930
+  let qchar = /["']/  (* " *)
c2e930
+
c2e930
+  (* We split the handling of right hand sides into a few cases:
c2e930
+   *   bare  - strings that contain no spaces, optionally enclosed in
c2e930
+   *           single or double quotes
c2e930
+   *   dquot - strings that contain at least one space, apostrophe or slash
c2e930
+   *           which must be enclosed in double quotes
c2e930
+   *   squot - strings that contain an unescaped double quote
c2e930
+   *)
c2e930
+  let bare = del qchar? "" . store (bchar+) . del qchar? ""
c2e930
+  let quote = Quote.do_quote (store (bchar* . /[ \t'\/]/ . bchar*)+)
c2e930
+  let dquote = Quote.do_dquote (store (bchar+))
c2e930
+  (* these two are for special cases.  bare_to_scl is for any bareword that is
c2e930
+   * space or semicolon terminated.  dquote_any allows almost any character in
c2e930
+   * between the quotes. *)
c2e930
+  let bare_to_scl = Quote.do_dquote_opt (store /[^" \t\n;]+/)
c2e930
+  let dquote_any = Quote.do_dquote (store /[^"\n]*[ \t]+[^"\n]*/)
c2e930
+
c2e930
+let sto_to_spc        = store /[^\\#,;\{\}" \t\n]+|"[^\\#"\n]+"/
c2e930
+let sto_to_scl        = store /[^ \t;][^;\n=]+[^ \t;]|[^ \t;=]+/
c2e930
+
c2e930
+let sto_number        = store /[0-9][0-9]*/
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         NO ARG STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+
c2e930
+let stmt_noarg_re     =   "authoritative"
c2e930
+                        | "primary"
c2e930
+                        | "secondary"
c2e930
+
c2e930
+let stmt_noarg        = [ indent
c2e930
+                        . key stmt_noarg_re
c2e930
+                        . sep_scl
c2e930
+                        . eos ]
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         INT ARG STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+
c2e930
+let stmt_integer_re   = "default-lease-time"
c2e930
+                      | "max-lease-time"
c2e930
+                      | "min-lease-time"
c2e930
+                      | /lease[ ]+limit/
c2e930
+                      | "port"
c2e930
+                      | /peer[ ]+port/
c2e930
+                      | "max-response-delay"
c2e930
+                      | "max-unacked-updates"
c2e930
+                      | "mclt"
c2e930
+                      | "split"
c2e930
+                      | /load[ ]+balance[ ]+max[ ]+seconds/
c2e930
+                      | "max-lease-misbalance"
c2e930
+                      | "max-lease-ownership"
c2e930
+                      | "min-balance"
c2e930
+                      | "max-balance"
c2e930
+                      | "adaptive-lease-time-threshold"
c2e930
+                      | "dynamic-bootp-lease-length"
c2e930
+                      | "local-port"
c2e930
+                      | "min-sec"
c2e930
+                      | "omapi-port"
c2e930
+                      | "ping-timeout"
c2e930
+                      | "remote-port"
c2e930
+
c2e930
+let stmt_integer      = [ indent
c2e930
+                        . key stmt_integer_re
c2e930
+                        . sep_spc
c2e930
+                        . sto_number
c2e930
+                        . sep_scl
c2e930
+                        . eos ]
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         STRING ARG STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+
c2e930
+let stmt_string_re    = "ddns-update-style"
c2e930
+                      | "ddns-updates"
c2e930
+                      | "ddns-hostname"
c2e930
+                      | "ddns-domainname"
c2e930
+                      | "ddns-rev-domainname"
c2e930
+                      | "log-facility"
c2e930
+                      | "server-name"
c2e930
+                      | "fixed-address"
c2e930
+                      | /failover[ ]+peer/
c2e930
+                      | "use-host-decl-names"
c2e930
+                      | "next-server"
c2e930
+                      | "address"
c2e930
+                      | /peer[ ]+address/
c2e930
+                      | "type"
c2e930
+                      | "file"
c2e930
+                      | "algorithm"
c2e930
+                      | "secret"
c2e930
+                      | "key"
c2e930
+                      | "include"
c2e930
+                      | "hba"
c2e930
+                      | "boot-unknown-clients"
c2e930
+                      | "db-time-format"
c2e930
+                      | "do-forward-updates"
c2e930
+                      | "dynamic-bootp-lease-cutoff"
c2e930
+                      | "get-lease-hostnames"
c2e930
+                      | "infinite-is-reserved"
c2e930
+                      | "lease-file-name"
c2e930
+                      | "local-address"
c2e930
+                      | "one-lease-per-client"
c2e930
+                      | "pid-file-name"
c2e930
+                      | "ping-check"
c2e930
+                      | "server-identifier"
c2e930
+                      | "site-option-space"
c2e930
+                      | "stash-agent-options"
c2e930
+                      | "update-conflict-detection"
c2e930
+                      | "update-optimization"
c2e930
+                      | "update-static-leases"
c2e930
+                      | "use-host-decl-names"
c2e930
+                      | "use-lease-addr-for-default-route"
c2e930
+                      | "vendor-option-space"
c2e930
+                      | "primary"
c2e930
+                      | "omapi-key"
c2e930
+
c2e930
+let stmt_string_tpl (kw:regexp) (l:lens) = [ indent
c2e930
+                        . key kw
c2e930
+                        . sep_spc
c2e930
+                        . l
c2e930
+                        . sep_scl
c2e930
+                        . eos ]
c2e930
+
c2e930
+let stmt_string  = stmt_string_tpl stmt_string_re bare
c2e930
+                 | stmt_string_tpl stmt_string_re quote
c2e930
+                 | stmt_string_tpl "filename" dquote
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         RANGE STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+
c2e930
+let stmt_range        = [ indent
c2e930
+                        . key "range"
c2e930
+                        . sep_spc
c2e930
+                        . [ label "flag" . store /dynamic-bootp/ . sep_spc ]?
c2e930
+                        . [ label "from" . store ip . sep_spc ]?
c2e930
+                        . [ label "to" . store ip ]
c2e930
+                        . sep_scl
c2e930
+                        . eos ]
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         HARDWARE STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+
c2e930
+let stmt_hardware     = [ indent
c2e930
+                        . key "hardware"
c2e930
+                        . sep_spc
c2e930
+                        . [ label "type" . store /ethernet|tokenring|fddi/ ]
c2e930
+                        . sep_spc
c2e930
+                        . [ label "address" . store /[a-fA-F0-9:-]+/ ]
c2e930
+                        . sep_scl
c2e930
+                        . eos ]
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         SET STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+let stmt_set          = [ indent
c2e930
+                        . key "set"
c2e930
+                        . sep_spc
c2e930
+                        . store word
c2e930
+                        . sep_spc
c2e930
+                        . Sep.equal
c2e930
+                        . sep_spc
c2e930
+                        . [ label "value" . sto_to_scl ]
c2e930
+                        . sep_scl
c2e930
+                        . eos ]
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         OPTION STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+(* The general case is considering options as a list *)
c2e930
+
c2e930
+
c2e930
+let stmt_option_value = /((array of[ \t]+)?(((un)?signed[ \t]+)?integer (8|16|32)|string|ip6?-address|boolean|domain-list|text)|encapsulate [A-Za-z0-9_.-]+)/
c2e930
+
c2e930
+let stmt_option_list  = ([ label "arg" . bare ] | [ label "arg" . quote ])
c2e930
+                        . ( sep_com . ([ label "arg" . bare ] | [ label "arg" . quote ]))*
c2e930
+
c2e930
+let del_trail_spc = del /[ \t\n]*/ ""
c2e930
+
c2e930
+let stmt_record = counter "record" . Util.del_str "{"
c2e930
+                . sep_spc
c2e930
+                . ([seq "record" . store stmt_option_value . sep_com]*
c2e930
+                .  [seq "record" . store stmt_option_value . del_trail_spc])?
c2e930
+                . Util.del_str "}"
c2e930
+
c2e930
+let stmt_option_code  = [ label "label" . store word . sep_spc ]
c2e930
+                        . [ key "code" . sep_spc . store word ]
c2e930
+                        . sep_eq
c2e930
+                        . ([ label "type" . store stmt_option_value ]
c2e930
+                          |[ label "record" . stmt_record ]) 
c2e930
+
c2e930
+let stmt_option_basic = [ key word . sep_spc . stmt_option_list ]
c2e930
+let stmt_option_extra = [ key word . sep_spc . store /true|false/ . sep_spc . stmt_option_list ]
c2e930
+
c2e930
+let stmt_option_body = stmt_option_basic | stmt_option_extra
c2e930
+
c2e930
+let stmt_option1  = [ indent
c2e930
+                        . key "option"
c2e930
+                        . sep_spc
c2e930
+                        . stmt_option_body
c2e930
+                        . sep_scl
c2e930
+                        . eos ]
c2e930
+
c2e930
+let stmt_option2  = [ indent
c2e930
+                        . dels "option" . label "rfc-code"
c2e930
+                        . sep_spc
c2e930
+                        . stmt_option_code
c2e930
+                        . sep_scl
c2e930
+                        . eos ]
c2e930
+
c2e930
+let stmt_option = stmt_option1 | stmt_option2
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         SUBCLASS STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+(* this statement is not well documented in the manual dhcpd.conf
c2e930
+   we support basic use case *)
c2e930
+
c2e930
+let stmt_subclass = [ indent . key "subclass" . sep_spc 
c2e930
+                      . ( [ label "name" .  bare_to_scl ]|[ label "name" .  dquote_any ] )
c2e930
+                      . sep_spc 
c2e930
+                      . ( [ label "value" . bare_to_scl ]|[ label "value" . dquote_any ] ) 
c2e930
+                      . sep_scl 
c2e930
+                      . eos ]
c2e930
+
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         ALLOW/DENY STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+(* We have to use special key for allow/deny members of
c2e930
+  to avoid ambiguity in the put direction *)
c2e930
+
c2e930
+let allow_deny_re     = /unknown(-|[ ]+)clients/
c2e930
+                      | /known(-|[ ]+)clients/
c2e930
+                      | /all[ ]+clients/
c2e930
+                      | /dynamic[ ]+bootp[ ]+clients/
c2e930
+                      | /authenticated[ ]+clients/
c2e930
+                      | /unauthenticated[ ]+clients/
c2e930
+                      | "bootp"
c2e930
+                      | "booting"
c2e930
+                      | "duplicates"
c2e930
+                      | "declines"
c2e930
+                      | "client-updates"
c2e930
+                      | "leasequery"
c2e930
+
c2e930
+let stmt_secu_re      = "allow"
c2e930
+                      | "deny"
c2e930
+
c2e930
+let del_allow = del /allow[ ]+members[ ]+of/ "allow members of"
c2e930
+let del_deny  = del /deny[ \t]+members[ \t]+of/ "deny members of"
c2e930
+
c2e930
+(* bare is anything but whitespace, quote marks or semicolon.
c2e930
+ * technically this should be locked down to mostly alphanumerics, but the
c2e930
+ * idea right now is just to make things work.  Also ideally I would use
c2e930
+ * dquote_space but I had a whale of a time with it.  It doesn't like
c2e930
+ * semicolon termination and my attempts to fix that led me to 3 hours of
c2e930
+ * frustration and back to this :)
c2e930
+ *)
c2e930
+let stmt_secu_tpl (l:lens) (s:string) =
c2e930
+                  [ indent . l . sep_spc . label s . bare_to_scl . sep_scl . eos ] |
c2e930
+                  [ indent . l . sep_spc . label s . dquote_any . sep_scl . eos ]
c2e930
+
c2e930
+
c2e930
+let stmt_secu         = [ indent . key stmt_secu_re . sep_spc .
c2e930
+                          store allow_deny_re . sep_scl . eos ] |
c2e930
+                        stmt_secu_tpl del_allow "allow-members-of" |
c2e930
+                        stmt_secu_tpl del_deny "deny-members-of"
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         MATCH STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+
c2e930
+let sto_com = /[^ \t\n,\(\)][^,\(\)]*[^ \t\n,\(\)]|[^ \t\n,\(\)]+/ | word . /[ \t]*\([^)]*\)/
c2e930
+(* this is already the most complicated part of this module and it's about to
c2e930
+ * get worse.  match statements can be way more complicated than this
c2e930
+ *
c2e930
+ * examples:
c2e930
+ *      using or:
c2e930
+ *      match if ((option vendor-class-identifier="Banana Bready") or (option vendor-class-identifier="Cherry Sunfire"));
c2e930
+ *      unneeded parenthesis:
c2e930
+ *      match if (option vendor-class-identifier="Hello");
c2e930
+ *
c2e930
+ *      and of course the fact that the above two rules used one of infinately
c2e930
+ *      many potential options instead of a builtin function.
c2e930
+ *)
c2e930
+(* sto_com doesn't support quoted strings as arguments.  It also doesn't
c2e930
+   support single arguments (needs to match a comma) It will need to be
c2e930
+   updated for lcase, ucase and log to be workable.
c2e930
+
c2e930
+   it also doesn't support no arguments, so gethostbyname() doesn't work.
c2e930
+
c2e930
+   option and config-option are considered operators.  They should be matched
c2e930
+   in stmt_entry but also available under "match if" and "if" conditionals
c2e930
+   leased-address, host-decl-name, both take no args and return a value.  We
c2e930
+   might need to treat them as variable names in the parser.
c2e930
+
c2e930
+   things like this may be near-impossible to parse even with recursion
c2e930
+   because we have no way of knowing when or if a subfunction takes arguments
c2e930
+   set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
c2e930
+
c2e930
+   even if we could parse it, they could get arbitrarily complicated like:
c2e930
+   binary-to-ascii(16, 8, ":", substring(hardware, 1, 6) and substring(hardware, 2, 3));
c2e930
+
c2e930
+   so at some point we may need to programmatically knock it off and tell
c2e930
+   people to put weird stuff in an include file that augeas doesn't parse.
c2e930
+
c2e930
+   the other option is to change the API to not parse the if statement at all,
c2e930
+   just pull in the conditional as a string.
c2e930
+ *)
c2e930
+
c2e930
+let fct_re = "substring" | "binary-to-ascii" | "suffix" | "lcase" | "ucase"
c2e930
+             | "gethostbyname" | "packet"
c2e930
+             | "concat" | "reverse" | "encode-int"
c2e930
+             | "extract-int" | "lease-time" | "client-state" | "exists" | "known" | "static"
c2e930
+             | "pick-first-value" | "log" | "execute"
c2e930
+
c2e930
+(* not needs to be different because it's a negation of whatever happens next *)
c2e930
+let op_re = "~="|"="|"~~"|"and"|"or"
c2e930
+
c2e930
+let fct_args = [ label "args" . dels "(" . sep_osp .
c2e930
+                 ([ label "arg" . store sto_com ] . [ label "arg" . sep_com . store sto_com ]+) .
c2e930
+                        sep_osp . dels ")" ]
c2e930
+
c2e930
+let stmt_match_ifopt = [ dels "if" . sep_spc . key "option" . sep_spc . store word .
c2e930
+                      sep_eq . ([ label "value" . bare_to_scl ]|[ label "value" . dquote_any ]) ]
c2e930
+
c2e930
+let stmt_match_func = [ store fct_re . sep_osp . label "function" . fct_args ] .
c2e930
+                      sep_eq . ([ label "value" . bare_to_scl ]|[ label "value" . dquote_any ])
c2e930
+
c2e930
+let stmt_match_pfv = [ label "function" . store "pick-first-value" . sep_spc .
c2e930
+                       dels "(" . sep_osp .
c2e930
+                       [ label "args" .
c2e930
+                         [ label "arg" . store sto_com ] .
c2e930
+                         [ sep_com . label "arg" . store sto_com ]+ ] .
c2e930
+                       dels ")" ]
c2e930
+
c2e930
+let stmt_match_tpl (l:lens) = [ indent . key "match" . sep_spc . l . sep_scl . eos ]
c2e930
+
c2e930
+let stmt_match = stmt_match_tpl (dels "if" . sep_spc . stmt_match_func | stmt_match_pfv | stmt_match_ifopt)
c2e930
+
c2e930
+(************************************************************************
c2e930
+ *                         BLOCK STATEMENTS
c2e930
+ *************************************************************************)
c2e930
+(* Blocks doesn't support comments at the end of the closing bracket *)
c2e930
+
c2e930
+let stmt_entry        =   stmt_secu
c2e930
+                        | stmt_option
c2e930
+                        | stmt_hardware
c2e930
+                        | stmt_range
c2e930
+                        | stmt_string
c2e930
+                        | stmt_integer
c2e930
+                        | stmt_noarg
c2e930
+                        | stmt_match
c2e930
+                        | stmt_subclass
c2e930
+                        | stmt_set
c2e930
+                        | empty
c2e930
+                        | comment
c2e930
+
c2e930
+let stmt_block_noarg_re = "pool" | "group"
c2e930
+
c2e930
+let stmt_block_noarg (body:lens)
c2e930
+                        = [ indent
c2e930
+                        . key stmt_block_noarg_re
c2e930
+                        . sep_obr
c2e930
+                        . body*
c2e930
+                        . sep_cbr ]
c2e930
+
c2e930
+let stmt_block_arg_re = "host"
c2e930
+                      | "class"
c2e930
+                      | "shared-network"
c2e930
+                      | /failover[ ]+peer/
c2e930
+                      | "zone"
c2e930
+                      | "group"
c2e930
+                      | "on"
c2e930
+
c2e930
+let stmt_block_arg (body:lens)
c2e930
+                      = ([ indent . key stmt_block_arg_re . sep_spc . dquote_any . sep_obr . body* . sep_cbr ]
c2e930
+                         |[ indent . key stmt_block_arg_re . sep_spc . bare_to_scl . sep_obr . body* . sep_cbr ]
c2e930
+                         |[ indent . del /key/ "key" . label "key_block" . sep_spc . dquote_any . sep_obr . body* . sep_cbr . del /(;([ \t]*\n)*)?/ ""  ]
c2e930
+                         |[ indent . del /key/ "key" . label "key_block" . sep_spc . bare_to_scl . sep_obr . body* . sep_cbr . del /(;([ \t]*\n)*)?/ "" ])
c2e930
+
c2e930
+let stmt_block_subnet (body:lens)
c2e930
+                      = [ indent
c2e930
+                        . key "subnet"
c2e930
+                        . sep_spc
c2e930
+                        . [ label "network" . store ip ]
c2e930
+                        . sep_spc
c2e930
+                        . [ key "netmask" . sep_spc . store ip ]
c2e930
+                        . sep_obr
c2e930
+                        . body*
c2e930
+                        . sep_cbr ]
c2e930
+
c2e930
+let conditional (body:lens) =
c2e930
+     let condition         = /[^{ \r\t\n][^{\n]*[^{ \r\t\n]|[^{ \t\n\r]/
c2e930
+  in let elsif = [ indent
c2e930
+                 . Build.xchgs "elsif" "@elsif"
c2e930
+                 . sep_spc
c2e930
+                 . store condition
c2e930
+                 . sep_obr
c2e930
+                 . body*
c2e930
+                 . sep_cbr ]
c2e930
+  in let else = [  indent
c2e930
+                 . Build.xchgs "else" "@else"
c2e930
+                 . sep_obr
c2e930
+                 . body*
c2e930
+                 . sep_cbr ]
c2e930
+  in [ indent
c2e930
+     . Build.xchgs "if" "@if"
c2e930
+     . sep_spc
c2e930
+     . store condition
c2e930
+     . sep_obr
c2e930
+     . body*
c2e930
+     . sep_cbr
c2e930
+     . elsif*
c2e930
+     . else? ]
c2e930
+
c2e930
+
c2e930
+let all_block (body:lens) =
c2e930
+    let lns1 = stmt_block_subnet body in
c2e930
+    let lns2 = stmt_block_arg body in
c2e930
+    let lns3 = stmt_block_noarg body in
c2e930
+    let lns4 = conditional body in
c2e930
+    (lns1 | lns2 | lns3 | lns4 | stmt_entry)
c2e930
+
c2e930
+let rec lns_staging = stmt_entry|all_block lns_staging
c2e930
+let lns = (lns_staging)*
c2e930
diff --git a/lenses/tests/test_dhcpd.aug b/lenses/tests/test_dhcpd.aug
c55e75
index 0af337c2..96630296 100644
c2e930
--- a/lenses/tests/test_dhcpd.aug
c2e930
+++ b/lenses/tests/test_dhcpd.aug
c2e930
@@ -28,9 +28,6 @@ max-lease-time 7200;
c2e930
 # network, the authoritative directive should be uncommented.
c2e930
 authoritative;
c2e930
 
c2e930
-allow booting;
c2e930
-allow bootp;
c2e930
-
c2e930
 # Use this to send dhcp log messages to a different log file (you also
c2e930
 # have to hack syslog.conf to complete the redirection).
c2e930
 log-facility local7;
c2e930
@@ -182,12 +179,7 @@ fixed-address 10.1.1.1;}}" =
c2e930
     }
c2e930
   }
c2e930
 
c2e930
-test lns get "group fan-tas_tic { }" =
c2e930
-  { "group" = "fan-tas_tic" }
c2e930
-
c2e930
 test Dhcpd.stmt_secu get "allow members of \"foo\";" =  { "allow-members-of" = "foo" }
c2e930
-test Dhcpd.stmt_secu get "allow booting;" =  { "allow" = "booting" }
c2e930
-test Dhcpd.stmt_secu get "allow bootp;" =  { "allow" = "bootp" }
c2e930
 test Dhcpd.stmt_option get "option voip-boot-server code 66 = string;" =
c2e930
   { "rfc-code"
c2e930
     { "label" = "voip-boot-server" }
c2e930
@@ -195,30 +187,6 @@ test Dhcpd.stmt_option get "option voip-boot-server code 66 = string;" =
c2e930
     { "type" = "string" }
c2e930
   }
c2e930
 
c2e930
-test Dhcpd.stmt_option get "option special-option code 25 = array of string;" =
c2e930
-  { "rfc-code"
c2e930
-    { "label" = "special-option" }
c2e930
-    { "code" = "25" }
c2e930
-    { "type" = "array of string" }
c2e930
-  }
c2e930
-
c2e930
-test Dhcpd.stmt_option get "option special-option code 25 = integer 32;" =
c2e930
-  { "rfc-code"
c2e930
-    { "label" = "special-option" }
c2e930
-    { "code" = "25" }
c2e930
-    { "type" = "integer 32" }
c2e930
-  }
c2e930
-
c2e930
-
c2e930
-test Dhcpd.stmt_option get "option special-option code 25 = array of integer 32;" =
c2e930
-  { "rfc-code"
c2e930
-    { "label" = "special-option" }
c2e930
-    { "code" = "25" }
c2e930
-    { "type" = "array of integer 32" }
c2e930
-  }
c2e930
-
c2e930
-
c2e930
-
c2e930
 test Dhcpd.lns get "authoritative;
c2e930
 log-facility local7;
c2e930
 ddns-update-style none;
c2e930
@@ -274,7 +242,7 @@ failover peer \"redondance01\" {
c2e930
     }
c2e930
   }
c2e930
   { "next-server" = "10.1.1.1" }
c2e930
-  { "failover peer" = "redondance01"
c2e930
+  { "failover peer" = "\"redondance01\""
c2e930
     { "primary" }
c2e930
     { "address" = "10.1.1.1" }
c2e930
     { "port" = "647" }
c2e930
@@ -291,26 +259,6 @@ failover peer \"redondance01\" {
c2e930
     { "load balance max seconds" = "3" }
c2e930
   }
c2e930
 
c2e930
-
c2e930
-(* test get and put for record types *)
c2e930
-let record_test = "option test_records code 123 = { string, ip-address, integer 32, ip6-address, domain-list };"
c2e930
-
c2e930
-test Dhcpd.lns get record_test =
c2e930
- { "rfc-code"
c2e930
-   { "label" = "test_records" }
c2e930
-   { "code" = "123" }
c2e930
-     { "record"
c2e930
-        { "1" = "string" }
c2e930
-        { "2" = "ip-address" }
c2e930
-        { "3" = "integer 32" }
c2e930
-        { "4" = "ip6-address" }
c2e930
-        { "5" = "domain-list" }
c2e930
-     }
c2e930
- }
c2e930
-
c2e930
-test Dhcpd.lns put record_test after set "/rfc-code[1]/code" "124" = 
c2e930
-  "option test_records code 124 = { string, ip-address, integer 32, ip6-address, domain-list };"
c2e930
-
c2e930
 test Dhcpd.lns get "
c2e930
 option CallManager code 150 = ip-address;
c2e930
 option slp-directory-agent true 10.1.1.1, 10.2.2.2;
c2e930
@@ -386,25 +334,6 @@ test Dhcpd.stmt_match get "match if substring (option dhcp-client-identifier, 1,
c2e930
     { "value" = "RAS" }
c2e930
   }
c2e930
 
c2e930
-test Dhcpd.stmt_match get "match if suffix (option dhcp-client-identifier, 4) = \"RAS\";" =
c2e930
-  { "match"
c2e930
-    { "function" = "suffix"
c2e930
-      { "args"
c2e930
-        { "arg" = "option dhcp-client-identifier" }
c2e930
-        { "arg" = "4" }
c2e930
-      }
c2e930
-    }
c2e930
-    { "value" = "RAS" }
c2e930
-  }
c2e930
-
c2e930
-test Dhcpd.stmt_match get "match if option vendor-class-identifier=\"RAS\";" =
c2e930
-  { "match"
c2e930
-    { "option" = "vendor-class-identifier"
c2e930
-      { "value" = "RAS" }
c2e930
-    }
c2e930
-  }
c2e930
-
c2e930
-
c2e930
 test Dhcpd.lns get "match pick-first-value (option dhcp-client-identifier, hardware);" =
c2e930
   { "match"
c2e930
     { "function" = "pick-first-value"
c2e930
@@ -436,26 +365,12 @@ test Dhcpd.stmt_match get "match if binary-to-ascii(16, 32, \"\", substring(hard
c2e930
     { "value" = "1525400" }
c2e930
   }
c2e930
 
c2e930
-test Dhcpd.lns get "subclass allocation-class-1 1:8:0:2b:4c:39:ad;" =
c2e930
-  { "subclass"
c2e930
-    { "name" = "allocation-class-1" }
c2e930
-    { "value" = "1:8:0:2b:4c:39:ad" }
c2e930
-  }
c2e930
-
c2e930
-
c2e930
 test Dhcpd.lns get "subclass \"allocation-class-1\" 1:8:0:2b:4c:39:ad;" =
c2e930
   { "subclass"
c2e930
     { "name" = "allocation-class-1" }
c2e930
     { "value" = "1:8:0:2b:4c:39:ad" }
c2e930
   }
c2e930
 
c2e930
-test Dhcpd.lns get "subclass \"quoted class\" \"quoted value\";" =
c2e930
-  { "subclass"
c2e930
-    { "name" = "quoted class" }
c2e930
-    { "value" = "quoted value" }
c2e930
-  }
c2e930
-
c2e930
-
c2e930
 (* overall test *)
c2e930
 test Dhcpd.lns put conf after rm "/x" = conf
c2e930
 
c2e930
@@ -477,130 +392,3 @@ filename \"pxelinux.0\";
c2e930
 test Dhcpd.lns put "subnet 172.16.0.0 netmask 255.255.255.0 {
c2e930
 }" after
c2e930
   set "subnet/filename" "pxelinux.0" = input311
c2e930
-
c2e930
-(* GH issue #34: support conditional structures *)
c2e930
-let gh34_empty = "if exists dhcp-parameter-request-list {
c2e930
-}\n"
c2e930
-
c2e930
-test Dhcpd.lns get gh34_empty =
c2e930
-  { "@if" = "exists dhcp-parameter-request-list" }
c2e930
-
c2e930
-let gh34_empty_multi = "subnet 192.168.100.0 netmask 255.255.255.0 {
c2e930
- if true {
c2e930
- } elsif false {
c2e930
- } else {
c2e930
- }
c2e930
-}\n"
c2e930
-
c2e930
-test Dhcpd.lns get gh34_empty_multi =
c2e930
-  { "subnet"
c2e930
-    { "network" = "192.168.100.0" }
c2e930
-    { "netmask" = "255.255.255.0" }
c2e930
-    { "@if" = "true"
c2e930
-      { "@elsif" = "false" }
c2e930
-      { "@else" } }
c2e930
-  }
c2e930
-
c2e930
-let gh34_simple = "if exists dhcp-parameter-request-list {
c2e930
-  default-lease-time 600;
c2e930
-  } else {
c2e930
-default-lease-time 200;
c2e930
-}\n"
c2e930
-
c2e930
-test Dhcpd.lns get gh34_simple =
c2e930
-  { "@if" = "exists dhcp-parameter-request-list"
c2e930
-    { "default-lease-time" = "600" }
c2e930
-    { "@else"
c2e930
-      { "default-lease-time" = "200" } } }
c2e930
-
c2e930
-test Dhcpd.lns get "omapi-key fookey;" =
c2e930
-  { "omapi-key" = "fookey" }
c2e930
-
c2e930
-(* almost all DHCP groups should support braces starting on the next line *)
c2e930
-test Dhcpd.lns get "class introduction
c2e930
-{
c2e930
-}" =
c2e930
-  { "class" = "introduction" }
c2e930
-
c2e930
-(* equals should work the same *)
c2e930
-test Dhcpd.lns get "option test_records code 123 =
c2e930
-                             string;" =
c2e930
- { "rfc-code"
c2e930
-   { "label" = "test_records" }
c2e930
-   { "code" = "123" }
c2e930
-   { "type" = "string" }
c2e930
- }
c2e930
-
c2e930
-test Dhcpd.lns get "deny members of \"Are things like () allowed?\";" =
c2e930
-  { "deny-members-of" = "Are things like () allowed?" }
c2e930
-
c2e930
-test Dhcpd.lns get "deny unknown clients;" =
c2e930
-  { "deny" = "unknown clients" }
c2e930
-test Dhcpd.lns get "deny known-clients;" =
c2e930
-  { "deny" = "known-clients" }
c2e930
-
c2e930
-test Dhcpd.lns get "set ClientMac = binary-to-ascii(16, 8, \":\" , substring(hardware, 1, 6));" =
c2e930
-  { "set" = "ClientMac"
c2e930
-    { "value" = "binary-to-ascii(16, 8, \":\" , substring(hardware, 1, 6))" }
c2e930
-  }
c2e930
-
c2e930
-test Dhcpd.lns get "set myvariable = foo;" =
c2e930
-  { "set" = "myvariable"
c2e930
-    { "value" = "foo" }
c2e930
-  }
c2e930
-
c2e930
-test Dhcpd.stmt_hardware get "hardware fddi 00:01:02:03:04:05;" =
c2e930
-  { "hardware"
c2e930
-    { "type" = "fddi" }
c2e930
-    { "address" = "00:01:02:03:04:05" }
c2e930
-  }
c2e930
-
c2e930
-test Dhcpd.lns get "on commit
c2e930
-{
c2e930
-  set test = thing;
c2e930
-}" =
c2e930
-  { "on" = "commit"
c2e930
-    { "set" = "test"
c2e930
-      { "value" = "thing" }
c2e930
-    }
c2e930
-  }
c2e930
-
c2e930
-(* key block get/put/set test *)
c2e930
-let key_tests = "key sample {
c2e930
-    algorithm hmac-md5;
c2e930
-    secret \"secret==\";
c2e930
-}
c2e930
-
c2e930
-key \"interesting\" { };
c2e930
-
c2e930
-key \"third key\" {
c2e930
-    secret \"two==\";
c2e930
-}"
c2e930
-
c2e930
-test Dhcpd.lns get key_tests =
c2e930
-  { "key_block" = "sample"
c2e930
-    { "algorithm"  = "hmac-md5" }
c2e930
-    { "secret" = "secret==" }
c2e930
-  }
c2e930
-  { "key_block" = "interesting" }
c2e930
-  { "key_block" = "third key"
c2e930
-    { "secret" = "two==" }
c2e930
-  }
c2e930
-
c2e930
-test Dhcpd.lns put key_tests after set "/key_block[1]" "sample2" =
c2e930
-  "key sample2 {
c2e930
-    algorithm hmac-md5;
c2e930
-    secret \"secret==\";
c2e930
-}
c2e930
-
c2e930
-key \"interesting\" { };
c2e930
-
c2e930
-key \"third key\" {
c2e930
-    secret \"two==\";
c2e930
-}"
c2e930
-
c2e930
-test Dhcpd.lns get "group \"hello\" { }" =
c2e930
-  { "group" = "hello" }
c2e930
-
c2e930
-test Dhcpd.lns get "class \"testing class with spaces and quotes and ()\" {}" =
c2e930
-  { "class" = "testing class with spaces and quotes and ()" }
c2e930
diff --git a/lenses/tests/test_dhcpd_140.aug b/lenses/tests/test_dhcpd_140.aug
c2e930
new file mode 100644
c55e75
index 00000000..9d6fdc88
c2e930
--- /dev/null
c2e930
+++ b/lenses/tests/test_dhcpd_140.aug
c2e930
@@ -0,0 +1,606 @@
c2e930
+module Test_dhcpd_140 =
c2e930
+
c2e930
+let lns = Dhcpd_140.lns
c2e930
+
c2e930
+let conf = "#
c2e930
+# Sample configuration file for ISC dhcpd for Debian
c2e930
+#
c2e930
+# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
c2e930
+# configuration file instead of this file.
c2e930
+#
c2e930
+# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
c2e930
+#
c2e930
+
c2e930
+# The ddns-updates-style parameter controls whether or not the server will
c2e930
+# attempt to do a DNS update when a lease is confirmed. We default to the
c2e930
+# behavior of the version 2 packages ('none', since DHCP v2 didn't
c2e930
+# have support for DDNS.)
c2e930
+ddns-update-style none;
c2e930
+
c2e930
+# option definitions common to all supported networks...
c2e930
+option domain-name \"example.org\";
c2e930
+option domain-name-servers ns1.example.org, ns2.example.org;
c2e930
+
c2e930
+default-lease-time 600;
c2e930
+max-lease-time 7200;
c2e930
+
c2e930
+# If this DHCP server is the official DHCP server for the local
c2e930
+# network, the authoritative directive should be uncommented.
c2e930
+authoritative;
c2e930
+
c2e930
+allow booting;
c2e930
+allow bootp;
c2e930
+
c2e930
+# Use this to send dhcp log messages to a different log file (you also
c2e930
+# have to hack syslog.conf to complete the redirection).
c2e930
+log-facility local7;
c2e930
+
c2e930
+# No service will be given on this subnet, but declaring it helps the
c2e930
+# DHCP server to understand the network topology.
c2e930
+
c2e930
+subnet 10.152.187.0 netmask 255.255.255.0 {
c2e930
+}
c2e930
+
c2e930
+# This is a very basic subnet declaration.
c2e930
+
c2e930
+subnet 10.254.239.0 netmask 255.255.255.224 {
c2e930
+  range 10.254.239.10 10.254.239.20;
c2e930
+  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
c2e930
+}
c2e930
+
c2e930
+# This declaration allows BOOTP clients to get dynamic addresses,
c2e930
+# which we don't really recommend.
c2e930
+
c2e930
+subnet 10.254.239.32 netmask 255.255.255.224 {
c2e930
+  range dynamic-bootp 10.254.239.40 10.254.239.60;
c2e930
+  option broadcast-address 10.254.239.31;
c2e930
+  option routers rtr-239-32-1.example.org;
c2e930
+}
c2e930
+
c2e930
+# A slightly different configuration for an internal subnet.
c2e930
+subnet 10.5.5.0 netmask 255.255.255.224 {
c2e930
+  range 10.5.5.26 10.5.5.30;
c2e930
+  option domain-name-servers ns1.internal.example.org;
c2e930
+  option domain-name \"internal.example.org\";
c2e930
+  option routers 10.5.5.1;
c2e930
+  option broadcast-address 10.5.5.31;
c2e930
+  default-lease-time 600;
c2e930
+  max-lease-time 7200;
c2e930
+}
c2e930
+
c2e930
+# Hosts which require special configuration options can be listed in
c2e930
+# host statements.   If no address is specified, the address will be
c2e930
+# allocated dynamically (if possible), but the host-specific information
c2e930
+# will still come from the host declaration.
c2e930
+
c2e930
+host passacaglia {
c2e930
+  hardware ethernet 0:0:c0:5d:bd:95;
c2e930
+  filename \"vmunix.passacaglia\";
c2e930
+  server-name \"toccata.fugue.com\";
c2e930
+}
c2e930
+
c2e930
+# Fixed IP addresses can also be specified for hosts.   These addresses
c2e930
+# should not also be listed as being available for dynamic assignment.
c2e930
+# Hosts for which fixed IP addresses have been specified can boot using
c2e930
+# BOOTP or DHCP.   Hosts for which no fixed address is specified can only
c2e930
+# be booted with DHCP, unless there is an address range on the subnet
c2e930
+# to which a BOOTP client is connected which has the dynamic-bootp flag
c2e930
+# set.
c2e930
+host fantasia {
c2e930
+  hardware ethernet 08:00:07:26:c0:a5;
c2e930
+  fixed-address fantasia.fugue.com;
c2e930
+}
c2e930
+
c2e930
+# You can declare a class of clients and then do address allocation
c2e930
+# based on that.   The example below shows a case where all clients
c2e930
+# in a certain class get addresses on the 10.17.224/24 subnet, and all
c2e930
+# other clients get addresses on the 10.0.29/24 subnet.
c2e930
+
c2e930
+#class \"foo\" {
c2e930
+#  match if substring (option vendor-class-identifier, 0, 4) = \"SUNW\";
c2e930
+#}
c2e930
+
c2e930
+shared-network 224-29 {
c2e930
+  subnet 10.17.224.0 netmask 255.255.255.0 {
c2e930
+    option routers rtr-224.example.org;
c2e930
+  }
c2e930
+  subnet 10.0.29.0 netmask 255.255.255.0 {
c2e930
+    option routers rtr-29.example.org;
c2e930
+  }
c2e930
+  pool {
c2e930
+    allow members of \"foo\";
c2e930
+    range 10.17.224.10 10.17.224.250;
c2e930
+  }
c2e930
+  pool {
c2e930
+    deny members of \"foo\";
c2e930
+    range 10.0.29.10 10.0.29.230;
c2e930
+  }
c2e930
+}
c2e930
+"
c2e930
+
c2e930
+test lns get "authoritative;" = { "authoritative" }
c2e930
+test lns get "ddns-update-style none;" = { "ddns-update-style" = "none" }
c2e930
+test lns get "option domain-name \"example.org\";" =
c2e930
+  { "option"
c2e930
+    { "domain-name"
c2e930
+      { "arg" = "example.org" }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+test lns get "option domain-name-servers ns1.example.org, ns2.example.org;" =
c2e930
+  { "option"
c2e930
+    { "domain-name-servers"
c2e930
+      { "arg" = "ns1.example.org" }
c2e930
+      { "arg" = "ns2.example.org" }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+test lns get "default-lease-time 600;" = { "default-lease-time" = "600" }
c2e930
+test lns get "range 10.254.239.60;" =
c2e930
+{ "range"
c2e930
+    { "to" = "10.254.239.60" }
c2e930
+  }
c2e930
+
c2e930
+test lns get "range dynamic-bootp 10.254.239.60;" =
c2e930
+  { "range"
c2e930
+    { "flag" = "dynamic-bootp" }
c2e930
+    { "to" = "10.254.239.60" }
c2e930
+  }
c2e930
+
c2e930
+test lns get "range dynamic-bootp 10.254.239.40 10.254.239.60;" =
c2e930
+  { "range"
c2e930
+    { "flag" = "dynamic-bootp" }
c2e930
+    { "from" = "10.254.239.40" }
c2e930
+    { "to" = "10.254.239.60" }
c2e930
+  }
c2e930
+
c2e930
+test lns get "subnet 10.152.187.0 netmask 255.255.255.0 {}\n" =
c2e930
+  { "subnet"
c2e930
+    { "network" = "10.152.187.0" }
c2e930
+    { "netmask" = "255.255.255.0" }
c2e930
+  }
c2e930
+
c2e930
+test lns get " pool {
c2e930
+    pool {
c2e930
+
c2e930
+    }
c2e930
+}
c2e930
+" =
c2e930
+  { "pool"
c2e930
+    { "pool" }
c2e930
+  }
c2e930
+
c2e930
+test lns get "group { host some-host {hardware ethernet 00:00:aa:bb:cc:dd;
c2e930
+fixed-address 10.1.1.1;}}" =
c2e930
+  { "group"
c2e930
+    { "host" = "some-host"
c2e930
+      { "hardware"
c2e930
+        { "type" = "ethernet" }
c2e930
+        { "address" = "00:00:aa:bb:cc:dd" }
c2e930
+      }
c2e930
+      { "fixed-address" = "10.1.1.1" }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+test lns get "group fan-tas_tic { }" =
c2e930
+  { "group" = "fan-tas_tic" }
c2e930
+
c2e930
+test Dhcpd_140.stmt_secu get "allow members of \"foo\";" =  { "allow-members-of" = "foo" }
c2e930
+test Dhcpd_140.stmt_secu get "allow booting;" =  { "allow" = "booting" }
c2e930
+test Dhcpd_140.stmt_secu get "allow bootp;" =  { "allow" = "bootp" }
c2e930
+test Dhcpd_140.stmt_option get "option voip-boot-server code 66 = string;" =
c2e930
+  { "rfc-code"
c2e930
+    { "label" = "voip-boot-server" }
c2e930
+    { "code" = "66" }
c2e930
+    { "type" = "string" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.stmt_option get "option special-option code 25 = array of string;" =
c2e930
+  { "rfc-code"
c2e930
+    { "label" = "special-option" }
c2e930
+    { "code" = "25" }
c2e930
+    { "type" = "array of string" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.stmt_option get "option special-option code 25 = integer 32;" =
c2e930
+  { "rfc-code"
c2e930
+    { "label" = "special-option" }
c2e930
+    { "code" = "25" }
c2e930
+    { "type" = "integer 32" }
c2e930
+  }
c2e930
+
c2e930
+
c2e930
+test Dhcpd_140.stmt_option get "option special-option code 25 = array of integer 32;" =
c2e930
+  { "rfc-code"
c2e930
+    { "label" = "special-option" }
c2e930
+    { "code" = "25" }
c2e930
+    { "type" = "array of integer 32" }
c2e930
+  }
c2e930
+
c2e930
+
c2e930
+
c2e930
+test Dhcpd_140.lns get "authoritative;
c2e930
+log-facility local7;
c2e930
+ddns-update-style none;
c2e930
+default-lease-time 21600;
c2e930
+max-lease-time 43200;
c2e930
+
c2e930
+# Additional options for VOIP
c2e930
+option voip-boot-server code 66 = string;
c2e930
+option voip-vlan-id code 128 = string;
c2e930
+" =
c2e930
+  { "authoritative" }
c2e930
+  { "log-facility" = "local7" }
c2e930
+  { "ddns-update-style" = "none" }
c2e930
+  { "default-lease-time" = "21600" }
c2e930
+  { "max-lease-time" = "43200"
c2e930
+    { "#comment" = "Additional options for VOIP" }
c2e930
+  }
c2e930
+  { "rfc-code"
c2e930
+    { "label" = "voip-boot-server" }
c2e930
+    { "code" = "66" }
c2e930
+    { "type" = "string" }
c2e930
+  }
c2e930
+  { "rfc-code"
c2e930
+    { "label" = "voip-vlan-id" }
c2e930
+    { "code" = "128" }
c2e930
+    { "type" = "string" }
c2e930
+  }
c2e930
+
c2e930
+
c2e930
+test Dhcpd_140.lns get "
c2e930
+option domain-name-servers 10.1.1.1, 10.11.2.1, 10.1.3.1;
c2e930
+next-server 10.1.1.1;
c2e930
+
c2e930
+failover peer \"redondance01\" {
c2e930
+         primary;
c2e930
+         address 10.1.1.1;
c2e930
+         port 647;
c2e930
+         peer address 10.1.1.1;
c2e930
+         peer port 647;
c2e930
+         max-response-delay 20;
c2e930
+         max-unacked-updates 10;
c2e930
+         mclt 3600;         #comment.
c2e930
+         split 128;         #comment.
c2e930
+         load balance max seconds 3;
c2e930
+       }
c2e930
+" =
c2e930
+  {  }
c2e930
+  { "option"
c2e930
+    { "domain-name-servers"
c2e930
+      { "arg" = "10.1.1.1" }
c2e930
+      { "arg" = "10.11.2.1" }
c2e930
+      { "arg" = "10.1.3.1" }
c2e930
+    }
c2e930
+  }
c2e930
+  { "next-server" = "10.1.1.1" }
c2e930
+  { "failover peer" = "redondance01"
c2e930
+    { "primary" }
c2e930
+    { "address" = "10.1.1.1" }
c2e930
+    { "port" = "647" }
c2e930
+    { "peer address" = "10.1.1.1" }
c2e930
+    { "peer port" = "647" }
c2e930
+    { "max-response-delay" = "20" }
c2e930
+    { "max-unacked-updates" = "10" }
c2e930
+    { "mclt" = "3600"
c2e930
+      { "#comment" = "comment." }
c2e930
+    }
c2e930
+    { "split" = "128"
c2e930
+      { "#comment" = "comment." }
c2e930
+    }
c2e930
+    { "load balance max seconds" = "3" }
c2e930
+  }
c2e930
+
c2e930
+
c2e930
+(* test get and put for record types *)
c2e930
+let record_test = "option test_records code 123 = { string, ip-address, integer 32, ip6-address, domain-list };"
c2e930
+
c2e930
+test Dhcpd_140.lns get record_test =
c2e930
+ { "rfc-code"
c2e930
+   { "label" = "test_records" }
c2e930
+   { "code" = "123" }
c2e930
+     { "record"
c2e930
+        { "1" = "string" }
c2e930
+        { "2" = "ip-address" }
c2e930
+        { "3" = "integer 32" }
c2e930
+        { "4" = "ip6-address" }
c2e930
+        { "5" = "domain-list" }
c2e930
+     }
c2e930
+ }
c2e930
+
c2e930
+test Dhcpd_140.lns put record_test after set "/rfc-code[1]/code" "124" = 
c2e930
+  "option test_records code 124 = { string, ip-address, integer 32, ip6-address, domain-list };"
c2e930
+
c2e930
+test Dhcpd_140.lns get "
c2e930
+option CallManager code 150 = ip-address;
c2e930
+option slp-directory-agent true 10.1.1.1, 10.2.2.2;
c2e930
+option slp-service-scope true \"SLP-GLOBAL\";
c2e930
+option nds-context \"EXAMPLE\";
c2e930
+option nds-tree-name \"EXAMPLE\";
c2e930
+" =
c2e930
+  {  }
c2e930
+  { "rfc-code"
c2e930
+    { "label" = "CallManager" }
c2e930
+    { "code" = "150" }
c2e930
+    { "type" = "ip-address" }
c2e930
+  }
c2e930
+  { "option"
c2e930
+    { "slp-directory-agent" = "true"
c2e930
+      { "arg" = "10.1.1.1" }
c2e930
+      { "arg" = "10.2.2.2" }
c2e930
+    }
c2e930
+  }
c2e930
+  { "option"
c2e930
+    { "slp-service-scope" = "true"
c2e930
+      { "arg" = "SLP-GLOBAL" }
c2e930
+    }
c2e930
+  }
c2e930
+  { "option"
c2e930
+    { "nds-context"
c2e930
+      { "arg" = "EXAMPLE" }
c2e930
+    }
c2e930
+  }
c2e930
+  { "option"
c2e930
+    { "nds-tree-name"
c2e930
+      { "arg" = "EXAMPLE" }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+
c2e930
+test Dhcpd_140.lns get "option voip-vlan-id \"VLAN=1234;\";" =
c2e930
+  { "option"
c2e930
+    { "voip-vlan-id"
c2e930
+      { "arg" = "VLAN=1234;" }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.lns get "option domain-name \"x.example.com y.example.com z.example.com\";" =
c2e930
+  { "option"
c2e930
+    { "domain-name"
c2e930
+      { "arg" = "x.example.com y.example.com z.example.com" }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.lns get "include \"/etc/dhcpd.master\";" =
c2e930
+  { "include" = "/etc/dhcpd.master" }
c2e930
+
c2e930
+test Dhcpd_140.lns put "\n" after set "/include" "/etc/dhcpd.master" =
c2e930
+  "\ninclude \"/etc/dhcpd.master\";\n"
c2e930
+
c2e930
+test Dhcpd_140.fct_args get "(option dhcp-client-identifier, 1, 3)" =
c2e930
+  { "args"
c2e930
+    { "arg" = "option dhcp-client-identifier" }
c2e930
+    { "arg" = "1" }
c2e930
+    { "arg" = "3" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.stmt_match get "match if substring (option dhcp-client-identifier, 1, 3) = \"RAS\";" =
c2e930
+  { "match"
c2e930
+    { "function" = "substring"
c2e930
+      { "args"
c2e930
+        { "arg" = "option dhcp-client-identifier" }
c2e930
+        { "arg" = "1" }
c2e930
+        { "arg" = "3" }
c2e930
+      }
c2e930
+    }
c2e930
+    { "value" = "RAS" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.stmt_match get "match if suffix (option dhcp-client-identifier, 4) = \"RAS\";" =
c2e930
+  { "match"
c2e930
+    { "function" = "suffix"
c2e930
+      { "args"
c2e930
+        { "arg" = "option dhcp-client-identifier" }
c2e930
+        { "arg" = "4" }
c2e930
+      }
c2e930
+    }
c2e930
+    { "value" = "RAS" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.stmt_match get "match if option vendor-class-identifier=\"RAS\";" =
c2e930
+  { "match"
c2e930
+    { "option" = "vendor-class-identifier"
c2e930
+      { "value" = "RAS" }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+
c2e930
+test Dhcpd_140.lns get "match pick-first-value (option dhcp-client-identifier, hardware);" =
c2e930
+  { "match"
c2e930
+    { "function" = "pick-first-value"
c2e930
+      { "args"
c2e930
+        { "arg" = "option dhcp-client-identifier" }
c2e930
+        { "arg" = "hardware"  }
c2e930
+      }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.fct_args get "(16, 32, \"\", substring(hardware, 0, 4))" =
c2e930
+  { "args"
c2e930
+    { "arg" = "16" }
c2e930
+    { "arg" = "32" }
c2e930
+    { "arg" = "\"\"" }
c2e930
+    { "arg" = "substring(hardware, 0, 4)" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.stmt_match get "match if binary-to-ascii(16, 32, \"\", substring(hardware, 0, 4)) = \"1525400\";" =
c2e930
+  { "match"
c2e930
+    { "function" = "binary-to-ascii"
c2e930
+      { "args"
c2e930
+        { "arg" = "16" }
c2e930
+        { "arg" = "32" }
c2e930
+        { "arg" = "\"\"" }
c2e930
+        { "arg" = "substring(hardware, 0, 4)" }
c2e930
+      }
c2e930
+    }
c2e930
+    { "value" = "1525400" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.lns get "subclass allocation-class-1 1:8:0:2b:4c:39:ad;" =
c2e930
+  { "subclass"
c2e930
+    { "name" = "allocation-class-1" }
c2e930
+    { "value" = "1:8:0:2b:4c:39:ad" }
c2e930
+  }
c2e930
+
c2e930
+
c2e930
+test Dhcpd_140.lns get "subclass \"allocation-class-1\" 1:8:0:2b:4c:39:ad;" =
c2e930
+  { "subclass"
c2e930
+    { "name" = "allocation-class-1" }
c2e930
+    { "value" = "1:8:0:2b:4c:39:ad" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.lns get "subclass \"quoted class\" \"quoted value\";" =
c2e930
+  { "subclass"
c2e930
+    { "name" = "quoted class" }
c2e930
+    { "value" = "quoted value" }
c2e930
+  }
c2e930
+
c2e930
+
c2e930
+(* overall test *)
c2e930
+test Dhcpd_140.lns put conf after rm "/x" = conf
c2e930
+
c2e930
+(* bug #293: primary should support argument *)
c2e930
+let input293 = "zone EXAMPLE.ORG. {
c2e930
+  primary 127.0.0.1;
c2e930
+}"
c2e930
+
c2e930
+test Dhcpd_140.lns get input293 = 
c2e930
+  { "zone" = "EXAMPLE.ORG."
c2e930
+    { "primary" = "127.0.0.1" }
c2e930
+  }
c2e930
+
c2e930
+(* bug #311: filename should be quoted *)
c2e930
+let input311 = "subnet 172.16.0.0 netmask 255.255.255.0 {
c2e930
+filename \"pxelinux.0\";
c2e930
+}"
c2e930
+
c2e930
+test Dhcpd_140.lns put "subnet 172.16.0.0 netmask 255.255.255.0 {
c2e930
+}" after
c2e930
+  set "subnet/filename" "pxelinux.0" = input311
c2e930
+
c2e930
+(* GH issue #34: support conditional structures *)
c2e930
+let gh34_empty = "if exists dhcp-parameter-request-list {
c2e930
+}\n"
c2e930
+
c2e930
+test Dhcpd_140.lns get gh34_empty =
c2e930
+  { "@if" = "exists dhcp-parameter-request-list" }
c2e930
+
c2e930
+let gh34_empty_multi = "subnet 192.168.100.0 netmask 255.255.255.0 {
c2e930
+ if true {
c2e930
+ } elsif false {
c2e930
+ } else {
c2e930
+ }
c2e930
+}\n"
c2e930
+
c2e930
+test Dhcpd_140.lns get gh34_empty_multi =
c2e930
+  { "subnet"
c2e930
+    { "network" = "192.168.100.0" }
c2e930
+    { "netmask" = "255.255.255.0" }
c2e930
+    { "@if" = "true"
c2e930
+      { "@elsif" = "false" }
c2e930
+      { "@else" } }
c2e930
+  }
c2e930
+
c2e930
+let gh34_simple = "if exists dhcp-parameter-request-list {
c2e930
+  default-lease-time 600;
c2e930
+  } else {
c2e930
+default-lease-time 200;
c2e930
+}\n"
c2e930
+
c2e930
+test Dhcpd_140.lns get gh34_simple =
c2e930
+  { "@if" = "exists dhcp-parameter-request-list"
c2e930
+    { "default-lease-time" = "600" }
c2e930
+    { "@else"
c2e930
+      { "default-lease-time" = "200" } } }
c2e930
+
c2e930
+test Dhcpd_140.lns get "omapi-key fookey;" =
c2e930
+  { "omapi-key" = "fookey" }
c2e930
+
c2e930
+(* almost all DHCP groups should support braces starting on the next line *)
c2e930
+test Dhcpd_140.lns get "class introduction
c2e930
+{
c2e930
+}" =
c2e930
+  { "class" = "introduction" }
c2e930
+
c2e930
+(* equals should work the same *)
c2e930
+test Dhcpd_140.lns get "option test_records code 123 =
c2e930
+                             string;" =
c2e930
+ { "rfc-code"
c2e930
+   { "label" = "test_records" }
c2e930
+   { "code" = "123" }
c2e930
+   { "type" = "string" }
c2e930
+ }
c2e930
+
c2e930
+test Dhcpd_140.lns get "deny members of \"Are things like () allowed?\";" =
c2e930
+  { "deny-members-of" = "Are things like () allowed?" }
c2e930
+
c2e930
+test Dhcpd_140.lns get "deny unknown clients;" =
c2e930
+  { "deny" = "unknown clients" }
c2e930
+test Dhcpd_140.lns get "deny known-clients;" =
c2e930
+  { "deny" = "known-clients" }
c2e930
+
c2e930
+test Dhcpd_140.lns get "set ClientMac = binary-to-ascii(16, 8, \":\" , substring(hardware, 1, 6));" =
c2e930
+  { "set" = "ClientMac"
c2e930
+    { "value" = "binary-to-ascii(16, 8, \":\" , substring(hardware, 1, 6))" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.lns get "set myvariable = foo;" =
c2e930
+  { "set" = "myvariable"
c2e930
+    { "value" = "foo" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.stmt_hardware get "hardware fddi 00:01:02:03:04:05;" =
c2e930
+  { "hardware"
c2e930
+    { "type" = "fddi" }
c2e930
+    { "address" = "00:01:02:03:04:05" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.lns get "on commit
c2e930
+{
c2e930
+  set test = thing;
c2e930
+}" =
c2e930
+  { "on" = "commit"
c2e930
+    { "set" = "test"
c2e930
+      { "value" = "thing" }
c2e930
+    }
c2e930
+  }
c2e930
+
c2e930
+(* key block get/put/set test *)
c2e930
+let key_tests = "key sample {
c2e930
+    algorithm hmac-md5;
c2e930
+    secret \"secret==\";
c2e930
+}
c2e930
+
c2e930
+key \"interesting\" { };
c2e930
+
c2e930
+key \"third key\" {
c2e930
+    secret \"two==\";
c2e930
+}"
c2e930
+
c2e930
+test Dhcpd_140.lns get key_tests =
c2e930
+  { "key_block" = "sample"
c2e930
+    { "algorithm"  = "hmac-md5" }
c2e930
+    { "secret" = "secret==" }
c2e930
+  }
c2e930
+  { "key_block" = "interesting" }
c2e930
+  { "key_block" = "third key"
c2e930
+    { "secret" = "two==" }
c2e930
+  }
c2e930
+
c2e930
+test Dhcpd_140.lns put key_tests after set "/key_block[1]" "sample2" =
c2e930
+  "key sample2 {
c2e930
+    algorithm hmac-md5;
c2e930
+    secret \"secret==\";
c2e930
+}
c2e930
+
c2e930
+key \"interesting\" { };
c2e930
+
c2e930
+key \"third key\" {
c2e930
+    secret \"two==\";
c2e930
+}"
c2e930
+
c2e930
+test Dhcpd_140.lns get "group \"hello\" { }" =
c2e930
+  { "group" = "hello" }
c2e930
+
c2e930
+test Dhcpd_140.lns get "class \"testing class with spaces and quotes and ()\" {}" =
c2e930
+  { "class" = "testing class with spaces and quotes and ()" }
c2e930
diff --git a/tests/Makefile.am b/tests/Makefile.am
c55e75
index 387ac7d2..315cac9c 100644
c2e930
--- a/tests/Makefile.am
c2e930
+++ b/tests/Makefile.am
c2e930
@@ -58,6 +58,7 @@ lens_tests =			\
c2e930
   lens-device_map.sh    \
c2e930
   lens-dhclient.sh		\
c2e930
   lens-dhcpd.sh		\
c2e930
+  lens-dhcpd_140.sh		\
c2e930
   lens-dns_zone.sh		\
c2e930
   lens-dnsmasq.sh		\
c2e930
   lens-dovecot.sh		\
c55e75
-- 
f375a7
2.14.3
c55e75