Diff for /embedaddon/quagga/ospf6d/ospf6_lsa.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2013/07/21 23:54:39 version 1.1.1.3, 2016/11/02 10:09:11
Line 75  struct ospf6_lsa_handler unknown_handler = Line 75  struct ospf6_lsa_handler unknown_handler =
 {  {
   OSPF6_LSTYPE_UNKNOWN,    OSPF6_LSTYPE_UNKNOWN,
   "Unknown",    "Unknown",
     "Unk",
   ospf6_unknown_lsa_show,    ospf6_unknown_lsa_show,
     NULL,
   OSPF6_LSA_DEBUG,    OSPF6_LSA_DEBUG,
 };  };
   
Line 118  ospf6_lstype_name (u_int16_t type) Line 120  ospf6_lstype_name (u_int16_t type)
   return buf;    return buf;
 }  }
   
   const char *
   ospf6_lstype_short_name (u_int16_t type)
   {
     static char buf[8];
     struct ospf6_lsa_handler *handler;
   
     handler = ospf6_get_lsa_handler (type);
     if (handler && handler != &unknown_handler)
       return handler->short_name;
   
     snprintf (buf, sizeof (buf), "0x%04hx", ntohs (type));
     return buf;
   }
   
 u_char  u_char
 ospf6_lstype_debug (u_int16_t type)  ospf6_lstype_debug (u_int16_t type)
 {  {
Line 139  ospf6_lsa_is_differ (struct ospf6_lsa *lsa1, Line 155  ospf6_lsa_is_differ (struct ospf6_lsa *lsa1,
   
   ospf6_lsa_age_current (lsa1);    ospf6_lsa_age_current (lsa1);
   ospf6_lsa_age_current (lsa2);    ospf6_lsa_age_current (lsa2);
  if (ntohs (lsa1->header->age) == MAXAGE &&  if (ntohs (lsa1->header->age) == OSPF_LSA_MAXAGE &&
      ntohs (lsa2->header->age) != MAXAGE)      ntohs (lsa2->header->age) != OSPF_LSA_MAXAGE)
     return 1;      return 1;
  if (ntohs (lsa1->header->age) != MAXAGE &&  if (ntohs (lsa1->header->age) != OSPF_LSA_MAXAGE &&
      ntohs (lsa2->header->age) == MAXAGE)      ntohs (lsa2->header->age) == OSPF_LSA_MAXAGE)
     return 1;      return 1;
   
   /* compare body */    /* compare body */
Line 218  ospf6_lsa_age_current (struct ospf6_lsa *lsa) Line 234  ospf6_lsa_age_current (struct ospf6_lsa *lsa)
     zlog_warn ("LSA: quagga_gettime failed, may fail LSA AGEs: %s",      zlog_warn ("LSA: quagga_gettime failed, may fail LSA AGEs: %s",
                safe_strerror (errno));                 safe_strerror (errno));
   
  if (ntohs (lsa->header->age) >= MAXAGE)  if (ntohs (lsa->header->age) >= OSPF_LSA_MAXAGE)
     {      {
       /* ospf6_lsa_premature_aging () sets age to MAXAGE; when using        /* ospf6_lsa_premature_aging () sets age to MAXAGE; when using
          relative time, we cannot compare against lsa birth time, so           relative time, we cannot compare against lsa birth time, so
          we catch this special case here. */           we catch this special case here. */
      lsa->header->age = htons (MAXAGE);      lsa->header->age = htons (OSPF_LSA_MAXAGE);
      return MAXAGE;      return OSPF_LSA_MAXAGE;
     }      }
   /* calculate age */    /* calculate age */
   ulage = now.tv_sec - lsa->birth.tv_sec;    ulage = now.tv_sec - lsa->birth.tv_sec;
   
   /* if over MAXAGE, set to it */    /* if over MAXAGE, set to it */
  age = (ulage > MAXAGE ? MAXAGE : ulage);  age = (ulage > OSPF_LSA_MAXAGE ? OSPF_LSA_MAXAGE : ulage);
   
   lsa->header->age = htons (age);    lsa->header->age = htons (age);
   return age;    return age;
Line 243  ospf6_lsa_age_update_to_send (struct ospf6_lsa *lsa, u Line 259  ospf6_lsa_age_update_to_send (struct ospf6_lsa *lsa, u
   unsigned short age;    unsigned short age;
   
   age = ospf6_lsa_age_current (lsa) + transdelay;    age = ospf6_lsa_age_current (lsa) + transdelay;
  if (age > MAXAGE)  if (age > OSPF_LSA_MAXAGE)
    age = MAXAGE;    age = OSPF_LSA_MAXAGE;
   lsa->header->age = htons (age);    lsa->header->age = htons (age);
 }  }
   
Line 258  ospf6_lsa_premature_aging (struct ospf6_lsa *lsa) Line 274  ospf6_lsa_premature_aging (struct ospf6_lsa *lsa)
   THREAD_OFF (lsa->expire);    THREAD_OFF (lsa->expire);
   THREAD_OFF (lsa->refresh);    THREAD_OFF (lsa->refresh);
   
  lsa->header->age = htons (MAXAGE);  /*
    * We clear the LSA from the neighbor retx lists now because it
    * will not get deleted later. Essentially, changing the age to
    * MaxAge will prevent this LSA from being matched with its
    * existing entries in the retx list thereby causing those entries
    * to be silently replaced with its MaxAged version, but with ever
    * increasing retx count causing this LSA to remain forever and
    * for the MaxAge remover thread to be called forever too.
    *
    * The reason the previous entry silently disappears is that when
    * entry is added to a neighbor's retx list, it replaces the existing
    * entry. But since the ospf6_lsdb_add() routine is generic and not aware
    * of the special semantics of retx count, the retx count is not
    * decremented when its replaced. Attempting to add the incr and decr
    * retx count routines as the hook_add and hook_remove for the retx lists
    * have a problem because the hook_remove routine is called for MaxAge
    * entries (as will be the case in a traditional LSDB, unlike in this case
    * where an LSDB is used as an efficient tree structure to store all kinds
    * of data) that are added instead of calling the hook_add routine.
    */
 
   ospf6_flood_clear (lsa);
 
   lsa->header->age = htons (OSPF_LSA_MAXAGE);
   thread_execute (master, ospf6_lsa_expire, lsa, 0);    thread_execute (master, ospf6_lsa_expire, lsa, 0);
 }  }
   
Line 267  ospf6_lsa_premature_aging (struct ospf6_lsa *lsa) Line 306  ospf6_lsa_premature_aging (struct ospf6_lsa *lsa)
 int  int
 ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_lsa *b)  ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_lsa *b)
 {  {
  int seqnuma, seqnumb;  int32_t seqnuma, seqnumb;
   u_int16_t cksuma, cksumb;    u_int16_t cksuma, cksumb;
   u_int16_t agea, ageb;    u_int16_t agea, ageb;
   
Line 275  ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_l Line 314  ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_l
   assert (b && b->header);    assert (b && b->header);
   assert (OSPF6_LSA_IS_SAME (a, b));    assert (OSPF6_LSA_IS_SAME (a, b));
   
  seqnuma = (int) ntohl (a->header->seqnum);  seqnuma = (int32_t) ntohl (a->header->seqnum);
  seqnumb = (int) ntohl (b->header->seqnum);  seqnumb = (int32_t) ntohl (b->header->seqnum);
   
   /* compare by sequence number */    /* compare by sequence number */
   if (seqnuma > seqnumb)    if (seqnuma > seqnumb)
Line 297  ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_l Line 336  ospf6_lsa_compare (struct ospf6_lsa *a, struct ospf6_l
   ageb = ospf6_lsa_age_current (b);    ageb = ospf6_lsa_age_current (b);
   
   /* MaxAge check */    /* MaxAge check */
  if (agea == MAXAGE && ageb != MAXAGE)  if (agea == OSPF_LSA_MAXAGE && ageb != OSPF_LSA_MAXAGE)
     return -1;      return -1;
  else if (agea != MAXAGE && ageb == MAXAGE)  else if (agea != OSPF_LSA_MAXAGE && ageb == OSPF_LSA_MAXAGE)
     return 1;      return 1;
   
   /* Age check */    /* Age check */
  if (agea > ageb && agea - ageb >= MAX_AGE_DIFF)  if (agea > ageb && agea - ageb >= OSPF_LSA_MAXAGE_DIFF)
     return 1;      return 1;
  else if (agea < ageb && ageb - agea >= MAX_AGE_DIFF)  else if (agea < ageb && ageb - agea >= OSPF_LSA_MAXAGE_DIFF)
     return -1;      return -1;
   
   /* neither recent */    /* neither recent */
Line 348  ospf6_lsa_header_print (struct ospf6_lsa *lsa) Line 387  ospf6_lsa_header_print (struct ospf6_lsa *lsa)
 void  void
 ospf6_lsa_show_summary_header (struct vty *vty)  ospf6_lsa_show_summary_header (struct vty *vty)
 {  {
  vty_out (vty, "%-12s %-15s %-15s %4s %8s %4s %4s %-8s%s",  vty_out (vty, "%-4s %-15s%-15s%4s %8s %30s%s",
            "Type", "LSId", "AdvRouter", "Age", "SeqNum",             "Type", "LSId", "AdvRouter", "Age", "SeqNum",
           "Cksm", "Len", "Duration", VNL);           "Payload", VNL);
 }  }
   
 void  void
 ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa)  ospf6_lsa_show_summary (struct vty *vty, struct ospf6_lsa *lsa)
 {  {
   char adv_router[16], id[16];    char adv_router[16], id[16];
  struct timeval now, res;  int type;
  char duration[16];  struct ospf6_lsa_handler *handler;
   char buf[64], tmpbuf[80];
   int cnt = 0;
   
   assert (lsa);    assert (lsa);
   assert (lsa->header);    assert (lsa->header);
Line 367  ospf6_lsa_show_summary (struct vty *vty, struct ospf6_ Line 408  ospf6_lsa_show_summary (struct vty *vty, struct ospf6_
   inet_ntop (AF_INET, &lsa->header->adv_router, adv_router,    inet_ntop (AF_INET, &lsa->header->adv_router, adv_router,
              sizeof (adv_router));               sizeof (adv_router));
   
  quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);  type = ntohs(lsa->header->type);
  timersub (&now, &lsa->installed, &res);  handler = ospf6_get_lsa_handler (lsa->header->type);
  timerstring (&res, duration, sizeof (duration));  if ((type == OSPF6_LSTYPE_INTER_PREFIX) ||
       (type == OSPF6_LSTYPE_INTER_ROUTER) ||
       (type == OSPF6_LSTYPE_AS_EXTERNAL))
     {
       vty_out (vty, "%-4s %-15s%-15s%4hu %8lx %30s%s",
                ospf6_lstype_short_name (lsa->header->type),
                id, adv_router, ospf6_lsa_age_current (lsa),
                (u_long) ntohl (lsa->header->seqnum),
                handler->get_prefix_str(lsa, buf, sizeof(buf), 0), VNL);
     }
   else if (type != OSPF6_LSTYPE_UNKNOWN)
     {
       sprintf (tmpbuf, "%-4s %-15s%-15s%4hu %8lx",
                ospf6_lstype_short_name (lsa->header->type),
                id, adv_router, ospf6_lsa_age_current (lsa),
                (u_long) ntohl (lsa->header->seqnum));
   
  vty_out (vty, "%-12s %-15s %-15s %4hu %8lx %04hx %4hu %8s%s",      while (handler->get_prefix_str(lsa, buf, sizeof(buf), cnt) != NULL)
           ospf6_lstype_name (lsa->header->type),        {
           id, adv_router, ospf6_lsa_age_current (lsa),          vty_out (vty, "%s %30s%s", tmpbuf, buf, VNL);
           (u_long) ntohl (lsa->header->seqnum),          cnt++;
           ntohs (lsa->header->checksum), ntohs (lsa->header->length),        }
           duration, VNL);    }
   else
     {
       vty_out (vty, "%-4s %-15s%-15s%4hu %8lx%s",
                ospf6_lstype_short_name (lsa->header->type),
                id, adv_router, ospf6_lsa_age_current (lsa),
                (u_long) ntohl (lsa->header->seqnum), VNL);
     }
 }  }
   
 void  void
Line 427  ospf6_lsa_show_internal (struct vty *vty, struct ospf6 Line 490  ospf6_lsa_show_internal (struct vty *vty, struct ospf6
   vty_out (vty, "CheckSum: %#06hx Length: %hu%s",    vty_out (vty, "CheckSum: %#06hx Length: %hu%s",
            ntohs (lsa->header->checksum),             ntohs (lsa->header->checksum),
            ntohs (lsa->header->length), VNL);             ntohs (lsa->header->length), VNL);
  vty_out (vty, "    Prev: %p This: %p Next: %p%s",  vty_out (vty, "Flag: %x %s", lsa->flag, VNL);
           lsa->prev, lsa, lsa->next, VNL);  vty_out (vty, "Lock: %d %s", lsa->lock, VNL);
   vty_out (vty, "ReTx Count: %d%s", lsa->retrans_count, VNL);
   vty_out (vty, "Threads: Expire: 0x%p, Refresh: 0x%p %s",
            (void *)lsa->expire, (void *)lsa->refresh, VNL);
   vty_out (vty, "%s", VNL);    vty_out (vty, "%s", VNL);
   return;    return;
 }  }
Line 438  ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa Line 504  ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa
 {  {
   char adv_router[64], id[64];    char adv_router[64], id[64];
   struct ospf6_lsa_handler *handler;    struct ospf6_lsa_handler *handler;
     struct timeval now, res;
     char duration[16];
   
   assert (lsa && lsa->header);    assert (lsa && lsa->header);
   
Line 445  ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa Line 513  ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa
   inet_ntop (AF_INET, &lsa->header->adv_router,    inet_ntop (AF_INET, &lsa->header->adv_router,
              adv_router, sizeof (adv_router));               adv_router, sizeof (adv_router));
   
     quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
     timersub (&now, &lsa->installed, &res);
     timerstring (&res, duration, sizeof (duration));
   
   vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),    vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),
            ospf6_lstype_name (lsa->header->type), VNL);             ospf6_lstype_name (lsa->header->type), VNL);
   vty_out (vty, "Link State ID: %s%s", id, VNL);    vty_out (vty, "Link State ID: %s%s", id, VNL);
Line 454  ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa Line 526  ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa
   vty_out (vty, "CheckSum: %#06hx Length: %hu%s",    vty_out (vty, "CheckSum: %#06hx Length: %hu%s",
            ntohs (lsa->header->checksum),             ntohs (lsa->header->checksum),
            ntohs (lsa->header->length), VNL);             ntohs (lsa->header->length), VNL);
     vty_out (vty, "Duration: %s%s", duration, VNL);
   
   handler = ospf6_get_lsa_handler (lsa->header->type);    handler = ospf6_get_lsa_handler (lsa->header->type);
   if (handler->show == NULL)    if (handler->show == NULL)
Line 558  ospf6_lsa_copy (struct ospf6_lsa *lsa) Line 631  ospf6_lsa_copy (struct ospf6_lsa *lsa)
   copy->received = lsa->received;    copy->received = lsa->received;
   copy->installed = lsa->installed;    copy->installed = lsa->installed;
   copy->lsdb = lsa->lsdb;    copy->lsdb = lsa->lsdb;
     copy->rn = NULL;
   
   return copy;    return copy;
 }  }
