Setting tag sliver-openvswitch-2.2.90-1
[sliver-openvswitch.git] / lib / sflow_agent.c
index 4b25c25..817420d 100644 (file)
@@ -1,7 +1,12 @@
-/* Copyright (c) 2002-2009 InMon Corp. Licensed under the terms of the InMon sFlow licence: */
-/* http://www.inmon.com/technology/sflowlicense.txt */
+/* Copyright (c) 2002-2009 InMon Corp. Licensed under the terms of either the
+ *   Sun Industry Standards Source License 1.1, that is available at:
+ *    http://host-sflow.sourceforge.net/sissl.html
+ * or the InMon sFlow License, that is available at:
+ *    http://www.inmon.com/technology/sflowlicense.txt
+ */
 
 #include "sflow_api.h"
+#include "util.h"
 
 static void * sflAlloc(SFLAgent *agent, size_t bytes);
 static void sflFree(SFLAgent *agent, void *obj);
@@ -37,7 +42,7 @@ void sfl_agent_init(SFLAgent *agent,
     agent->errorFn = errorFn;
     agent->sendFn = sendFn;
 
-#ifdef SFLOW_DO_SOCKET  
+#ifdef SFLOW_DO_SOCKET
     if(sendFn == NULL) {
        /* open the socket - really need one for v4 and another for v6? */
        if((agent->receiverSocket4 = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
@@ -186,14 +191,14 @@ SFLSampler *sfl_agent_addSampler(SFLAgent *agent, SFLDataSource_instance *pdsi)
        if(cmp < 0) break;       /* insert here */
     }
     /* either we found the insert point, or reached the end of the list...*/
-    
+
     {
        SFLSampler *newsm = (SFLSampler *)sflAlloc(agent, sizeof(SFLSampler));
        sfl_sampler_init(newsm, agent, pdsi);
        if(prev) prev->nxt = newsm;
        else agent->samplers = newsm;
        newsm->nxt = sm;
-       
+
        /* see if we should go in the ifIndex jumpTable */
        if(SFL_DS_CLASS(newsm->dsi) == 0) {
            SFLSampler *test = sfl_agent_getSamplerByIfIndex(agent, SFL_DS_INDEX(newsm->dsi));
@@ -431,7 +436,7 @@ void sfl_agent_resetReceiver(SFLAgent *agent, SFLReceiver *receiver)
 
            for(; sm != NULL; sm = sm->nxt)
                if(sfl_sampler_get_sFlowFsReceiver(sm) == rcvIdx) sfl_sampler_set_sFlowFsReceiver(sm, 0);
-      
+
            for(; pl != NULL; pl = pl->nxt)
                if(sfl_poller_get_sFlowCpReceiver(pl) == rcvIdx) sfl_poller_set_sFlowCpReceiver(pl, 0);
 
@@ -439,7 +444,7 @@ void sfl_agent_resetReceiver(SFLAgent *agent, SFLReceiver *receiver)
        }
     }
 }
-  
+
 /*_________________---------------------------__________________
   _________________     sfl_agent_error       __________________
   -----------------___________________________------------------
@@ -449,7 +454,7 @@ void sfl_agent_resetReceiver(SFLAgent *agent, SFLReceiver *receiver)
 void sfl_agent_error(SFLAgent *agent, char *modName, char *msg)
 {
     char errm[MAX_ERRMSG_LEN];
-    sprintf(errm, "sfl_agent_error: %s: %s\n", modName, msg);
+    snprintf(errm, sizeof errm, "sfl_agent_error: %s: %s\n", modName, msg);
     if(agent->errorFn) (*agent->errorFn)(agent->magic, agent, errm);
     else {
        fprintf(stderr, "%s\n", errm);
@@ -465,7 +470,7 @@ void sfl_agent_error(SFLAgent *agent, char *modName, char *msg)
 void sfl_agent_sysError(SFLAgent *agent, char *modName, char *msg)
 {
     char errm[MAX_ERRMSG_LEN];
-    sprintf(errm, "sfl_agent_sysError: %s: %s (errno = %d - %s)\n", modName, msg, errno, strerror(errno));
+    snprintf(errm, sizeof errm, "sfl_agent_sysError: %s: %s (errno = %d - %s)\n", modName, msg, errno, ovs_strerror(errno));
     if(agent->errorFn) (*agent->errorFn)(agent->magic, agent, errm);
     else {
        fprintf(stderr, "%s\n", errm);