RI-Ack for RI-Upd

This commit is contained in:
Josh Deprez 2024-04-19 17:10:00 +10:00
parent e37c4e48e2
commit 677e5592e5
No known key found for this signature in database
2 changed files with 12 additions and 0 deletions

View File

@ -170,6 +170,7 @@ func main() {
RecieveCh: make(chan aurp.Packet, 1024),
RoutingTable: routes,
ZoneTable: zones,
Reconnect: true,
}
aurp.Inc(&nextConnID)
peers[udpAddrFromNet(raddr)] = peer
@ -439,6 +440,7 @@ func main() {
RecieveCh: make(chan aurp.Packet, 1024),
RoutingTable: routes,
ZoneTable: zones,
Reconnect: false,
}
aurp.Inc(&nextConnID)
peers[ra] = pr

View File

@ -33,6 +33,7 @@ const (
tickleRetryLimit = 10
sendRetryTimer = 10 * time.Second
sendRetryLimit = 5
reconnectTimer = 10 * time.Minute
)
type receiverState int
@ -83,6 +84,7 @@ type Peer struct {
RecieveCh chan aurp.Packet
RoutingTable *RoutingTable
ZoneTable *ZoneTable
Reconnect bool
}
// Send encodes and sends pkt to the remote host.
@ -202,6 +204,9 @@ func (p *Peer) Handle(ctx context.Context) error {
case rsUnconnected:
// TODO: periodically try to reconnect,
// if this peer is in the config file
// TODO: if sstate != ssUnconnected, send a null RI-Upd to check
// that the sender side is also unconnected
}
case pkt := <-p.RecieveCh:
@ -357,6 +362,11 @@ func (p *Peer) Handle(ctx context.Context) error {
log.Printf("AURP Peer: RI-Upd event %v", et)
}
if _, err := p.Send(p.Transport.NewRIAckPacket(pkt.ConnectionID, pkt.Sequence, 0)); err != nil {
log.Printf("AURP Peer: Couldn't send RI-Ack: %v", err)
return err
}
case *aurp.RDPacket:
if rstate == rsUnconnected || rstate == rsWaitForOpenRsp {
log.Printf("AURP Peer: Received RD but was not expecting one (receiver state was %v)", rstate)