Diff for /embedaddon/quagga/ospf6d/ospf6_intra.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 17:26:12 version 1.1.1.2, 2016/11/02 10:09:11
Line 46 Line 46
 #include "ospf6_abr.h"  #include "ospf6_abr.h"
 #include "ospf6_flood.h"  #include "ospf6_flood.h"
 #include "ospf6d.h"  #include "ospf6d.h"
   #include "ospf6_spf.h"
   
   
 unsigned char conf_debug_ospf6_brouter = 0;  unsigned char conf_debug_ospf6_brouter = 0;
 u_int32_t conf_debug_ospf6_brouter_specific_router_id;  u_int32_t conf_debug_ospf6_brouter_specific_router_id;
 u_int32_t conf_debug_ospf6_brouter_specific_area_id;  u_int32_t conf_debug_ospf6_brouter_specific_area_id;
Line 56  u_int32_t conf_debug_ospf6_brouter_specific_area_id; Line 56  u_int32_t conf_debug_ospf6_brouter_specific_area_id;
 /* RFC2740 3.4.3.1 Router-LSA */  /* RFC2740 3.4.3.1 Router-LSA */
 /******************************/  /******************************/
   
   static char *
   ospf6_router_lsa_get_nbr_id (struct ospf6_lsa *lsa, char *buf, int buflen,
                                int pos)
   {
     struct ospf6_router_lsa *router_lsa;
     struct ospf6_router_lsdesc *lsdesc;
     char *start, *end;
     char buf1[INET_ADDRSTRLEN], buf2[INET_ADDRSTRLEN];
   
     if (lsa)
       {
         router_lsa = (struct ospf6_router_lsa *)
           ((char *) lsa->header + sizeof (struct ospf6_lsa_header));
         start = (char *) router_lsa + sizeof (struct ospf6_router_lsa);
         end = (char *) lsa->header + ntohs (lsa->header->length);
   
         lsdesc = (struct ospf6_router_lsdesc *)
           (start + pos*(sizeof (struct ospf6_router_lsdesc)));
         if ((char *)lsdesc < end)
           {
             if (buf && (buflen > INET_ADDRSTRLEN*2))
               {
                 inet_ntop (AF_INET, &lsdesc->neighbor_interface_id,
                            buf1, sizeof(buf1));
                 inet_ntop (AF_INET, &lsdesc->neighbor_router_id,
                            buf2, sizeof(buf2));
                 sprintf (buf, "%s/%s", buf2, buf1);
               }
           }
         else
           return NULL;
       }
   
     return buf;
   }
   
 static int  static int
 ospf6_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)  ospf6_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
 {  {
Line 105  ospf6_router_lsa_show (struct vty *vty, struct ospf6_l Line 141  ospf6_router_lsa_show (struct vty *vty, struct ospf6_l
 }  }
   
 int  int
   ospf6_router_is_stub_router (struct ospf6_lsa *lsa)
   {
     struct ospf6_router_lsa *rtr_lsa;
   
     if (lsa != NULL && OSPF6_LSA_IS_TYPE (ROUTER, lsa))
       {
         rtr_lsa = (struct ospf6_router_lsa *)
           ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
   
         if (!OSPF6_OPT_ISSET (rtr_lsa->options, OSPF6_OPT_R))
           {
             return (OSPF6_IS_STUB_ROUTER);
           }
         else if (!OSPF6_OPT_ISSET (rtr_lsa->options, OSPF6_OPT_V6))
           {
             return (OSPF6_IS_STUB_ROUTER_V6);
           }
       }
   
     return (OSPF6_NOT_STUB_ROUTER);
   }
   
   int
 ospf6_router_lsa_originate (struct thread *thread)  ospf6_router_lsa_originate (struct thread *thread)
 {  {
   struct ospf6_area *oa;    struct ospf6_area *oa;
Line 175  ospf6_router_lsa_originate (struct thread *thread) Line 234  ospf6_router_lsa_originate (struct thread *thread)
   
       /* Multiple Router-LSA instance according to size limit setting */        /* Multiple Router-LSA instance according to size limit setting */
       if ( (oa->router_lsa_size_limit != 0)        if ( (oa->router_lsa_size_limit != 0)
          && ((caddr_t) lsdesc + sizeof (struct ospf6_router_lsdesc) -          && ((size_t)((char *)lsdesc - buffer)
              /* XXX warning: comparison between signed and unsigned */                 + sizeof (struct ospf6_router_lsdesc)
              (caddr_t) buffer > oa->router_lsa_size_limit))               > oa->router_lsa_size_limit))
         {          {
           if ((caddr_t) lsdesc == (caddr_t) router_lsa +            if ((caddr_t) lsdesc == (caddr_t) router_lsa +
                                   sizeof (struct ospf6_router_lsa))                                    sizeof (struct ospf6_router_lsa))
Line 215  ospf6_router_lsa_originate (struct thread *thread) Line 274  ospf6_router_lsa_originate (struct thread *thread)
         }          }
   
       /* Point-to-Point interfaces */        /* Point-to-Point interfaces */
      if (if_is_pointopoint (oi->interface))      if (oi->type == OSPF_IFTYPE_POINTOPOINT)
         {          {
           for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on))            for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on))
             {              {
Line 233  ospf6_router_lsa_originate (struct thread *thread) Line 292  ospf6_router_lsa_originate (struct thread *thread)
         }          }
   
       /* Broadcast and NBMA interfaces */        /* Broadcast and NBMA interfaces */
      if (if_is_broadcast (oi->interface))      else if (oi->type == OSPF_IFTYPE_BROADCAST)
         {          {
           /* If this router is not DR,            /* If this router is not DR,
              and If this router not fully adjacent with DR,               and If this router not fully adjacent with DR,
Line 261  ospf6_router_lsa_originate (struct thread *thread) Line 320  ospf6_router_lsa_originate (struct thread *thread)
   
           lsdesc++;            lsdesc++;
         }          }
         else
           {
             assert (0);           /* Unknown interface type */
           }
   
       /* Virtual links */        /* Virtual links */
         /* xxx */          /* xxx */
Line 268  ospf6_router_lsa_originate (struct thread *thread) Line 331  ospf6_router_lsa_originate (struct thread *thread)
         /* xxx */          /* xxx */
     }      }
   
  if ((caddr_t) lsdesc != (caddr_t) router_lsa +  /* Fill LSA Header */
                          sizeof (struct ospf6_router_lsa))  lsa_header->age = 0;
    {  lsa_header->type = htons (OSPF6_LSTYPE_ROUTER);
      /* Fill LSA Header */  lsa_header->id = htonl (link_state_id);
      lsa_header->age = 0;  lsa_header->adv_router = oa->ospf6->router_id;
      lsa_header->type = htons (OSPF6_LSTYPE_ROUTER);  lsa_header->seqnum =
      lsa_header->id = htonl (link_state_id);    ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
      lsa_header->adv_router = oa->ospf6->router_id;                         lsa_header->adv_router, oa->lsdb);
      lsa_header->seqnum =  lsa_header->length = htons ((caddr_t) lsdesc - (caddr_t) buffer);
        ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, 
                             lsa_header->adv_router, oa->lsdb); 
      lsa_header->length = htons ((caddr_t) lsdesc - (caddr_t) buffer); 
   
      /* LSA checksum */  /* LSA checksum */
      ospf6_lsa_checksum (lsa_header);  ospf6_lsa_checksum (lsa_header);
   
      /* create LSA */  /* create LSA */
      lsa = ospf6_lsa_create (lsa_header);  lsa = ospf6_lsa_create (lsa_header);
   
      /* Originate */  /* Originate */
      ospf6_lsa_originate_area (lsa, oa);  ospf6_lsa_originate_area (lsa, oa);
   
      link_state_id ++;  link_state_id ++;
    } 
  else 
    { 
      if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER)) 
        zlog_debug ("Nothing to describe in Router-LSA, suppress"); 
    } 
   
   /* Do premature-aging of rest, undesired Router-LSAs */    /* Do premature-aging of rest, undesired Router-LSAs */
   type = ntohs (OSPF6_LSTYPE_ROUTER);    type = ntohs (OSPF6_LSTYPE_ROUTER);
