add dhcp failing test

This commit is contained in:
soypat
2025-06-17 02:07:11 -03:00
parent 47eae76dcf
commit 2133966a16
17 changed files with 596 additions and 195 deletions
+34
View File
@@ -104,6 +104,28 @@ func getNode(nodes []node, port uint16, protocol uint16) (node *node) {
return nil
}
func getEncapsulateNode(nodes *[]node, carrierData []byte, frameOffset int) (nodeIdx int, written int, err error) {
destroyed := false
for i := range *nodes {
node := &(*nodes)[i]
if checkNode(node) {
destroyed = true
node.destroy()
continue
}
written, err = node.encapsulate(carrierData, frameOffset)
if written > 0 {
return i, written, err
} else if err != nil {
}
}
if destroyed {
*nodes = nodesCompact(*nodes)
}
return -1, 0, nil
}
// destroy removes all references to underlying StackNode. Allows garbage collection of node if possible.
func (n *node) destroy() {
*n = node{}
@@ -116,5 +138,17 @@ func getNodeByProto(nodes []node, protocol uint16) int {
return i
}
}
return -1
}
func nodesCompact(nodes []node) []node {
nilOff := 0
for i := 0; i < len(nodes); i++ {
if !checkNode(&nodes[i]) {
nodes[nilOff] = nodes[i]
nilOff++
}
}
return nodes[:nilOff]
}