Skip to content

Adding networking.h to provide RAII and iterator support for networking calls #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
82c79fd
Adding the new sockets header
keith-horton Oct 17, 2024
c348041
adding networking tests
keith-horton Oct 28, 2024
90e420c
Renamed to networking.h
keith-horton Oct 28, 2024
0007fba
Updates
keith-horton Oct 28, 2024
98196a0
Currently added tests are building and passing
keith-horton Oct 30, 2024
2c7f2d8
Adding more tests
keith-horton Oct 30, 2024
6a7d769
more tests
keith-horton Oct 30, 2024
ce07fdf
more tests, more subtle fixes
keith-horton Nov 1, 2024
9dc0852
Many more updates
keith-horton Nov 18, 2024
6c8644e
Finished all unit tests
keith-horton Jan 1, 2025
f513f58
cleaning up some comments.
keith-horton Jan 1, 2025
22f371e
Addressing feedback
keith-horton Jan 12, 2025
ea0f1c3
Addressing feedback
keith-horton Jan 12, 2025
6602bfa
Missed a variable init.
keith-horton Jan 12, 2025
15ecc5d
Simplifying the function to load the extension function pointers.
keith-horton Jan 12, 2025
ca07b3f
Simplified the addr_info RAII + iterator object -- now also supports …
keith-horton Jan 16, 2025
5c34e19
pushing a new approach to objects managing the result from name resol…
keith-horton Jan 19, 2025
f4d9c87
More updates - more consolidation. Making addr_info ranges.
keith-horton Jan 19, 2025
40540a5
More simplification; more tidy work.
keith-horton Jan 20, 2025
be244d5
Add tests for other addr_info types
keith-horton Jan 20, 2025
fa46f3f
merge with parent after syncing with master branch
keith-horton Jan 23, 2025
66d3582
Fixing comparison operator cases. Fixing comments.
keith-horton Jan 26, 2025
f002655
Fixing iterators.
keith-horton Jan 26, 2025
9c85c85
ran scripts\run-clang-format.cmd
keith-horton Feb 2, 2025
03e6de0
minor formatting
keith-horton Feb 2, 2025
cbf4e60
Fix clang x86 issue with stateless lambdas as callbacks
keith-horton Feb 2, 2025
41720e3
Adding comments to a failed test for future maintainers.
keith-horton Feb 3, 2025
7caedb6
I think I addressed the ComTest issues. will push and let the test ru…
keith-horton Feb 10, 2025
bf81390
Making overlapping requests - giving more time before the timeout fires.
keith-horton Feb 10, 2025
e85139f
Trying to fix the COM test again
keith-horton Feb 10, 2025
1df5f4d
ran scripts\run-clang-format.cmd
keith-horton Feb 18, 2025
7c5fe7f
Bumping timeouts to see if can fix the pipeline tests - since these c…
keith-horton Feb 22, 2025
f71cad1
Merge branch 'microsoft:master' into user/khorton/wil_sockets
keith-horton Feb 23, 2025
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 include/wil/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ namespace details
: sizeof(val) == 2 ? static_cast<unsigned short>(val) \
: sizeof(val) == 4 ? static_cast<unsigned long>(val) \
: static_cast<unsigned long long>(val)) __pragma(warning(pop)))
#define __WI_IS_UNSIGNED_SINGLE_FLAG_SET(val) ((val) && !((val) & ((val)-1)))
#define __WI_IS_UNSIGNED_SINGLE_FLAG_SET(val) ((val) && !((val) & ((val) - 1)))
#define __WI_IS_SINGLE_FLAG_SET(val) __WI_IS_UNSIGNED_SINGLE_FLAG_SET(__WI_MAKE_UNSIGNED(val))

template <typename TVal, typename TFlags>
Expand Down
1,320 changes: 1,320 additions & 0 deletions include/wil/network.h

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions include/wil/nt_result_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ _Always_(_Post_satisfies_(return < 0)) __declspec(noinline) inline NTSTATUS Stat
namespace details
{
template <FailureType>
__declspec(noinline) inline NTSTATUS
ReportStatus_CaughtException(__R_FN_PARAMS_FULL, SupportedExceptions supported = SupportedExceptions::Default);
__declspec(noinline) inline NTSTATUS ReportStatus_CaughtException(
__R_FN_PARAMS_FULL, SupportedExceptions supported = SupportedExceptions::Default);
template <FailureType>
__declspec(noinline) inline NTSTATUS
ReportStatus_CaughtExceptionMsg(__R_FN_PARAMS_FULL, _Printf_format_string_ PCSTR formatString, va_list argList);
__declspec(noinline) inline NTSTATUS ReportStatus_CaughtExceptionMsg(
__R_FN_PARAMS_FULL, _Printf_format_string_ PCSTR formatString, va_list argList);

namespace __R_NS_NAME
{
Expand Down Expand Up @@ -191,8 +191,7 @@ namespace details
}

template <FailureType T>
__declspec(noinline) inline NTSTATUS
ReportStatus_CaughtExceptionMsg(__R_FN_PARAMS_FULL, _Printf_format_string_ PCSTR formatString, va_list argList)
__declspec(noinline) inline NTSTATUS ReportStatus_CaughtExceptionMsg(__R_FN_PARAMS_FULL, _Printf_format_string_ PCSTR formatString, va_list argList)
{
// Pre-populate the buffer with our message, the exception message will be added to it...
wchar_t message[2048];
Expand Down
10 changes: 5 additions & 5 deletions include/wil/registry_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ namespace reg
{
return REG_SZ;
}
#endif // #if defined(__WIL_OBJBASE_H_STL)
#endif // #if defined(__WIL_OBJBASE_H_STL)
} // namespace reg_value_type_info

template <typename err_policy = ::wil::err_exception_policy>
Expand Down Expand Up @@ -1294,8 +1294,8 @@ namespace reg
#if defined(WIL_ENABLE_EXCEPTIONS)
using reg_view = ::wil::reg::reg_view_details::reg_view_t<::wil::err_exception_policy>;
#endif // #if defined(WIL_ENABLE_EXCEPTIONS)
} // namespace reg_view_details
/// @endcond
} // namespace reg_view_details
/// @endcond