Line 316  ospf6_router_lsa_originate (struct thread *thread) Line 370  ospf6_router_lsa_originate (struct thread *thread)
 /* RFC2740 3.4.3.2 Network-LSA */  /* RFC2740 3.4.3.2 Network-LSA */
 /*******************************/  /*******************************/
   
   static char *
   ospf6_network_lsa_get_ar_id (struct ospf6_lsa *lsa, char *buf, int buflen,
                                int pos)
   {
     char *start, *end, *current;
     struct ospf6_network_lsa *network_lsa;
     struct ospf6_network_lsdesc *lsdesc;
   
     if (lsa)
       {
         network_lsa = (struct ospf6_network_lsa *)
           ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
   
         start = (char *) network_lsa + sizeof (struct ospf6_network_lsa);
         end = (char *) lsa->header + ntohs (lsa->header->length);
         current = start + pos*(sizeof (struct ospf6_network_lsdesc));
   
         if ((current + sizeof(struct ospf6_network_lsdesc)) <= end)
           {
             lsdesc = (struct ospf6_network_lsdesc *)current;
             if (buf)
               inet_ntop (AF_INET, &lsdesc->router_id, buf, buflen);
           }
         else
           return NULL;
       }
   
     return (buf);
   }
   
 static int  static int
 ospf6_network_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)  ospf6_network_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
 {  {
Line 462  ospf6_network_lsa_originate (struct thread *thread) Line 546  ospf6_network_lsa_originate (struct thread *thread)
 /* RFC2740 3.4.3.6 Link-LSA */  /* RFC2740 3.4.3.6 Link-LSA */
 /****************************/  /****************************/
   
   static char *
   ospf6_link_lsa_get_prefix_str (struct ospf6_lsa *lsa, char *buf, int buflen,
                                  int pos)
   {
     char *start, *end, *current;
     struct ospf6_link_lsa *link_lsa;
     struct in6_addr in6;
     struct ospf6_prefix *prefix;
     int cnt = 0, prefixnum;
   
     if (lsa)
       {
         link_lsa = (struct ospf6_link_lsa *)
           ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
   
         if (pos == 0) {
           inet_ntop (AF_INET6, &link_lsa->linklocal_addr, buf, buflen);
           return (buf);
         }
   
         prefixnum = ntohl (link_lsa->prefix_num);
         if (pos > prefixnum)
           return (NULL);
   
         start = (char *) link_lsa + sizeof (struct ospf6_link_lsa);
         end = (char *) lsa->header + ntohs (lsa->header->length);
         current = start;
   
         do
           {
             prefix = (struct ospf6_prefix *) current;
             if (prefix->prefix_length == 0 ||
                 current + OSPF6_PREFIX_SIZE (prefix) > end)
               {
                 return (NULL);
               }
   
             if (cnt < pos)
               {
                 current = start + pos*OSPF6_PREFIX_SIZE(prefix);
                 cnt++;
               }
             else
               {
                 memset (&in6, 0, sizeof (in6));
                 memcpy (&in6, OSPF6_PREFIX_BODY (prefix),
                         OSPF6_PREFIX_SPACE (prefix->prefix_length));
                 inet_ntop (AF_INET6, &in6, buf, buflen);
                 return (buf);
               }
           } while (current <= end);
       }
     return (NULL);
   }
   
 static int  static int
 ospf6_link_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)  ospf6_link_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
 {  {
Line 614  ospf6_link_lsa_originate (struct thread *thread) Line 753  ospf6_link_lsa_originate (struct thread *thread)
 /*****************************************/  /*****************************************/
 /* RFC2740 3.4.3.7 Intra-Area-Prefix-LSA */  /* RFC2740 3.4.3.7 Intra-Area-Prefix-LSA */
 /*****************************************/  /*****************************************/
   static char *
   ospf6_intra_prefix_lsa_get_prefix_str (struct ospf6_lsa *lsa, char *buf,
                                          int buflen, int pos)
   {
     char *start, *end, *current;
     struct ospf6_intra_prefix_lsa *intra_prefix_lsa;
     struct in6_addr in6;
     int prefixnum, cnt = 0;
     struct ospf6_prefix *prefix;
   
     if (lsa)
       {
         intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)
           ((caddr_t) lsa->header + sizeof (struct ospf6_lsa_header));
   
         prefixnum = ntohs (intra_prefix_lsa->prefix_num);
         if (pos > prefixnum)
           return (NULL);
   
         start = (char *) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa);
         end = (char *) lsa->header + ntohs (lsa->header->length);
         current = start;
   
         do
           {
             prefix = (struct ospf6_prefix *) current;
             if (prefix->prefix_length == 0 ||
                 current + OSPF6_PREFIX_SIZE (prefix) > end)
               {
                 return NULL;
               }
   
             if (cnt < pos)
               {
                 current = start + pos*OSPF6_PREFIX_SIZE(prefix);
                 cnt++;
               }
             else
               {
                 memset (&in6, 0, sizeof (in6));
                 memcpy (&in6, OSPF6_PREFIX_BODY (prefix),
                         OSPF6_PREFIX_SPACE (prefix->prefix_length));
                 inet_ntop (AF_INET6, &in6, buf, buflen);
                 sprintf(&buf[strlen(buf)], "/%d", prefix->prefix_length);
                 return (buf);
               }
           } while (current <= end);
       }
     return (buf);
   }
   
 static int  static int
 ospf6_intra_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)  ospf6_intra_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
 {  {
Line 1029  ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa) Line 1218  ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa)
   struct ospf6_prefix *op;    struct ospf6_prefix *op;
   char *start, *current, *end;    char *start, *current, *end;
   char buf[64];    char buf[64];
     struct interface *ifp;
     int direct_connect = 0;
   
   if (OSPF6_LSA_IS_MAXAGE (lsa))    if (OSPF6_LSA_IS_MAXAGE (lsa))
     return;      return;
