mirror of
https://github.com/soypat/lneto.git
synced 2026-08-22 15:39:06 +00:00
refactor lneto2->lneto package
This commit is contained in:
+5
-5
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/soypat/lneto/lneto2"
|
||||
"github.com/soypat/lneto"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -140,7 +140,7 @@ func (tfrm Frame) Segment(payloadSize int) Segment {
|
||||
}
|
||||
}
|
||||
|
||||
func (tfrm Frame) CRCWrite(crc *lneto2.CRC791) {
|
||||
func (tfrm Frame) CRCWrite(crc *lneto.CRC791) {
|
||||
// Write excluding CRC
|
||||
crc.Write(tfrm.buf[:16])
|
||||
crc.Write(tfrm.buf[18:])
|
||||
@@ -192,14 +192,14 @@ var (
|
||||
errZeroSrcPort = errors.New("TCP zero source port")
|
||||
)
|
||||
|
||||
// func (tfrm Frame) Validate(v *lneto2.Validator) {
|
||||
// func (tfrm Frame) Validate(v *lneto.Validator) {
|
||||
// tfrm.ValidateSize(v)
|
||||
// tfrm.ValidateExceptCRC(v)
|
||||
// }
|
||||
|
||||
// ValidateSize checks the frame's size fields and compares with the actual buffer
|
||||
// the frame. It returns a non-nil error on finding an inconsistency.
|
||||
func (tfrm Frame) ValidateSize(v *lneto2.Validator) {
|
||||
func (tfrm Frame) ValidateSize(v *lneto.Validator) {
|
||||
off := tfrm.HeaderLength()
|
||||
if off < sizeHeaderTCP {
|
||||
v.AddBitPosErr(12*8, 4, errBadTCPOff)
|
||||
@@ -209,7 +209,7 @@ func (tfrm Frame) ValidateSize(v *lneto2.Validator) {
|
||||
}
|
||||
}
|
||||
|
||||
func (tfrm Frame) ValidateExceptCRC(v *lneto2.Validator) {
|
||||
func (tfrm Frame) ValidateExceptCRC(v *lneto.Validator) {
|
||||
tfrm.ValidateSize(v)
|
||||
if tfrm.DestinationPort() == 0 {
|
||||
v.AddBitPosErr(2*8, 16, errZeroDstPort)
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"log/slog"
|
||||
|
||||
"github.com/soypat/lneto"
|
||||
"github.com/soypat/lneto/internal"
|
||||
"github.com/soypat/lneto/lneto2"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -24,7 +24,7 @@ type Handler struct {
|
||||
bufTx ringTx
|
||||
bufRx internal.Ring
|
||||
logger
|
||||
validator lneto2.Validator
|
||||
validator lneto.Validator
|
||||
localPort uint16
|
||||
remotePort uint16
|
||||
// connid is a conenction counter that is incremented each time a new
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/soypat/lneto"
|
||||
"github.com/soypat/lneto/ethernet"
|
||||
"github.com/soypat/lneto/ipv4"
|
||||
"github.com/soypat/lneto/lneto2"
|
||||
"github.com/soypat/lneto/tcp"
|
||||
)
|
||||
|
||||
@@ -586,7 +586,7 @@ func TestExchange_helloworld_client(t *testing.T) {
|
||||
}
|
||||
|
||||
func parseSegment(t *testing.T, b []byte) (tcp.Segment, []byte) {
|
||||
var vld lneto2.Validator
|
||||
var vld lneto.Validator
|
||||
t.Helper()
|
||||
efrm, err := ethernet.NewFrame(b)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user