[dhcp-agent-commits] dhcp-agent/conf default.sysconf,1.2,1.3
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2003-05-23 03:31:18
|
Update of /cvsroot/dhcp-agent/dhcp-agent/conf In directory sc8-pr-cvs1:/tmp/cvs-serv3864/conf Modified Files: default.sysconf Log Message: redid sysconf to use closures; hooks now in place for reconfigure and unconfigure Index: default.sysconf =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/conf/default.sysconf,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** default.sysconf 20 May 2003 01:43:39 -0000 1.2 --- default.sysconf 23 May 2003 03:31:15 -0000 1.3 *************** *** 4,11 **** ; ! ; XXX ! ; IMPORTANT: You should not need to edit the interface setup below. ! ; Without this the client may not function properly at all. ; (define configure-interface --- 4,15 ---- ; ! ; XXX IMPORTANT: ! ; You should not need to edit the interface setup ! ; below. Without this the client may not function properly at ! ; all since it relies on it to configure the interface. ; + ; This only gets called on a new lease. We should _never_ get a + ; different IP on any of the other hooks. + (define configure-interface *************** *** 28,52 **** ; that's it we're ready to bring up the interface - (begin (client-info-message "bringing up interface...") (if (not (client-interface-up client-control dhcp-requested-ip-address subnet-mask mtu)) ! (client-fatal-message "could not bring up interface... exiting."))))))) ; XXX ; Add option handling here. ; ; Domain and domain-name servers ; ! (define configure-dns ! (lambda () ! (if (and (client-configure? client-control 'dhcp-domain-name-servers) ! (client-configure? client-control 'dhcp-domain-name) ! (defined? 'dhcp-domain-name-servers) ! (defined? 'dhcp-domain-name)) ! (let ((resolv-conf-file-port (open "/etc/resolv.conf" O_WRONLY 0644))) ! (begin (client-info-message "configuring resolver") (map-in-order --- 32,71 ---- ; that's it we're ready to bring up the interface (client-info-message "bringing up interface...") (if (not (client-interface-up client-control dhcp-requested-ip-address subnet-mask mtu)) ! (client-fatal-message "could not bring up interface... exiting.")))))) ; XXX ; Add option handling here. + ; All configure-* functions are placed inside of closures. This + ; allows seemless persistantance of old values and thus + ; reconfigure-* can be written easily. ; + ; reconfigure-* is called during rebind or renew. + ; Domain and domain-name servers ; ! (define configure-dns #f) ! (define reconfigure-dns #f) ! (define unconfigure-dns #f) ! (let* ((configured-domain-name #f) ! (configured-domain-name-servers #f) ! ! ; check to see if we really need to configure ! (do-configure ! (lambda() ! (and (client-configure? client-control 'dhcp-domain-name-servers) ! (client-configure? client-control 'dhcp-domain-name) ! (defined? 'dhcp-domain-name-servers) ! (defined? 'dhcp-domain-name)))) ! ! ; define this here since we'll be calling it from reconfigure as well. ! ! (real-configure-dns ! (lambda() ! (let ((resolv-conf-file-port (open "/etc/resolv.conf" O_WRONLY 0644))) (client-info-message "configuring resolver") (map-in-order *************** *** 54,80 **** (simple-format resolv-conf-file-port "nameserver ~A\n" dns-server)) dhcp-domain-name-servers) (simple-format resolv-conf-file-port "search ~A\n" dhcp-domain-name) ! (close-port resolv-conf-file-port)))))) ; Routers. We use client-set-default-route to add the route. ; ! (define configure-default-route ! (lambda() ! (if (and (client-configure? client-control 'dhcp-routers) ! (defined? 'dhcp-routers)) ! (begin ! (client-info-message (string-append "adding default route to: " (car dhcp-routers))) ! (client-set-default-route client-control (car dhcp-routers)))))) ; After everything is defined set to hooks ; ! ; We have four hooks. dhcp-bound, dhcp-rebind, dhcp-renew, dhcp-release ; setup options on dhcp-bound - ; (add-hook! dhcp-bound-hook configure-dns) (add-hook! dhcp-bound-hook configure-default-route) (add-hook! dhcp-bound-hook configure-interface) --- 73,184 ---- (simple-format resolv-conf-file-port "nameserver ~A\n" dns-server)) dhcp-domain-name-servers) (simple-format resolv-conf-file-port "search ~A\n" dhcp-domain-name) ! (close-port resolv-conf-file-port) ! ! ; now setup the options so we can use them again. ! (set! configured-domain-name dhcp-domain-name) ! (set! configured-domain-name-servers dhcp-domain-name-servers))))) ! ! ! ; configure dns options ! (set! configure-dns ! ! (lambda () ! (if (do-configure) ! (real-configure-dns)))) ! ! ; unconfigure dns options ! (set! unconfigure-dns ! (lambda() ! ! ; We shouldn't really be doing anything. Any name server ! ; is a good server :-) ! ! #t)) ! ! (set! reconfigure-dns ! (lambda() ! (if (do-configure) ! (if (and configured-domain-name configured-domain-name-servers) ! (if (not (or (string=? configured-domain-name dhcp-domain-name) ! (string=? configured-domain-name-servers dhcp-domain-name-servers))) ! (begin ! (client-info-message "domain name options have changed. reconfiguring...") ! (real-configure-dns)))) + ; otherwise this is the first time we've received this option + (real-configure-dns))))) ; Routers. We use client-set-default-route to add the route. ; ! (define configure-default-route #f) ! (define unconfigure-default-route #f) ! (define reconfigure-default-route #f) ! ! (let* ((configured-default-route #f) ! ! ; check to see if really need to configure ! (do-configure ! (lambda() ! (and (client-configure? client-control 'dhcp-routers) ! (defined? 'dhcp-routers)))) ! ! (real-configure-default-route ! (lambda() ! (begin ! (client-info-message (string-append "adding default route to: " (car dhcp-routers))) ! (client-set-default-route client-control (car dhcp-routers)) ! (set! configured-default-route (car dhcp-routers))))) ! ! (real-unconfigure-default-route ! (lambda() ! (begin ! (client-info-message (string-append "removing default route to: " (car dhcp-routers))) ! (client-remove-default-route client-control configured-default-route))))) ! ! (set! configure-default-route ! (lambda() ! (if (do-configure) ! (real-configure-default-route)))) ! ! ! (set! reconfigure-default-route ! (lambda() ! (if (do-configure) ! (if configured-default-route ! (begin ! (real-unconfigure-default-route) ! (real-configure-default-route)) ! (real-configure-default-route))))) ! ! (set! unconfigure-default-route ! (lambda() ! (if configured-default-route ! (real-unconfigure-default-route))))) ; After everything is defined set to hooks ; ! ; We have four hooks. dhcp-bound-hook, dhcp-rebind-hook, ! ; dhcp-renew-hook, dhcp-release-hook ! ; ; setup options on dhcp-bound (add-hook! dhcp-bound-hook configure-dns) (add-hook! dhcp-bound-hook configure-default-route) (add-hook! dhcp-bound-hook configure-interface) + + ; on rebind and renew call reconfigure to check if + ; reconfiguration is necessary. + + (add-hook! dhcp-rebind-hook reconfigure-dns) + (add-hook! dhcp-rebind-hook reconfigure-default-route) + + (add-hook! dhcp-renew-hook reconfigure-dns) + (add-hook! dhcp-renew-hook reconfigure-default-route) + + ; unconfigure options on dhcp-release-hook + + (add-hook! dhcp-release-hook unconfigure-dns) + (add-hook! dhcp-release-hook unconfigure-default-route) |