mirror of
https://github.com/soypat/lneto.git
synced 2026-08-17 13:23:30 +00:00
add proactive window update (#39)
* add proactive window update * fix xnet tests due to runt padding bug
This commit is contained in:
+18
-1
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/soypat/lneto/arp"
|
||||
"github.com/soypat/lneto/ethernet"
|
||||
"github.com/soypat/lneto/internet/pcap"
|
||||
"github.com/soypat/lneto/ipv4"
|
||||
"github.com/soypat/lneto/tcp"
|
||||
)
|
||||
|
||||
@@ -589,7 +590,23 @@ func (tst *tester) ARPExchangeOnly(querying, target *StackAsync) {
|
||||
}
|
||||
|
||||
func (tst *tester) getTCPFrame() tcp.Frame {
|
||||
data := tst.getPayload(ethernet.TypeIPv4)
|
||||
tst.t.Helper()
|
||||
// Find the IP frame's position in the captured packet buffer.
|
||||
ipFrm := getProtoFrame(tst.frmbuf, ethernet.TypeIPv4)
|
||||
if ipFrm == nil {
|
||||
tst.t.Fatal("no IP frame in capture")
|
||||
}
|
||||
ipStart := ipFrm.PacketBitOffset / 8
|
||||
// Use IP TotalLength to correctly bound the frame, stripping any
|
||||
// Ethernet runt-frame padding (802.3 §3.2.7). This mirrors what
|
||||
// StackIP.Demux does before passing data to TCP.
|
||||
ifrm, err := ipv4.NewFrame(tst.buf[ipStart:])
|
||||
if err != nil {
|
||||
tst.t.Fatal("parsing IP frame:", err)
|
||||
}
|
||||
totalLen := int(ifrm.TotalLength())
|
||||
ihl := ifrm.HeaderLength()
|
||||
data := tst.buf[ipStart+ihl : ipStart+totalLen]
|
||||
frame, err := tcp.NewFrame(data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user