Tweaks to logging

This commit is contained in:
Tony Garnock-Jones 2014-06-16 17:51:37 -04:00
parent 57e22a5d3c
commit 630d0e29bd
2 changed files with 10 additions and 10 deletions

View File

@ -27,18 +27,18 @@
([ (prefix :: binary bytes offset) ([ (prefix :: binary bytes offset)
(:: binary bytes 2) (:: binary bytes 2)
(suffix :: binary) ] (suffix :: binary) ]
(log-info "Packet pre checksum:\n~a" (dump-bytes->string blob)) ;; (log-info "Packet pre checksum:\n~a" (dump-bytes->string blob))
(define result (ones-complement-+16 (define result (ones-complement-+16
(ones-complement-sum16 pseudo-header) (ones-complement-sum16 pseudo-header)
(ones-complement-+16 (ones-complement-sum16 prefix) (ones-complement-+16 (ones-complement-sum16 prefix)
(ones-complement-sum16 suffix)))) (ones-complement-sum16 suffix))))
(log-info "result: ~a" (number->string result 16)) ;; (log-info "result: ~a" (number->string result 16))
(define checksum (ones-complement-negate16-safely result)) (define checksum (ones-complement-negate16-safely result))
(log-info "Checksum ~a" (number->string checksum 16)) ;; (log-info "Checksum ~a" (number->string checksum 16))
(define final-packet (bit-string (prefix :: binary) (define final-packet (bit-string (prefix :: binary)
(checksum :: integer bytes 2) (checksum :: integer bytes 2)
(suffix :: binary))) (suffix :: binary)))
(log-info "Packet with checksum:\n~a" (dump-bytes->string final-packet)) ;; (log-info "Packet with checksum:\n~a" (dump-bytes->string final-packet))
final-packet))) final-packet)))
(module+ test (module+ test

View File

@ -56,20 +56,20 @@
(begin (async-channel-put control-ch 'unblock) (begin (async-channel-put control-ch 'unblock)
#f))] #f))]
[(message (? ethernet-packet? p) 1 #f) ;; from metalevel 1 [(message (? ethernet-packet? p) 1 #f) ;; from metalevel 1
(log-info "Interface ~a inbound packet ~a -> ~a (type 0x~a):\n~a" (log-info "Interface ~a inbound packet ~a -> ~a (type 0x~a)"
(ethernet-interface-name (ethernet-packet-interface p)) (ethernet-interface-name (ethernet-packet-interface p))
(pretty-bytes (ethernet-packet-source p)) (pretty-bytes (ethernet-packet-source p))
(pretty-bytes (ethernet-packet-destination p)) (pretty-bytes (ethernet-packet-destination p))
(number->string (ethernet-packet-ethertype p) 16) (number->string (ethernet-packet-ethertype p) 16))
(dump-bytes->string (ethernet-packet-body p))) (log-info "~a" (dump-bytes->string (ethernet-packet-body p)))
(transition h (send p))] (transition h (send p))]
[(message (? ethernet-packet? p) 0 #f) ;; from metalevel 0 [(message (? ethernet-packet? p) 0 #f) ;; from metalevel 0
(log-info "Interface ~a OUTBOUND packet ~a -> ~a (type 0x~a):\n~a" (log-info "Interface ~a OUTBOUND packet ~a -> ~a (type 0x~a)"
(ethernet-interface-name (ethernet-packet-interface p)) (ethernet-interface-name (ethernet-packet-interface p))
(pretty-bytes (ethernet-packet-source p)) (pretty-bytes (ethernet-packet-source p))
(pretty-bytes (ethernet-packet-destination p)) (pretty-bytes (ethernet-packet-destination p))
(number->string (ethernet-packet-ethertype p) 16) (number->string (ethernet-packet-ethertype p) 16))
(dump-bytes->string (ethernet-packet-body p))) (log-info "~a" (dump-bytes->string (ethernet-packet-body p)))
(raw-interface-write h (encode-ethernet-packet p)) (raw-interface-write h (encode-ethernet-packet p))
#f] #f]
[_ #f])) [_ #f]))