Tweak ZI-Rsp subcode logic

This commit is contained in:
Josh Deprez 2024-04-01 15:14:31 +11:00
parent 26e9f67dc5
commit d45678b812
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw

View file

@ -182,15 +182,20 @@ func (tr *Transport) NewRIAckPacket(connID, seq uint16, szi RoutingFlag) *RIAckP
// zone information. It automatically chooses between subcodes 1 or 2 depending
// on whether there is one network ID or more than one network ID.
func (tr *Transport) NewZIRspPacket(zones ZoneTuples) *ZIRspPacket {
nns := make(map[uint16]struct{})
for _, z := range zones {
nns[z.Network] = struct{}{}
}
// Only one network: use extended
// More than one network: use non-extended
subcode := SubcodeZoneInfoExt
if len(nns) != 1 {
subcode = SubcodeZoneInfoNonExt
// Only one zone: use non-extended
subcode := SubcodeZoneInfoNonExt
if len(zones) > 1 {
// Count distinct networks
nns := make(map[uint16]struct{})
for _, z := range zones {
nns[z.Network] = struct{}{}
}
// Only one network: use extended format
// More than one network: use non-extended
if len(nns) == 1 {
subcode = SubcodeZoneInfoExt
}
}
return &ZIRspPacket{