service_matcher-go/packet.go

28 lines
362 B
Go
Raw Normal View History

2018-08-13 07:48:32 +00:00
package matcher
type Packet struct {
Buffer []byte
Len int
}
2018-09-03 06:42:56 +00:00
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
}
2018-08-13 07:48:32 +00:00
func NewPacket(buf []byte, len int) *Packet {
return &Packet{
Buffer: buf,
Len: len,
}
}