service_matcher-go/packet.go
crusader 6ce87348ba ing
2018-09-03 15:42:56 +09:00

28 lines
362 B
Go

package matcher
type Packet struct {
Buffer []byte
Len int
}
func (p *Packet) Valid() bool {
if nil == p.Buffer || 0 == p.Len {
return false
}
return true
}
func (p *Packet) Bytes() []byte {
if p.Valid() {
return p.Buffer[:p.Len]
}
return nil
}
func NewPacket(buf []byte, len int) *Packet {
return &Packet{
Buffer: buf,
Len: len,
}
}