mirror of
https://github.com/impact-eintr/netstack.git
synced 2025-10-25 05:30:21 +08:00
udp基本写完了 关于socket的不少细节还没看 另外在网络栈静置一段时间后再次发起连接将无法找到路由
This commit is contained in:
@@ -108,7 +108,7 @@ func (e *endpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload b
|
||||
|
||||
// 写入网卡接口
|
||||
if protocol == header.ICMPv4ProtocolNumber {
|
||||
log.Printf("IP 写回ICMP报文 长度: %d\n", hdr.UsedLength()+payload.Size())
|
||||
log.Println("IP 写回ICMP报文", header.IPv4(append(ip, payload.ToView()...)))
|
||||
} else {
|
||||
//log.Printf("send ipv4 packet %d bytes, proto: 0x%x", hdr.UsedLength()+payload.Size(), protocol)
|
||||
log.Println(header.IPv4(append(ip, payload.ToView()...)))
|
||||
@@ -132,7 +132,6 @@ func (e *endpoint) HandlePacket(r *stack.Route, vv buffer.VectorisedView) {
|
||||
tlen := int(h.TotalLength())
|
||||
vv.TrimFront(hlen)
|
||||
vv.CapLength(tlen - hlen)
|
||||
log.Println(hlen, tlen)
|
||||
|
||||
// 报文重组
|
||||
more := (h.Flags() & header.IPv4FlagMoreFragments) != 0
|
||||
@@ -157,7 +156,7 @@ func (e *endpoint) HandlePacket(r *stack.Route, vv buffer.VectorisedView) {
|
||||
}
|
||||
r.Stats().IP.PacketsDelivered.Increment()
|
||||
// 根据协议分发到不同处理函数,比如协议时TCP,会进入tcp.HandlePacket
|
||||
log.Printf("recv ipv4 packet %d bytes, proto: 0x%x", tlen, p)
|
||||
log.Printf("准备前往 UDP/TCP recv ipv4 packet %d bytes, proto: 0x%x", tlen, p)
|
||||
e.dispatcher.DeliverTransportPacket(r, p, vv)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user