From b53092ac95fa25d0e6e4e4fc3de9531f43038c4f Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 11 Apr 2020 18:40:39 +0200 Subject: Use local interface addresses for mDNS announce --- backends/libmmbackend.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'backends/libmmbackend.h') diff --git a/backends/libmmbackend.h b/backends/libmmbackend.h index aa0d0f0..cb211a6 100644 --- a/backends/libmmbackend.h +++ b/backends/libmmbackend.h @@ -18,6 +18,10 @@ /*** BACKEND IMPLEMENTATION LIBRARY ***/ +/** Convenience functions **/ + +int mmbackend_strdup(char** dest, char* src); + /** Networking functions **/ /* -- cgit v1.2.3 From bac13064352234acea012de30ee36dd51748b97f Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 11 Apr 2020 19:22:57 +0200 Subject: Implement strerror abstraction for Windows --- backends/libmmbackend.h | 1 + 1 file changed, 1 insertion(+) (limited to 'backends/libmmbackend.h') diff --git a/backends/libmmbackend.h b/backends/libmmbackend.h index cb211a6..f487ee1 100644 --- a/backends/libmmbackend.h +++ b/backends/libmmbackend.h @@ -21,6 +21,7 @@ /** Convenience functions **/ int mmbackend_strdup(char** dest, char* src); +char* mmbackend_sockstrerror(int errno); /** Networking functions **/ -- cgit v1.2.3 From 9a035724c13396e9ccb3a27287a220a178ec1ab6 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 12 Apr 2020 09:28:05 +0200 Subject: Fix errno shadowing --- backends/libmmbackend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/libmmbackend.h') diff --git a/backends/libmmbackend.h b/backends/libmmbackend.h index f487ee1..969de6f 100644 --- a/backends/libmmbackend.h +++ b/backends/libmmbackend.h @@ -21,7 +21,7 @@ /** Convenience functions **/ int mmbackend_strdup(char** dest, char* src); -char* mmbackend_sockstrerror(int errno); +char* mmbackend_sockstrerror(int err_no); /** Networking functions **/ -- cgit v1.2.3 From dd90f0a2283e6feb36d553b32f96efae0999a916 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 12 Apr 2020 12:11:32 +0200 Subject: Move sockaddr_ntop implementation to libmmbackend --- backends/libmmbackend.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'backends/libmmbackend.h') diff --git a/backends/libmmbackend.h b/backends/libmmbackend.h index 969de6f..557c243 100644 --- a/backends/libmmbackend.h +++ b/backends/libmmbackend.h @@ -5,6 +5,7 @@ #include //#define close closesocket #else +#include #include #include #endif @@ -21,7 +22,8 @@ /** Convenience functions **/ int mmbackend_strdup(char** dest, char* src); -char* mmbackend_sockstrerror(int err_no); +char* mmbackend_socket_strerror(int err_no); +const char* mmbackend_sockaddr_ntop(struct sockaddr* peer, char* buffer, size_t length); /** Networking functions **/ -- cgit v1.2.3 From fe6a11b69fdc3ea7c01f8ffca0c0aa26abe6d9ca Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 13 Apr 2020 22:41:29 +0200 Subject: Refactor local address query, document libmmbackend calls --- backends/libmmbackend.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'backends/libmmbackend.h') diff --git a/backends/libmmbackend.h b/backends/libmmbackend.h index 557c243..08f03aa 100644 --- a/backends/libmmbackend.h +++ b/backends/libmmbackend.h @@ -21,8 +21,30 @@ /** Convenience functions **/ +/* + * Duplicate src into *dest, freeing earlier content of *dest if present + * On success, 0 is returned + * On failure, a message is printed, *dest is a NULL pointer and 1 is returned + */ int mmbackend_strdup(char** dest, char* src); + +/* + * Return a formatted error message pertaining to the last socket operation. + * On Linux/OSX, this calls through to strerror using the provided err_no. + * On Windows, err_no is ignored and WSAGetLastError is called to retrieve + * the status of the last operation. This information is then processed via + * FormatMessage into a fixed buffer, which is returned. Thus, this function + * is not thread-safe on Windows. On Linux, refer to strerror's documentation + * for information on thread-safety. + */ char* mmbackend_socket_strerror(int err_no); + +/* + * Wrap / reimplement (on Windows) inet_ntop to work with struct sockaddr* directly. + * Prints the address in a "human-readable" form into buffer. + * Will modify at most length bytes into buffer, output will be zero-terminated. + * This function only works with AF_INET and AF_INET6 addresses. + */ const char* mmbackend_sockaddr_ntop(struct sockaddr* peer, char* buffer, size_t length); /** Networking functions **/ -- cgit v1.2.3 From a8be76f20b3eaa20b53e1cda7686845a08cef32b Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 23 Apr 2020 23:38:36 +0200 Subject: Split mDNS socket into v4/v6 --- backends/libmmbackend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/libmmbackend.h') diff --git a/backends/libmmbackend.h b/backends/libmmbackend.h index 08f03aa..1f0b4d7 100644 --- a/backends/libmmbackend.h +++ b/backends/libmmbackend.h @@ -72,7 +72,7 @@ int mmbackend_parse_sockaddr(char* host, char* port, struct sockaddr_storage* ad * Create a socket of given type and mode for a bind / connect host. * Returns -1 on failure, a valid file descriptor for the socket on success. */ -int mmbackend_socket(char* host, char* port, int socktype, uint8_t listener, uint8_t mcast); +int mmbackend_socket(char* host, char* port, int socktype, uint8_t listener, uint8_t mcast, uint8_t dualstack); /* * Send arbitrary data over multiple writes if necessary -- cgit v1.2.3