local seq

This commit is contained in:
Josh Deprez 2024-03-30 20:35:19 +11:00
parent 21fcf11e5e
commit f03dea9136
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw
2 changed files with 18 additions and 3 deletions

View file

@ -51,6 +51,20 @@ type Transport struct {
LocalSeq, RemoteSeq uint16 LocalSeq, RemoteSeq uint16
} }
func (tr *Transport) IncLocalSeq() {
tr.LocalSeq++
if tr.LocalSeq == 0 {
tr.LocalSeq = 1
}
}
func (tr *Transport) IncRemoteSeq() {
tr.RemoteSeq++
if tr.RemoteSeq == 0 {
tr.RemoteSeq = 1
}
}
// domainHeader returns a new domain header suitable for sending a packet. // domainHeader returns a new domain header suitable for sending a packet.
func (tr *Transport) domainHeader(pt PacketType) DomainHeader { func (tr *Transport) domainHeader(pt PacketType) DomainHeader {
return DomainHeader{ return DomainHeader{
@ -111,10 +125,10 @@ func (tr *Transport) NewOpenRspPacket(envFlags RoutingFlag, rateOrErr int16, opt
} }
} }
func (tr *Transport) NewRIRspPacket(connID, seq uint16, last RoutingFlag, nets NetworkTuples) *RIRspPacket { func (tr *Transport) NewRIRspPacket(last RoutingFlag, nets NetworkTuples) *RIRspPacket {
return &RIRspPacket{ return &RIRspPacket{
Header: Header{ Header: Header{
TrHeader: tr.sequenced(connID, seq), TrHeader: tr.sequenced(tr.RemoteConnID, tr.LocalSeq),
CommandCode: CmdCodeRIRsp, CommandCode: CmdCodeRIRsp,
Flags: last, Flags: last,
}, },

View file

@ -233,7 +233,8 @@ func (p *peer) handle(ctx context.Context) error {
Distance: 1, Distance: 1,
}, },
} }
if _, err := p.send(p.tr.NewRIRspPacket(pkt.ConnectionID, p.tr.LocalSeq, aurp.RoutingFlagLast, nets)); err != nil { p.tr.LocalSeq = 1
if _, err := p.send(p.tr.NewRIRspPacket(aurp.RoutingFlagLast, nets)); err != nil {
log.Printf("Couldn't send RI-Rsp packet: %v", err) log.Printf("Couldn't send RI-Rsp packet: %v", err)
} }
sstate = ssWaitForRIAck1 sstate = ssWaitForRIAck1