IPC route entry issues fixed
authorAndreas Tonnesen <andreto@olsr.org>
Fri, 12 Nov 2004 22:11:54 +0000 (22:11 +0000)
committerAndreas Tonnesen <andreto@olsr.org>
Fri, 12 Nov 2004 22:11:54 +0000 (22:11 +0000)
src/defs.h
src/ipc_frontend.c
src/linux/kernel_routes.c
src/main.c

index 42e4189..4e5a52e 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: defs.h,v 1.25 2004/11/09 21:09:57 kattemat Exp $
+ * $Id: defs.h,v 1.26 2004/11/12 22:11:54 kattemat Exp $
  *
  */
 
@@ -184,7 +184,7 @@ int
 ipc_send_net_info(void);
 
 int
-ipc_route_send_rtentry(union olsr_kernel_route *, int, char *);
+ipc_route_send_rtentry(union olsr_ip_addr*, union olsr_ip_addr *, int, int, char *);
 
 
 
index 5ad5af7..c6351a4 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: ipc_frontend.c,v 1.17 2004/11/12 16:27:48 kattemat Exp $
+ * $Id: ipc_frontend.c,v 1.18 2004/11/12 22:11:54 kattemat Exp $
  *
  */
 
@@ -240,7 +240,7 @@ frontend_msgparser(union olsr_message *msg, struct interface *in_if, union olsr_
  *@return negative on error
  */
 int
-ipc_route_send_rtentry(union olsr_kernel_route *kernel_route, int add, char *int_name)
+ipc_route_send_rtentry(union olsr_ip_addr *dst, union olsr_ip_addr *gw, int met, int add, char *int_name)
 {
   struct ipcmsg packet;
   //int i, x;
@@ -249,39 +249,23 @@ ipc_route_send_rtentry(union olsr_kernel_route *kernel_route, int add, char *int
   if(!ipc_active)
     return 0;
 
+  memset(&packet, 0, sizeof(struct ipcmsg));
   packet.size = htons(IPC_PACK_SIZE);
   packet.msgtype = ROUTE_IPC;
 
-  if(olsr_cnf->ip_version == AF_INET)
-    COPY_IP(&packet.target_addr, &((struct sockaddr_in *)&kernel_route->v4.rt_dst)->sin_addr.s_addr);
-  else
-    COPY_IP(&packet.target_addr, &kernel_route->v6.rtmsg_dst);
+  COPY_IP(&packet.target_addr, dst);
 
   packet.add = add;
-  if(add)
+  if(add && gw)
     {
-      if(olsr_cnf->ip_version == AF_INET)
-       {
-         packet.metric = kernel_route->v4.rt_metric - 1;
-         COPY_IP(&packet.gateway_addr, &((struct sockaddr_in *)&kernel_route->v4.rt_gateway)->sin_addr.s_addr);
-       }
-      else
-       {
-         packet.metric = kernel_route->v6.rtmsg_metric;
-         COPY_IP(&packet.gateway_addr, &kernel_route->v6.rtmsg_gateway);
-       }
-
-      if(int_name != NULL)
-       memcpy(&packet.device[0], int_name, 4);
-      else
-       memset(&packet.device[0], 0, 4);
+      packet.metric = met;
+      COPY_IP(&packet.gateway_addr, gw);
     }
+
+  if(int_name != NULL)
+    memcpy(&packet.device[0], int_name, 4);
   else
-    {
-      memset(&packet.metric, 0, 1);
-      memset(&packet.gateway_addr, 0, 4);
-      memset(&packet.device[0], 0, 4);
-    }
+    memset(&packet.device[0], 0, 4);
 
 
   tmp = (char *) &packet;
index e794b87..612058e 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: kernel_routes.c,v 1.9 2004/11/02 21:14:12 kattemat Exp $
+ * $Id: kernel_routes.c,v 1.10 2004/11/12 22:11:54 kattemat Exp $
  *
  */
 
@@ -113,10 +113,11 @@ olsr_ioctl_add_route(struct rt_entry *destination)
   
   if(olsr_cnf->open_ipc)
       {
-       if(destination->rt_router.v4)
-         ipc_route_send_rtentry((union olsr_kernel_route *)&kernel_route, 1, destination->rt_if->int_name); /* Send interface name */
-       else
-         ipc_route_send_rtentry((union olsr_kernel_route *)&kernel_route, 1, NULL);
+       ipc_route_send_rtentry(&destination->rt_dst, 
+                              &destination->rt_router, 
+                              destination->rt_metric, 
+                              1,
+                              destination->rt_if->int_name); /* Send interface name */
       }
   
   
@@ -193,9 +194,12 @@ olsr_ioctl_add_route6(struct rt_entry *destination)
       if(olsr_cnf->open_ipc)
        {
          if(memcmp(&destination->rt_router, &null_addr6, ipsize) != 0)
-           ipc_route_send_rtentry((union olsr_kernel_route *)&kernel_route, 1, destination->rt_if->int_name); // Send interface name
-         else
-           ipc_route_send_rtentry((union olsr_kernel_route *)&kernel_route, 1, NULL);
+           ipc_route_send_rtentry(&destination->rt_dst, 
+                                  &destination->rt_router, 
+                                  destination->rt_metric, 
+                                  1,
+                                  destination->rt_if->int_name); /* Send interface name */
+
        }
     }
     return(tmp);
@@ -255,7 +259,11 @@ olsr_ioctl_del_route(struct rt_entry *destination)
      */
 
   if(olsr_cnf->open_ipc)
-    ipc_route_send_rtentry((union olsr_kernel_route *)&kernel_route, 0, NULL);
+    ipc_route_send_rtentry(&destination->rt_dst, 
+                          NULL, 
+                          destination->rt_metric, 
+                          0,
+                          NULL); /* Send interface name */
 
   return tmp;
 }
@@ -308,7 +316,11 @@ olsr_ioctl_del_route6(struct rt_entry *destination)
      */
 
   if(olsr_cnf->open_ipc)
-    ipc_route_send_rtentry((union olsr_kernel_route *)&kernel_route, 0, NULL);
+    ipc_route_send_rtentry(&destination->rt_dst, 
+                          NULL, 
+                          destination->rt_metric, 
+                          0,
+                          NULL); /* Send interface name */
 
   return tmp;
 }
index 1b84c85..637436b 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: main.c,v 1.37 2004/11/12 21:20:23 kattemat Exp $
+ * $Id: main.c,v 1.38 2004/11/12 22:11:54 kattemat Exp $
  *
  */
 
@@ -630,8 +630,6 @@ main(int argc, char *argv[])
 
   /* Starting scheduler */
   scheduler();
-  /* Go into listenloop */
-  //listen_loop();
 
   /* Like we're ever going to reach this ;-) */
   return 1;