40#ifndef AERN_TOPOLOGY_H
41#define AERN_TOPOLOGY_H
92#if defined(AERN_NETWORK_PROTOCOL_IPV6)
93# define AERN_TOPOLOGY_NODE_ENCODED_SIZE (AERN_CHILD_CERTIFICATE_ISSUER_PREFIX_SIZE + AERN_CERTIFICATE_ISSUER_SIZE + AERN_CERTIFICATE_SEPERATOR_SIZE + \
94 AERN_CHILD_CERTIFICATE_ADDRESS_PREFIX_SIZE + QSC_IPINFO_IPV6_STRNLEN + AERN_CERTIFICATE_SEPERATOR_SIZE + \
95 AERN_ROOT_CERTIFICATE_HASH_PREFIX_SIZE + (AERN_CERTIFICATE_HASH_SIZE * 2U) + AERN_CERTIFICATE_SEPERATOR_SIZE + \
96 AERN_CHILD_CERTIFICATE_SERIAL_PREFIX_SIZE + (AERN_CERTIFICATE_SERIAL_SIZE * 2U) + AERN_CERTIFICATE_SEPERATOR_SIZE + \
97 AERN_CHILD_CERTIFICATE_DESIGNATION_PREFIX_SIZE + AERN_NETWORK_DESIGNATION_SIZE + AERN_CERTIFICATE_SEPERATOR_SIZE + \
98 AERN_CHILD_CERTIFICATE_VALID_FROM_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + AERN_CERTIFICATE_SEPERATOR_SIZE + \
99 AERN_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + AERN_CERTIFICATE_SEPERATOR_SIZE)
101# define AERN_TOPOLOGY_NODE_ENCODED_SIZE (AERN_CHILD_CERTIFICATE_ISSUER_PREFIX_SIZE + AERN_CERTIFICATE_ISSUER_SIZE + AERN_CERTIFICATE_SEPERATOR_SIZE + \
102 AERN_CHILD_CERTIFICATE_ADDRESS_PREFIX_SIZE + QSC_IPINFO_IPV4_STRNLEN + AERN_CERTIFICATE_SEPERATOR_SIZE + \
103 AERN_ROOT_CERTIFICATE_HASH_PREFIX_SIZE + (AERN_CERTIFICATE_HASH_SIZE * 2U) + AERN_CERTIFICATE_SEPERATOR_SIZE + \
104 AERN_CHILD_CERTIFICATE_SERIAL_PREFIX_SIZE + (AERN_CERTIFICATE_SERIAL_SIZE * 2U) + AERN_CERTIFICATE_SEPERATOR_SIZE + \
105 AERN_CHILD_CERTIFICATE_DESIGNATION_PREFIX_SIZE + AERN_NETWORK_DESIGNATION_SIZE + AERN_CERTIFICATE_SEPERATOR_SIZE + \
106 AERN_CHILD_CERTIFICATE_VALID_FROM_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + AERN_CERTIFICATE_SEPERATOR_SIZE + \
107 AERN_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + AERN_CERTIFICATE_SEPERATOR_SIZE)
114#define AERN_TOPOLOGY_NODE_MINIMUM_ISSUER_SIZE 3U
120#define AERN_TOPOLOGY_NODE_NOT_FOUND -1
126#define AERN_NETWORK_TOPOLOGY_MAX_SIZE 1024U
132#define AERN_NETWORK_TOPOLOGY_NODE_SIZE (AERN_CERTIFICATE_ADDRESS_SIZE + \
133 AERN_CERTIFICATE_HASH_SIZE + \
134 AERN_CERTIFICATE_SERIAL_SIZE + \
135 AERN_CERTIFICATE_ISSUER_SIZE + \
136 AERN_CERTIFICATE_EXPIRATION_SIZE + \
137 AERN_CERTIFICATE_DESIGNATION_SIZE)
146static const char AERN_TOPOLOGY_NETWORK_DELIMITER[] =
"/";
151static const char AERN_TOPOLOGY_CTYPE_DELIMITER[] =
".";
156static const char AERN_TOPOLOGY_ALIAS_DELIMITER[] =
":";
654#if defined(AERN_DEBUG_MODE)
662AERN_EXPORT_API
bool aern_topology_functions_test();
AERN Common Definitions and Protocol Configuration.
#define AERN_CERTIFICATE_ISSUER_SIZE
The maximum certificate issuer string length. The last character must be a string terminator.
Definition aern.h:813
#define AERN_CERTIFICATE_ADDRESS_SIZE
The maximum IP address length.
Definition aern.h:776
aern_network_designations
The AERN device designation.
Definition aern.h:1140
#define AERN_CERTIFICATE_HASH_SIZE
The size of the certificate hash in bytes.
Definition aern.h:806
#define AERN_CERTIFICATE_SERIAL_SIZE
The certificate serial number field length.
Definition aern.h:837
AERN Certificate Handling Functions.
The certificate expiration time structure.
Definition aern.h:1308
The child certificate structure.
Definition aern.h:1318
The root certificate structure.
Definition aern.h:1436
The AERN topology list structure.
Definition topology.h:185
uint8_t * topology
Definition topology.h:186
uint32_t count
Definition topology.h:187
The AERN topology node structure.
Definition topology.h:169
char issuer[AERN_CERTIFICATE_ISSUER_SIZE]
Definition topology.h:173
char address[AERN_CERTIFICATE_ADDRESS_SIZE]
Definition topology.h:170
aern_certificate_expiration expiration
Definition topology.h:174
uint8_t serial[AERN_CERTIFICATE_SERIAL_SIZE]
Definition topology.h:172
aern_network_designations designation
Definition topology.h:175
uint8_t chash[AERN_CERTIFICATE_HASH_SIZE]
Definition topology.h:171
AERN_EXPORT_API void aern_topology_node_remove_duplicate(aern_topology_list_state *list, const char *issuer)
Remove a node from the topology with the same issuer name.
Definition topology.c:1035
AERN_EXPORT_API bool aern_topology_node_find_ads(const aern_topology_list_state *list, aern_topology_node_state *node)
Return the ADC node from the list.
Definition topology.c:822
AERN_EXPORT_API size_t aern_topology_list_update_pack(uint8_t *output, const aern_topology_list_state *list, aern_network_designations ntype)
Pack a node update set to an array.
Definition topology.c:468
AERN_EXPORT_API bool aern_topology_node_find_address(const aern_topology_list_state *list, aern_topology_node_state *node, const char *address)
Return the node pointer in the list matching the address string.
Definition topology.c:748
AERN_EXPORT_API bool aern_topology_node_find_issuer(const aern_topology_list_state *list, aern_topology_node_state *node, const char *issuer)
Return the node pointer in the list matching the name string.
Definition topology.c:858
AERN_EXPORT_API void aern_topology_list_deserialize(aern_topology_list_state *list, const uint8_t *input, size_t inplen)
Deserialize a topology list.
Definition topology.c:235
AERN_EXPORT_API size_t aern_topology_list_serialize(uint8_t *output, const aern_topology_list_state *list)
Serialize a topology list.
Definition topology.c:420
AERN_EXPORT_API size_t aern_topology_list_size(const aern_topology_list_state *list)
Get the byte size of the serialized list.
Definition topology.c:449
AERN_EXPORT_API void aern_topology_from_file(const char *fpath, aern_topology_list_state *list)
Copy a topology list from a file.
Definition topology.c:1299
AERN_EXPORT_API size_t aern_topology_list_server_count(const aern_topology_list_state *list, aern_network_designations ntype)
Get the count of a type of node in the database.
Definition topology.c:393
AERN_EXPORT_API size_t aern_topology_list_update_unpack(aern_topology_list_state *list, const uint8_t *input, size_t inplen)
Unpack a node update set to the topology list.
Definition topology.c:497
AERN_EXPORT_API int32_t aern_topology_node_get_index(const aern_topology_list_state *list, const uint8_t *serial)
Find the index number of a node in an array.
Definition topology.c:958
AERN_EXPORT_API void aern_topology_child_register(aern_topology_list_state *list, const aern_child_certificate *ccert, const char *address)
Register a child to a topology list.
Definition topology.c:187
AERN_EXPORT_API bool aern_topology_node_verify_root(const aern_topology_list_state *list, const aern_root_certificate *rcert)
Verify that the root certificate matches the hash stored in the topology.
Definition topology.c:1133
AERN_EXPORT_API size_t aern_topology_node_encode(const aern_topology_node_state *node, char output[AERN_TOPOLOGY_NODE_ENCODED_SIZE])
Encode a topological node into a printable string.
Definition topology.c:1210
AERN_EXPORT_API bool aern_topology_node_verify_issuer(const aern_topology_list_state *list, const aern_child_certificate *ccert, const char *issuer)
Verify that an issuing node's certificate matches the hash stored in the topology.
Definition topology.c:1107
AERN_EXPORT_API uint8_t * aern_topology_child_add_empty_node(aern_topology_list_state *list)
Get an empty node pointer from the topology list.
Definition topology.c:43
AERN_EXPORT_API void aern_topology_node_copy(const aern_topology_node_state *source, aern_topology_node_state *destination)
Copy a source node to a destination node structure.
Definition topology.c:669
AERN_EXPORT_API bool aern_topology_node_verify_ads(const aern_topology_list_state *list, const aern_child_certificate *ccert)
Verify that the ADC certificate matches the hash stored in the topology.
Definition topology.c:1082
AERN_EXPORT_API bool aern_topology_canonical_to_issuer_name(char *issuer, size_t isslen, const char *domain, const char *cname)
Translate a canonical name to an issuer name.
Definition topology.c:109
AERN_EXPORT_API bool aern_topology_node_find_alias(const aern_topology_list_state *list, aern_topology_node_state *node, const char *alias)
Return the node pointer in the list matching the alias string.
Definition topology.c:785
#define AERN_TOPOLOGY_NODE_ENCODED_SIZE
The size of an encoded node string.
Definition topology.h:101
AERN_EXPORT_API bool aern_topology_nodes_are_equal(const aern_topology_node_state *a, const aern_topology_node_state *b)
Compare two topological nodes for equality.
Definition topology.c:618
AERN_EXPORT_API bool aern_topology_node_find_root(const aern_topology_list_state *list, aern_topology_node_state *node)
Return the ARS server node from the list.
Definition topology.c:905
AERN_EXPORT_API void aern_topology_list_initialize(aern_topology_list_state *list)
Initialize the topology list.
Definition topology.c:283
AERN_EXPORT_API void aern_topology_to_file(const aern_topology_list_state *list, const char *fpath)
Copy a topology list to a file.
Definition topology.c:1328
AERN_EXPORT_API size_t aern_topology_node_serialize(uint8_t *output, const aern_topology_node_state *node)
Serialize a topological node structure, including the mfk.
Definition topology.c:1052
AERN_EXPORT_API bool aern_topology_issuer_to_canonical_name(char *cname, size_t namelen, const char *issuer)
Translate an issuer name to a canonical name.
Definition topology.c:147
AERN_EXPORT_API void aern_topology_list_dispose(aern_topology_list_state *list)
Dispose of the topology list and release memory.
Definition topology.c:267
AERN_EXPORT_API void aern_topology_root_register(aern_topology_list_state *list, const aern_root_certificate *rcert, const char *address)
Register a root to a topology list.
Definition topology.c:1158
AERN_EXPORT_API size_t aern_topology_ordered_server_list(aern_topology_list_state *olist, const aern_topology_list_state *tlist, aern_network_designations ntype)
Return a list of nodes of a type, sorted by serial number.
Definition topology.c:527
AERN_EXPORT_API void aern_topology_node_add_alias(aern_topology_node_state *node, const char *alias)
Add an alias string to an issuer path.
Definition topology.c:585
AERN_EXPORT_API void aern_topology_node_remove(aern_topology_list_state *list, const uint8_t *serial)
Find and remove a node from the topology.
Definition topology.c:987
AERN_EXPORT_API void aern_topology_node_deserialize(aern_topology_node_state *node, const uint8_t *input)
Deserialize a topological node.
Definition topology.c:686
AERN_EXPORT_API void aern_topology_node_clear(aern_topology_node_state *node)
Erase a node structure.
Definition topology.c:653
AERN_EXPORT_API bool aern_topology_list_item(const aern_topology_list_state *list, aern_topology_node_state *node, size_t index)
Get a node from the index.
Definition topology.c:294
AERN_EXPORT_API void aern_topology_child_add_item(aern_topology_list_state *list, const aern_topology_node_state *node)
Add a node to the topology list.
Definition topology.c:87
AERN_EXPORT_API size_t aern_topology_list_to_string(const aern_topology_list_state *list, char *output, size_t outlen)
Convert the topology list to a printable string.
Definition topology.c:1181
AERN_EXPORT_API size_t aern_topology_list_remove_duplicates(aern_topology_list_state *list)
Remove duplicate nodes from the topology.
Definition topology.c:320
AERN_EXPORT_API bool aern_topology_node_find(const aern_topology_list_state *list, aern_topology_node_state *node, const uint8_t *serial)
Return the node pointer in the list matching the serial number.
Definition topology.c:711
AERN_EXPORT_API void aern_topology_address_from_issuer(char *address, const char *issuer, const aern_topology_list_state *list)
Returns an IP address from an issuer string.
Definition topology.c:12
AERN_EXPORT_API bool aern_topology_node_exists(const aern_topology_list_state *list, const uint8_t *serial)
Queries on the serial number if the node is in the database.
Definition topology.c:941
AERN_EXPORT_API void aern_topology_list_clone(const aern_topology_list_state *tlist, aern_topology_list_state *tcopy)
Clone a topology list.
Definition topology.c:220