Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# List alphabetically by surname

Pål-Erik Martinsen <palmarti@cisco.com>

Vladislav Volkov <wwwvladislav@gmail.com>
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include ( Uncrustify )
include ( GetGitRevisionDescription )
git_describe(VERSION --tags --dirty=-d)

string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" STUNLIBL_VERSION_MAJOR "${VERSION}")
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" STUNLIB_VERSION_MAJOR "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" STUNLIB_VERSION_MINOR "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STUNLIB_VERSION_PATCH "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" STUNLIB_VERSION_SHA1 "${VERSION}")
Expand Down Expand Up @@ -128,20 +128,20 @@ UncrustifyTop(${uncrustify})
if (build_docs)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
endif()

set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
else()
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

configure_file(${doxyfile_in} ${doxyfile} @ONLY)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)

add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation wit1h Doxygen"
VERBATIM)
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation wit1h Doxygen"
VERBATIM)

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
endif()
endif()


Expand Down
4 changes: 2 additions & 2 deletions include/stun_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -13,7 +13,7 @@ unsigned char* stunlib_util_md5(const void* data, size_t len, unsigned char* md)

void stunlib_util_sha1_hmac(const void* key, size_t keyLength, const void* data, size_t dataLength, void* macOut, unsigned int* macLength);

void stunlib_util_random(void* buffer, size_t size);
void stunlib_util_random(void* buffer, size_t size); // not threadsafe

uint32_t stunlib_util_crc32(long crc, const uint8_t* buf, size_t len);

Expand Down
26 changes: 4 additions & 22 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ set ( stunlib_srcs
stunlib.c
turnclient.c
stuntrace.c
stun_crypto.c
stun_random.c
stun_crc32.c
stun_md5.c
stun_sha1.c
)

set (ADDITIONAL_LIBS "")
Expand All @@ -25,27 +28,6 @@ install ( TARGETS stunlib

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)

find_package( ZLIB )
if ( ZLIB_FOUND )
include_directories( ${ZLIB_INCLUDE_DIRS} )
list(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES})
add_definitions(-DSTUNLIB_USE_ZLIB)
endif( ZLIB_FOUND )


find_package( OpenSSL )
if( OPENSSL_FOUND )
include_directories( ${OPENSSL_INCLUDE_DIR} )
list(APPEND ADDITIONAL_LIBS ${OPENSSL_LIBRARIES})
add_definitions(-DSTUNLIB_USE_OPENSSL)
endif( OPENSSL_FOUND )

# Todo fix propper library discovery.
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
list(APPEND ADDITIONAL_LIBS "bsd")
add_definitions(-DSTUNLIB_USE_BSD)
endif()

target_link_libraries ( stunlib PRIVATE sockaddrutil
${ADDITIONAL_LIBS})

Expand Down
48 changes: 48 additions & 0 deletions src/stun_crc32.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* See license file
*/

#include <stun_crypto.h>

static void
make_crc_table(uint32_t crc_table[256])
{
uint32_t c, n, k;

for (n = 0; n < 256u; n++)
{
c = n;
for (k = 0; k < 8; k++)
{
c = c & 1 ? 0xedb88320ul ^ (c >> 1) : c >> 1;
}
crc_table[n] = c;
}
}

static unsigned long
update_crc(uint32_t crc,
const uint8_t* buf,
size_t len,
uint32_t crc_table[256])
{
uint32_t c = crc ^ 0xfffffffful;
size_t n;

for (n = 0; n < len; n++)
{
c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
}

return c ^ 0xfffffffful;
}

uint32_t
stunlib_util_crc32(long crc,
const uint8_t* buf,
size_t len)
{
uint32_t crc_table[256];
make_crc_table(crc_table);
return update_crc(crc, buf, len, crc_table);
}
60 changes: 0 additions & 60 deletions src/stun_crypto.c

This file was deleted.

Loading