diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2012-03-02 00:26:12 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2012-03-02 00:26:12 +0100 |
commit | 50b9a83e70e8dfbdcd2cd90b4a64e7071ad22a21 (patch) | |
tree | 74d5573f44730e2571cfb756cad414fef4477fb2 /ebus-racket/dumper.rkt | |
parent | 27e06b6e29c92e802a950e7c318daae7b8582f69 (diff) | |
download | ebus-alt-50b9a83e70e8dfbdcd2cd90b4a64e7071ad22a21.tar.gz ebus-alt-50b9a83e70e8dfbdcd2cd90b4a64e7071ad22a21.zip |
ebus-racket:
* dumper
* use racket/base
* use racket/pretty pretty-print
* support layer7 parser (--layer7)
* layer2
* define constants as #xHEX values
instead of bytestrings
* layer7
* support more datatypes
* reformat with emacs
* layer7
* support more datatypes
* reformat with emacs
Diffstat (limited to 'ebus-racket/dumper.rkt')
-rwxr-xr-x | ebus-racket/dumper.rkt | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/ebus-racket/dumper.rkt b/ebus-racket/dumper.rkt index 3c66015..7ffd556 100755 --- a/ebus-racket/dumper.rkt +++ b/ebus-racket/dumper.rkt @@ -1,27 +1,51 @@ #! /usr/bin/env racket -#lang racket - -(require "layer2.rkt") +#lang racket/base +(require racket/cmdline + racket/tcp + racket/pretty + "layer2.rkt" + "layer7.rkt") ;(define verbose? (make-parameter #f)) (define connect-host? (make-parameter null)) (define connect-port? (make-parameter null)) +(define layer7? (make-parameter #f)) (define greeting (command-line #:once-each -; [("-v") "Verbose mode" (verbose? #t)] - [("-c" "--connect") host port - "Connect to server <host> <port>" - (connect-host? host) - (connect-port? (string->number port)) - ])) + [("-a" "--layer7") + "Parse Layer7" (layer7? #t)] + [("-c" "--connect") + host port + "Connect to server <host> <port>" + (connect-host? host) + (connect-port? (string->number port)) + ])) + ; Connect (if (or (null? (connect-host?)) (null? (connect-port?))) - (display "Using stdin") + (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))) -; -(layer2-read-ebus-loop (current-input-port)) +(define (read-ebus-loop2 input-port) + (let ([paket (layer2-read-ebus (current-input-port))]) + (pretty-print 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))))) + +(if (layer7?) + (let () + (display "Layer 7\n") + (read-ebus-loop7 (current-input-port))) + (let () + (display "Layer 2\n") + (read-ebus-loop2 (current-input-port)))) |