mirror of
https://github.com/soypat/lneto.git
synced 2026-08-18 13:44:02 +00:00
major ARP Handler refactor; DNS improvements; bridge example rework
This commit is contained in:
+10
-15
@@ -24,28 +24,23 @@ func (narp *NodeARP) Protocol() uint64 { return uint64(ethernet.TypeARP) }
|
||||
func (narp *NodeARP) ConnectionID() *uint64 { return narp.handler.ConnectionID() }
|
||||
|
||||
func (narp *NodeARP) Demux(EtherFrame []byte, arpOff int) error {
|
||||
afrm, err := arp.NewFrame(EtherFrame[arpOff:])
|
||||
if err != nil {
|
||||
slog.Error("bad-ARP", slog.String("err", err.Error()))
|
||||
return nil
|
||||
}
|
||||
afrm.ValidateSize(&narp.vld)
|
||||
if narp.vld.HasError() {
|
||||
slog.Error("invalid-ARP", slog.String("err", narp.vld.ErrPop().Error()))
|
||||
return nil
|
||||
}
|
||||
return narp.handler.Recv(EtherFrame[arpOff:])
|
||||
return narp.handler.Demux(EtherFrame, arpOff)
|
||||
}
|
||||
|
||||
func (narp *NodeARP) Encapsulate(EtherFrame []byte, arpOff int) (int, error) {
|
||||
n, err := narp.handler.Send(EtherFrame[arpOff:])
|
||||
n, err := narp.handler.Encapsulate(EtherFrame, arpOff)
|
||||
if err != nil || n == 0 {
|
||||
return 0, err // end with error.
|
||||
}
|
||||
afrm, _ := arp.NewFrame(EtherFrame[arpOff:])
|
||||
hwaddr, _ := afrm.Target()
|
||||
efrm, _ := ethernet.NewFrame(EtherFrame)
|
||||
copy(efrm.DestinationHardwareAddr()[:], hwaddr)
|
||||
slog.Info("handle", slog.String("out", afrm.String()))
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (narp *NodeARP) StartQuery(proto []byte) error {
|
||||
return narp.handler.StartQuery(proto)
|
||||
}
|
||||
|
||||
func (narp *NodeARP) QueryResult(proto []byte) ([]byte, error) {
|
||||
return narp.handler.QueryResult(proto)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user