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.
if (res == -1)
{
sock_geterror("pcap_startcapture_remote()", fp->errbuf, PCAP_ERRBUF_SIZE);
- SOCK_ASSERT(fp->errbuf, 1);
+ SOCK_MESSAGE(fp->errbuf);
}
/*
{
if (sock_initaddress(address, RPCAP_DEFAULT_NETPORT_ACTIVE, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
{
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
return (SOCKET)-2;
}
}
{
if (sock_initaddress(address, port, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
{
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
return (SOCKET)-2;
}
}
if ((sockmain = sock_open(addrinfo, SOCKOPEN_SERVER, 1, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
{
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
freeaddrinfo(addrinfo);
return (SOCKET)-2;
}
// signal to the main that the user closed the control connection
// This is used only in case of active mode
pars->activeclose = 1;
- SOCK_ASSERT("The other end system asked to close the connection.", 1);
+ SOCK_MESSAGE("The other end system asked to close the connection.");
goto end;
- break;
}
case RPCAP_MSG_STATS_REQ:
}
// Print message and exit
- SOCK_ASSERT("I'm exiting from the child loop", 1);
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE("I'm exiting from the child loop");
+ SOCK_MESSAGE(errbuf);
if (!pars->isactive)
{
#include <signal.h>
#include <pcap.h> // for PCAP_ERRBUF_SIZE
-#include "sockutils.h" // for SOCK_ASSERT
+#include "sockutils.h" // for SOCK_MESSAGE
#include "portability.h"
#include "rpcapd.h"
#include "fileconf.h"
activelist[i].port[MAX_LINE] = 0;
}
else
- SOCK_ASSERT("Only MAX_ACTIVE_LIST active connections are currently supported.", 1);
+ SOCK_MESSAGE("Only MAX_ACTIVE_LIST active connections are currently supported.");
i++;
continue;
strrem(hostlist, '\n');
pcap_snprintf(msg, PCAP_ERRBUF_SIZE, "New passive host list: %s\n\n", hostlist);
- SOCK_ASSERT(msg, 1);
+ SOCK_MESSAGE(msg);
fclose(fp);
}
}
if (sock_init(errbuf, PCAP_ERRBUF_SIZE) == -1)
{
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
exit(-1);
}
}
if (i > MAX_ACTIVE_LIST)
- SOCK_ASSERT("Only MAX_ACTIVE_LIST active connections are currently supported.", 1);
+ SOCK_MESSAGE("Only MAX_ACTIVE_LIST active connections are currently supported.");
// I don't initialize the remaining part of the structure, since
// it is already zeroed (it is a global var)
}
}
- if (savefile[0])
- {
- if (fileconf_save(savefile))
- SOCK_ASSERT("Error when saving the configuration to file", 1);
- }
+ if (savefile[0] && fileconf_save(savefile))
+ SOCK_MESSAGE("Error when saving the configuration to file");
// If the file does not exist, it keeps the settings provided by the command line
if (loadfile[0])
#else
// If this call succeeds, it is blocking on Win32
if (svc_start() != 1)
- SOCK_ASSERT("Unable to start the service", 1);
+ SOCK_MESSAGE("Unable to start the service");
// When the previous call returns, the entire application has to be stopped.
exit(0);
(void *)&activelist[i], 0, NULL);
if (threadId == 0)
{
- SOCK_ASSERT("Error creating the active child threads", 1);
+ SOCK_MESSAGE("Error creating the active child threads");
continue;
}
CloseHandle(threadId);
//
if (sock_initaddress((address[0]) ? address : NULL, port, &mainhints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
{
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
return;
}
if ((sock = sock_open(tempaddrinfo, SOCKOPEN_SERVER, SOCKET_MAXCONN, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
{
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
continue;
}
//
// We're done; exit.
//
- SOCK_ASSERT(PROGRAM_NAME " is closing.\n", 1);
+ SOCK_MESSAGE(PROGRAM_NAME " is closing.\n");
#ifndef _WIN32
//
// For reference, Stevens, pg 128
while ((pid = waitpid(-1, &exitstat, WNOHANG)) > 0)
- SOCK_ASSERT("Child terminated", 1);
+ SOCK_MESSAGE("Child terminated");
return;
}
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Connecting to host %s, port %s, using protocol %s",
activepars->address, activepars->port, (hints.ai_family == AF_INET) ? "IPv4":
(hints.ai_family == AF_INET6) ? "IPv6" : "Unspecified");
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
// Initialize errbuf
memset(errbuf, 0, sizeof(errbuf));
// Do the work
if (sock_initaddress(activepars->address, activepars->port, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
{
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
return 0;
}
if ((sockctrl = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
{
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error connecting to host %s, port %s, using protocol %s",
activepars->address, activepars->port, (hints.ai_family == AF_INET) ? "IPv4":
(hints.ai_family == AF_INET6) ? "IPv6" : "Unspecified");
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
sleep_secs(RPCAP_ACTIVE_WAIT);
#include "rpcapd.h"
#include <pcap.h> // for PCAP_ERRBUF_SIZE
-#include "sockutils.h" // for SOCK_ASSERT
+#include "sockutils.h" // for SOCK_MESSAGE
#include "portability.h"
#include "fileconf.h"
pcap_snprintf(message, PCAP_ERRBUF_SIZE, "%s failed with error %d: %s", str, val, string);
- SOCK_ASSERT(message, 1);
+ SOCK_MESSAGE(message);
}
void WINAPI svc_control_handler(DWORD Opcode)
if (size == 0)
{
- SOCK_ASSERT("I have been requested to read zero bytes", 1);
+ SOCK_MESSAGE("I have been requested to read zero bytes");
return 0;
}
if (size > INT_MAX)
if (size == 0)
{
- SOCK_ASSERT("I have been requested to read zero bytes", 1);
+ SOCK_MESSAGE("I have been requested to read zero bytes");
return 0;
}
if (size > INT_MAX)
return -1;
}
- SOCK_ASSERT("I'm currently discarding data\n", 1);
+ SOCK_MESSAGE("I'm currently discarding data\n");
return 0;
}
if (errbuf)
pcap_snprintf(errbuf, errbuflen, "getaddrinfo() %s", gai_strerror(retval));
- SOCK_ASSERT(errbuf, 1);
+ SOCK_MESSAGE(errbuf);
/* Get next token */
token = pcap_strtok_r(NULL, sep, &lasts);
* \return No return values.
*/
#ifdef NDEBUG
- #define SOCK_ASSERT(msg, expr) ((void)0)
+ #define SOCK_MESSAGE(msg) ((void)0)
#else
- #include <assert.h>
#if (defined(_WIN32) && defined(_MSC_VER))
#include <crtdbg.h> /* for _CrtDbgReport */
/* Use MessageBox(NULL, msg, "warning", MB_OK)' instead of the other calls if you want to debug a Win32 service */
/* Remember to activate the 'allow service to interact with desktop' flag of the service */
- #define SOCK_ASSERT(msg, expr) { _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%s\n", msg); fprintf(stderr, "%s\n", msg); assert(expr); }
+ #define SOCK_MESSAGE(msg) { _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%s\n", msg); fprintf(stderr, "%s\n", msg); }
#else
- #define SOCK_ASSERT(msg, expr) { fprintf(stderr, "%s\n", msg); assert(expr); }
+ #define SOCK_MESSAGE(msg) { fprintf(stderr, "%s\n", msg); }
#endif
#endif