diff --git a/src/UDPC.h b/src/UDPC.h index 903a039..2cb9952 100644 --- a/src/UDPC.h +++ b/src/UDPC.h @@ -446,7 +446,7 @@ void UDPC_client_initiate_connection( * \param size The size in bytes of the data to be sent */ void UDPC_queue_send(UDPC_HContext ctx, UDPC_ConnectionId destinationId, - int isChecked, void *data, uint32_t size); + int isChecked, const void *data, uint32_t size); /*! * \brief Gets the size of the data structure holding queued packets @@ -475,6 +475,11 @@ unsigned long UDPC_get_queue_send_current_size(UDPC_HContext ctx); * UDPC_update() will lock this mutex, regardless of whether or not the context * is using threaded update). * + * If \p exists is a non-null pointer to an \p int, and a connection to a peer + * identified by \p id exists, then the value of \p exists will be set to + * non-zero, otherwise a non-existing peer will set the value of \p exists to + * zero. + * * \return The size of a connection's queue */ unsigned long UDPC_get_queued_size(UDPC_HContext ctx, UDPC_ConnectionId id, int *exists); @@ -625,15 +630,15 @@ UDPC_Event UDPC_get_event(UDPC_HContext ctx, unsigned long *remaining); UDPC_PacketInfo UDPC_get_received(UDPC_HContext ctx, unsigned long *remaining); -int UDPC_set_libsodium_keys(UDPC_HContext ctx, unsigned char *sk, unsigned char *pk); +int UDPC_set_libsodium_keys(UDPC_HContext ctx, const unsigned char *sk, const unsigned char *pk); -int UDPC_set_libsodium_key_easy(UDPC_HContext ctx, unsigned char *sk); +int UDPC_set_libsodium_key_easy(UDPC_HContext ctx, const unsigned char *sk); int UDPC_unset_libsodium_keys(UDPC_HContext ctx); -int UDPC_add_whitelist_pk(UDPC_HContext ctx, unsigned char *pk); -int UDPC_has_whitelist_pk(UDPC_HContext ctx, unsigned char *pk); -int UDPC_remove_whitelist_pk(UDPC_HContext ctx, unsigned char *pk); +int UDPC_add_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk); +int UDPC_has_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk); +int UDPC_remove_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk); int UDPC_clear_whitelist(UDPC_HContext ctx); int UDPC_get_auth_policy(UDPC_HContext ctx); diff --git a/src/UDPC_Defines.hpp b/src/UDPC_Defines.hpp index 368434e..e43d189 100644 --- a/src/UDPC_Defines.hpp +++ b/src/UDPC_Defines.hpp @@ -84,7 +84,7 @@ struct IPV6_Hasher { struct PKContainer { PKContainer(); - PKContainer(unsigned char *pk); + PKContainer(const unsigned char *pk); unsigned char pk[crypto_sign_PUBLICKEYBYTES]; diff --git a/src/UDPConnection.cpp b/src/UDPConnection.cpp index f0bb981..01055b0 100644 --- a/src/UDPConnection.cpp +++ b/src/UDPConnection.cpp @@ -69,7 +69,7 @@ UDPC::PKContainer::PKContainer() { std::memset(pk, 0, crypto_sign_PUBLICKEYBYTES); } -UDPC::PKContainer::PKContainer(unsigned char *pk) { +UDPC::PKContainer::PKContainer(const unsigned char *pk) { std::memcpy(this->pk, pk, crypto_sign_PUBLICKEYBYTES); } @@ -2117,7 +2117,7 @@ void UDPC_client_initiate_connection( } void UDPC_queue_send(UDPC_HContext ctx, UDPC_ConnectionId destinationId, - int isChecked, void *data, uint32_t size) { + int isChecked, const void *data, uint32_t size) { if(size == 0 || !data) { return; } @@ -2325,7 +2325,7 @@ UDPC_PacketInfo UDPC_get_received(UDPC_HContext ctx, unsigned long *remaining) { } } -int UDPC_set_libsodium_keys(UDPC_HContext ctx, unsigned char *sk, unsigned char *pk) { +int UDPC_set_libsodium_keys(UDPC_HContext ctx, const unsigned char *sk, const unsigned char *pk) { UDPC::Context *c = UDPC::verifyContext(ctx); if(!c || !c->flags.test(2)) { return 0; @@ -2338,7 +2338,7 @@ int UDPC_set_libsodium_keys(UDPC_HContext ctx, unsigned char *sk, unsigned char return 1; } -int UDPC_set_libsodium_key_easy(UDPC_HContext ctx, unsigned char *sk) { +int UDPC_set_libsodium_key_easy(UDPC_HContext ctx, const unsigned char *sk) { unsigned char pk[crypto_sign_PUBLICKEYBYTES]; if(crypto_sign_ed25519_sk_to_pk(pk, sk) != 0) { return 0; @@ -2358,7 +2358,7 @@ int UDPC_unset_libsodium_keys(UDPC_HContext ctx) { return 1; } -int UDPC_add_whitelist_pk(UDPC_HContext ctx, unsigned char *pk) { +int UDPC_add_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk) { UDPC::Context *c = UDPC::verifyContext(ctx); if(!c || !c->flags.test(2)) { return 0; @@ -2372,7 +2372,7 @@ int UDPC_add_whitelist_pk(UDPC_HContext ctx, unsigned char *pk) { return 0; } -int UDPC_has_whitelist_pk(UDPC_HContext ctx, unsigned char *pk) { +int UDPC_has_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk) { UDPC::Context *c = UDPC::verifyContext(ctx); if(!c || !c->flags.test(2)) { return 0; @@ -2385,7 +2385,7 @@ int UDPC_has_whitelist_pk(UDPC_HContext ctx, unsigned char *pk) { return 0; } -int UDPC_remove_whitelist_pk(UDPC_HContext ctx, unsigned char *pk) { +int UDPC_remove_whitelist_pk(UDPC_HContext ctx, const unsigned char *pk) { UDPC::Context *c = UDPC::verifyContext(ctx); if(!c || !c->flags.test(2)) { return 0;