Skip to content

Commit

Permalink
Buildify, lintify, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion committed Nov 20, 2024
1 parent 2f37106 commit 3990f96
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion router/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go_library(
srcs = [
"connector.go",
"dataplane.go",
"serializeProxy.go",
"fnv1aCheap.go",
"metrics.go",
"serializeProxy.go",
"svc.go",
],
importpath = "github.com/scionproto/scion/router",
Expand Down
14 changes: 7 additions & 7 deletions router/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -2288,15 +2288,15 @@ func decodeSCMP(scmp *slayers.SCMP) ([]gopacket.SerializableLayer, error) {
}

// updateSCIONLayer rewrites the SCION header at the start of the given raw packet buffer; replacing
// it with the serialization of the given new SCION header. This works only if the new header
// is of the same size as the old one. This function has no knowledge of the actual size of the
// headers; it only ensures that the new one ends exactly where the old one did. It is possible to
// use this function to replace a header with a smaller one; but the preceding headers, and the
// start of the slice must be corrected afterwards.
// it with the serialization of the given new SCION header. This works only if the new header is of
// the same size as the old one. This function has no knowledge of the actual size of the headers;
// it only ensures that the new one ends exactly where the old one did. It is possible to use this
// function to replace a header with a smaller one; but the rawPacket's slice must be fixed
// afterwards (and the preceding headers, if any).
func updateSCIONLayer(rawPkt []byte, s slayers.SCION) error {
payloadOffset := len(rawPkt) - len(s.LayerPayload())
serBuf := newSerializeProxy(rawPkt)
serBuf.clear(payloadOffset) // So, prepending just in front of the payload. Better not append!
serBuf.clear(payloadOffset) // Prepends will go just before payload. (Appends will wreck it)
return s.SerializeTo(&serBuf, gopacket.SerializeOptions{})
}

Expand Down Expand Up @@ -2403,7 +2403,7 @@ func (b *bfdSend) Send(bfd *layers.BFD) error {
return err
}

// The usefull part of the buffer is given by Bytes. We don't copy the bytes; just the slice's
// The useful part of the buffer is given by Bytes. We don't copy the bytes; just the slice's
// metadata.
p.rawPacket = serBuf.Bytes()
if count < 10 {
Expand Down
12 changes: 6 additions & 6 deletions router/serializeProxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
type serializeProxy struct {
initStart int // Initial starting point (where the first prepend or append occurs)
data []byte
start int // data[0] == buf[0] (bc changing it is one way), so we keep track of the real start.
start int // The slice's offset can't change (irreversible). So keep track separately.
layers []gopacket.LayerType
}

Expand All @@ -45,15 +45,15 @@ func newSerializeProxy(buf []byte) serializeProxy {
// Resets the buffer to empty and sets the initial prepend/append point to the given position.
func (s *serializeProxy) clear(newStart int) {
s.initStart = newStart
s.Clear()
s.start = newStart
s.data = s.data[:newStart]
s.layers = s.layers[:0]
}

// Implements serializeBuffer.Clear(). Never returns an error.
// Implements serializeBuffer.Clear(). This implementation never returns an error.
// The initial prepend/append point is reset to that which was set by the last call to clear().
func (s *serializeProxy) Clear() error {
s.start = s.initStart
s.data = s.data[:s.start]
s.layers = s.layers[:0]
s.clear(s.initStart)
return nil
}

Expand Down

0 comments on commit 3990f96

Please sign in to comment.