mirror of
https://github.com/fumiama/WireGold.git
synced 2025-09-26 19:21:11 +08:00
38 lines
614 B
Go
38 lines
614 B
Go
package head
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
hasmorebit FlagsProto = 0x20 << iota
|
|
nofragbit
|
|
topbit //TODO: 改为 trans 标记
|
|
)
|
|
|
|
const (
|
|
impossiblebit = hasmorebit | nofragbit
|
|
flagsbit = topbit | impossiblebit
|
|
protobit = ^flagsbit
|
|
)
|
|
|
|
type FlagsProto uint8
|
|
|
|
func (pf FlagsProto) String() string {
|
|
return fmt.Sprintf("%02x", uint8(pf))
|
|
}
|
|
|
|
func (pf FlagsProto) IsValid() bool {
|
|
return pf&topbit == 0 &&
|
|
pf&impossiblebit != impossiblebit &&
|
|
pf.Proto() < ProtoTop
|
|
}
|
|
|
|
func (pf FlagsProto) HasMore() bool {
|
|
return pf&hasmorebit != 0
|
|
}
|
|
|
|
func (pf FlagsProto) NoFrag() bool {
|
|
return pf&nofragbit != 0
|
|
}
|