1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
util.go 866 Bytes
一键复制 编辑 原始数据 按行查看 历史
urso 提交于 2016-01-08 15:03 . Adds flows feature to packetbeat
package decoder
import "github.com/tsg/gopacket"
// implement DecodingLayer with support of switching between multiple layers to
// remember outter layer results
type multiLayer struct {
layers []gopacket.DecodingLayer // all layers must have same type
i int
cnt int
}
func (m *multiLayer) next() {
m.i++
m.cnt++
if m.i >= len(m.layers) {
m.i = 0
}
}
func (m *multiLayer) init(layer ...gopacket.DecodingLayer) {
m.layers = layer
}
func (m *multiLayer) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
return m.layers[m.i].DecodeFromBytes(data, df)
}
func (m *multiLayer) CanDecode() gopacket.LayerClass {
return m.layers[m.i].CanDecode()
}
func (m *multiLayer) NextLayerType() gopacket.LayerType {
return m.layers[m.i].NextLayerType()
}
func (m *multiLayer) LayerPayload() []byte {
return m.layers[m.i].LayerPayload()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v5.6.12

搜索帮助