本文整理汇总了Golang中github.com/google/gopacket.Flow.Reverse方法的典型用法代码示例。如果您正苦于以下问题:Golang Flow.Reverse方法的具体用法?Golang Flow.Reverse怎么用?Golang Flow.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/google/gopacket.Flow
的用法示例。
在下文中一共展示了Flow.Reverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
// New is the factory method called by the tcpassembly to generate new tcpassembly.Stream.
func (os *MongoOpStream) New(netFlow, tcpFlow gopacket.Flow) tcpassembly.Stream {
key := bidiKey{netFlow, tcpFlow}
rkey := bidiKey{netFlow.Reverse(), tcpFlow.Reverse()}
if bidi, ok := os.bidiMap[key]; ok {
atomic.AddInt32(&bidi.openStreamCount, 1)
delete(os.bidiMap, key)
return bidi.streams[1]
}
bidi := newBidi(netFlow, tcpFlow, os, <-os.connectionCounter)
os.bidiMap[rkey] = bidi
atomic.AddInt32(&bidi.openStreamCount, 1)
go bidi.streamOps()
return bidi.streams[0]
}
示例2: New
// New handles creating a new tcpassembly.Stream.
func (f *myFactory) New(netFlow, tcpFlow gopacket.Flow) tcpassembly.Stream {
// Create a new stream.
s := &myStream{}
// Find the bidi bidirectional struct for this stream, creating a new one if
// one doesn't already exist in the map.
k := key{netFlow, tcpFlow}
bd := f.bidiMap[k]
if bd == nil {
bd = &bidi{a: s, key: k}
// Register bidirectional with the reverse key, so the matching stream going
// the other direction will find it.
f.bidiMap[key{netFlow.Reverse(), tcpFlow.Reverse()}] = bd
} else {
bd.b = s
// Clear out the bidi we're using from the map, just in case.
delete(f.bidiMap, k)
}
s.bidi = bd
return s
}
示例3: newBidi
func newBidi(netFlow, tcpFlow gopacket.Flow, opStream *MongoOpStream, num int64) *bidi {
bidi := &bidi{connectionNumber: num}
bidi.streams[0] = &stream{
bidi: bidi,
reassembled: make(chan []tcpassembly.Reassembly),
done: make(chan interface{}),
op: &RawOp{},
netFlow: netFlow,
tcpFlow: tcpFlow,
}
bidi.streams[1] = &stream{
bidi: bidi,
reassembled: make(chan []tcpassembly.Reassembly),
done: make(chan interface{}),
op: &RawOp{},
netFlow: netFlow.Reverse(),
tcpFlow: tcpFlow.Reverse(),
}
bidi.opStream = opStream
return bidi
}