Line 1065  ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa) Line 1256  ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa)
       return;        return;
     }      }
   
     if (intra_prefix_lsa->ref_adv_router == oa->ospf6->router_id)
       {
         /* the intra-prefix are directly connected */
         direct_connect = 1;
       }
   
   prefix_num = ntohs (intra_prefix_lsa->prefix_num);    prefix_num = ntohs (intra_prefix_lsa->prefix_num);
   start = (caddr_t) intra_prefix_lsa +    start = (caddr_t) intra_prefix_lsa +
           sizeof (struct ospf6_intra_prefix_lsa);            sizeof (struct ospf6_intra_prefix_lsa);
Line 1077  ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa) Line 1274  ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa)
       if (end < current + OSPF6_PREFIX_SIZE (op))        if (end < current + OSPF6_PREFIX_SIZE (op))
         break;          break;
   
         /* Appendix A.4.1.1 */
         if (CHECK_FLAG(op->prefix_options, OSPF6_PREFIX_OPTION_NU) ||
             CHECK_FLAG(op->prefix_options, OSPF6_PREFIX_OPTION_LA))
           {
             if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
               {
                 ospf6_linkstate_prefix2str ((struct prefix *)OSPF6_PREFIX_BODY(op),
                                             buf, sizeof (buf));
                 zlog_debug ("%s: Skipping Prefix %s has NU/LA option set",
                             __func__, buf);
               }
             continue;
           }
   
       route = ospf6_route_create ();        route = ospf6_route_create ();
   
       memset (&route->prefix, 0, sizeof (struct prefix));        memset (&route->prefix, 0, sizeof (struct prefix));
