Skip to content

Commit c9e05e5

Browse files
authored
update MSG_ACKNOWLEDGE on demand fields (#1303)
1 parent 3e6331c commit c9e05e5

File tree

4 files changed

+181
-31
lines changed

4 files changed

+181
-31
lines changed

c/include/libsbp/integrity_macros.h

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -313,22 +313,22 @@
313313
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_FORBIDDEN (2)
314314
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_INVALID_REQUEST (3)
315315
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_INVALID_AREA_ID (4)
316-
#define SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_MASK (0x1u)
317-
#define SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_SHIFT (0u)
318-
#define SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_GET(flags) \
319-
((u16)((u16)((flags) >> SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_SHIFT) & \
320-
SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_MASK))
321-
#define SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_SET(flags, val) \
322-
do { \
323-
(flags) = \
324-
(u16)((flags & (~(SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_MASK \
325-
<< SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_SHIFT))) | \
326-
(((val) & (SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_MASK)) \
327-
<< (SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_SHIFT))); \
316+
#define SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_MASK (0x1u)
317+
#define SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_SHIFT (0u)
318+
#define SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_GET(flags) \
319+
((u16)((u16)((flags) >> SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_SHIFT) & \
320+
SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_MASK))
321+
#define SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_SET(flags, val) \
322+
do { \
323+
(flags) = (u16)( \
324+
(flags & (~(SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_MASK \
325+
<< SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_SHIFT))) | \
326+
(((val) & (SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_MASK)) \
327+
<< (SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_SHIFT))); \
328328
} while (0)
329329

330-
#define SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_NOT_REQUESTED (0)
331-
#define SBP_ACKNOWLEDGE_PUBLIC_SIGNING_KEY_REQUESTED (1)
330+
#define SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_NOT_REQUESTED (0)
331+
#define SBP_ACKNOWLEDGE_CORRECTIONS_CERTIFICATE_REQUESTED (1)
332332
#define SBP_ACKNOWLEDGE_LOW_RATE_MESSAGES_MASK (0x1u)
333333
#define SBP_ACKNOWLEDGE_LOW_RATE_MESSAGES_SHIFT (1u)
334334
#define SBP_ACKNOWLEDGE_LOW_RATE_MESSAGES_GET(flags) \
@@ -452,6 +452,38 @@
452452

453453
#define SBP_ACKNOWLEDGE_INTEGRITY_NOT_REQUESTED (0)
454454
#define SBP_ACKNOWLEDGE_INTEGRITY_REQUESTED (1)
455+
#define SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_MASK (0x1u)
456+
#define SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_SHIFT (9u)
457+
#define SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_GET(flags) \
458+
((u16)((u16)((flags) >> SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_SHIFT) & \
459+
SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_MASK))
460+
#define SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_SET(flags, val) \
461+
do { \
462+
(flags) = (u16)( \
463+
(flags & (~(SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_MASK \
464+
<< SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_SHIFT))) | \
465+
(((val) & (SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_MASK)) \
466+
<< (SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_SHIFT))); \
467+
} while (0)
468+
469+
#define SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_NOT_REQUESTED (0)
470+
#define SBP_ACKNOWLEDGE_INTERMEDIATE_CERTIFICATE_REQUESTED (1)
471+
#define SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_MASK (0x1u)
472+
#define SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_SHIFT (10u)
473+
#define SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_GET(flags) \
474+
((u16)((u16)((flags) >> SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_SHIFT) & \
475+
SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_MASK))
476+
#define SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_SET(flags, val) \
477+
do { \
478+
(flags) = \
479+
(u16)((flags & (~(SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_MASK \
480+
<< SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_SHIFT))) | \
481+
(((val) & (SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_MASK)) \
482+
<< (SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_SHIFT))); \
483+
} while (0)
484+
485+
#define SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_NOT_REQUESTED (0)
486+
#define SBP_ACKNOWLEDGE_CERTIFICATE_CHAIN_REQUESTED (1)
455487
/**
456488
* Encoded length of sbp_msg_acknowledge_t (V4 API) and
457489
* msg_acknowledge_t (legacy API)

docs/sbp.pdf

286 Bytes
Binary file not shown.

rust/sbp/src/messages/integrity.rs

Lines changed: 123 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,23 @@ pub mod msg_acknowledge {
148148
set_bit_range!(&mut self.response_code, response_code, u8, u8, 7, 0);
149149
}
150150

151-
/// Gets the [PublicSigningKey][self::PublicSigningKey] stored in the `correction_mask_on_demand` bitfield.
151+
/// Gets the [CorrectionsCertificate][self::CorrectionsCertificate] stored in the `correction_mask_on_demand` bitfield.
152152
///
153-
/// Returns `Ok` if the bitrange contains a known `PublicSigningKey` variant.
153+
/// Returns `Ok` if the bitrange contains a known `CorrectionsCertificate` variant.
154154
/// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
155-
/// or because new variants of `PublicSigningKey` were added.
156-
pub fn public_signing_key(&self) -> Result<PublicSigningKey, u8> {
155+
/// or because new variants of `CorrectionsCertificate` were added.
156+
pub fn corrections_certificate(&self) -> Result<CorrectionsCertificate, u8> {
157157
get_bit_range!(self.correction_mask_on_demand, u16, u8, 0, 0).try_into()
158158
}
159159

160-
/// Set the bitrange corresponding to the [PublicSigningKey][PublicSigningKey] of the `correction_mask_on_demand` bitfield.
161-
pub fn set_public_signing_key(&mut self, public_signing_key: PublicSigningKey) {
160+
/// Set the bitrange corresponding to the [CorrectionsCertificate][CorrectionsCertificate] of the `correction_mask_on_demand` bitfield.
161+
pub fn set_corrections_certificate(
162+
&mut self,
163+
corrections_certificate: CorrectionsCertificate,
164+
) {
162165
set_bit_range!(
163166
&mut self.correction_mask_on_demand,
164-
public_signing_key,
167+
corrections_certificate,
165168
u16,
166169
u8,
167170
0,
@@ -336,6 +339,51 @@ pub mod msg_acknowledge {
336339
8
337340
);
338341
}
342+
343+
/// Gets the [IntermediateCertificate][self::IntermediateCertificate] stored in the `correction_mask_on_demand` bitfield.
344+
///
345+
/// Returns `Ok` if the bitrange contains a known `IntermediateCertificate` variant.
346+
/// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
347+
/// or because new variants of `IntermediateCertificate` were added.
348+
pub fn intermediate_certificate(&self) -> Result<IntermediateCertificate, u8> {
349+
get_bit_range!(self.correction_mask_on_demand, u16, u8, 9, 9).try_into()
350+
}
351+
352+
/// Set the bitrange corresponding to the [IntermediateCertificate][IntermediateCertificate] of the `correction_mask_on_demand` bitfield.
353+
pub fn set_intermediate_certificate(
354+
&mut self,
355+
intermediate_certificate: IntermediateCertificate,
356+
) {
357+
set_bit_range!(
358+
&mut self.correction_mask_on_demand,
359+
intermediate_certificate,
360+
u16,
361+
u8,
362+
9,
363+
9
364+
);
365+
}
366+
367+
/// Gets the [CertificateChain][self::CertificateChain] stored in the `correction_mask_on_demand` bitfield.
368+
///
369+
/// Returns `Ok` if the bitrange contains a known `CertificateChain` variant.
370+
/// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
371+
/// or because new variants of `CertificateChain` were added.
372+
pub fn certificate_chain(&self) -> Result<CertificateChain, u8> {
373+
get_bit_range!(self.correction_mask_on_demand, u16, u8, 10, 10).try_into()
374+
}
375+
376+
/// Set the bitrange corresponding to the [CertificateChain][CertificateChain] of the `correction_mask_on_demand` bitfield.
377+
pub fn set_certificate_chain(&mut self, certificate_chain: CertificateChain) {
378+
set_bit_range!(
379+
&mut self.correction_mask_on_demand,
380+
certificate_chain,
381+
u16,
382+
u8,
383+
10,
384+
10
385+
);
386+
}
339387
}
340388

341389
impl ConcreteMessage for MsgAcknowledge {
@@ -458,31 +506,31 @@ pub mod msg_acknowledge {
458506
}
459507
}
460508

461-
/// Public Signing Key
509+
/// Corrections certificate
462510
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
463-
pub enum PublicSigningKey {
511+
pub enum CorrectionsCertificate {
464512
/// Not requested
465513
NotRequested = 0,
466514

467515
/// Requested
468516
Requested = 1,
469517
}
470518

471-
impl std::fmt::Display for PublicSigningKey {
519+
impl std::fmt::Display for CorrectionsCertificate {
472520
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
473521
match self {
474-
PublicSigningKey::NotRequested => f.write_str("Not requested"),
475-
PublicSigningKey::Requested => f.write_str("Requested"),
522+
CorrectionsCertificate::NotRequested => f.write_str("Not requested"),
523+
CorrectionsCertificate::Requested => f.write_str("Requested"),
476524
}
477525
}
478526
}
479527

480-
impl TryFrom<u8> for PublicSigningKey {
528+
impl TryFrom<u8> for CorrectionsCertificate {
481529
type Error = u8;
482530
fn try_from(i: u8) -> Result<Self, u8> {
483531
match i {
484-
0 => Ok(PublicSigningKey::NotRequested),
485-
1 => Ok(PublicSigningKey::Requested),
532+
0 => Ok(CorrectionsCertificate::NotRequested),
533+
1 => Ok(CorrectionsCertificate::Requested),
486534
i => Err(i),
487535
}
488536
}
@@ -727,6 +775,66 @@ pub mod msg_acknowledge {
727775
}
728776
}
729777
}
778+
779+
/// Intermediate certificate
780+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
781+
pub enum IntermediateCertificate {
782+
/// Not requested
783+
NotRequested = 0,
784+
785+
/// Requested
786+
Requested = 1,
787+
}
788+
789+
impl std::fmt::Display for IntermediateCertificate {
790+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
791+
match self {
792+
IntermediateCertificate::NotRequested => f.write_str("Not requested"),
793+
IntermediateCertificate::Requested => f.write_str("Requested"),
794+
}
795+
}
796+
}
797+
798+
impl TryFrom<u8> for IntermediateCertificate {
799+
type Error = u8;
800+
fn try_from(i: u8) -> Result<Self, u8> {
801+
match i {
802+
0 => Ok(IntermediateCertificate::NotRequested),
803+
1 => Ok(IntermediateCertificate::Requested),
804+
i => Err(i),
805+
}
806+
}
807+
}
808+
809+
/// Certificate chain
810+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
811+
pub enum CertificateChain {
812+
/// Not requested
813+
NotRequested = 0,
814+
815+
/// Requested
816+
Requested = 1,
817+
}
818+
819+
impl std::fmt::Display for CertificateChain {
820+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
821+
match self {
822+
CertificateChain::NotRequested => f.write_str("Not requested"),
823+
CertificateChain::Requested => f.write_str("Requested"),
824+
}
825+
}
826+
}
827+
828+
impl TryFrom<u8> for CertificateChain {
829+
type Error = u8;
830+
fn try_from(i: u8) -> Result<Self, u8> {
831+
match i {
832+
0 => Ok(CertificateChain::NotRequested),
833+
1 => Ok(CertificateChain::Requested),
834+
i => Err(i),
835+
}
836+
}
837+
}
730838
}
731839

732840
pub mod msg_ssr_flag_high_level {

spec/yaml/swiftnav/sbp/integrity.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ definitions:
307307
An echo of the correction mask field from the corresponding CRA message.
308308
fields:
309309
- 0:
310-
desc: Public Signing Key
310+
desc: Corrections certificate
311311
values:
312312
- 0: Not requested
313313
- 1: Requested
@@ -351,7 +351,17 @@ definitions:
351351
values:
352352
- 0: Not requested
353353
- 1: Requested
354-
- 9-15:
354+
- 9:
355+
desc: Intermediate certificate
356+
values:
357+
- 0: Not requested
358+
- 1: Requested
359+
- 10:
360+
desc: Certificate chain
361+
values:
362+
- 0: Not requested
363+
- 1: Requested
364+
- 11-15:
355365
desc: Reserved
356366

357367
- correction_mask_stream:

0 commit comments

Comments
 (0)