Skip to content

Commit

Permalink
ns: Store ResetInd cipher id in MAC state
Browse files Browse the repository at this point in the history
  • Loading branch information
halimi committed Aug 28, 2024
1 parent d5ab632 commit 0782fc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pkg/networkserver/mac/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"go.thethings.network/lorawan-stack/v3/pkg/events"
"go.thethings.network/lorawan-stack/v3/pkg/frequencyplans"
"go.thethings.network/lorawan-stack/v3/pkg/specification/macspec"
"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
)

Expand Down Expand Up @@ -51,10 +52,11 @@ func HandleResetInd(ctx context.Context, dev *ttnpb.EndDevice, pld *ttnpb.MACCom
}
dev.MacState = macState
dev.MacState.LorawanVersion = dev.LorawanVersion
dev.MacState.CipherId = macspec.NegotiatedCipherSuite(pld.Cipher)

conf := &ttnpb.MACCommand_ResetConf{
MinorVersion: pld.MinorVersion,
Cipher: pld.Cipher,
Cipher: ttnpb.CipherEnum(dev.MacState.CipherId),
}
dev.MacState.QueuedResponses = append(dev.MacState.QueuedResponses, conf.MACCommand())
return append(evs,
Expand Down
8 changes: 4 additions & 4 deletions pkg/networkserver/mac/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,23 @@ func TestHandleResetInd(t *testing.T) {
dev.MacState.QueuedResponses = []*ttnpb.MACCommand{
(&ttnpb.MACCommand_ResetConf{
MinorVersion: 2,
Cipher: 3,
Cipher: 0,
}).MACCommand(),
}
return dev
}(),
Payload: &ttnpb.MACCommand_ResetInd{
MinorVersion: 2,
Cipher: 3,
Cipher: 0,
},
Events: events.Builders{
EvtReceiveResetIndication.With(events.WithData(&ttnpb.MACCommand_ResetInd{
MinorVersion: 2,
Cipher: 3,
Cipher: 0,
})),
EvtEnqueueResetConfirmation.With(events.WithData(&ttnpb.MACCommand_ResetConf{
MinorVersion: 2,
Cipher: 3,
Cipher: 0,
})),
},
},
Expand Down

0 comments on commit 0782fc4

Please sign in to comment.