Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
63125b4
Use original d927858d347dd2f7a2295bd38d43495330e88cfb from repo - to …
talaviram Oct 31, 2024
e28d84e
mdns.h - use latest commit with non-breaking API. (4c64fbaa4a5dcac567…
talaviram Oct 31, 2024
e43065b
Refactored ServiceRecord to mdns.cpp it's not used elsewhere and chan…
talaviram Nov 3, 2024
a33ff81
mdns.h - [Broken! not compiling] 4c64fbaa4a5dcac567c63f182cac2d7a4adc…
talaviram Oct 31, 2024
a86c9f2
mdns.h - [Still won't compile "cherry-pick" Explicit conversion requi…
talaviram Oct 31, 2024
88e1237
Still broken! - adjusted ServiceRecord to reduce diff.
talaviram Nov 3, 2024
f5c09a0
Updated mDNS.cpp to support newer mdns.h - still broken (fix in next …
talaviram Nov 3, 2024
138364d
mdns.h - af99e99a1c8f922ddfc32bed9c143aba215c2805
talaviram Nov 3, 2024
186b649
mdns.cpp fixes for prev commit
talaviram Nov 3, 2024
542062c
mDNS.cpp - validate service_name (equivalent to mdns.h commit 9f76e58…
talaviram Nov 3, 2024
6476c15
mdns.h - minor cleanups 1f48fec798fb1d40165ea05b11ffecc1f7544dc5
talaviram Nov 3, 2024
974904d
mdns.h - tighter variable scoping - a91aefbf37e051fa0f614bc503073322d…
talaviram Nov 3, 2024
3f594a0
mdns.h - (use const pointer in open and setup func) updated with aedb…
talaviram Nov 3, 2024
dcc67bc
mdns.h - equivalent with add possibility to stop service announcement…
talaviram Nov 3, 2024
766ddde
mdns.h - Fix clang warning: suggest braces around initialization of s…
talaviram Nov 3, 2024
5699976
mdns.cpp - sync with mdns.h 2d1563adb970e32c1aa5fb00f8efb0babee100e6
talaviram Nov 3, 2024
5c7a4ed
mdns.h Allow class type ANY in queries - 77fb33e0599e6f27970c9af53a88…
talaviram Nov 3, 2024
4929cbe
mdns.h - Fix warnings about unused functions 22cc54d09efdd5f30c3607ca…
talaviram Nov 3, 2024
25cda95
mdns.h - fix bad inline decl 73a81e8907f511bbc3203202a8ed4617918bfc36
talaviram Nov 3, 2024
fc6973c
mdns.h - add missing string skip in discovery answer processing 87d43…
talaviram Nov 3, 2024
06931b8
mdns.h - add multiquery function a70b8a3dd6402559185673636b0626935888…
talaviram Nov 3, 2024
9be5021
mdns.cpp - basic multi-query support
talaviram Nov 3, 2024
51b3163
mdns.h - fix flush bit for shared record d62c6118f78a7107c92a3ea5f702…
talaviram Nov 3, 2024
769af82
mdns.cpp - add dump mode similar to mdns.c one.
talaviram Nov 4, 2024
1586503
mdns.cpp - ignore link local addresses similar to mdns.h 40a8b4f77a61…
talaviram Nov 3, 2024
e4aaadb
mdns.h - ignore questions in query receive e092f068b9cedccec06d040f3a…
talaviram Nov 3, 2024
abc08a1
mdns.h - ignore questions in query receive e092f068b9cedccec06d040f3a…
talaviram Nov 3, 2024
beb103d
mdns.h - Reset value parameters for boolean txt records 660b872dddcd8…
talaviram Nov 3, 2024
af6a7f3
mdns.h - Fix a possible heap overflow in txt record parse 166152bfbd8…
talaviram Nov 3, 2024
c668e70
mdns.h -Avoid buffer overflow in send path 8aabf221e78c62cd059416f81b…
talaviram Nov 3, 2024
aa4bd60
mdns.cpp - Semantic print fixes similar to mdns.h 23c6f01bb8c68e0e9f6…
talaviram Nov 3, 2024
8b57036
renamed to_mdns_str to hint it's a ref/ptr rather than by value.
talaviram Nov 4, 2024
c80217b
Added flag for graceful exit of long-running operations (similar to 9…
talaviram Nov 4, 2024
775196c
tidy/nit - made TSAN happy on macOS.
talaviram Nov 4, 2024
00f7bba
tidy - fixed missing whitespace.
talaviram Nov 5, 2024
b9a61d4
fixup for executeQuery changes
talaviram Nov 10, 2024
6431603
Fix Windows (MSVC) compilation.
talaviram Nov 10, 2024
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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ target_include_directories(
target_sources(
${PROJECT_NAME}
PRIVATE include/mdns_cpp/macros.hpp
include/mdns_cpp/defs.hpp
include/mdns_cpp/logger.hpp
src/logger.cpp
src/mdns.h
Expand Down
2 changes: 1 addition & 1 deletion example/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main() {
mdns_cpp::mDNS mdns;
const std::string service = "_http._tcp.local.";

mdns.executeQuery(service);
mdns.executeQuery({{service, 0}});

while (true) {
std::this_thread::sleep_for(std::chrono::seconds(1));
Expand Down
16 changes: 0 additions & 16 deletions include/mdns_cpp/defs.hpp

This file was deleted.

31 changes: 20 additions & 11 deletions include/mdns_cpp/mdns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@
#include <string>
#include <thread>

#include "mdns_cpp/defs.hpp"

struct sockaddr;
#include "mdns_cpp/utils.hpp"

#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#else
#include <ifaddrs.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#endif

namespace mdns_cpp {

class mDNS {
public:
~mDNS();

void startService();
void startService(bool dumpMode = false);
void stopService();
bool isServiceRunning();

Expand All @@ -23,11 +32,13 @@ class mDNS {
void setServiceName(const std::string &name);
void setServiceTxtRecord(const std::string &text_record);

void executeQuery(const std::string &service);
using ServiceQueries = std::vector<std::pair<std::string, int>>;
void executeQuery(ServiceQueries service);
void executeDiscovery();

private:
void runMainLoop();
void runDumpMode(int *sockets, int num_sockets);
int openClientSockets(int *sockets, int max_sockets, int port);
int openServiceSockets(int *sockets, int max_sockets);

Expand All @@ -36,13 +47,11 @@ class mDNS {
std::uint16_t port_{42424};
std::string txt_record_{};

bool running_{false};

bool has_ipv4_{false};
bool has_ipv6_{false};
std::atomic<bool> running_{false};
bool dumpMode_{false};

uint32_t service_address_ipv4_{0};
uint8_t service_address_ipv6_[16]{0};
struct sockaddr_in service_address_ipv4_;
struct sockaddr_in6 service_address_ipv6_;

std::thread worker_thread_;
};
Expand Down
Loading