Line 584  ospf6_lsa_unlock (struct ospf6_lsa *lsa) Line 658  ospf6_lsa_unlock (struct ospf6_lsa *lsa)
   ospf6_lsa_delete (lsa);    ospf6_lsa_delete (lsa);
 }  }
   
 /* ospf6 lsa expiry */  /* ospf6 lsa expiry */
 int  int
 ospf6_lsa_expire (struct thread *thread)  ospf6_lsa_expire (struct thread *thread)
Line 608  ospf6_lsa_expire (struct thread *thread) Line 682  ospf6_lsa_expire (struct thread *thread)
   if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY))    if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY))
     return 0;    /* dbexchange will do something ... */      return 0;    /* dbexchange will do something ... */
   
   /* reflood lsa */  
   ospf6_flood (NULL, lsa);  
   
   /* reinstall lsa */    /* reinstall lsa */
   ospf6_install_lsa (lsa);    ospf6_install_lsa (lsa);
   
     /* reflood lsa */
     ospf6_flood (NULL, lsa);
   
   /* schedule maxage remover */    /* schedule maxage remover */
   ospf6_maxage_remove (ospf6);    ospf6_maxage_remove (ospf6);
   
Line 653  ospf6_lsa_refresh (struct thread *thread) Line 727  ospf6_lsa_refresh (struct thread *thread)
   new = ospf6_lsa_create (self->header);    new = ospf6_lsa_create (self->header);
   new->lsdb = old->lsdb;    new->lsdb = old->lsdb;
   new->refresh = thread_add_timer (master, ospf6_lsa_refresh, new,    new->refresh = thread_add_timer (master, ospf6_lsa_refresh, new,
                                   LS_REFRESH_TIME);                                   OSPF_LS_REFRESH_TIME);
   
   /* store it in the LSDB for self-originated LSAs */    /* store it in the LSDB for self-originated LSAs */
   ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self);    ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self);
