Skip to content

fix: take the Winsock keepalive constants from the header that defines them - #728

Merged
DavidCozens merged 2 commits into
mainfrom
fix/winsock-tcpstream-ws2tcpip-include
Aug 10, 2026
Merged

fix: take the Winsock keepalive constants from the header that defines them#728
DavidCozens merged 2 commits into
mainfrom
fix/winsock-tcpstream-ws2tcpip-include

Conversation

@DavidCozens

@DavidCozens DavidCozens commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Problem

Platform/Windows/Source/SolidSyslogWinsockTcpStream.c included <mstcpip.h>
for TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT. That header cannot supply
them.

Verified against Windows SDK 10.0.26100.0:

  • All three are defined only in shared\ws2ipdef.h (lines 980-982), reached
    from public headers via um\WS2tcpip.h:44. TCP_KEEPIDLE is an alias for the
    older TCP_KEEPALIVE.
  • <mstcpip.h> provides the ioctl-style interface instead — struct tcp_keepalive and SIO_KEEPALIVE_VALS. Its whole include list is
    <winapifamily.h> and <nldef.h>, and nldef.h includes only
    <winapifamily.h>. There is no path from mstcpip.h to ws2ipdef.h.
  • The macros actually arrived through SolidSyslogWinsockTcpStreamInternal.h,
    which pulls <ws2tcpip.h> in for the test-seam typedefs. A production
    constant was riding on an internal header the file never names — a future
    tidy of that header's includes would have broken the build for a reason
    nobody would look for.

Change

Include <ws2tcpip.h> directly, drop the inert <mstcpip.h>, and correct both
comments to name the defining header.

The clang-format off/on guard goes with it. WS2tcpip.h:43 includes
<winsock2.h> itself, so the ordering constraint the old comment asserted never
existed, and winsock2.h / ws2tcpip.h sort alphabetically into the plain
block. The file now matches SolidSyslogWinsockDatagram.c:5, which already
included <ws2tcpip.h> this way.

misra_suppressions.txt pins for the file shift by two lines.

No sibling carries the same mistake — <mstcpip.h> appeared only in this file.

Verification

Done on Windows, since the point of the change is that the translation unit
compiles against the real SDK.

Check Result
cl /W4 /WX, SDK 10.0.26100.0 clean
clang-format --dry-run --Werror (CI container, v19.1.7) clean
API-identifiers-in-prose gate clean
MISRA pins vs. actual content all five confirmed at n-2 by line-content match

Supporting probe, same toolchain:

Probe Includes Result
A <winsock2.h> + <mstcpip.h> only fails — error C2065: 'TCP_KEEPIDLE': undeclared identifier, and the other two
B A + <ws2tcpip.h> compiles clean
Real file, <mstcpip.h> deleted, nothing else changed compiles clean at /W4

The full scripts/misra_renumber.py cppcheck pass was not run locally — the
shift is uniform and every line's content was matched, so analyze-cppcheck is
the check on that.

Closes #726

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved Windows TCP keepalive compatibility by using the appropriate networking definitions.
    • Updated static-analysis suppressions to remain aligned with the current source code.

…s them

SolidSyslogWinsockTcpStream.c included <mstcpip.h> for TCP_KEEPIDLE,
TCP_KEEPINTVL and TCP_KEEPCNT. That header cannot supply them — the SDK
defines all three in <ws2ipdef.h>, reached only via <ws2tcpip.h>, and
mstcpip.h's include list leads nowhere near it. The file compiled anyway
because SolidSyslogWinsockTcpStreamInternal.h pulls <ws2tcpip.h> in for
the test-seam typedefs, so a production constant was riding on an
internal header the file never names.

Include <ws2tcpip.h> directly and drop the inert <mstcpip.h>, matching
SolidSyslogWinsockDatagram.c. The clang-format off/on guard goes with it:
WS2tcpip.h includes <winsock2.h> itself, so the ordering constraint the
old comment described never existed and the block sorts alphabetically.

Both comments now name the defining header. The MISRA suppression pins
for the file shift by two lines.

Verified on Windows against SDK 10.0.26100.0: cl /W4 /WX clean, and a
probe with only <winsock2.h> + <mstcpip.h> fails to find all three
macros.

Closes #726

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: db90c3c3-88e6-4ba0-b50b-4efb68a2f40c

📥 Commits

Reviewing files that changed from the base of the PR and between 457e2c1 and 8618e0d.

