mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 08:40:28 +00:00
Use addUint64 instead to not interfere with coordinate parsing
This commit is contained in:
parent
81fde1a805
commit
38e8b036d2
@ -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
|
||||||
|
addUint64 := func(bs []byte) {
|
||||||
|
// Converts bytes to a uint64
|
||||||
|
// Converts that back to variable length bytes
|
||||||
|
// Appends it to coords
|
||||||
|
var u uint64
|
||||||
|
for _, b := range bs {
|
||||||
|
u <<= 8
|
||||||
|
u |= uint64(b)
|
||||||
|
}
|
||||||
|
coords = append(coords, wire_encode_uint64(u)...)
|
||||||
|
}
|
||||||
coords = append(coords, sinfo.coords...) // Start with the real coords
|
coords = append(coords, sinfo.coords...) // Start with the real coords
|
||||||
flowlabel := int(bs[1:2][0]&0x0f)<<16 | int(bs[2:3][0])<<8 | int(bs[3:4][0])
|
coords = append(coords, 0) // Then target the local switchport
|
||||||
if flowlabel > 0 {
|
flowlabel := append([]byte(nil), bs[1:4]...)
|
||||||
coords = append(coords, 0) // Add an explicit 0 for the destination's self peer
|
flowlabel[0] &= 0x0f
|
||||||
if flowlabel>>16 > 0 {
|
addUint64(flowlabel)
|
||||||
coords = append(coords, byte(flowlabel>>16))
|
|
||||||
}
|
|
||||||
if flowlabel>>8 > 0 {
|
|
||||||
coords = append(coords, byte(flowlabel>>8))
|
|
||||||
}
|
|
||||||
if flowlabel>>0 > 0 {
|
|
||||||
coords = append(coords, byte(flowlabel>>0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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{
|
||||||
|
Loading…
Reference in New Issue
Block a user