Tweaks to logging
This commit is contained in:
parent
57e22a5d3c
commit
630d0e29bd
|
@ -27,18 +27,18 @@
|
|||
([ (prefix :: binary bytes offset)
|
||||
(:: binary bytes 2)
|
||||
(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
|
||||
(ones-complement-sum16 pseudo-header)
|
||||
(ones-complement-+16 (ones-complement-sum16 prefix)
|
||||
(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))
|
||||
(log-info "Checksum ~a" (number->string checksum 16))
|
||||
;; (log-info "Checksum ~a" (number->string checksum 16))
|
||||
(define final-packet (bit-string (prefix :: binary)
|
||||
(checksum :: integer bytes 2)
|
||||
(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)))
|
||||
|
||||
(module+ test
|
||||
|
|
12
ethernet.rkt
12
ethernet.rkt
|
@ -56,20 +56,20 @@
|
|||
(begin (async-channel-put control-ch 'unblock)
|
||||
#f))]
|
||||
[(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))
|
||||
(pretty-bytes (ethernet-packet-source p))
|
||||
(pretty-bytes (ethernet-packet-destination p))
|
||||
(number->string (ethernet-packet-ethertype p) 16)
|
||||
(dump-bytes->string (ethernet-packet-body p)))
|
||||
(number->string (ethernet-packet-ethertype p) 16))
|
||||
(log-info "~a" (dump-bytes->string (ethernet-packet-body p)))
|
||||
(transition h (send p))]
|
||||
[(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))
|
||||
(pretty-bytes (ethernet-packet-source p))
|
||||
(pretty-bytes (ethernet-packet-destination p))
|
||||
(number->string (ethernet-packet-ethertype p) 16)
|
||||
(dump-bytes->string (ethernet-packet-body p)))
|
||||
(number->string (ethernet-packet-ethertype p) 16))
|
||||
(log-info "~a" (dump-bytes->string (ethernet-packet-body p)))
|
||||
(raw-interface-write h (encode-ethernet-packet p))
|
||||
#f]
|
||||
[_ #f]))
|
||||
|
|
Loading…
Reference in New Issue