mirror of
https://github.com/soypat/lneto.git
synced 2026-08-08 17:03:40 +00:00
989bb6a0b9
* reduce heap allocations in tcp logging; omit use of AppendFloat which allocates a metric sh*tton * debugheaplog: better heap statistic logging * heap: use string for pcap.Frame.Protocol * add potential to eliminate Flags.String heap alloc, remove incorrect HEAP comments * add StackAsync.DebugErr and httpraw.SetBytes * many heap alloc reductions and replacement of bytes.Equal with internal.BytesEqual
31 lines
749 B
Go
31 lines
749 B
Go
//go:build tinygo
|
|
|
|
package internet
|
|
|
|
func makecbnode(s StackNode) cbnode {
|
|
return cbnode{
|
|
_demux: s.Demux,
|
|
_encapsulate: s.Encapsulate,
|
|
}
|
|
}
|
|
|
|
type cbnode struct {
|
|
// Do not access outside of handlers/node logic.
|
|
_demux func([]byte, int) error
|
|
// Do not access outside of handlers/node logic.
|
|
_encapsulate func([]byte, int, int) (int, error)
|
|
}
|
|
|
|
func (s *cbnode) Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (int, error) {
|
|
return s._encapsulate(carrierData, offsetToIP, offsetToFrame)
|
|
}
|
|
|
|
func (s *cbnode) Demux(carrierData []byte, frameOffset int) error {
|
|
debugLog("cbnode:pre-demux")
|
|
return s._demux(carrierData, frameOffset)
|
|
}
|
|
|
|
func (s cbnode) IsZeroed() bool {
|
|
return s._demux == nil || s._encapsulate == nil
|
|
}
|