Line 1095  ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa) Line 1306  ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa)
       route->path.cost = ls_entry->path.cost +        route->path.cost = ls_entry->path.cost +
                          ntohs (op->prefix_metric);                           ntohs (op->prefix_metric);
   
      for (i = 0; ospf6_nexthop_is_set (&ls_entry->nexthop[i]) &&      if (direct_connect)
           i < OSPF6_MULTI_PATH_LIMIT; i++)        {
        ospf6_nexthop_copy (&route->nexthop[i], &ls_entry->nexthop[i]);          ifp = if_lookup_prefix(&route->prefix);
           if (ifp)
             route->nexthop[0].ifindex = ifp->ifindex;
         }
       else
         {
           for (i = 0; ospf6_nexthop_is_set (&ls_entry->nexthop[i]) &&
                i < OSPF6_MULTI_PATH_LIMIT; i++)
             ospf6_nexthop_copy (&route->nexthop[i], &ls_entry->nexthop[i]);
         }
   
       if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))        if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
         {          {
Line 1275  ospf6_brouter_debug_print (struct ospf6_route *brouter Line 1495  ospf6_brouter_debug_print (struct ospf6_route *brouter
   
   zlog_info ("Brouter: %s via area %s", brouter_name, area_name);    zlog_info ("Brouter: %s via area %s", brouter_name, area_name);
   zlog_info ("  memory: prev: %p this: %p next: %p parent rnode: %p",    zlog_info ("  memory: prev: %p this: %p next: %p parent rnode: %p",
             brouter->prev, brouter, brouter->next, brouter->rnode);             (void *)brouter->prev, (void *)brouter, (void *)brouter->next,
              (void *)brouter->rnode);
   zlog_info ("  type: %d prefix: %s installed: %s changed: %s",    zlog_info ("  type: %d prefix: %s installed: %s changed: %s",
              brouter->type, destination, installed, changed);               brouter->type, destination, installed, changed);
   zlog_info ("  lock: %d flags: %s%s%s%s", brouter->lock,    zlog_info ("  lock: %d flags: %s%s%s%s", brouter->lock,
Line 1323  ospf6_intra_brouter_calculation (struct ospf6_area *oa Line 1544  ospf6_intra_brouter_calculation (struct ospf6_area *oa
           IS_OSPF6_DEBUG_ROUTE (MEMORY))            IS_OSPF6_DEBUG_ROUTE (MEMORY))
         {          {
           zlog_info ("%p: mark as removing: area %s brouter %s",            zlog_info ("%p: mark as removing: area %s brouter %s",
                     brouter, oa->name, brouter_name);                     (void *)brouter, oa->name, brouter_name);
           ospf6_brouter_debug_print (brouter);            ospf6_brouter_debug_print (brouter);
         }          }
     }      }
Line 1342  ospf6_intra_brouter_calculation (struct ospf6_area *oa Line 1563  ospf6_intra_brouter_calculation (struct ospf6_area *oa
           ! CHECK_FLAG (brouter->path.router_bits, OSPF6_ROUTER_BIT_B))            ! CHECK_FLAG (brouter->path.router_bits, OSPF6_ROUTER_BIT_B))
         continue;          continue;
   
         if (! OSPF6_OPT_ISSET (brouter->path.options, OSPF6_OPT_V6) ||
             ! OSPF6_OPT_ISSET (brouter->path.options, OSPF6_OPT_R))
           continue;
   
       copy = ospf6_route_copy (brouter);        copy = ospf6_route_copy (brouter);
       copy->type = OSPF6_DEST_TYPE_ROUTER;        copy->type = OSPF6_DEST_TYPE_ROUTER;
       copy->path.area_id = oa->area_id;        copy->path.area_id = oa->area_id;
Line 1351  ospf6_intra_brouter_calculation (struct ospf6_area *oa Line 1576  ospf6_intra_brouter_calculation (struct ospf6_area *oa
           IS_OSPF6_DEBUG_ROUTE (MEMORY))            IS_OSPF6_DEBUG_ROUTE (MEMORY))
         {          {
           zlog_info ("%p: transfer: area %s brouter %s",            zlog_info ("%p: transfer: area %s brouter %s",
                     brouter, oa->name, brouter_name);                     (void *)brouter, oa->name, brouter_name);
           ospf6_brouter_debug_print (brouter);            ospf6_brouter_debug_print (brouter);
         }          }
     }      }
Line 1419  struct ospf6_lsa_handler router_handler = Line 1644  struct ospf6_lsa_handler router_handler =
 {  {
   OSPF6_LSTYPE_ROUTER,    OSPF6_LSTYPE_ROUTER,
   "Router",    "Router",
  ospf6_router_lsa_show  "Rtr",
   ospf6_router_lsa_show,
   ospf6_router_lsa_get_nbr_id
 };  };
   
 struct ospf6_lsa_handler network_handler =  struct ospf6_lsa_handler network_handler =
 {  {
   OSPF6_LSTYPE_NETWORK,    OSPF6_LSTYPE_NETWORK,
   "Network",    "Network",
  ospf6_network_lsa_show  "Net",
   ospf6_network_lsa_show,
   ospf6_network_lsa_get_ar_id
 };  };
   
 struct ospf6_lsa_handler link_handler =  struct ospf6_lsa_handler link_handler =
 {  {
   OSPF6_LSTYPE_LINK,    OSPF6_LSTYPE_LINK,
   "Link",    "Link",
  ospf6_link_lsa_show  "Lnk",
   ospf6_link_lsa_show,
   ospf6_link_lsa_get_prefix_str
 };  };
   
 struct ospf6_lsa_handler intra_prefix_handler =  struct ospf6_lsa_handler intra_prefix_handler =
 {  {
   OSPF6_LSTYPE_INTRA_PREFIX,    OSPF6_LSTYPE_INTRA_PREFIX,
   "Intra-Prefix",    "Intra-Prefix",
  ospf6_intra_prefix_lsa_show  "INP",
   ospf6_intra_prefix_lsa_show,
   ospf6_intra_prefix_lsa_get_prefix_str
 };  };
   
 void  void

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>