Line 664  ospf6_lsa_refresh (struct thread *thread) Line 738  ospf6_lsa_refresh (struct thread *thread)
       ospf6_lsa_header_print (new);        ospf6_lsa_header_print (new);
     }      }
   
   ospf6_flood_clear (old);  
   ospf6_flood (NULL, new);  
   ospf6_install_lsa (new);    ospf6_install_lsa (new);
     ospf6_flood (NULL, new);
   
   return 0;    return 0;
 }  }
   
   
   
   
 /* Fletcher Checksum -- Refer to RFC1008. */  /* Fletcher Checksum -- Refer to RFC1008. */
   
 /* All the offsets are zero-based. The offsets in the RFC1008 are  /* All the offsets are zero-based. The offsets in the RFC1008 are
Line 717  ospf6_lsa_terminate (void) Line 790  ospf6_lsa_terminate (void)
 {  {
   vector_free (ospf6_lsa_handler_vector);    vector_free (ospf6_lsa_handler_vector);
 }  }
 static char *  static char *
 ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)  ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)
 {  {
Line 725  ospf6_lsa_handler_name (struct ospf6_lsa_handler *h) Line 798  ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)
   unsigned int i;     unsigned int i; 
   unsigned int size = strlen (h->name);    unsigned int size = strlen (h->name);
   
  if (!strcmp(h->name, "Unknown") &&  if (!strcmp(h->name, "unknown") &&
       h->type != OSPF6_LSTYPE_UNKNOWN)        h->type != OSPF6_LSTYPE_UNKNOWN)
     {      {
       snprintf (buf, sizeof (buf), "%#04hx", h->type);        snprintf (buf, sizeof (buf), "%#04hx", h->type);
Line 734  ospf6_lsa_handler_name (struct ospf6_lsa_handler *h) Line 807  ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)
   
   for (i = 0; i < MIN (size, sizeof (buf)); i++)    for (i = 0; i < MIN (size, sizeof (buf)); i++)
     {      {
      if (! islower (h->name[i]))      if (! islower ((unsigned char)h->name[i]))
        buf[i] = tolower (h->name[i]);        buf[i] = tolower ((unsigned char)h->name[i]);
       else        else
         buf[i] = h->name[i];          buf[i] = h->name[i];
     }      }
Line 745  ospf6_lsa_handler_name (struct ospf6_lsa_handler *h) Line 818  ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)
   
 DEFUN (debug_ospf6_lsa_type,  DEFUN (debug_ospf6_lsa_type,
        debug_ospf6_lsa_hex_cmd,         debug_ospf6_lsa_hex_cmd,
       "debug ospf6 lsa XXXX/0xXXXX",       "debug ospf6 lsa (router|network|inter-prefix|inter-router|as-ext|grp-mbr|type7|link|intra-prefix|unknown)",
        DEBUG_STR         DEBUG_STR
        OSPF6_STR         OSPF6_STR
        "Debug Link State Advertisements (LSAs)\n"         "Debug Link State Advertisements (LSAs)\n"
Line 754  DEFUN (debug_ospf6_lsa_type, Line 827  DEFUN (debug_ospf6_lsa_type,
 {  {
   unsigned int i;    unsigned int i;
   struct ospf6_lsa_handler *handler = NULL;    struct ospf6_lsa_handler *handler = NULL;
   unsigned long val;  
   char *endptr = NULL;  
   u_int16_t type = 0;  
   
   assert (argc);    assert (argc);
   
   if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||  
       (strlen (argv[0]) == 4))  
     {  
       val = strtoul (argv[0], &endptr, 16);  
       if (*endptr == '\0')  
         type = val;  
     }  
   
   for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++)    for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++)
     {      {
       handler = vector_slot (ospf6_lsa_handler_vector, i);        handler = vector_slot (ospf6_lsa_handler_vector, i);
       if (handler == NULL)        if (handler == NULL)
         continue;          continue;
      if (type && handler->type == type)      if (strncmp (argv[0], ospf6_lsa_handler_name(handler), strlen(argv[0])) == 0)
         break;          break;
       if (! strcasecmp (argv[0], handler->name))        if (! strcasecmp (argv[0], handler->name))
         break;          break;
       handler = NULL;        handler = NULL;
     }      }
   
   if (type && handler == NULL)  
     {  
       handler = (struct ospf6_lsa_handler *)  
         malloc (sizeof (struct ospf6_lsa_handler));  
       memset (handler, 0, sizeof (struct ospf6_lsa_handler));  
       handler->type = type;  
       handler->name = "Unknown";  
       handler->show = ospf6_unknown_lsa_show;  
       vector_set_index (ospf6_lsa_handler_vector,  
                         handler->type & OSPF6_LSTYPE_FCODE_MASK, handler);  
     }  
   
   if (handler == NULL)    if (handler == NULL)
     handler = &unknown_handler;      handler = &unknown_handler;
   
Line 799  DEFUN (debug_ospf6_lsa_type, Line 849  DEFUN (debug_ospf6_lsa_type,
     {      {
       if (! strcmp (argv[1], "originate"))        if (! strcmp (argv[1], "originate"))
         SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);          SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
      if (! strcmp (argv[1], "examin"))      if (! strcmp (argv[1], "examine"))
         SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);          SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
       if (! strcmp (argv[1], "flooding"))        if (! strcmp (argv[1], "flooding"))
         SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);          SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
Line 810  DEFUN (debug_ospf6_lsa_type, Line 860  DEFUN (debug_ospf6_lsa_type,
   return CMD_SUCCESS;    return CMD_SUCCESS;
 }  }
   
   ALIAS (debug_ospf6_lsa_type,
          debug_ospf6_lsa_hex_detail_cmd,
          "debug ospf6 lsa (router|network|inter-prefix|inter-router|as-ext|grp-mbr|type7|link|intra-prefix|unknown) (originate|examine|flooding)",
          DEBUG_STR
          OSPF6_STR
          "Debug Link State Advertisements (LSAs)\n"
          "Specify LS type as Hexadecimal\n"
         )
   
 DEFUN (no_debug_ospf6_lsa_type,  DEFUN (no_debug_ospf6_lsa_type,
        no_debug_ospf6_lsa_hex_cmd,         no_debug_ospf6_lsa_hex_cmd,
       "no debug ospf6 lsa XXXX/0xXXXX",       "no debug ospf6 lsa (router|network|inter-prefix|inter-router|as-ext|grp-mbr|type7|link|intra-prefix|unknown)",
        NO_STR         NO_STR
        DEBUG_STR         DEBUG_STR
        OSPF6_STR         OSPF6_STR
Line 822  DEFUN (no_debug_ospf6_lsa_type, Line 881  DEFUN (no_debug_ospf6_lsa_type,
 {  {
   u_int i;    u_int i;
   struct ospf6_lsa_handler *handler = NULL;    struct ospf6_lsa_handler *handler = NULL;
   unsigned long val;  
   char *endptr = NULL;  
   u_int16_t type = 0;  
   
   assert (argc);    assert (argc);
   
   if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||  
       (strlen (argv[0]) == 4))  
     {  
       val = strtoul (argv[0], &endptr, 16);  
       if (*endptr == '\0')  
         type = val;  
     }  
   
   for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++)    for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++)
     {      {
       handler = vector_slot (ospf6_lsa_handler_vector, i);        handler = vector_slot (ospf6_lsa_handler_vector, i);
       if (handler == NULL)        if (handler == NULL)
         continue;          continue;
      if (type && handler->type == type)      if (strncmp (argv[0], ospf6_lsa_handler_name(handler), strlen(argv[0])) == 0)
         break;          break;
       if (! strcasecmp (argv[0], handler->name))        if (! strcasecmp (argv[0], handler->name))
         break;          break;
Line 854  DEFUN (no_debug_ospf6_lsa_type, Line 902  DEFUN (no_debug_ospf6_lsa_type,
     {      {
       if (! strcmp (argv[1], "originate"))        if (! strcmp (argv[1], "originate"))
         UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);          UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
      if (! strcmp (argv[1], "examin"))      if (! strcmp (argv[1], "examine"))
         UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);          UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
       if (! strcmp (argv[1], "flooding"))        if (! strcmp (argv[1], "flooding"))
         UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);          UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
Line 862  DEFUN (no_debug_ospf6_lsa_type, Line 910  DEFUN (no_debug_ospf6_lsa_type,
   else    else
     UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG);      UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
   
   if (handler->debug == 0 &&  
       !strcmp(handler->name, "Unknown") && type != OSPF6_LSTYPE_UNKNOWN)  
     {  
       free (handler);  
       vector_slot (ospf6_lsa_handler_vector, i) = NULL;  
     }  
   
   return CMD_SUCCESS;    return CMD_SUCCESS;
 }  }
   
struct cmd_element debug_ospf6_lsa_type_cmd;ALIAS (no_debug_ospf6_lsa_type,
struct cmd_element debug_ospf6_lsa_type_detail_cmd;       no_debug_ospf6_lsa_hex_detail_cmd,
struct cmd_element no_debug_ospf6_lsa_type_cmd;       "no debug ospf6 lsa (router|network|inter-prefix|inter-router|as-ext|grp-mbr|type7|link|intra-prefix) (originate|examine|flooding)",
struct cmd_element no_debug_ospf6_lsa_type_detail_cmd;       NO_STR
        DEBUG_STR
        OSPF6_STR
        "Debug Link State Advertisements (LSAs)\n"
        "Specify LS type as Hexadecimal\n"
       )
   
 void  void
 install_element_ospf6_debug_lsa (void)  install_element_ospf6_debug_lsa (void)
 {  {
   u_int i;  
   struct ospf6_lsa_handler *handler;  
 #define STRSIZE  256  
 #define DOCSIZE  1024  
   static char strbuf[STRSIZE];  
   static char docbuf[DOCSIZE];  
   static char detail_strbuf[STRSIZE];  
   static char detail_docbuf[DOCSIZE];  
   char *str, *no_str;  
   char *doc, *no_doc;  
   
   strbuf[0] = '\0';  
   no_str = &strbuf[strlen (strbuf)];  
   strncat (strbuf, "no ", STRSIZE - strlen (strbuf));  
   str = &strbuf[strlen (strbuf)];  
   
   strncat (strbuf, "debug ospf6 lsa (", STRSIZE - strlen (strbuf));  
   for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++)  
     {  
       handler = vector_slot (ospf6_lsa_handler_vector, i);  
       if (handler == NULL)  
         continue;  
       strncat (strbuf, ospf6_lsa_handler_name (handler),  
                STRSIZE - strlen (strbuf));  
       strncat (strbuf, "|", STRSIZE - strlen (strbuf));  
     }  
   strbuf[strlen (strbuf) - 1] = ')';  
   strbuf[strlen (strbuf)] = '\0';  
   
   docbuf[0] = '\0';  
   no_doc = &docbuf[strlen (docbuf)];  
   strncat (docbuf, NO_STR, DOCSIZE - strlen (docbuf));  
   doc = &docbuf[strlen (docbuf)];  
   
   strncat (docbuf, DEBUG_STR, DOCSIZE - strlen (docbuf));  
   strncat (docbuf, OSPF6_STR, DOCSIZE - strlen (docbuf));  
   strncat (docbuf, "Debug Link State Advertisements (LSAs)\n",  
            DOCSIZE - strlen (docbuf));  
   
   for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++)  
     {  
       handler = vector_slot (ospf6_lsa_handler_vector, i);  
       if (handler == NULL)  
         continue;  
       strncat (docbuf, "Debug ", DOCSIZE - strlen (docbuf));  
       strncat (docbuf, handler->name, DOCSIZE - strlen (docbuf));  
       strncat (docbuf, "-LSA\n", DOCSIZE - strlen (docbuf));  
     }  
   docbuf[strlen (docbuf)] = '\0';  
   
   debug_ospf6_lsa_type_cmd.string = str;  
   debug_ospf6_lsa_type_cmd.func = debug_ospf6_lsa_type;  
   debug_ospf6_lsa_type_cmd.doc = doc;  
   
   no_debug_ospf6_lsa_type_cmd.string = no_str;  
   no_debug_ospf6_lsa_type_cmd.func = no_debug_ospf6_lsa_type;  
   no_debug_ospf6_lsa_type_cmd.doc = no_doc;  
   
   strncpy (detail_strbuf, strbuf, STRSIZE);  
   strncat (detail_strbuf, " (originate|examin|flooding)",  
            STRSIZE - strlen (detail_strbuf));  
   detail_strbuf[strlen (detail_strbuf)] = '\0';  
   no_str = &detail_strbuf[0];  
   str = &detail_strbuf[strlen ("no ")];  
   
   strncpy (detail_docbuf, docbuf, DOCSIZE);  
   strncat (detail_docbuf, "Debug Originating LSA\n",  
            DOCSIZE - strlen (detail_docbuf));  
   strncat (detail_docbuf, "Debug Examining LSA\n",  
            DOCSIZE - strlen (detail_docbuf));  
   strncat (detail_docbuf, "Debug Flooding LSA\n",  
            DOCSIZE - strlen (detail_docbuf));  
   detail_docbuf[strlen (detail_docbuf)] = '\0';  
   no_doc = &detail_docbuf[0];  
   doc = &detail_docbuf[strlen (NO_STR)];  
   
   debug_ospf6_lsa_type_detail_cmd.string = str;  
   debug_ospf6_lsa_type_detail_cmd.func = debug_ospf6_lsa_type;  
   debug_ospf6_lsa_type_detail_cmd.doc = doc;  
   
   no_debug_ospf6_lsa_type_detail_cmd.string = no_str;  
   no_debug_ospf6_lsa_type_detail_cmd.func = no_debug_ospf6_lsa_type;  
   no_debug_ospf6_lsa_type_detail_cmd.doc = no_doc;  
   
   install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd);    install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd);
  install_element (ENABLE_NODE, &debug_ospf6_lsa_type_cmd);  install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_detail_cmd);
  install_element (ENABLE_NODE, &debug_ospf6_lsa_type_detail_cmd); 
   install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);    install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);
  install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_cmd);  install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_detail_cmd);
  install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_detail_cmd); 
   install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);    install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);
  install_element (CONFIG_NODE, &debug_ospf6_lsa_type_cmd);  install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_detail_cmd);
  install_element (CONFIG_NODE, &debug_ospf6_lsa_type_detail_cmd); 
   install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd);    install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd);
  install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_cmd);  install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_detail_cmd);
  install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_detail_cmd); 
 }  }
   
 int  int
Line 996  config_write_ospf6_debug_lsa (struct vty *vty) Line 954  config_write_ospf6_debug_lsa (struct vty *vty)
         vty_out (vty, "debug ospf6 lsa %s originate%s",          vty_out (vty, "debug ospf6 lsa %s originate%s",
                  ospf6_lsa_handler_name (handler), VNL);                   ospf6_lsa_handler_name (handler), VNL);
       if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN))        if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN))
        vty_out (vty, "debug ospf6 lsa %s examin%s",        vty_out (vty, "debug ospf6 lsa %s examine%s",
                  ospf6_lsa_handler_name (handler), VNL);                   ospf6_lsa_handler_name (handler), VNL);
       if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD))        if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD))
         vty_out (vty, "debug ospf6 lsa %s flooding%s",          vty_out (vty, "debug ospf6 lsa %s flooding%s",

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


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