]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/snmp_core.cc
Merged from parent (trunk r10600).
[thirdparty/squid.git] / src / snmp_core.cc
index 287fbef1b5ecd147e4972a486bc5570685352a47..74dce91e7eecb08db832b4f246ebda3aae6ffc02 100644 (file)
  *
  */
 #include "squid.h"
-#include "comm.h"
-#include "cache_snmp.h"
 #include "acl/FilledChecklist.h"
-#include "ip/IpAddress.h"
+#include "cache_snmp.h"
+#include "comm.h"
 #include "ipc/StartListening.h"
+#include "compat/strsep.h"
+#include "ip/Address.h"
 
 #define SNMP_REQUEST_SIZE 4096
 #define MAX_PROTOSTAT 5
 
-
 /// dials snmpConnectionOpened call
 class SnmpListeningStartedDialer: public CallDialer,
         public Ipc::StartListeningCb
@@ -58,7 +58,7 @@ public:
 };
 
 
-IpAddress theOutSNMPAddr;
+Ip::Address theOutSNMPAddr;
 
 typedef struct _mib_tree_entry mib_tree_entry;
 typedef oid *(instance_Fn) (oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn);
@@ -436,7 +436,7 @@ void
 snmpHandleUdp(int sock, void *not_used)
 {
     LOCAL_ARRAY(char, buf, SNMP_REQUEST_SIZE);
-    IpAddress from;
+    Ip::Address from;
     snmp_request_t *snmp_rq;
     int len;
 
@@ -827,8 +827,8 @@ static oid *
 client_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn)
 {
     oid *instance = NULL;
-    IpAddress laddr;
-    IpAddress *aux;
+    Ip::Address laddr;
+    Ip::Address *aux;
     int size = 0;
     int newshift = 0;
 
@@ -974,7 +974,7 @@ snmpLookupNodeStr(mib_tree_entry *root, const char *str)
     }
 
     int i, r = 1;
-    while (r <= namelen) {
+    while (r < namelen) {
 
         /* Find the child node which matches this */
         for (i = 0; i < e->children && e->leaves[i]->name[r] != name[r]; i++) ; // seek-loop
@@ -1002,9 +1002,10 @@ snmpCreateOidFromStr(const char *str, oid **name, int *nl)
     *name = NULL;
     *nl = 0;
     char *s = xstrdup(str);
+    char *s_ = s;
 
     /* Parse the OID string into oid bits */
-    while ( (p = strsep(&s, delim)) != NULL) {
+    while ( (p = strsep(&s_, delim)) != NULL) {
         *name = (oid*)xrealloc(*name, sizeof(oid) * ((*nl) + 1));
         (*name)[*nl] = atoi(p);
         (*nl)++;
@@ -1139,7 +1140,7 @@ snmpSnmplibDebug(int lvl, char *buf)
    oid == 32.1.50.239.162.33.251.20.50.0.0.0.0.0.0.0.0.0.1
 */
 void
-addr2oid(IpAddress &addr, oid * Dest)
+addr2oid(Ip::Address &addr, oid * Dest)
 {
     u_int i ;
     u_char *cp = NULL;
@@ -1178,7 +1179,7 @@ addr2oid(IpAddress &addr, oid * Dest)
    IPv6 adress : 20:01:32:ef:a2:21:fb:32:00:00:00:00:00:00:00:00:OO:01
 */
 void
-oid2addr(oid * id, IpAddress &addr, u_int size)
+oid2addr(oid * id, Ip::Address &addr, u_int size)
 {
     struct in_addr iaddr;
     u_int i;