Skip to content

Commit

Permalink
ns: Use full frame counter during downlink frame counter check
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansmares committed Jul 14, 2022
1 parent 8d02160 commit c842e66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
13 changes: 2 additions & 11 deletions pkg/networkserver/downlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,22 +1074,13 @@ func toMACStateMHDr(mhdr *ttnpb.MHDR) *ttnpb.MACState_DownlinkMessage_Message_MH
}
}

func toMACStateFHDR(fhdr *ttnpb.FHDR) *ttnpb.MACState_DownlinkMessage_Message_MACPayload_FHDR {
if fhdr == nil {
return nil
}
return &ttnpb.MACState_DownlinkMessage_Message_MACPayload_FHDR{
FCnt: fhdr.FCnt,
}
}

func toMACStateMACPayload(macPayload *ttnpb.MACPayload) *ttnpb.MACState_DownlinkMessage_Message_MACPayload {
if macPayload == nil {
return nil
}
return &ttnpb.MACState_DownlinkMessage_Message_MACPayload{
FHdr: toMACStateFHDR(macPayload.FHdr),
FPort: macPayload.FPort,
FPort: macPayload.FPort,
FullFCnt: macPayload.FullFCnt,
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/networkserver/grpc_asns.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ func minAFCntDown(session *ttnpb.Session, macState *ttnpb.MACState) (uint32, err
if macPayload == nil {
return 0, errInvalidPayload.New()
}
if macPayload.FPort > 0 && macPayload.FHdr.FCnt >= minFCnt {
if macPayload.FPort > 0 && macPayload.FullFCnt >= minFCnt {
// NOTE: In an unlikely case all len(recentDowns) downlinks are FPort==0 or something unmatched in the switch (e.g. a proprietary downlink) minFCnt will
// not reflect the correct AFCntDown - that is fine, because this is AS's responsibility and FCnt checking here is essentially just a sanity check.
minFCnt = macPayload.FHdr.FCnt + 1
minFCnt = macPayload.FullFCnt + 1
break outer
}
case ttnpb.MType_JOIN_ACCEPT:
Expand Down

0 comments on commit c842e66

Please sign in to comment.