Operator Id
include/rid/operator_id.h
Operator ID message handling per ASTM F3411-22a.
Example usage:
rid_operator_id_t operator_id;
rid_operator_id_init(&operator_id);
rid_operator_id_set_type(&operator_id, RID_OPERATOR_ID_TYPE_DEFAULT);
rid_operator_id_set(&operator_id, "FIN87astrdge12k8");
hexdump(&operator_id, sizeof(operator_id));
char id[RID_OPERATOR_ID_SIZE + 1];
rid_operator_id_get(&operator_id, id, sizeof(id));
rid_operator_id_type_t id_type = rid_operator_id_get_type(&operator_id);
printf("Operator ID: %s\n", id);
printf("ID type: %d\n", id_type);
Structures and Types
| Type | Name |
|---|---|
| struct | rid_operator_id_t Operator ID message structure per ASTM F3411-22a. |
| enum | rid_operator_id_type_t Operator ID type classification per ASTM F3411-22a. |
Functions
| Type | Name |
|---|---|
| int | rid_operator_id_get (const rid_operator_id_t *message, char *buffer, size_t buffer_size) Get the Operator ID from an Operator ID message. |
| rid_operator_id_type_t | rid_operator_id_get_type (const rid_operator_id_t *message) Get the ID type from an Operator ID message. |
| int | rid_operator_id_init (rid_operator_id_t *message) Initialize an Operator ID message with default values. |
| int | rid_operator_id_set (rid_operator_id_t *message, const char *operator_id) Set the Operator ID for an Operator ID message. |
| int | rid_operator_id_set_type (rid_operator_id_t *message, rid_operator_id_type_t type) Set the ID type for an Operator ID message. |
| int | rid_operator_id_to_json (const rid_operator_id_t *message, char *buffer, size_t buffer_size, size_t *needed_size) Format an Operator ID message as a JSON string. |
| const char * | rid_operator_id_type_to_string (rid_operator_id_type_t type) Convert operator ID type to string representation. |
| int | rid_operator_id_validate (const rid_operator_id_t *message) Validate an Operator ID message structure. |
Macros
| Type | Name |
|---|---|
| define | RID_OPERATOR_ID_SIZE 20 Operator ID field size in bytes per ASTM F3411-22a. |
Structures and Types Documentation
struct rid_operator_id_t
Operator ID message structure per ASTM F3411-22a.
Variables:
-
uint8_t id_type
-
uint8_t message_type
-
char operator_id
-
uint8_t protocol_version
-
char reserved
enum rid_operator_id_type_t
Operator ID type classification per ASTM F3411-22a.
enum rid_operator_id_type_t {
RID_OPERATOR_ID_TYPE_DEFAULT = 0,
RID_OPERATOR_ID_TYPE_MAX = 255
};
Functions Documentation
function rid_operator_id_get
Get the Operator ID from an Operator ID message.
int rid_operator_id_get (
const rid_operator_id_t *message,
char *buffer,
size_t buffer_size
)
Copies the Operator ID to the provided buffer as a null-terminated string.
Parameters:
messagePointer to the Operator ID message structure.bufferBuffer to store the Operator ID.buffer_sizeSize of the buffer (must be at least RID_OPERATOR_ID_SIZE + 1).
Return value:
RID_SUCCESSon success.RID_ERROR_NULL_POINTERif message or buffer is NULL.RID_ERROR_BUFFER_TOO_SMALLif buffer_size is insufficient.
function rid_operator_id_get_type
Get the ID type from an Operator ID message.
rid_operator_id_type_t rid_operator_id_get_type (
const rid_operator_id_t *message
)
Parameters:
messagePointer to the Operator ID message structure.
Returns:
The ID type or RID_OPERATOR_ID_TYPE_DEFAULT if message is NULL.
function rid_operator_id_init
Initialize an Operator ID message with default values.
int rid_operator_id_init (
rid_operator_id_t *message
)
Sets protocol version to 2 and message type to OPERATOR_ID. All other fields are set to zero.
Parameters:
messagePointer to the Operator ID message structure.
Return value:
RID_SUCCESSon success.RID_ERROR_NULL_POINTERif message is NULL.
function rid_operator_id_set
Set the Operator ID for an Operator ID message.
int rid_operator_id_set (
rid_operator_id_t *message,
const char *operator_id
)
The Operator ID is a null-terminated string up to RID_OPERATOR_ID_SIZE characters.
Parameters:
messagePointer to the Operator ID message structure.operator_idThe Operator ID string to set.
Return value:
RID_SUCCESSon success.RID_ERROR_NULL_POINTERif message or operator_id is NULL.RID_ERROR_BUFFER_TOO_LARGEif operator_id exceeds RID_OPERATOR_ID_SIZE characters.RID_ERROR_INVALID_CHARACTERif operator ID contains non-ASCII or control characters.
function rid_operator_id_set_type
Set the ID type for an Operator ID message.
int rid_operator_id_set_type (
rid_operator_id_t *message,
rid_operator_id_type_t type
)
Parameters:
messagePointer to the Operator ID message structure.typeThe ID type to set.
Return value:
RID_SUCCESSon success.RID_ERROR_NULL_POINTERif message is NULL.RID_ERROR_OUT_OF_RANGEif type exceeds RID_OPERATOR_ID_TYPE_MAX.
function rid_operator_id_to_json
Format an Operator ID message as a JSON string.
int rid_operator_id_to_json (
const rid_operator_id_t *message,
char *buffer,
size_t buffer_size,
size_t *needed_size
)
Parameters:
messagePointer to the Operator ID message structure.bufferBuffer to store the JSON string or NULL.buffer_sizeSize of the buffer.needed_sizeIf non-NULL receives the required buffer size.
Return value:
RID_SUCCESSon success.RID_ERROR_NULL_POINTERifmessageis NULL or if bothbufferandneeded_sizeare NULL.RID_ERROR_BUFFER_TOO_SMALLifbufferis too small.
function rid_operator_id_type_to_string
Convert operator ID type to string representation.
const char * rid_operator_id_type_to_string (
rid_operator_id_type_t type
)
Parameters:
typeThe operator ID type to convert.
Returns:
String representation of the operator ID type. Returns "UNKNOWN" for invalid values.
function rid_operator_id_validate
Validate an Operator ID message structure.
int rid_operator_id_validate (
const rid_operator_id_t *message
)
Checks that all fields contain valid encoded values according to ASTM F3411-22a.
Parameters:
messagePointer to the Operator ID message structure to validate.
Return value:
RID_SUCCESSif all fields are valid.RID_ERROR_NULL_POINTERif message is NULL.RID_ERROR_INVALID_PROTOCOL_VERSIONif protocol version is invalid.RID_ERROR_UNKNOWN_MESSAGE_TYPEif message type is not OPERATOR_ID.RID_ERROR_INVALID_CHARACTERif operator ID contains non-ASCII or control characters.
Macros Documentation
define RID_OPERATOR_ID_SIZE
Operator ID field size in bytes per ASTM F3411-22a.
#define RID_OPERATOR_ID_SIZE 20