diff --git a/examples/netstack/demo-config.rkt b/examples/netstack/demo-config.rkt index 329a1aa..b251acb 100644 --- a/examples/netstack/demo-config.rkt +++ b/examples/netstack/demo-config.rkt @@ -1,25 +1,21 @@ -#lang racket/base +#lang syndicate/actor ;; Demonstration stack configuration for various hosts. (require racket/match) -(require syndicate/monolithic) (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" - (scn/union (assertion (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "en0")) - (assertion (host-route (bytes 192 168 1 222) 24 "en0")))] - [(or "hop" "walk") - (scn/union (assertion (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "wlan0")) - (assertion (host-route (bytes 192 168 1 222) 24 "wlan0")))] - ["stockholm.ccs.neu.edu" - (scn/union (assertion (host-route (bytes 129 10 115 94) 24 "eth0")) - (assertion (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))]))) +(actor + (react + (match (gethostname) + ["skip" + (assert (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "en0")) + (assert (host-route (bytes 192 168 1 222) 24 "en0"))] + [(or "hop" "walk") + (assert (gateway-route (bytes 0 0 0 0) 0 (bytes 192 168 1 1) "wlan0")) + (assert (host-route (bytes 192 168 1 222) 24 "wlan0"))] + ["stockholm.ccs.neu.edu" + (assert (host-route (bytes 129 10 115 94) 24 "eth0")) + (assert (gateway-route (bytes 0 0 0 0) 0 (bytes 129 10 115 1) "eth0"))] + [other + (error 'demo-config "No setup for hostname ~a" other)]))) diff --git a/examples/netstack/main.rkt b/examples/netstack/main.rkt index 81c63d7..9241934 100644 --- a/examples/netstack/main.rkt +++ b/examples/netstack/main.rkt @@ -1,21 +1,20 @@ #lang syndicate/monolithic -(require/activate syndicate/drivers/timer) -(require/activate "ethernet.rkt") -(require/activate "arp.rkt") (require syndicate/demand-matcher) -(require "demo-config.rkt") (require "ip.rkt") (require "tcp.rkt") (require "udp.rkt") ;;(log-events-and-actions? #t) +(require/activate syndicate/drivers/timer) +(require/activate "ethernet.rkt") +(require/activate "arp.rkt") (spawn-ip-driver) (spawn-tcp-driver) (spawn-udp-driver) -(spawn-demo-config) +(require/activate "demo-config.rkt") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;