Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate
Browse files Browse the repository at this point in the history
RReichert committed Aug 13, 2024
1 parent 67826ac commit 4dc77a7
Showing 32 changed files with 2,077 additions and 3 deletions.
36 changes: 36 additions & 0 deletions c/include/libsbp/cpp/message_traits.h
Original file line number Diff line number Diff line change
@@ -1413,6 +1413,42 @@ struct MessageTraits<sbp_msg_dgnss_status_t> {
}
};

template <>
struct MessageTraits<sbp_msg_digital_signature_t> {
static constexpr sbp_msg_type_t id = SbpMsgDigitalSignature;
static constexpr const char *name = "MSG_DIGITAL_SIGNATURE";
static const sbp_msg_digital_signature_t &get(const sbp_msg_t &msg) {
return msg.digital_signature;
}
static sbp_msg_digital_signature_t &get(sbp_msg_t &msg) {
return msg.digital_signature;
}
static void to_sbp_msg(const sbp_msg_digital_signature_t &msg,
sbp_msg_t *sbp_msg) {
sbp_msg->digital_signature = msg;
}
static sbp_msg_t to_sbp_msg(const sbp_msg_digital_signature_t &msg) {
sbp_msg_t sbp_msg;
sbp_msg.digital_signature = msg;
return sbp_msg;
}
static s8 send(sbp_state_t *state, u16 sender_id,
const sbp_msg_digital_signature_t &msg, sbp_write_fn_t write) {
return sbp_msg_digital_signature_send(state, sender_id, &msg, write);
}
static s8 encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
const sbp_msg_digital_signature_t &msg) {
return sbp_msg_digital_signature_encode(buf, len, n_written, &msg);
}
static s8 decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
sbp_msg_digital_signature_t *msg) {
return sbp_msg_digital_signature_decode(buf, len, n_read, msg);
}
static size_t encoded_len(const sbp_msg_digital_signature_t &msg) {
return sbp_msg_digital_signature_encoded_len(&msg);
}
};

