]> git.proxmox.com Git - mirror_frr.git/commitdiff
Second part of fixes from Laurent Rabret.
authorhasso <hasso>
Wed, 15 Sep 2004 16:21:59 +0000 (16:21 +0000)
committerhasso <hasso>
Wed, 15 Sep 2004 16:21:59 +0000 (16:21 +0000)
isisd/ChangeLog
isisd/isis_pdu.c
isisd/isis_tlv.c
isisd/isisd.c
isisd/iso_checksum.c

index 3dc341f09763dbbf28569913d5140fbd9618b3b8..abaa7e827e288353efe8bbf091850c5800f64d5d 100644 (file)
@@ -1,3 +1,15 @@
+2004-09-15 Laurent Rabret <laurent.rabret at francetelecom.com>
+
+       * isis_pdu.c: Fix error in same subnet comparison. The previous
+         algorithm only worked when netmask % 8 == 0.
+       * isisd.c: Show domain and area passwords in configuration.
+       * iso_checksum.c: Fixed error in the checksum calculation. The previous
+         algorithm could produce a bad checksum if the 2 complement's vs 1
+         complement's adaptation was required.
+       * isis_pdu.c: Authentication in LSPs does not mean authentication in
+         SNPs.
+       * isis_tlv.c: Fix errors in password checking.
+
 2004-09-14 Hasso Tepper <hasso at quagga.net>
 
        * isis_circuit.c: Mostly cosmetical changes in isis_circuit_add_addr()
index 1ecdab48cca3c8adae83d752727a03842e7cbb2b..cd685286ce4fe3ade8bc5104979cb6158fde862e 100644 (file)
@@ -106,7 +106,7 @@ int
 ip_same_subnet (struct prefix_ipv4 *ip1, struct in_addr *ip2)
 {
   u_char *addr1, *addr2;
-  int shift, offset;
+  int shift, offset, offsetloop;
   int len;
 
   addr1 = (u_char *) & ip1->prefix.s_addr;
@@ -114,23 +114,15 @@ ip_same_subnet (struct prefix_ipv4 *ip1, struct in_addr *ip2)
   len = ip1->prefixlen;
 
   shift = len % PNBBY;
-  offset = len / PNBBY;
+  offsetloop = offset = len / PNBBY;
 
-  while (offset--)
-    {
-      if (addr1[offset] != addr2[offset])
-       {
-         return 0;
-       }
-    }
+  while (offsetloop--)
+    if (addr1[offsetloop] != addr2[offsetloop])
+      return 0;
 
   if (shift)
-    {
-      if (maskbit[shift] & (addr1[offset] ^ addr2[offset]))
-       {
-         return 0;
-       }
-    }
+    if (maskbit[shift] & (addr1[offset] ^ addr2[offset]))
+      return 0;
 
   return 1;                    /* match  */
 }
@@ -1414,6 +1406,13 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
       return retval;
     }
 
+  /* FIXME: Authentication in LSPs does not mean authentication in SNPs...
+   * In fact by default IOS only deals with LSPs authentication!!
+   * To force authentication in SNPs, one must specify the 'authenticate
+   * snp' command after 'area-password WORD' or 'domain-password WORD'.
+   * This command is not supported for the moment.
+   */
+#if 0
   (level == 1) ? (passwd = &circuit->area->area_passwd) :
     (passwd = &circuit->area->domain_passwd);
   if (passwd->type)
@@ -1427,6 +1426,7 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
          return ISIS_OK;
        }
     }
+#endif /* 0 */
 
   /* debug isis snp-packets */
   if (isis->debugs & DEBUG_SNP_PACKETS)
