Move DF indication into LogFrame

This commit is contained in:
David Wragg committed 2015-06-25 17:11:20 +01:00
1 parent 4162dcafd3
commit 5690902173
3 files changed
+19 -19

No files matched your search

+10 -5
View File
@@ -11,7 +11,6 @@ import (
"runtime"
"strings"
"code.google.com/p/gopacket/layers"
"github.com/davecheney/profile"
"github.com/gorilla/mux"
. "github.com/weaveworks/weave/common"
@@ -196,11 +195,17 @@ func logFrameFunc(debug bool) weave.LogFrameFunc {
}
return func(prefix string, frame []byte, dec *weave.EthernetDecoder) {
h := fmt.Sprintf("%x", sha256.Sum256(frame))
if dec == nil {
log.Println(prefix, len(frame), "bytes (", h, ")")
} else {
log.Println(prefix, len(frame), "bytes (", h, "):", dec.Eth.SrcMAC, "->", dec.Eth.DstMAC)
parts := []interface{}{prefix, len(frame), "bytes (", h, ")"}
if dec != nil {
parts = append(parts, dec.Eth.SrcMAC, "->", dec.Eth.DstMAC)
if dec.DF() {
parts = append(parts, "(DF)")
}
}
log.Println(parts...)
}
}