template <>
struct MessageTraits<sbp_msg_dops_dep_a_t> {
static constexpr sbp_msg_type_t id = SbpMsgDopsDepA;
12 changes: 12 additions & 0 deletions c/include/libsbp/sbp_msg.h
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ typedef union {
sbp_msg_cw_start_t cw_start;
sbp_msg_device_monitor_t device_monitor;
sbp_msg_dgnss_status_t dgnss_status;
sbp_msg_digital_signature_t digital_signature;
sbp_msg_dops_dep_a_t dops_dep_a;
sbp_msg_dops_t dops;
sbp_msg_ecdsa_certificate_t ecdsa_certificate;
@@ -423,6 +424,9 @@ static inline s8 sbp_message_encode(uint8_t *buf, uint8_t len,
case SbpMsgDgnssStatus:
return sbp_msg_dgnss_status_encode(buf, len, n_written,
&msg->dgnss_status);
case SbpMsgDigitalSignature:
return sbp_msg_digital_signature_encode(buf, len, n_written,
&msg->digital_signature);
case SbpMsgDopsDepA:
return sbp_msg_dops_dep_a_encode(buf, len, n_written, &msg->dops_dep_a);
case SbpMsgDops:
@@ -1090,6 +1094,9 @@ static inline s8 sbp_message_decode(const uint8_t *buf, uint8_t len,
&msg->device_monitor);
case SbpMsgDgnssStatus:
return sbp_msg_dgnss_status_decode(buf, len, n_read, &msg->dgnss_status);
case SbpMsgDigitalSignature:
return sbp_msg_digital_signature_decode(buf, len, n_read,
&msg->digital_signature);
case SbpMsgDopsDepA:
return sbp_msg_dops_dep_a_decode(buf, len, n_read, &msg->dops_dep_a);
case SbpMsgDops:
@@ -1728,6 +1735,8 @@ static inline size_t sbp_message_encoded_len(sbp_msg_type_t msg_type,
return sbp_msg_device_monitor_encoded_len(&msg->device_monitor);
case SbpMsgDgnssStatus:
return sbp_msg_dgnss_status_encoded_len(&msg->dgnss_status);
case SbpMsgDigitalSignature:
return sbp_msg_digital_signature_encoded_len(&msg->digital_signature);
case SbpMsgDopsDepA:
return sbp_msg_dops_dep_a_encoded_len(&msg->dops_dep_a);
case SbpMsgDops:
@@ -2292,6 +2301,9 @@ static inline int sbp_message_cmp(sbp_msg_type_t msg_type, const sbp_msg_t *a,
return sbp_msg_device_monitor_cmp(&a->device_monitor, &b->device_monitor);
case SbpMsgDgnssStatus:
return sbp_msg_dgnss_status_cmp(&a->dgnss_status, &b->dgnss_status);
case SbpMsgDigitalSignature:
return sbp_msg_digital_signature_cmp(&a->digital_signature,
&b->digital_signature);
case SbpMsgDopsDepA:
return sbp_msg_dops_dep_a_cmp(&a->dops_dep_a, &b->dops_dep_a);
case SbpMsgDops:
3 changes: 3 additions & 0 deletions c/include/libsbp/sbp_msg_type.h
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@ typedef enum {
SbpMsgCwStart = 0x00C1,
SbpMsgDeviceMonitor = 0x00B5,
SbpMsgDgnssStatus = 0xFF02,
SbpMsgDigitalSignature = 0x0C10,
SbpMsgDopsDepA = 0x0206,
SbpMsgDops = 0x0208,
SbpMsgEcdsaCertificate = 0x0C04,
@@ -370,6 +371,8 @@ static inline const char *sbp_msg_type_to_string(sbp_msg_type_t msg_type) {
return "MSG_DEVICE_MONITOR";
case SbpMsgDgnssStatus:
return "MSG_DGNSS_STATUS";
case SbpMsgDigitalSignature:
return "MSG_DIGITAL_SIGNATURE";
case SbpMsgDopsDepA:
return "MSG_DOPS_DEP_A";
case SbpMsgDops:
2 changes: 2 additions & 0 deletions c/include/libsbp/signing.h
Original file line number Diff line number Diff line change
@@ -17,9 +17,11 @@

#ifndef LIBSBP_SIGNING_MESSAGES_H
#define LIBSBP_SIGNING_MESSAGES_H
#include <libsbp/signing/DigitalSignature.h>
#include <libsbp/signing/ECDSASignature.h>
#include <libsbp/signing/MSG_CERTIFICATE_CHAIN.h>
#include <libsbp/signing/MSG_CERTIFICATE_CHAIN_DEP.h>
#include <libsbp/signing/MSG_DIGITAL_SIGNATURE.h>
#include <libsbp/signing/MSG_ECDSA_CERTIFICATE.h>
#include <libsbp/signing/MSG_ECDSA_SIGNATURE.h>
#include <libsbp/signing/MSG_ECDSA_SIGNATURE_DEP_A.h>
169 changes: 169 additions & 0 deletions c/include/libsbp/signing/DigitalSignature.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/*
* Copyright (C) 2015-2021 Swift Navigation Inc.
* Contact: https://support.swiftnav.com
*
* This source is subject to the license found in the file 'LICENSE' which must
* be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

/*****************************************************************************
* Automatically generated from yaml/swiftnav/sbp/signing.yaml
* with generate.py. Please do not hand edit!
*****************************************************************************/

#ifndef LIBSBP_SIGNING_DIGITALSIGNATURE_H
#define LIBSBP_SIGNING_DIGITALSIGNATURE_H

#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#include <libsbp/common.h>
#include <libsbp/signing_macros.h>
#include <libsbp/string/sbp_string.h>

#ifdef __cplusplus
extern "C" {
#endif

/******************************************************************************
*
* SBP_DIGITALSIGNATURE
*
*****************************************************************************/
/** Digital signature
*
* Digital signature along with the algorithm used to generate it.
*/
typedef struct {
/**
* Algorithm used to generate the digital signature.
*/
u8 algorithm;

/**
* Number of bytes making up the signature
*/
u8 length;

/**
* Signature
*/
u8 data[SBP_DIGITAL_SIGNATURE_DATA_MAX];
} sbp_digital_signature_t;

/**
* Get encoded size of an instance of sbp_digital_signature_t
*
* @param msg sbp_digital_signature_t instance
* @return Length of on-wire representation
*/
static inline size_t sbp_digital_signature_encoded_len(
const sbp_digital_signature_t *msg) {
(void)msg;
return SBP_DIGITAL_SIGNATURE_ENCODED_LEN;
}

/**
* Encode an instance of sbp_digital_signature_t to wire representation
*
* This function encodes the given instance in to the user provided buffer. The
* buffer provided to this function must be large enough to store the encoded
* message otherwise it will return SBP_ENCODE_ERROR without writing anything to
* the buffer.
*
* Specify the length of the destination buffer in the \p len parameter. If
* non-null the number of bytes written to the buffer will be returned in \p
* n_written.
*
* @param buf Destination buffer
* @param len Length of \p buf
* @param n_written If not null, on success will be set to the number of bytes
* written to \p buf
* @param msg Instance of sbp_digital_signature_t to encode
* @return SBP_OK on success, or other libsbp error code
*/
SBP_EXPORT s8 sbp_digital_signature_encode(uint8_t *buf, uint8_t len,
uint8_t *n_written,
const sbp_digital_signature_t *msg);

/**
* Decode an instance of sbp_digital_signature_t from wire representation
*
* This function decodes the wire representation of a sbp_digital_signature_t
* message to the given instance. The caller must specify the length of the
* buffer in the \p len parameter. If non-null the number of bytes read from the
* buffer will be returned in \p n_read.
*
* @param buf Wire representation of the sbp_digital_signature_t instance
* @param len Length of \p buf
* @param n_read If not null, on success will be set to the number of bytes read
* from \p buf
* @param msg Destination
* @return SBP_OK on success, or other libsbp error code
*/
SBP_EXPORT s8 sbp_digital_signature_decode(const uint8_t *buf, uint8_t len,
uint8_t *n_read,
sbp_digital_signature_t *msg);

/**
* Compare two instances of sbp_digital_signature_t
*
* The two instances will be compared and a value returned consistent with the
* return codes of comparison functions from the C standard library
*
* 0 will be returned if \p a and \p b are considered equal
* A value less than 0 will be returned if \p a is considered to be less than \p
* b A value greater than 0 will be returned if \p b is considered to be greater
* than \p b
*
* @param a sbp_digital_signature_t instance
* @param b sbp_digital_signature_t instance
* @return 0, <0, >0
*/
SBP_EXPORT int sbp_digital_signature_cmp(const sbp_digital_signature_t *a,
const sbp_digital_signature_t *b);

#ifdef __cplusplus
}

static inline bool operator==(const sbp_digital_signature_t &lhs,
const sbp_digital_signature_t &rhs) {
return sbp_digital_signature_cmp(&lhs, &rhs) == 0;
}

static inline bool operator!=(const sbp_digital_signature_t &lhs,
const sbp_digital_signature_t &rhs) {
return sbp_digital_signature_cmp(&lhs, &rhs) != 0;
}

static inline bool operator<(const sbp_digital_signature_t &lhs,
const sbp_digital_signature_t &rhs) {
return sbp_digital_signature_cmp(&lhs, &rhs) < 0;
}

static inline bool operator<=(const sbp_digital_signature_t &lhs,
const sbp_digital_signature_t &rhs) {
return sbp_digital_signature_cmp(&lhs, &rhs) <= 0;
}

static inline bool operator>(const sbp_digital_signature_t &lhs,
const sbp_digital_signature_t &rhs) {
return sbp_digital_signature_cmp(&lhs, &rhs) > 0;
}

static inline bool operator>=(const sbp_digital_signature_t &lhs,
const sbp_digital_signature_t &rhs) {
return sbp_digital_signature_cmp(&lhs, &rhs) >= 0;
}

#endif // ifdef __cplusplus

#endif /* LIBSBP_SIGNING_DIGITALSIGNATURE_H */
Loading

0 comments on commit 4dc77a7

Please sign in to comment.