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

View file

@ -33,6 +33,7 @@ const (
tickleRetryLimit = 10 tickleRetryLimit = 10
sendRetryTimer = 10 * time.Second sendRetryTimer = 10 * time.Second
sendRetryLimit = 5 sendRetryLimit = 5
reconnectTimer = 10 * time.Minute
) )
type receiverState int type receiverState int
@ -83,6 +84,7 @@ type Peer struct {
RecieveCh chan aurp.Packet RecieveCh chan aurp.Packet
RoutingTable *RoutingTable RoutingTable *RoutingTable
ZoneTable *ZoneTable ZoneTable *ZoneTable
Reconnect bool
} }
// Send encodes and sends pkt to the remote host. // Send encodes and sends pkt to the remote host.
@ -202,6 +204,9 @@ func (p *Peer) Handle(ctx context.Context) error {
case rsUnconnected: case rsUnconnected:
// TODO: periodically try to reconnect, // TODO: periodically try to reconnect,
// if this peer is in the config file // 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: 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) 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: case *aurp.RDPacket:
if rstate == rsUnconnected || rstate == rsWaitForOpenRsp { if rstate == rsUnconnected || rstate == rsWaitForOpenRsp {
log.Printf("AURP Peer: Received RD but was not expecting one (receiver state was %v)", rstate) log.Printf("AURP Peer: Received RD but was not expecting one (receiver state was %v)", rstate)