Skip to content

Commit

Permalink
Merge remote-tracking branch 'ethouris/dev-add-obtaining-network-id' …
Browse files Browse the repository at this point in the history
…into dev-add-obtaining-network-id
  • Loading branch information
Mikołaj Małecki committed Aug 14, 2024
2 parents efaf0d7 + 42666ca commit 4f9aa57
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cxx11-win.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: configure
run: |
md _build && cd _build
cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_LOCALIF_WIN32
cmake ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_ENCRYPTION=OFF -DENABLE_UNITTESTS=ON -DENABLE_BONDING=ON -DENABLE_LOCALIF_WIN32=ON
- name: build
run: cd _build && cmake --build ./ --config Release
- name: test
Expand Down
19 changes: 13 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ option(ENABLE_PKTINFO "Enable using IP_PKTINFO to allow the listener extracting
option(ENABLE_RELATIVE_LIBPATH "Should application contain relative library paths, like ../lib" OFF)
option(ENABLE_GETNAMEINFO "In-logs sockaddr-to-string should do rev-dns" OFF)
option(ENABLE_UNITTESTS "Enable unit tests" OFF)
option(ENABLE_UNITTESTS_AUTO "Enable unit tests" OFF)
option(ENABLE_ENCRYPTION "Enable encryption in SRT" ON)
option(ENABLE_AEAD_API_PREVIEW "Enable AEAD API preview in SRT" Off)
option(ENABLE_MAXREXMITBW "Enable SRTO_MAXREXMITBW (v1.6.0 API preview)" Off)
Expand All @@ -175,7 +176,7 @@ option(USE_OPENSSL_PC "Use pkg-config to find OpenSSL libraries" ON)
option(OPENSSL_USE_STATIC_LIBS "Link OpenSSL libraries statically." OFF)
option(USE_BUSY_WAITING "Enable more accurate sending times at a cost of potentially higher CPU load" OFF)
option(USE_GNUSTL "Get c++ library/headers from the gnustl.pc" OFF)
option(ENABLE_LOCALIF_WIN32 "Enable rendezvous-connect-to-self prevention on Windows (adds Iphlpapi.lib dep)" OFF)
option(ENABLE_LOCALIF_WIN32 "Enable local interface check ability on Windows (adds Iphlpapi.lib dep)" OFF)
option(ENABLE_SOCK_CLOEXEC "Enable setting SOCK_CLOEXEC on a socket" ON)
option(ENABLE_SHOW_PROJECT_CONFIG "Enable show Project Configuration" OFF)

Expand Down Expand Up @@ -1282,6 +1283,10 @@ macro(srt_add_program_dont_install name)
add_executable(${name} ${ARGN})
target_include_directories(${name} PRIVATE apps)
target_include_directories(${name} PRIVATE common)
if (MICROSOFT AND ENABLE_LOCALIF_WIN32)
target_link_libraries(${name} Iphlpapi)
add_definitions(-DSRT_ENABLE_LOCALIF_WIN32)
endif()
endmacro()

macro(srt_add_program name)
Expand All @@ -1293,10 +1298,6 @@ macro(srt_add_program name)
else()
message(WARNING "No location to install program ${name}")
endif()
if (MICROSOFT AND ENABLE_LOCALIF_WIN32)
target_link_libraries(${name} Iphlpapi)
add_definitions(-DSRT_ENABLE_LOCALIF_WIN32)
endif()
endmacro()

macro(srt_make_application name)
Expand Down Expand Up @@ -1477,6 +1478,10 @@ endif()
srt_add_example(testcapi-connect.c)
endif()

if (ENABLE_UNITTESTS_AUTO)
set (ENABLE_UNITTESTS ON)
endif()


if (ENABLE_UNITTESTS AND ENABLE_CXX11)

Expand Down Expand Up @@ -1532,7 +1537,9 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11)
#set_tests_properties(test-srt PROPERTIES RUN_SERIAL TRUE)
else()
set_tests_properties(${tests_srt} PROPERTIES RUN_SERIAL TRUE)
gtest_discover_tests(test-srt)
if (ENABLE_UNITTESTS_AUTO)
gtest_discover_tests(test-srt)
endif()
endif()

enable_testing()
Expand Down
8 changes: 5 additions & 3 deletions srtcore/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,15 @@ vector<LocalInterface> GetLocalInterfaces()
ULONG st = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &outBufLen);
if (st == ERROR_SUCCESS)
{
for (PIP_ADAPTER_ADDRESSES* i = pAddresses; i; i = pAddresses->Next)
for (PIP_ADAPTER_ADDRESSES i = pAddresses; i; i = pAddresses->Next)
{
std::string name = i->AdapterName;
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = pAddresses->FirstUnicastAddress;
while (pUnicast)
{
LocalInterface a;
a.addr = pUnicast->Address.lpSockaddr;
if (pUnicast->Address.lpSockaddr)
a.addr = pUnicast->Address.lpSockaddr;
if (a.addr.len > 0)
{
// DO NOT collect addresses that are not of
Expand All @@ -527,7 +528,8 @@ vector<LocalInterface> GetLocalInterfaces()
for (pif = pifa; pif; pif = pif->ifa_next)
{
LocalInterface i;
i.addr = pif->ifa_addr;
if (pif->ifa_addr)
i.addr = pif->ifa_addr;
if (i.addr.len > 0)
{
// DO NOT collect addresses that are not of
Expand Down
8 changes: 6 additions & 2 deletions testing/testmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,17 @@ void SrtCommon::AcceptNewClient()
}

sockaddr_any agentaddr(AF_INET6);
string agent = "<?AGENT?>";
string agent = "<?AGENT?>", dev;
if (-1 != srt_getsockname(m_sock, (agentaddr.get()), (&agentaddr.len)))
{
agent = agentaddr.str();
char name[256];
size_t len = 255;
if (srt_getsockdevname(m_sock, name, &len) == SRT_SUCCESS)
dev.assign(name, len);
}

Verb() << " connected [" << agent << "] <-- " << peer;
Verb() << " connected [" << agent << "] <-- " << peer << " [" << dev << "]";
}
::transmit_throw_on_interrupt = false;

Expand Down

0 comments on commit 4f9aa57

Please sign in to comment.