Factor out demo stack configuration

This commit is contained in:
Tony Garnock-Jones 2015-10-17 20:33:10 -04:00
parent 63039b63f0
commit 0072607f65
3 changed files with 30 additions and 36 deletions

26
demo-config.rkt Normal file
View File

@ -0,0 +1,26 @@
#lang racket/base
;; Demonstration stack configuration for various hosts.
(require racket/match)
(require minimart)
(require (only-in mzlib/os gethostname))
(require "configuration.rkt")
(provide spawn-demo-config)
(define (spawn-demo-config)
(spawn (lambda (e s) #f)
(void)
(match (gethostname)
["skip"
(gestalt-union (pub (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "en0"))
(pub (host-route (bytes 192 168 1 222) 24 "en0")))]
[(or "hop" "walk")
(gestalt-union (pub (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "wlan0"))
(pub (host-route (bytes 192 168 1 222) 24 "wlan0")))]
["stockholm.ccs.neu.edu"
(gestalt-union (pub (host-route (bytes 129 10 115 94) 24 "eth0"))
(pub (host-route (bytes 192 168 56 222) 24 "vboxnet0"))
(pub (gateway-route (bytes 0 0 0 0) 0 (bytes 129 10 115 1) "eth0")))]
[else
(error 'spawn-demo-config "No setup for hostname ~a" (gethostname))])))

View File

@ -2,8 +2,7 @@
(require minimart/demand-matcher)
(require minimart/drivers/timer)
(require (only-in mzlib/os gethostname))
(require "configuration.rkt")
(require "demo-config.rkt")
(require "ethernet.rkt")
(require "arp.rkt")
(require "ip.rkt")
@ -18,22 +17,7 @@
(spawn-ip-driver)
(spawn-tcp-driver)
(spawn-udp-driver)
(spawn (lambda (e s) #f)
(void)
(match (gethostname)
["skip"
(gestalt-union (pub (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "en0"))
(pub (host-route (bytes 192 168 1 222) 24 "en0")))]
["hop"
(gestalt-union (pub (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "wlan0"))
(pub (host-route (bytes 192 168 1 222) 24 "wlan0")))]
["stockholm.ccs.neu.edu"
(gestalt-union (pub (host-route (bytes 129 10 115 94) 24 "eth0"))
(pub (host-route (bytes 192 168 56 222) 24 "vboxnet0"))
(pub (gateway-route (bytes 0 0 0 0) 0 (bytes 129 10 115 1) "eth0")))]
[else
(error 'stack-configuration "No setup for hostname ~a" (gethostname))]))
(spawn-demo-config)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -2,8 +2,7 @@
(require minimart/demand-matcher)
(require minimart/drivers/timer)
(require (only-in mzlib/os gethostname))
(require "configuration.rkt")
(require "demo-config.rkt")
(require "ethernet.rkt")
(require "arp.rkt")
(require "ip.rkt")
@ -18,22 +17,7 @@
(spawn-ip-driver)
(spawn-tcp-driver)
(spawn-udp-driver)
(spawn (lambda (e s) #f)
(void)
(match (gethostname)
["skip"
(gestalt-union (pub (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "en0"))
(pub (host-route (bytes 192 168 1 222) 24 "en0")))]
[(or "hop" "walk")
(gestalt-union (pub (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "wlan0"))
(pub (host-route (bytes 192 168 1 222) 24 "wlan0")))]
["stockholm.ccs.neu.edu"
(gestalt-union (pub (host-route (bytes 129 10 115 94) 24 "eth0"))
(pub (host-route (bytes 192 168 56 222) 24 "vboxnet0"))
(pub (gateway-route (bytes 0 0 0 0) 0 (bytes 129 10 115 1) "eth0")))]
[else
(error 'stack-configuration "No setup for hostname ~a" (gethostname))]))
(spawn-demo-config)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;