Imported Upstream version 2.7
[ossec-hids.git] / src / config / remote-config.c
index 6627813..e85d625 100755 (executable)
@@ -34,6 +34,7 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
     /* Remote options */       
     char *xml_remote_port = "port";
     char *xml_remote_proto = "protocol";
+    char *xml_remote_ipv6 = "ipv6";
     char *xml_remote_connection = "connection";
     char *xml_remote_lip = "local_ip";
 
@@ -52,8 +53,8 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
         while(logr->denyips[deny_size -1])
             deny_size++;
     }
-                                            
-    
+
+
     /* conn and port must not be null */
     if(!logr->conn)
     {
@@ -70,13 +71,18 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
         os_calloc(1, sizeof(int), logr->proto);
         logr->proto[0] = 0;
     }
+    if(!logr->ipv6)
+    {
+        os_calloc(1, sizeof(int), logr->ipv6);
+        logr->ipv6[0] = 0;
+    }
     if(!logr->lip)
     {
         os_calloc(1, sizeof(char *), logr->lip);
         logr->lip[0] = NULL;
     }
-    
-    
+
+
     /* Cleaning */
     while(logr->conn[pl] != 0)
         pl++;
@@ -86,22 +92,25 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
     logr->port = realloc(logr->port, sizeof(int)*(pl +2));
     logr->conn = realloc(logr->conn, sizeof(int)*(pl +2));
     logr->proto = realloc(logr->proto, sizeof(int)*(pl +2));
+    logr->ipv6 = realloc(logr->ipv6, sizeof(int)*(pl +2));
     logr->lip = realloc(logr->lip, sizeof(char *)*(pl +2));
     if(!logr->port || !logr->conn || !logr->proto || !logr->lip)
     {
         merror(MEM_ERROR, ARGV0);
     }
-    
+
     logr->port[pl] = 0;
     logr->conn[pl] = 0;
     logr->proto[pl] = 0;
+    logr->ipv6[pl] = 0;
     logr->lip[pl] = NULL;
-    
+
     logr->port[pl +1] = 0;
     logr->conn[pl +1] = 0;
     logr->proto[pl +1] = 0;
+    logr->ipv6[pl +1] = 0;
     logr->lip[pl +1] = NULL;
-    
+
     while(node[i])
     {
         if(!node[i]->element)
@@ -162,6 +171,13 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
                 return(OS_INVALID);
             }
         }
+        else if(strcasecmp(node[i]->element,xml_remote_ipv6) == 0)
+        {
+            if(strcasecmp(node[i]->content, "yes") == 0)
+            {
+                logr->ipv6[pl] = 1;
+            }
+        }
         else if(strcasecmp(node[i]->element,xml_remote_lip) == 0)
         {
             os_strdup(node[i]->content,logr->lip[pl]);
@@ -183,7 +199,7 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
 
             os_calloc(1, sizeof(os_ip), logr->allowips[allow_size -2]);
             logr->allowips[allow_size -1] = NULL;
-            
+
             if(!OS_IsValidIP(node[i]->content,logr->allowips[allow_size -2]))
             {
                 merror(INVALID_IP, ARGV0, node[i]->content);
@@ -194,7 +210,7 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
         {
             deny_size++;
             logr->denyips = realloc(logr->denyips,sizeof(os_ip *)*deny_size);
-            if(!logr->denyips)             
+            if(!logr->denyips)
             {
                 merror(MEM_ERROR, ARGV0);
                 return(OS_INVALID);
@@ -222,14 +238,14 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
         merror(CONN_ERROR, ARGV0);
         return(OS_INVALID);
     }
-    
+
     /* Set port in here */
     if(logr->port[pl] == 0)
     {
         if(logr->conn[pl] == SECURE_CONN)
             logr->port[pl] = DEFAULT_SECURE;
         else
-            logr->port[pl] = DEFAULT_SYSLOG;    
+            logr->port[pl] = DEFAULT_SYSLOG;
     }
 
     /* set default protocol */
@@ -243,7 +259,7 @@ int Read_Remote(XML_NODE node, void *d1, void *d2)
     {
         logr->proto[pl] = UDP_PROTO;
     }
-    
+
     return(0);
 }