📒 Files selected for processing (1)
  • Platform/Windows/Source/SolidSyslogWinsockTcpStream.c

Walkthrough

The Windows TCP stream now includes <ws2tcpip.h> for TCP keepalive constants and identifies <ws2ipdef.h> as their source. MISRA suppression entries were updated for the resulting source line shifts.

Changes

Winsock keepalive include correction

Layer / File(s) Summary
Correct keepalive header attribution
Platform/Windows/Source/SolidSyslogWinsockTcpStream.c
The source replaces <mstcpip.h> with <ws2tcpip.h> and updates the keepalive constant comment.
Align MISRA suppression lines
misra_suppressions.txt
The Rule 11.3, 11.8, 5.7, and 11.5 suppression entries use the shifted source line numbers.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, uses Conventional Commits format, and clearly describes the primary header correction.
Description check ✅ Passed The description covers the purpose, implementation, verification, and affected file, although it does not use the template's exact section headings.
Linked Issues check ✅ Passed The change meets the coding objectives in #726: it names <ws2tcpip.h>, corrects both comments, updates MISRA pins, and reports sibling checks.
Out of Scope Changes check ✅ Passed The changes are limited to the required Winsock include and comments, formatting guard removal, and related MISRA line updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/winsock-tcpstream-ws2tcpip-include

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Platform/Windows/Source/SolidSyslogWinsockTcpStream.c`:
- Around line 245-246: Update the Winsock comment near the keepalive
socket-option handling to state that setsockopt is declared in <winsock2.h>,
while TCP_KEEPIDLE, TCP_KEEPINTVL, and TCP_KEEPCNT come from <ws2ipdef.h> via
<ws2tcpip.h>. Document that TCP_KEEPCNT requires Windows 10 version 1703 and
TCP_KEEPIDLE/TCP_KEEPINTVL require version 1709, while preserving the existing
note about no TCP_USER_TIMEOUT analogue.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c736e25f-0a54-47e2-a6f2-b6c8fae7a574

📥 Commits

Reviewing files that changed from the base of the PR and between 82539bd and 457e2c1.

📒 Files selected for processing (2)
  • Platform/Windows/Source/SolidSyslogWinsockTcpStream.c
  • misra_suppressions.txt

Comment thread Platform/Windows/Source/SolidSyslogWinsockTcpStream.c Outdated
The parenthetical sat next to setsockopt, so "defined in <ws2ipdef.h>"
could be read as describing setsockopt — which is declared in
<winsock2.h>. Put the three constants up front as the subject instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   JUnit   build-linux-gcc (Whole Project): ✅ successful — 1529 passed
   JUnit   build-freertos-host-tdd-plustcp (Whole Project): ✅ successful — 1881 passed
   JUnit   build-linux-clang (Whole Project): ✅ successful — 1460 passed
   JUnit   sanitize-linux-gcc (Whole Project): ✅ successful — 1460 passed
   JUnit   integration-linux-openssl (Whole Project): ✅ successful — 16 passed
   JUnit   integration-linux-mbedtls (Whole Project): ✅ successful — 14 passed
   JUnit   integration-windows-openssl (Whole Project): ✅ successful — 16 passed
   JUnit   bdd-linux-syslog-ng (Whole Project): ✅ successful — 49 passed, 3 skipped
   JUnit   bdd-windows-otel (Whole Project): ✅ successful — 46 passed, 6 skipped
   JUnit   bdd-freertos-qemu-plustcp (Whole Project): ✅ successful — 45 passed, 7 skipped
   JUnit   bdd-freertos-qemu-lwip (Whole Project): ✅ successful — 45 passed, 7 skipped
   JUnit   build-windows-msvc (Whole Project): ✅ successful — 1302 passed
   JUnit   build-linux-tunable-override (Whole Project): ✅ successful — 1460 passed
   ⚠️   Clang-Tidy (Whole Project): No warnings
   ⚠️   CPPCheck (Whole Project): No warnings


Created by Quality Monitor v4.15.0 (#82d77af). More details are shown in the GitHub Checks Result.

@DavidCozens
DavidCozens merged commit ac79c1d into main Aug 10, 2026
36 checks passed
@DavidCozens
DavidCozens deleted the fix/winsock-tcpstream-ws2tcpip-include branch August 10, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WinsockTcpStream includes mstcpip.h, which cannot supply the keepalive constants it uses

1 participant