split out node callback between tinygo and go to avoid heap allocs

This commit is contained in:
Patricio Whittingslow
2026-01-13 10:38:21 -03:00
parent f51cdf74b6
commit 2e6e66e691
6 changed files with 78 additions and 21 deletions
+29
View File
@@ -0,0 +1,29 @@
//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 {
return s.demux(carrierData, frameOffset)
}
func (s cbnode) IsZeroed() bool {
return s.demux == nil || s.encapsulate == nil
}