40#ifndef UDIF_TOPOLOGY_H
41#define UDIF_TOPOLOGY_H
92#if defined(UDIF_NETWORK_PROTOCOL_IPV6)
93# define UDIF_TOPOLOGY_NODE_ENCODED_SIZE (UDIF_CHILD_CERTIFICATE_ISSUER_PREFIX_SIZE + UDIF_CERTIFICATE_ISSUER_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
94 UDIF_CHILD_CERTIFICATE_ADDRESS_PREFIX_SIZE + QSC_IPINFO_IPV6_STRNLEN + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
95 UDIF_ROOT_CERTIFICATE_HASH_PREFIX_SIZE + (UDIF_CERTIFICATE_HASH_SIZE * 2U) + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
96 UDIF_CHILD_CERTIFICATE_SERIAL_PREFIX_SIZE + (UDIF_CERTIFICATE_SERIAL_SIZE * 2U) + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
97 UDIF_CHILD_CERTIFICATE_DESIGNATION_PREFIX + UDIF_NETWORK_DESIGNATION_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
98 UDIF_CHILD_CERTIFICATE_VALID_FROM_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
99 UDIF_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE)
101# define UDIF_TOPOLOGY_NODE_ENCODED_SIZE (UDIF_CHILD_CERTIFICATE_ISSUER_PREFIX_SIZE + UDIF_CERTIFICATE_ISSUER_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
102 UDIF_CHILD_CERTIFICATE_ADDRESS_PREFIX_SIZE + QSC_IPINFO_IPV4_STRNLEN + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
103 UDIF_ROOT_CERTIFICATE_HASH_PREFIX_SIZE + (UDIF_CERTIFICATE_HASH_SIZE * 2U) + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
104 UDIF_CHILD_CERTIFICATE_SERIAL_PREFIX_SIZE + (UDIF_CERTIFICATE_SERIAL_SIZE * 2U) + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
105 UDIF_CHILD_CERTIFICATE_DESIGNATION_PREFIX_SIZE + UDIF_NETWORK_DESIGNATION_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
106 UDIF_CHILD_CERTIFICATE_VALID_FROM_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
107 UDIF_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE)
114#define UDIF_TOPOLOGY_NODE_MINIMUM_ISSUER_SIZE 3U
120#define UDIF_TOPOLOGY_NODE_NOT_FOUND -1
126#define UDIF_NETWORK_TOPOLOGY_MAX_SIZE 1024U
132#define UDIF_NETWORK_TOPOLOGY_NODE_SIZE (UDIF_CERTIFICATE_ADDRESS_SIZE + \
133 UDIF_CERTIFICATE_HASH_SIZE + \
134 UDIF_CERTIFICATE_SERIAL_SIZE + \
135 UDIF_CERTIFICATE_ISSUER_SIZE + \
136 UDIF_CERTIFICATE_EXPIRATION_SIZE + \
137 UDIF_CERTIFICATE_DESIGNATION_SIZE)
146static const char UDIF_TOPOLOGY_NETWORK_DELIMITER[] =
"/";
151static const char UDIF_TOPOLOGY_CTYPE_DELIMITER[] =
".";
156static const char UDIF_TOPOLOGY_ALIAS_DELIMITER[] =
":";
654#if defined(UDIF_DEBUG_MODE)
662UDIF_EXPORT_API
bool udif_topology_functions_test();
UDIF Certificate Handling Functions.
The UDIF topology list structure.
Definition topology.h:185
uint8_t * topology
Definition topology.h:186
uint32_t count
Definition topology.h:187
The UDIF topology node structure.
Definition topology.h:169
udif_certificate_expiration expiration
Definition topology.h:174
uint8_t chash[UDIF_CERTIFICATE_HASH_SIZE]
Definition topology.h:171
char address[UDIF_CERTIFICATE_ADDRESS_SIZE]
Definition topology.h:170
uint8_t serial[UDIF_CERTIFICATE_SERIAL_SIZE]
Definition topology.h:172
udif_network_designations designation
Definition topology.h:175
char issuer[UDIF_CERTIFICATE_ISSUER_SIZE]
Definition topology.h:173
UDIF_EXPORT_API size_t udif_topology_list_size(const udif_topology_list_state *list)
Get the byte size of the serialized list.
Definition topology.c:449
UDIF_EXPORT_API bool udif_topology_node_verify_root(const udif_topology_list_state *list, const udif_root_certificate *rcert)
Verify that the root certificate matches the hash stored in the topology.
Definition topology.c:1133
UDIF_EXPORT_API bool udif_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
UDIF_EXPORT_API bool udif_topology_node_verify_issuer(const udif_topology_list_state *list, const udif_child_certificate *ccert, const char *issuer)
Verify that an issuing node's certificate matches the hash stored in the topology.
Definition topology.c:1107
UDIF_EXPORT_API bool udif_topology_node_find_alias(const udif_topology_list_state *list, udif_topology_node_state *node, const char *alias)
Return the node pointer in the list matching the alias string.
Definition topology.c:785
UDIF_EXPORT_API void udif_topology_address_from_issuer(char *address, const char *issuer, const udif_topology_list_state *list)
Returns an IP address from an issuer string.
Definition topology.c:12
UDIF_EXPORT_API void udif_topology_list_clone(const udif_topology_list_state *tlist, udif_topology_list_state *tcopy)
Clone a topology list.
Definition topology.c:220
UDIF_EXPORT_API void udif_topology_node_remove(udif_topology_list_state *list, const uint8_t *serial)
Find and remove a node from the topology.
Definition topology.c:987
UDIF_EXPORT_API bool udif_topology_node_find(const udif_topology_list_state *list, udif_topology_node_state *node, const uint8_t *serial)
Return the node pointer in the list matching the serial number.
Definition topology.c:711
UDIF_EXPORT_API void udif_topology_list_dispose(udif_topology_list_state *list)
Dispose of the topology list and release memory.
Definition topology.c:267
UDIF_EXPORT_API void udif_topology_list_deserialize(udif_topology_list_state *list, const uint8_t *input, size_t inplen)
Deserialize a topology list.
Definition topology.c:235
UDIF_EXPORT_API void udif_topology_to_file(const udif_topology_list_state *list, const char *fpath)
Copy a topology list to a file.
Definition topology.c:1328
UDIF_EXPORT_API void udif_topology_list_initialize(udif_topology_list_state *list)
Initialize the topology list.
Definition topology.c:283
UDIF_EXPORT_API size_t udif_topology_node_encode(const udif_topology_node_state *node, char output[UDIF_TOPOLOGY_NODE_ENCODED_SIZE])
Encode a topological node into a printable string.
UDIF_EXPORT_API size_t udif_topology_ordered_server_list(udif_topology_list_state *olist, const udif_topology_list_state *tlist, udif_network_designations ntype)
Return a list of nodes of a type, sorted by serial number.
Definition topology.c:527
UDIF_EXPORT_API size_t udif_topology_list_remove_duplicates(udif_topology_list_state *list)
Remove duplicate nodes from the topology.
Definition topology.c:320
UDIF_EXPORT_API void udif_topology_root_register(udif_topology_list_state *list, const udif_root_certificate *rcert, const char *address)
Register a root to a topology list.
Definition topology.c:1158
UDIF_EXPORT_API void udif_topology_child_add_item(udif_topology_list_state *list, const udif_topology_node_state *node)
Add a node to the topology list.
Definition topology.c:87
UDIF_EXPORT_API size_t udif_topology_list_serialize(uint8_t *output, const udif_topology_list_state *list)
Serialize a topology list.
Definition topology.c:420
UDIF_EXPORT_API bool udif_topology_nodes_are_equal(const udif_topology_node_state *a, const udif_topology_node_state *b)
Compare two topological nodes for equality.
Definition topology.c:618
#define UDIF_TOPOLOGY_NODE_ENCODED_SIZE
The size of an encoded node string.
Definition topology.h:101
UDIF_EXPORT_API size_t udif_topology_list_update_unpack(udif_topology_list_state *list, const uint8_t *input, size_t inplen)
Unpack a node update set to the topology list.
Definition topology.c:497
UDIF_EXPORT_API size_t udif_topology_list_update_pack(uint8_t *output, const udif_topology_list_state *list, udif_network_designations ntype)
Pack a node update set to an array.
Definition topology.c:468
UDIF_EXPORT_API int32_t udif_topology_node_get_index(const udif_topology_list_state *list, const uint8_t *serial)
Find the index number of a node in an array.
Definition topology.c:958
UDIF_EXPORT_API bool udif_topology_node_find_issuer(const udif_topology_list_state *list, udif_topology_node_state *node, const char *issuer)
Return the node pointer in the list matching the name string.
Definition topology.c:858
UDIF_EXPORT_API void udif_topology_from_file(const char *fpath, udif_topology_list_state *list)
Copy a topology list from a file.
Definition topology.c:1299
UDIF_EXPORT_API bool udif_topology_list_item(const udif_topology_list_state *list, udif_topology_node_state *node, size_t index)
Get a node from the index.
Definition topology.c:294
UDIF_EXPORT_API size_t udif_topology_list_server_count(const udif_topology_list_state *list, udif_network_designations ntype)
Get the count of a type of node in the database.
Definition topology.c:393
UDIF_EXPORT_API void udif_topology_node_deserialize(udif_topology_node_state *node, const uint8_t *input)
Deserialize a topological node.
Definition topology.c:686
UDIF_EXPORT_API bool udif_topology_node_find_ads(const udif_topology_list_state *list, udif_topology_node_state *node)
Return the ADC node from the list.
Definition topology.c:822
UDIF_EXPORT_API void udif_topology_node_remove_duplicate(udif_topology_list_state *list, const char *issuer)
Remove a node from the topology with the same issuer name.
Definition topology.c:1035
UDIF_EXPORT_API size_t udif_topology_list_to_string(const udif_topology_list_state *list, char *output, size_t outlen)
Convert the topology list to a printable string.
Definition topology.c:1181
UDIF_EXPORT_API void udif_topology_node_copy(const udif_topology_node_state *source, udif_topology_node_state *destination)
Copy a source node to a destination node structure.
Definition topology.c:669
UDIF_EXPORT_API size_t udif_topology_node_serialize(uint8_t *output, const udif_topology_node_state *node)
Serialize a topological node structure, including the mfk.
Definition topology.c:1052
UDIF_EXPORT_API bool udif_topology_node_find_root(const udif_topology_list_state *list, udif_topology_node_state *node)
Return the ARS server node from the list.
Definition topology.c:905
UDIF_EXPORT_API void udif_topology_node_add_alias(udif_topology_node_state *node, const char *alias)
Add an alias string to an issuer path.
Definition topology.c:585
UDIF_EXPORT_API void udif_topology_child_register(udif_topology_list_state *list, const udif_child_certificate *ccert, const char *address)
Register a child to a topology list.
Definition topology.c:187
UDIF_EXPORT_API bool udif_topology_node_find_address(const udif_topology_list_state *list, udif_topology_node_state *node, const char *address)
Return the node pointer in the list matching the address string.
Definition topology.c:748
UDIF_EXPORT_API bool udif_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
UDIF_EXPORT_API void udif_topology_node_clear(udif_topology_node_state *node)
Erase a node structure.
Definition topology.c:653
UDIF_EXPORT_API bool udif_topology_node_verify_ads(const udif_topology_list_state *list, const udif_child_certificate *ccert)
Verify that the ADC certificate matches the hash stored in the topology.
Definition topology.c:1082
UDIF_EXPORT_API bool udif_topology_node_exists(const udif_topology_list_state *list, const uint8_t *serial)
Queries on the serial number if the node is in the database.
Definition topology.c:941
UDIF_EXPORT_API uint8_t * udif_topology_child_add_empty_node(udif_topology_list_state *list)
Get an empty node pointer from the topology list.
Definition topology.c:43
UDIF Common Definitions and Core Library Configuration.
#define UDIF_CERTIFICATE_HASH_SIZE
The size of the certificate hash in bytes.
Definition udif.h:892
#define UDIF_CERTIFICATE_ADDRESS_SIZE
The maximum IP address length.
Definition udif.h:862
udif_network_designations
The UDIF device designation.
Definition udif.h:1297
#define UDIF_CERTIFICATE_SERIAL_SIZE
The certificate serial number field length.
Definition udif.h:923
#define UDIF_CERTIFICATE_ISSUER_SIZE
The maximum certificate issuer string length. The last character must be a string terminator.
Definition udif.h:899