index 273d19c2235c387ccd8d5a23fe946e271946bf88..70b3c1770e1d41d1ad5215904ee645a9e7e8da95 100644 (file)
@@ -463,6 +463,7 @@ parse_tlvs (char *areatag, u_char * stream, int size, u_int32_t * expected,
          if (*expected & TLVFLAG_AUTH_INFO)
            {
              tlvs->auth_info.type = *pnt;
+             tlvs->auth_info.len = length-1;
              pnt++;
              memcpy (tlvs->auth_info.passwd, pnt, length - 1);
              pnt += length - 1;
@@ -885,7 +886,7 @@ tlv_add_authinfo (char auth_type, char auth_len, char *auth_value,
 {
   u_char value[255];
   u_char *pos = value;
-  pos++;
+  *pos++ = ISIS_PASSWD_TYPE_CLEARTXT;
   memcpy (pos, auth_value, auth_len);
 
   return add_tlv (AUTH_INFO, auth_len + 1, value, stream);
index 3c499dc3ccf89926c6b144fe451bac4503dc5824..3fbed0beac3be00faa142d22af96da61f7f48cf0 100644 (file)
@@ -1901,6 +1901,19 @@ isis_config_write (struct vty *vty)
                write++;
              }
          }
+       /* Authentication passwords. */
+       if (area->area_passwd.len > 0)
+         {
+           vty_out(vty, " area-password %s%s",
+                   area->area_passwd.passwd, VTY_NEWLINE);
+           write++; 
+         }  
+       if (area->domain_passwd.len > 0)
+         {
+           vty_out(vty, " domain-password %s%s",
+                   area->domain_passwd.passwd, VTY_NEWLINE);
+           write++;
+         }
 #ifdef TOPOLOGY_GENERATE
        /* seems we save the whole command line here */
        if (area->top_params)
index e65f6ef67122b0619d5718bcf45b52ad1c52ce58..eabe281fb30ae61f69f8e91205cfdd3e69730c5c 100644 (file)
@@ -42,7 +42,6 @@
  * Verifies that the checksum is correct.
  * Return 0 on correct and 1 on invalid checksum.
  * Based on Annex C.4 of ISO/IEC 8473
- * FIXME: Check for overflow 
  */
 
 int
@@ -52,7 +51,7 @@ iso_csum_verify (u_char * buffer, int len, uint16_t * csum)
   u_int32_t c0;
   u_int32_t c1;
   u_int16_t checksum;
-  int i;
+  int i, partial_len;
 
   p = buffer;
   checksum = 0;
@@ -77,14 +76,21 @@ iso_csum_verify (u_char * buffer, int len, uint16_t * csum)
   c0 = 0;
   c1 = 0;
 
-  for (i = 0; i < len; i++)
+  while (len)
     {
-      c0 = c0 + *(p++);
-      c1 += c0;
-    }
+      partial_len = MIN(len, 5803);
+
+      for (i = 0; i < partial_len; i++)
+       {
+         c0 = c0 + *(p++);
+         c1 += c0;
+       }
 
-  c0 = c0 % 255;
-  c1 = c1 % 255;
+      c0 = c0 % 255;
+      c1 = c1 % 255;
+
+      len -= partial_len;
+    }
 
   if (c0 == 0 && c1 == 0)
     return 0;
@@ -96,9 +102,6 @@ iso_csum_verify (u_char * buffer, int len, uint16_t * csum)
  * Creates the checksum. *csum points to the position of the checksum in the 
  * PDU. 
  * Based on Annex C.4 of ISO/IEC 8473
- * we will not overflow until about length of 6000,
- * which is the answer to (255+255n)*n/2 > 2^32
- * so if we have a length of over 5000 we will return zero (for now)
  */
 #define FIXED_CODE
 u_int16_t
@@ -113,7 +116,7 @@ iso_csum_create (u_char * buffer, int len, u_int16_t n)
   u_int32_t c1;
   u_int16_t checksum;
   u_int16_t *csum;
-  int i;
+  int i, init_len, partial_len;
 
   checksum = 0;
 
@@ -123,32 +126,34 @@ iso_csum_create (u_char * buffer, int len, u_int16_t n)
   csum = (u_int16_t *) (buffer + n);
   *(csum) = checksum;
 
-  /* for the limitation of our implementation */
-  if (len > 5000)
-    {
-      return 0;
-    }
-
   p = buffer;
   c0 = 0;
   c1 = 0;
+  init_len = len;
 
-  for (i = 0; i < len; i++)
+  while (len != 0)
     {
-      c0 = c0 + *(p++);
-      c1 += c0;
-    }
+      partial_len = MIN(len, 5803);
+
+      for (i = 0; i < partial_len; i++)
+       {
+         c0 = c0 + *(p++);
+         c1 += c0;
+       }
 
-  c0 = c0 % 255;
-  c1 = c1 % 255;
+      c0 = c0 % 255;
+      c1 = c1 % 255;
+
+      len -= partial_len;
+    }
 
-  mul = (len - n) * (c0);
+  mul = (init_len - n)*(c0);
 
 #ifdef FIXED_CODE
   x = mul - c0 - c1;
   y = c1 - mul - 1;
 
-  if (y >= 0)
+  if (y > 0)
     y++;
   if (x < 0)
     x--;
@@ -159,11 +164,9 @@ iso_csum_create (u_char * buffer, int len, u_int16_t n)
   if (x == 0)
     x = 255;
   if (y == 0)
-    y = 255;
-
-  x &= 0x00FF;
+    y = 1;
 
-  checksum = ((y << 8) | x);
+  checksum = (y << 8) | (x & 0xFF);
 
 #else
   x = mul - c0 - c1;