mirror of
https://github.com/fumiama/WireGold.git
synced 2025-09-26 19:21:11 +08:00
21 lines
283 B
Go
21 lines
283 B
Go
package head
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
const (
|
|
ttloffset = unsafe.Offsetof(Packet{}.TTL)
|
|
)
|
|
|
|
// ClearTTL for hash use
|
|
func ClearTTL(data []byte) {
|
|
data[ttloffset] = 0
|
|
}
|
|
|
|
// DecTTL on transferring
|
|
func DecTTL(data []byte) (drop bool) {
|
|
data[ttloffset]--
|
|
return data[ttloffset] == 0
|
|
}
|