mirror of
https://github.com/soypat/lneto.git
synced 2026-08-20 22:49:11 +00:00
Tcp rst handling (#40)
* claude suggests a way forward * add timing to capture printer * add pcap.Flags * fix ICMP CRC calculation and add test * bugfix: still send data on half-close state(close-wait) * fix pcap test
This commit is contained in:
@@ -98,7 +98,7 @@ func (sb *StackIP) Demux(carrierData []byte, offset int) error {
|
||||
totalLen := ifrm.TotalLength()
|
||||
proto := ifrm.Protocol()
|
||||
if proto == lneto.IPProtoICMP {
|
||||
return sb.recvicmp(ifrm.RawData(), ifrm.HeaderLength())
|
||||
return sb.recvicmp(ifrm.Payload())
|
||||
}
|
||||
node := sb.handlers.nodeByProto(uint16(proto))
|
||||
// nodeIdx := getNodeByProto(sb.handlers, uint16(proto))
|
||||
@@ -205,10 +205,9 @@ func (sb *StackIP) Register(h StackNode) error {
|
||||
return sb.handlers.registerByPortProto(nodeFromStackNode(h, h.LocalPort(), proto, nil))
|
||||
}
|
||||
|
||||
func (sb *StackIP) recvicmp(carrierData []byte, offset int) error {
|
||||
frameData := carrierData[offset:]
|
||||
func (sb *StackIP) recvicmp(icmpData []byte) error {
|
||||
var crc lneto.CRC791
|
||||
if crc.PayloadSum16(frameData) != 0 {
|
||||
if crc.PayloadSum16(icmpData) != 0 {
|
||||
return errors.New("ICMP CRC mismatch")
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user