#! /usr/bin/env racket #lang racket/base (require racket/cmdline racket/tcp racket/pretty "ebus/layer2.rkt" "ebus/layer7.rkt") ;(define verbose? (make-parameter #f)) (define connect-host? (make-parameter null)) (define connect-port? (make-parameter null)) (define greeting (command-line #:once-each [("-c" "--connect") host port "Connect to server " (connect-host? host) (connect-port? (string->number port)) ])) ;; Connect, replacing input with tcp connection (if (or (null? (connect-host?)) (null? (connect-port?))) (display "Using stdin\n") (let-values ([(cin cout) (tcp-connect (connect-host?) (connect-port?))]) (display (format "Connected to ~s ~s ~n" (connect-host?) (connect-port?))) (current-input-port cin))) (define (read-ebus-loop2 input-port) (let ([paket (layer2-read-ebus (current-input-port))]) (pretty-print paket) (pretty-print (layer7-paket-parse paket)) (cond ((not (eof-object? paket)) (read-ebus-loop2 input-port))))) ;(define (read-ebus-loop7 input-port) ; (let ([fields (layer7-read-ebus (current-input-port))]) ; (if (not (void? fields)) ; (pretty-print fields) ; (display "")) ; (cond ((not (eof-object? fields)) (read-ebus-loop7 input-port))))) (let () (display "Layer 2\n") (read-ebus-loop2 (current-input-port)))