]> The Tcpdump Group git mirrors - libpcap/commitdiff
Rename SOCK_MESSAGE() to SOCK_DEBUG_MESSAGE().
authorGuy Harris <[email protected]>
Mon, 2 Apr 2018 03:12:59 +0000 (20:12 -0700)
committerGuy Harris <[email protected]>
Mon, 2 Apr 2018 03:12:59 +0000 (20:12 -0700)
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().

pcap-rpcap.c
rpcapd/daemon.c
rpcapd/fileconf.c
rpcapd/rpcapd.c
rpcapd/win32-svc.c
sockutils.c
sockutils.h

index cf84bd9dbcd5836325233bd334ec9fea564253e4..42f381c8627378544d03c849ebe31f9dab190194 100644 (file)
@@ -1260,7 +1260,7 @@ static int pcap_startcapture_remote(pcap_t *fp)
        if (res == -1)
        {
                sock_geterror("pcap_startcapture_remote()", fp->errbuf, PCAP_ERRBUF_SIZE);
-               SOCK_MESSAGE(fp->errbuf);
+               SOCK_DEBUG_MESSAGE(fp->errbuf);
        }
 
        /*
@@ -2730,7 +2730,7 @@ SOCKET pcap_remoteact_accept(const char *address, const char *port, const char *
        {
                if (sock_initaddress(address, RPCAP_DEFAULT_NETPORT_ACTIVE, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
                {
-                       SOCK_MESSAGE(errbuf);
+                       SOCK_DEBUG_MESSAGE(errbuf);
                        return (SOCKET)-2;
                }
        }
@@ -2738,7 +2738,7 @@ SOCKET pcap_remoteact_accept(const char *address, const char *port, const char *
        {
                if (sock_initaddress(address, port, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
                {
-                       SOCK_MESSAGE(errbuf);
+                       SOCK_DEBUG_MESSAGE(errbuf);
                        return (SOCKET)-2;
                }
        }
@@ -2746,7 +2746,7 @@ SOCKET pcap_remoteact_accept(const char *address, const char *port, const char *
 
        if ((sockmain = sock_open(addrinfo, SOCKOPEN_SERVER, 1, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
        {
-               SOCK_MESSAGE(errbuf);
+               SOCK_DEBUG_MESSAGE(errbuf);
                freeaddrinfo(addrinfo);
                return (SOCKET)-2;
        }
index a0acd4af036abcefaef26398241be7c6545ee103..7c310111afae4f3e4d5fbdca2036a974b6d3d11e 100755 (executable)
@@ -648,7 +648,7 @@ daemon_serviceloop(SOCKET sockctrl_in, SOCKET sockctrl_out, int isactive, int nu
                                // This is used only in case of active mode.
                                //
                                client_told_us_to_close = 1;
-                               SOCK_MESSAGE("The other end system asked to close the connection.");
+                               SOCK_DEBUG_MESSAGE("The other end system asked to close the connection.");
                                goto end;
                        }
 
@@ -850,8 +850,8 @@ end:
        }
 
        // Print message and return
-       SOCK_MESSAGE("I'm exiting from the child loop");
-       SOCK_MESSAGE(errbuf);
+       SOCK_DEBUG_MESSAGE("I'm exiting from the child loop");
+       SOCK_DEBUG_MESSAGE(errbuf);
 
        return client_told_us_to_close;
 }
index 099cdf37db69fddeae6729cdfc040924e247157c..ab1e9dd38982d8e36fbbaae4e7edfb8d511a45ba 100755 (executable)
@@ -42,7 +42,7 @@
 #include <signal.h>
 #include <pcap.h>              // for PCAP_ERRBUF_SIZE
 
-#include "sockutils.h"         // for SOCK_MESSAGE
+#include "sockutils.h"         // for SOCK_DEBUG_MESSAGE
 #include "portability.h"
 #include "rpcapd.h"
 #include "config_params.h"     // configuration file parameters
@@ -94,7 +94,7 @@ void fileconf_read(void)
                                        activelist[i].port[MAX_LINE] = 0;
                                }
                                else
-                                       SOCK_MESSAGE("Only MAX_ACTIVE_LIST active connections are currently supported.");
+                                       SOCK_DEBUG_MESSAGE("Only MAX_ACTIVE_LIST active connections are currently supported.");
 
                                i++;
                                continue;
@@ -134,7 +134,7 @@ void fileconf_read(void)
                strrem(hostlist, '\n');
 
                pcap_snprintf(msg, PCAP_ERRBUF_SIZE, "New passive host list: %s\n\n", hostlist);
-               SOCK_MESSAGE(msg);
+               SOCK_DEBUG_MESSAGE(msg);
                fclose(fp);
        }
 }
index 7ea0ba90c21dbf5fa457d3e0b9ced9ca8c4b7024..c6e34285d16737ef0f5ab558ed6980472c126a67 100755 (executable)
@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
 
        if (sock_init(errbuf, PCAP_ERRBUF_SIZE) == -1)
        {
-               SOCK_MESSAGE(errbuf);
+               SOCK_DEBUG_MESSAGE(errbuf);
                exit(-1);
        }
 
@@ -253,7 +253,7 @@ int main(int argc, char *argv[])
                                }
 
                                if (i > MAX_ACTIVE_LIST)
-                                       SOCK_MESSAGE("Only MAX_ACTIVE_LIST active connections are currently supported.");
+                                       SOCK_DEBUG_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)
@@ -284,7 +284,7 @@ int main(int argc, char *argv[])
 #endif
 
        if (savefile[0] && fileconf_save(savefile))
-               SOCK_MESSAGE("Error when saving the configuration to file");
+               SOCK_DEBUG_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])
@@ -442,7 +442,7 @@ int main(int argc, char *argv[])
                // If this call succeeds, it is blocking on Win32
                //
                if (svc_start() != 1)
-                       SOCK_MESSAGE("Unable to start the service");
+                       SOCK_DEBUG_MESSAGE("Unable to start the service");
 
                // When the previous call returns, the entire application has to be stopped.
                exit(0);
@@ -503,7 +503,7 @@ void main_startup(void)
                    (void *)&activelist[i], 0, NULL);
                if (threadId == 0)
                {
-                       SOCK_MESSAGE("Error creating the active child threads");
+                       SOCK_DEBUG_MESSAGE("Error creating the active child threads");
                        continue;
                }
                CloseHandle(threadId);
@@ -538,7 +538,7 @@ void main_startup(void)
                //
                if (sock_initaddress((address[0]) ? address : NULL, port, &mainhints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
                {
-                       SOCK_MESSAGE(errbuf);
+                       SOCK_DEBUG_MESSAGE(errbuf);
                        return;
                }
 
@@ -550,7 +550,7 @@ void main_startup(void)
 
                        if ((sock = sock_open(tempaddrinfo, SOCKOPEN_SERVER, SOCKET_MAXCONN, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
                        {
-                               SOCK_MESSAGE(errbuf);
+                               SOCK_DEBUG_MESSAGE(errbuf);
                                continue;
                        }
 
@@ -576,7 +576,7 @@ void main_startup(void)
        //
        // We're done; exit.
        //
-       SOCK_MESSAGE(PROGRAM_NAME " is closing.\n");
+       SOCK_DEBUG_MESSAGE(PROGRAM_NAME " is closing.\n");
 
 #ifndef _WIN32
        //
@@ -722,7 +722,7 @@ static void main_reap_children(int sign)
        // For reference, Stevens, pg 128
 
        while ((pid = waitpid(-1, &exitstat, WNOHANG)) > 0)
-               SOCK_MESSAGE("Child terminated");
+               SOCK_DEBUG_MESSAGE("Child terminated");
 
        return;
 }
@@ -1197,7 +1197,7 @@ main_active(void *ptr)
        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_MESSAGE(errbuf);
+       SOCK_DEBUG_MESSAGE(errbuf);
 
        // Initialize errbuf
        memset(errbuf, 0, sizeof(errbuf));
@@ -1205,7 +1205,7 @@ main_active(void *ptr)
        // Do the work
        if (sock_initaddress(activepars->address, activepars->port, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
        {
-               SOCK_MESSAGE(errbuf);
+               SOCK_DEBUG_MESSAGE(errbuf);
                return 0;
        }
 
@@ -1215,13 +1215,13 @@ main_active(void *ptr)
 
                if ((sockctrl = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
                {
-                       SOCK_MESSAGE(errbuf);
+                       SOCK_DEBUG_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_MESSAGE(errbuf);
+                       SOCK_DEBUG_MESSAGE(errbuf);
 
                        sleep_secs(RPCAP_ACTIVE_WAIT);
 
index ea9d98351efcafc98a6062398e2f9fdcf44f1cb0..b59437812f2adbf34380507b97df3190247f64aa 100755 (executable)
@@ -33,7 +33,7 @@
 
 #include "rpcapd.h"
 #include <pcap.h>              // for PCAP_ERRBUF_SIZE
-#include "sockutils.h"         // for SOCK_MESSAGE
+#include "sockutils.h"         // for SOCK_DEBUG_MESSAGE
 #include "portability.h"
 #include "fileconf.h"
 
@@ -75,7 +75,7 @@ void svc_geterr(char *str)
 
        pcap_snprintf(message, PCAP_ERRBUF_SIZE, "%s failed with error %d: %s", str, val, string);
 
-       SOCK_MESSAGE(message);
+       SOCK_DEBUG_MESSAGE(message);
 }
 
 void WINAPI svc_control_handler(DWORD Opcode)
index 420fd5bce9a86626cbff0cb5a19929aeb3c5b49c..079c49db2cac166c92f923cbac2d69f2f6e0b6b1 100644 (file)
@@ -848,7 +848,7 @@ int sock_recv(SOCKET sock, void *buffer, size_t size, int flags,
 
        if (size == 0)
        {
-               SOCK_MESSAGE("I have been requested to read zero bytes");
+               SOCK_DEBUG_MESSAGE("I have been requested to read zero bytes");
                return 0;
        }
        if (size > INT_MAX)
@@ -939,7 +939,7 @@ int sock_recv_dgram(SOCKET sock, void *buffer, size_t size,
 
        if (size == 0)
        {
-               SOCK_MESSAGE("I have been requested to read zero bytes");
+               SOCK_DEBUG_MESSAGE("I have been requested to read zero bytes");
                return 0;
        }
        if (size > INT_MAX)
@@ -1095,7 +1095,7 @@ int sock_discard(SOCKET sock, int size, char *errbuf, int errbuflen)
                        return -1;
        }
 
-       SOCK_MESSAGE("I'm currently discarding data\n");
+       SOCK_DEBUG_MESSAGE("I'm currently discarding data\n");
 
        return 0;
 }
@@ -1170,7 +1170,7 @@ int sock_check_hostlist(char *hostlist, const char *sep, struct sockaddr_storage
                                if (errbuf)
                                        pcap_snprintf(errbuf, errbuflen, "getaddrinfo() %s", gai_strerror(retval));
 
-                               SOCK_MESSAGE(errbuf);
+                               SOCK_DEBUG_MESSAGE(errbuf);
 
                                /* Get next token */
                                token = pcap_strtok_r(NULL, sep, &lasts);
index 6c7198dfadc09234442ce1024ae7a3d0a1f5af7e..1df1ef7bb3ac39cd671543b9a1af4abab313309a 100644 (file)
@@ -139,15 +139,15 @@ int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
  * \return No return values.
  */
 #ifdef NDEBUG
-  #define SOCK_MESSAGE(msg) ((void)0)
+  #define SOCK_DEBUG_MESSAGE(msg) ((void)0)
 #else
   #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_MESSAGE(msg) { _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%s\n", msg); fprintf(stderr, "%s\n", msg); }
+    #define SOCK_DEBUG_MESSAGE(msg) { _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%s\n", msg); fprintf(stderr, "%s\n", msg); }
   #else
-    #define SOCK_MESSAGE(msg) { fprintf(stderr, "%s\n", msg); }
+    #define SOCK_DEBUG_MESSAGE(msg) { fprintf(stderr, "%s\n", msg); }
   #endif
 #endif