Use addUint64 instead to not interfere with coordinate parsing

This commit is contained in:
Neil Alexander 2018-07-22 18:33:53 +01:00
parent 81fde1a805
commit 38e8b036d2
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -431,20 +431,22 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
// The rest is ignored, but it's still part as the coords, so it affects switch queues // The rest is ignored, but it's still part as the coords, so it affects switch queues
// This helps separate traffic streams (coords, flowlabel) to be queued independently // This helps separate traffic streams (coords, flowlabel) to be queued independently
var coords []byte var coords []byte
coords = append(coords, sinfo.coords...) // Start with the real coords addUint64 := func(bs []byte) {
flowlabel := int(bs[1:2][0]&0x0f)<<16 | int(bs[2:3][0])<<8 | int(bs[3:4][0]) // Converts bytes to a uint64
if flowlabel > 0 { // Converts that back to variable length bytes
coords = append(coords, 0) // Add an explicit 0 for the destination's self peer // Appends it to coords
if flowlabel>>16 > 0 { var u uint64
coords = append(coords, byte(flowlabel>>16)) for _, b := range bs {
} u <<= 8
if flowlabel>>8 > 0 { u |= uint64(b)
coords = append(coords, byte(flowlabel>>8))
}
if flowlabel>>0 > 0 {
coords = append(coords, byte(flowlabel>>0))
} }
coords = append(coords, wire_encode_uint64(u)...)
} }
coords = append(coords, sinfo.coords...) // Start with the real coords
coords = append(coords, 0) // Then target the local switchport
flowlabel := append([]byte(nil), bs[1:4]...)
flowlabel[0] &= 0x0f
addUint64(flowlabel)
payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce) payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce)
defer util_putBytes(payload) defer util_putBytes(payload)
p := wire_trafficPacket{ p := wire_trafficPacket{