[Olsr-cvs] olsrd-current/src/bsd kernel_routes.c,1.11,1.12

Bernd Petrovitsch (spam-protected)
Wed Sep 5 18:11:13 CEST 2007


Update of /cvsroot/olsrd/olsrd-current/src/bsd
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18959/src/bsd

Modified Files:
	kernel_routes.c 
Log Message:
* applied rt-refactoring-6.diff from Hannes Gredler <(spam-protected)>

Index: kernel_routes.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/bsd/kernel_routes.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** kernel_routes.c	2 May 2007 07:41:20 -0000	1.11
--- kernel_routes.c	5 Sep 2007 16:11:11 -0000	1.12
***************
*** 50,54 ****
  static unsigned int seq = 0;
  
! static int add_del_route(struct rt_entry *dest, int add)
  {
    struct rt_msghdr *rtm;
--- 50,54 ----
  static unsigned int seq = 0;
  
! static int add_del_route(struct rt_entry *rt, int add)
  {
    struct rt_msghdr *rtm;
***************
*** 59,73 ****
    struct ifaddrs *addrs;
    struct ifaddrs *awalker;
    int step, step2;
    int len;
-   char Str1[16], Str2[16], Str3[16];
    int flags;
  
!   inet_ntop(AF_INET, &dest->rt_dst.v4, Str1, 16);
!   inet_ntop(AF_INET, &dest->rt_mask.v4, Str2, 16);
!   inet_ntop(AF_INET, &dest->rt_router.v4, Str3, 16);
! 
!   OLSR_PRINTF(1, "%s IPv4 route to %s/%s via %s.\n",
!     (add != 0) ? "Adding" : "Removing", Str1, Str2, Str3);
  
    memset(buff, 0, sizeof (buff));
--- 59,73 ----
    struct ifaddrs *addrs;
    struct ifaddrs *awalker;
+   struct rt_nexthop *nexthop;
+   union olsr_ip_addr mask;
    int step, step2;
    int len;
    int flags;
  
!   if (add) {
!       OLSR_PRINTF(2, "KERN: Adding %s\n", olsr_rtp_to_string(rt->rt_best));
!   } else {
!       OLSR_PRINTF(2, "KERN: Deleting %s\n", olsr_rt_to_string(rt));
!   }
  
    memset(buff, 0, sizeof (buff));
***************
*** 82,86 ****
    rtm = (struct rt_msghdr *)buff;
  
!   flags = dest->rt_flags;
  
    // the host is directly reachable, so use cloning and a /32 net
--- 82,86 ----
    rtm = (struct rt_msghdr *)buff;
  
!   flags = olsr_rt_flags(rt);
  
    // the host is directly reachable, so use cloning and a /32 net
***************
*** 102,113 ****
    walker = buff + sizeof (struct rt_msghdr);
  
!   sin.sin_addr.s_addr = dest->rt_dst.v4;
  
    memcpy(walker, &sin, sizeof (sin));
    walker += step;
  
    if ((flags & RTF_GATEWAY) != 0)
    {
!     sin.sin_addr.s_addr = dest->rt_router.v4;
  
      memcpy(walker, &sin, sizeof (sin));
--- 102,114 ----
    walker = buff + sizeof (struct rt_msghdr);
  
!   sin.sin_addr.s_addr = rt->rt_dst.prefix.v4;
  
    memcpy(walker, &sin, sizeof (sin));
    walker += step;
  
+   nexthop = olsr_get_nh(rt);
    if ((flags & RTF_GATEWAY) != 0)
    {
!     sin.sin_addr.s_addr = nexthop->gateway.v4;
  
      memcpy(walker, &sin, sizeof (sin));
***************
*** 128,137 ****
      for (awalker = addrs; awalker != NULL; awalker = awalker->ifa_next)
        if (awalker->ifa_addr->sa_family == AF_LINK &&
!           strcmp(awalker->ifa_name, dest->rt_if->int_name) == 0)
          break;
  
      if (awalker == NULL)
      {
!       fprintf(stderr, "interface %s not found\n", dest->rt_if->int_name);
        freeifaddrs(addrs);
        return -1;
--- 129,138 ----
      for (awalker = addrs; awalker != NULL; awalker = awalker->ifa_next)
        if (awalker->ifa_addr->sa_family == AF_LINK &&
!           strcmp(awalker->ifa_name, nexthop->iface->int_name) == 0)
          break;
  
      if (awalker == NULL)
      {
!       fprintf(stderr, "interface %s not found\n", nexthop->iface->int_name);
        freeifaddrs(addrs);
        return -1;
***************
*** 146,150 ****
    }
  
!   sin.sin_addr.s_addr = dest->rt_mask.v4;
  
    memcpy(walker, &sin, sizeof (sin));
--- 147,154 ----
    }
  
!   if (!olsr_prefix_to_netmask(&mask, rt->rt_dst.prefix_len)) {
!     return -1;
!   }
!   sin.sin_addr.s_addr = mask.v4;
  
    memcpy(walker, &sin, sizeof (sin));
***************
*** 161,175 ****
  }
  
! int olsr_ioctl_add_route(struct rt_entry *dest)
  {
!   return add_del_route(dest, 1);
  }
  
! int olsr_ioctl_del_route(struct rt_entry *dest)
  {
!   return add_del_route(dest, 0);
  }
  
! static int add_del_route6(struct rt_entry *dest, int add)
  {
    struct rt_msghdr *rtm;
--- 165,179 ----
  }
  
! int olsr_ioctl_add_route(struct rt_entry *rt)
  {
!   return add_del_route(rt, 1);
  }
  
! int olsr_ioctl_del_route(struct rt_entry *rt)
  {
!   return add_del_route(rt, 0);
  }
  
! static int add_del_route6(struct rt_entry *rt, int add)
  {
    struct rt_msghdr *rtm;
***************
*** 178,190 ****
    struct sockaddr_in6 sin6;
    struct sockaddr_dl sdl;
    int step, step_dl;
    int len;
-   char Str1[40], Str2[40];
- 
-   inet_ntop(AF_INET6, &dest->rt_dst.v6, Str1, 40);
-   inet_ntop(AF_INET6, &dest->rt_router.v6, Str2, 40);
  
!   OLSR_PRINTF(1, "%s IPv6 route to %s/%d via %s.\n", 
!     (add != 0) ? "Adding" : "Removing", Str1, dest->rt_mask.v6, Str2);
  
    memset(buff, 0, sizeof (buff));
--- 182,194 ----
    struct sockaddr_in6 sin6;
    struct sockaddr_dl sdl;
+   struct rt_nexthop *nexthop;
    int step, step_dl;
    int len;
  
!   if (add) {
!       OLSR_PRINTF(2, "KERN: Adding %s\n", olsr_rtp_to_string(rt->rt_best));
!   } else {
!       OLSR_PRINTF(2, "KERN: Deleting %s\n", olsr_rt_to_string(rt));
!   }
  
    memset(buff, 0, sizeof (buff));
***************
*** 204,208 ****
    rtm->rtm_type = (add != 0) ? RTM_ADD : RTM_DELETE;
    rtm->rtm_index = 0;
!   rtm->rtm_flags = dest->rt_flags;
    rtm->rtm_addrs = RTA_DST | RTA_GATEWAY;
    rtm->rtm_seq = ++seq;
--- 208,212 ----
    rtm->rtm_type = (add != 0) ? RTM_ADD : RTM_DELETE;
    rtm->rtm_index = 0;
!   rtm->rtm_flags = olsr_rt_flags(rt);
    rtm->rtm_addrs = RTA_DST | RTA_GATEWAY;
    rtm->rtm_seq = ++seq;
***************
*** 210,221 ****
    walker = buff + sizeof (struct rt_msghdr);
  
!   memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_dst.v6, sizeof(struct in6_addr));
  
    memcpy(walker, &sin6, sizeof (sin6));
    walker += step;
  
    if ((rtm->rtm_flags & RTF_GATEWAY) != 0)
    {
!     memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_router.v6, sizeof(struct in6_addr));
  
      memcpy(walker, &sin6, sizeof (sin6));
--- 214,226 ----
    walker = buff + sizeof (struct rt_msghdr);
  
!   memcpy(&sin6.sin6_addr.s6_addr, &rt->rt_dst.prefix.v6, sizeof(struct in6_addr));
  
    memcpy(walker, &sin6, sizeof (sin6));
    walker += step;
  
+   nexthop = olsr_get_nh(rt);
    if ((rtm->rtm_flags & RTF_GATEWAY) != 0)
    {
!     memcpy(&sin6.sin6_addr.s6_addr, &nexthop->gateway.v6, sizeof(struct in6_addr));
  
      memcpy(walker, &sin6, sizeof (sin6));
***************
*** 227,231 ****
    else
    {
!     memcpy(&sin6.sin6_addr.s6_addr, &dest->rt_if->int6_addr.sin6_addr.s6_addr,
        sizeof(struct in6_addr));
  
--- 232,236 ----
    else
    {
!     memcpy(&sin6.sin6_addr.s6_addr, &nexthop->iface->int6_addr.sin6_addr.s6_addr,
        sizeof(struct in6_addr));
  
***************
*** 237,241 ****
    if ((rtm->rtm_flags & RTF_HOST) == 0)
    {
!     olsr_prefix_to_netmask((union olsr_ip_addr *)&sin6.sin6_addr, dest->rt_mask.v6);
      memcpy(walker, &sin6, sizeof (sin6));
      walker += step;
--- 242,246 ----
    if ((rtm->rtm_flags & RTF_HOST) == 0)
    {
!     olsr_prefix_to_netmask((union olsr_ip_addr *)&sin6.sin6_addr, rt->rt_dst.prefix_len);
      memcpy(walker, &sin6, sizeof (sin6));
      walker += step;
***************
*** 245,250 ****
    if ((rtm->rtm_flags & RTF_GATEWAY) != 0)
    {
!     strcpy(&sdl.sdl_data[0], dest->rt_if->int_name);
!     sdl.sdl_nlen = (u_char)strlen(dest->rt_if->int_name);
      memcpy(walker, &sdl, sizeof (sdl));
      walker += step_dl;
--- 250,255 ----
    if ((rtm->rtm_flags & RTF_GATEWAY) != 0)
    {
!     strcpy(&sdl.sdl_data[0], nexthop->iface->int_name);
!     sdl.sdl_nlen = (u_char)strlen(nexthop->iface->int_name);
      memcpy(walker, &sdl, sizeof (sdl));
      walker += step_dl;
***************
*** 262,272 ****
  }
  
! int olsr_ioctl_add_route6(struct rt_entry *dest)
  {
!   return add_del_route6(dest, 1);
  }
  
! int olsr_ioctl_del_route6(struct rt_entry *dest)
  {
!   return add_del_route6(dest, 0);
  }
--- 267,283 ----
  }
  
! int olsr_ioctl_add_route6(struct rt_entry *rt)
  {
!   return add_del_route6(rt, 1);
  }
  
! int olsr_ioctl_del_route6(struct rt_entry *rt)
  {
!   return add_del_route6(rt, 0);
  }
+ 
+ /*
+  * Local Variables:
+  * c-basic-offset: 2
+  * End:
+  */





More information about the Olsr-cvs mailing list