52#ifndef UDIF_TOPOLOGY_H
53#define UDIF_TOPOLOGY_H
104#if defined(UDIF_NETWORK_PROTOCOL_IPV6)
105# define UDIF_TOPOLOGY_NODE_ENCODED_SIZE (UDIF_CHILD_CERTIFICATE_ISSUER_PREFIX_SIZE + UDIF_CERTIFICATE_ISSUER_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
106 UDIF_CHILD_CERTIFICATE_ADDRESS_PREFIX_SIZE + QSC_IPINFO_IPV6_STRNLEN + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
107 UDIF_ROOT_CERTIFICATE_HASH_PREFIX_SIZE + (UDIF_CERTIFICATE_HASH_SIZE * 2U) + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
108 UDIF_CHILD_CERTIFICATE_SERIAL_PREFIX_SIZE + (UDIF_CERTIFICATE_SERIAL_SIZE * 2U) + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
109 UDIF_CHILD_CERTIFICATE_DESIGNATION_PREFIX + UDIF_NETWORK_DESIGNATION_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
110 UDIF_CHILD_CERTIFICATE_VALID_FROM_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
111 UDIF_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE)
113# define UDIF_TOPOLOGY_NODE_ENCODED_SIZE (UDIF_CHILD_CERTIFICATE_ISSUER_PREFIX_SIZE + UDIF_CERTIFICATE_ISSUER_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
114 UDIF_CHILD_CERTIFICATE_ADDRESS_PREFIX_SIZE + QSC_IPINFO_IPV4_STRNLEN + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
115 UDIF_ROOT_CERTIFICATE_HASH_PREFIX_SIZE + (UDIF_CERTIFICATE_HASH_SIZE * 2U) + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
116 UDIF_CHILD_CERTIFICATE_SERIAL_PREFIX_SIZE + (UDIF_CERTIFICATE_SERIAL_SIZE * 2U) + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
117 UDIF_CHILD_CERTIFICATE_DESIGNATION_PREFIX_SIZE + UDIF_NETWORK_DESIGNATION_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
118 UDIF_CHILD_CERTIFICATE_VALID_FROM_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE + \
119 UDIF_CHILD_CERTIFICATE_EXPIRATION_TO_PREFIX_SIZE + QSC_TIMESTAMP_STRING_SIZE + UDIF_CERTIFICATE_SEPERATOR_SIZE)
126#define UDIF_TOPOLOGY_NODE_MINIMUM_ISSUER_SIZE 3U
132#define UDIF_TOPOLOGY_NODE_NOT_FOUND -1
138#define UDIF_NETWORK_TOPOLOGY_MAX_SIZE 1024U
144#define UDIF_NETWORK_TOPOLOGY_NODE_SIZE (UDIF_CERTIFICATE_ADDRESS_SIZE + \
145 UDIF_CERTIFICATE_HASH_SIZE + \
146 UDIF_CERTIFICATE_SERIAL_SIZE + \
147 UDIF_CERTIFICATE_ISSUER_SIZE + \
148 UDIF_CERTIFICATE_EXPIRATION_SIZE + \
149 UDIF_CERTIFICATE_DESIGNATION_SIZE)
158static const char UDIF_TOPOLOGY_NETWORK_DELIMITER[] =
"/";
163static const char UDIF_TOPOLOGY_CTYPE_DELIMITER[] =
".";
168static const char UDIF_TOPOLOGY_ALIAS_DELIMITER[] =
":";
183 uint8_t
chash[UDIF_CERTIFICATE_HASH_SIZE];
184 uint8_t
serial[UDIF_CERTIFICATE_SERIAL_SIZE];
666#if defined(UDIF_DEBUG_MODE)
UDIF Certificate Handling Functions.
#define UDIF_CERTIFICATE_ADDRESS_SIZE
The maximum IP address length.
Definition certificate.h:83
#define UDIF_CERTIFICATE_ISSUER_SIZE
The maximum certificate issuer string length. The last character must be a string terminator.
Definition certificate.h:138
The UDIF topology list structure.
Definition topology.h:197
uint8_t * topology
Definition topology.h:198
uint32_t count
Definition topology.h:199
The UDIF topology node structure.
Definition topology.h:181
udif_certificate_expiration expiration
Definition topology.h:186
uint8_t chash[UDIF_CERTIFICATE_HASH_SIZE]
Definition topology.h:183
char address[UDIF_CERTIFICATE_ADDRESS_SIZE]
Definition topology.h:182
uint8_t serial[UDIF_CERTIFICATE_SERIAL_SIZE]
Definition topology.h:184
udif_network_designations designation
Definition topology.h:187
char issuer[UDIF_CERTIFICATE_ISSUER_SIZE]
Definition topology.h:185
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.
Definition topology.c:1210
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:113
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 Protocol Configuration.
#define UDIF_EXPORT_API
The api export prefix.
Definition udifcommon.h:103