/// @cond
namespace reg_iterator_details
Expand Down Expand Up @@ -1426,8 +1426,8 @@ namespace reg
return ::wil::unique_bstr{::SysAllocStringLen(name.get(), static_cast<UINT>(length))};
}
#endif // #if defined(__WIL_OLEAUTO_H_)
} // namespace reg_iterator_details
/// @endcond
} // namespace reg_iterator_details
/// @endcond

// forward declaration to allow friend-ing the template iterator class
#if defined(WIL_ENABLE_EXCEPTIONS)
Expand Down
21 changes: 21 additions & 0 deletions include/wil/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -5085,6 +5085,27 @@ typedef shared_any<unique_socket> shared_socket;
typedef weak_any<shared_socket> weak_socket;
#endif // __WIL_WINSOCKAPI_STL

#if (defined(_WS2TCPIP_H_) && !defined(__WIL_WS2TCPIP_H_)) || defined(WIL_DOXYGEN)
/// @cond
#define __WIL_WS2TCPIP_H_
/// @endcond
typedef unique_any<ADDRINFOA*, decltype(&::freeaddrinfo), ::freeaddrinfo> unique_addrinfo_ansi;
typedef unique_any<ADDRINFOW*, decltype(&::FreeAddrInfoW), ::FreeAddrInfoW> unique_addrinfo;
// not defining a type for FreeAddrInfoEx(ADDRINFOEXA*) as that API is formally __declspec(deprecated)
typedef unique_any<ADDRINFOEXW*, decltype(&::FreeAddrInfoExW), ::FreeAddrInfoExW> unique_addrinfoex;
#endif // __WIL_WS2TCPIP_H_
#if (defined(__WIL_WS2TCPIP_H_) && !defined(__WIL_WS2TCPIP_H_STL) && defined(WIL_RESOURCE_STL)) || defined(WIL_DOXYGEN)
/// @cond
#define __WIL_WS2TCPIP_H_STL
/// @endcond
typedef shared_any<unique_addrinfo_ansi> shared_addrinfo_ansi;
typedef weak_any<unique_addrinfo_ansi> weak_addrinfo_ansi;
typedef shared_any<unique_addrinfo> shared_addrinfo;
typedef weak_any<unique_addrinfo> weak_addrinfo;
typedef shared_any<unique_addrinfoex> shared_addrinfoex;
typedef weak_any<unique_addrinfoex> weak_addrinfoex;
#endif // __WIL_WS2TCPIP_H_STL

#if (defined(_WINGDI_) && !defined(__WIL_WINGDI_) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && !defined(NOGDI) && !defined(WIL_KERNEL_MODE)) || \
defined(WIL_DOXYGEN)
/// @cond
Expand Down
4 changes: 2 additions & 2 deletions include/wil/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -1166,8 +1166,8 @@ inline void WilInitialize_Result(WilInitializeCommand state)
namespace details
{
#ifndef RESULT_SUPPRESS_STATIC_INITIALIZERS
__declspec(selectany)::wil::details_abi::ProcessLocalStorage<::wil::details_abi::ProcessLocalData> g_processLocalData("WilError_03");
__declspec(selectany)::wil::details_abi::ThreadLocalStorage<ThreadFailureCallbackHolder*> g_threadFailureCallbacks;
__declspec(selectany) ::wil::details_abi::ProcessLocalStorage<::wil::details_abi::ProcessLocalData> g_processLocalData("WilError_03");
__declspec(selectany) ::wil::details_abi::ThreadLocalStorage<ThreadFailureCallbackHolder*> g_threadFailureCallbacks;

WI_HEADER_INITIALIZATION_FUNCTION(InitializeResultHeader, [] {
g_pfnGetContextAndNotifyFailure = GetContextAndNotifyFailure;
Expand Down
Loading
Loading