| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When connecting as a client, don't create one socket, using the address
family of the first entry in the address list, and use that for all
entries; on most if not all platforms, an AF_INET socket can't be used
to connect to an IPv6 address and an AF_INET6 socket can't be used to
connect to an IPv4 address. Instead, construct a table of the entries
in the address list, sort it by address family, and cycle through the
entries. If there is no socket yet, create it based on the current
entry's address family; if there is a socket, but it's for a different
address family than the current entry's address family, close it and
open a new one.
If connecting fails for all addresses, don't just construct a long
barely-readable error message consisting of the full errors for each
failure. Instead, construct one that, for each error code, has a list
of the addresses that got that error code; if all the failures had the
same error code, just show the host name, not the complete list of
addresses.
Clean up some error handling routines - fix names, allow some to take a
printf-style argument list, etc..
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Make the first argument a void * - it can point to anything, not just,
for example, a character string. It's not a "buffer", it's just data,
whatever that might be, so call it "data", not "buffer".
Rename "tempbuf" to "outbuf" to indicate that it's a buffer location
into which data is copied.
In English, stuff would be contained in "data", not contained into
"data" - into suggests that stuff is being copied into it by the
routine, which isn't the case - and stuff isn't copied in "outbuf", it's
copied into "outbuf".
Update the comment for sock_bufferize() to reflect all this.
|
|
|
|
|
|
|
| |
This reverts commit 8b6b13d4cbb685db047af04c49817ed81fff7c35.
That solution allowed you to intermix declarations/definitions and
before the extern "C", so you can see what's being imported.
|
|
|
|
|
|
|
|
|
|
|
| |
Instead, explictly flag individual functions with extern "C" by adding
it to the tag we're already using for exported functions, and creating a
new tag to use for non-exported functions.
Rename those tags, and the tags used for exported data, to say what they
do, rather than saying "this is an API" (we may export things we don't
want to be treated as part of the API, but that we have to export
because some programs use them).
|
|
|
|
|
|
|
|
|
|
|
| |
Treat a failure to get the socket buffer size as an error; we were just
blithely driving on and using the variable into which the size *hadn't*
been put. That means that our caller will be handed the error message;
we presume they do something with it, so that we don't need to print it
as a debugging message.
In other cases, we already were reporting an error and providing the
error message; the same applies there.
|
|
|
|
|
|
|
|
| |
Get rid of definitions in sockutils.h that are also defined in
pcap/socket.h.
Have pcap/socket.h include the rough UN*X equivalents of <winsock.h> and
<ws2tcpip.h>.
|
| |
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This patch also encode the control sockets in adition to the data
socket. Clients performs a TLS handshake when the scheme is rpcaps://
rather than rpcap://. Both active and passive modes are supported, but
transfert via UDP is not (yet) supported (the lib returns an error in
that case).
I did some adaptation to the windows code but couldn't tested so for all
I know it may not even compile.
Also tried to fix the indentation.
|
|/
|
|
|
| |
It works like MSG_PEEK (because it causes MSG_PEEK to be set in the
recv() flags).
|
|
|
|
|
| |
Probably harmless, but do it to help catch some issues on LP64 (64-bit
UN*X) or LLP64 (64-bit Windows) platforms when compiling on macOS.
|
|
|
|
|
|
|
| |
This emphasizes that it's for *debugging* messages, not for errors sent
to the peer or logged to a daemon log file. Any message that would be
useful if printed/logged in a production environment should *not* be
reported with SOCK_DEBUG_MESSAGE().
|
|
|
|
|
| |
SOCK_ASSERT was always called with a true expression ("1") thus only ever executing the message part.
Rename the macro, remove the assert part and remove the "1" parameter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Have the main thread wait on all of the sockets on which we're
listening, using select() on UN*X and WSAWaitForMultipleEvents() on
Windows, rather than having separate threads or processes for each of
the sockets.
On UN*X, have "shut down" signals just set a flag, and have the select()
check for EINTR and, if it got EINTR, check the flag, and leave the main
event loop if it's set.
On Windows, set a console control event handler and, for all the "shut
down" events, set an event on which the main thread waits, in addition
to the socket events, and, if that event is signaled, leave the main
event loop.
|
|
|
|
|
| |
The equivalent argument to sock_recv() is a size_t; make sock_send()
more like sock_recv(), for consistency.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Have separate sockutils routines for reading from a stream socket and
receiving messages from a datagram socket. The latter assumes you get
the entire message in a single receive operation and checks for the
datagram being bigger than the provided buffer.
We don't need separate network and packet-to-provide-to-the-callback
buffers; use the standard buffer for both purposes, making it big enough
for the largest expected packet message. This eliminates a copy.
Use the "receive messages from a datagram socket" routine for UDP data
sockets. That way, we check for messages bigger than the largest
expected packet message; add additional checks to make sure the packet
is big enough to hold an rpcap header and, if so, that the packet length
in the rpcap header isn't larger than the part of the message.
Check for interrupted message receives in the "read a packet message"
code path.
If we get an invalid message from the server, discard the rest of it if
it's sent over TCP.
In the read routine, check for errors and, if we didn't get a packet and
didn't get an error - which could be a timeout or an interrupted receive
- check whether we were told to break out of the loop.
|
|
|
|
|
|
| |
On the server side, don't treat an immediate EOF when trying to read a
message header as an error, just silently terminate the session. Treat
EOFs after reading *some* of the message as an error.
|
| |
|
| |
|
|
|
|
| |
2003 (or earlier!) called; it wants its Microsoft C compiler back.
|
|
|
|
| |
That collides with the create-a-socket function socket().
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
In Winsock, recv() takes an int as the size argument and returns an int
as a return value, so it can't read more than INT_MAX bytes. Have it
take a size_t as an argument (so you don't have to cast away warnings
about narrowing sizeof values), return an error if it's bigger than
INT_MAX (which it can be even on ILP32 platforms, as size_t is
unsigned), and have the count of remaining bytes be an int.
|
| |
|
|
|
|
|
|
|
| |
That way, we don't require code that includes pcap/pcap.h to include
sockutils.h if pcap/pcap.h is declaring functions that use SOCKET.
Do other formatting cleanups while we're at it.
|
|
|
|
|
| |
Give it a signature more like that of recv(), and make the main loop a
for loop.
|
|
works with Wireshark.
|