-
Notifications
You must be signed in to change notification settings - Fork 379
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
Raw socket #2111
base: master
Are you sure you want to change the base?
Raw socket #2111
Conversation
Because I copy some source codes from so Codacy Static Code Analysis will produce the same issues for By the way, the Codacy team tells me to use Can these issues be ignored ? |
WalkthroughThe pull request introduces a new implementation for raw socket functionality in the ACE (Adaptive Communicative Environment) framework. A complete set of files has been added to support raw socket operations, including a new class Changes
Sequence DiagramsequenceDiagram
participant Client as RAW Socket Client
participant RawSocket as ACE_RAW_SOCKET
participant Network as Network Interface
Client->>RawSocket: open(local_addr, protocol)
RawSocket-->>Network: Create Raw Socket
Client->>RawSocket: send(data, remote_addr)
RawSocket->>Network: Transmit Raw Packet
Network->>RawSocket: Receive Packet
RawSocket-->>Client: recv(buffer, remote_addr)
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (9)
ACE/ace/RAW_Socket.h (3)
34-34
: Use the correct article and spelling in the brief description.
The comment currently says "An RAW Socket implemention class." which contains minor grammatical issues.- * @brief An RAW Socket implemention class. + * @brief A RAW Socket implementation class.
43-46
: Clarify fragmentation limitations.
Your documentation for IPPROTO_RAW mentions no support for fragmentation. Consider adding precise notes about packet size limitations and any recommendations for manual segmentation when exceeding MTU sizes, to avoid confusion for developers.
56-56
: Fix misspelling in the constructor documentation.
"bind a local address and fiter UDP protocol" should be "bind a local address and filter UDP protocol."- /// Constructor that bind a local address and fiter UDP protocol. + /// Constructor that binds a local address and filters UDP protocol.ACE/ace/RAW_Socket.cpp (2)
234-235
: Acknowledge that no partial-sent tracking is performed.
Thesend
method usesACE_OS::sendto
, but if the OS applies any packet-level constraints, partial writes might occur in theory. Though rare for raw sockets, a quick note or comment clarifying that partial sends are neither handled nor expected could improve maintainability.
364-379
: Address permissions for opening raw sockets.
On many operating systems, raw sockets require elevated privileges (e.g., root on Linux). Consider adding explicit error checks or user-friendly messages when permission is denied, enhancing diagnostics for end users.ACE/tests/RAW_Socket_Test.cpp (4)
229-229
: Correct minor typo in error message.
"reopen in failue" should read "reopen in failure."ACE_TEST_EXCEPTION_RETURN(rc < 0, " reopen in failue\n"); +ACE_TEST_EXCEPTION_RETURN(rc < 0, " reopen in failure\n");
236-236
: Fix spelling in function name.
Rename "readUdpSocektToEmpty" to "readUdpSocketToEmpty" to maintain consistency and clarity.-static void -readUdpSocektToEmpty(ACE_SOCK_Dgram& udpSock) +static void +readUdpSocketToEmpty(ACE_SOCK_Dgram& udpSock)
283-283
: Fix spelling in debug message.
"receive prcess reach the end" should be "receive process reach the end."- ACE_DEBUG ((LM_INFO, "%C receive prcess reach the end ...\n", __func__)); + ACE_DEBUG ((LM_INFO, "%C receive process reach the end ...\n", __func__));
714-714
: Clarify the error message condition.
The log statement "raw4 socket can send using iov" appears in the error pathrc == -1
. Consider rephrasing it for consistent debugging context:- ACE_TEST_EXCEPTION_RETURN(rc == -1, " raw4 socket can send using iov\n"); + ACE_TEST_EXCEPTION_RETURN(rc == -1, " raw4 socket failed to send using iov\n");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
ACE/ace/RAW_Socket.cpp
(1 hunks)ACE/ace/RAW_Socket.h
(1 hunks)ACE/ace/RAW_Socket.inl
(1 hunks)ACE/ace/ace.mpc
(1 hunks)ACE/tests/RAW_Socket_Test.cpp
(1 hunks)ACE/tests/run_test.lst
(1 hunks)ACE/tests/tests.mpc
(1 hunks)
🔇 Additional comments (6)
ACE/ace/RAW_Socket.cpp (1)
40-45
: Confirm handling of partial data writes.
TheACE_SEND_EXCEPTION_RETURN()
macro checks whether the handle is ready for writing, but doesn't retry if only part of the data was written. Raw sockets typically send packets in one go, yet it may be prudent to verify partial writes won't occur under certain network conditions.Would you like me to generate a script that searches for partial-send handling uses across the codebase to confirm no partial writes exist?
ACE/ace/RAW_Socket.inl (2)
7-11
: LGTM!The function correctly determines if the socket is send-only by checking if the protocol is
IPPROTO_RAW
.
13-17
: LGTM!The function correctly returns the protocol value stored in the class member.
ACE/tests/run_test.lst (1)
201-201
: LGTM!The test entry correctly specifies Linux platform restriction, which aligns with the PR objectives mentioning that the implementation has been tested on Linux platforms and has known issues on Windows.
ACE/ace/ace.mpc (1)
198-198
: LGTM!The source file is correctly added to the project configuration in a sorted order.
ACE/tests/tests.mpc (1)
1430-1436
: LGTM!The test project configuration follows the established pattern and correctly avoids the
ace_for_tao
dependency.
I have completed the work of RAW Socket by referring
ACE_ICMP_Socket
&ACE_Sock_Dgram
classes, these are provided by ACE long time ago.I have tested the API of RAW Socket on Linux platforms, such as Ubuntu 20.04 and CentOS 7.
On windows platform , there exist some surprise maybe for OS limits, RAW_Socket_Test case can not pass through.
For considering the fact that applications using RAW Socket almost run on Unix* or Linux* platforms, this failure is trivial!
So I decide to launch the PR :)
This PR has been launched some months ago, but it is based on master branch .
This time I launch a new PR based on a special branch :)
Summary by CodeRabbit
New Features
ACE_RAW_SOCKET
class for low-level network communicationDocumentation
Tests