New upstream version 1.2.3
[quagga-debian.git] / bgpd / bgp_packet.c
index b497e4546ea929bac57ea0c001341286eafd6839..5a8b18a33c5472cf4c9f2259a40c11bb6428ac6f 100644 (file)
@@ -1314,7 +1314,6 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
   int mp_capability;
   u_int8_t notify_data_remote_as[2];
   u_int8_t notify_data_remote_id[4];
   int mp_capability;
   u_int8_t notify_data_remote_as[2];
   u_int8_t notify_data_remote_id[4];
-  u_int16_t *holdtime_ptr;
 
   realpeer = NULL;
   
 
   realpeer = NULL;
   
@@ -1322,7 +1321,6 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
   version = stream_getc (peer->ibuf);
   memcpy (notify_data_remote_as, stream_pnt (peer->ibuf), 2);
   remote_as  = stream_getw (peer->ibuf);
   version = stream_getc (peer->ibuf);
   memcpy (notify_data_remote_as, stream_pnt (peer->ibuf), 2);
   remote_as  = stream_getw (peer->ibuf);
-  holdtime_ptr = (u_int16_t *)stream_pnt (peer->ibuf);
   holdtime = stream_getw (peer->ibuf);
   memcpy (notify_data_remote_id, stream_pnt (peer->ibuf), 4);
   remote_id.s_addr = stream_get_ipv4 (peer->ibuf);
   holdtime = stream_getw (peer->ibuf);
   memcpy (notify_data_remote_id, stream_pnt (peer->ibuf), 4);
   remote_id.s_addr = stream_get_ipv4 (peer->ibuf);
@@ -1628,10 +1626,11 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
 
   if (holdtime < 3 && holdtime != 0)
     {
 
   if (holdtime < 3 && holdtime != 0)
     {
+      uint16_t netholdtime = htons (holdtime);
       bgp_notify_send_with_data (peer,
                                 BGP_NOTIFY_OPEN_ERR,
                                 BGP_NOTIFY_OPEN_UNACEP_HOLDTIME,
       bgp_notify_send_with_data (peer,
                                 BGP_NOTIFY_OPEN_ERR,
                                 BGP_NOTIFY_OPEN_UNACEP_HOLDTIME,
-                                 (u_int8_t *)holdtime_ptr, 2);
+                                 (u_int8_t *) &netholdtime, 2);
       return -1;
     }
     
       return -1;
     }
     
@@ -2328,7 +2327,8 @@ bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length)
 
   end = pnt + length;
 
 
   end = pnt + length;
 
-  while (pnt < end)
+  /* XXX: Streamify this */
+  for (; pnt < end; pnt += hdr->length + 3)
     {      
       /* We need at least action, capability code and capability length. */
       if (pnt + 3 > end)
     {      
       /* We need at least action, capability code and capability length. */
       if (pnt + 3 > end)
@@ -2416,7 +2416,6 @@ bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length)
           zlog_warn ("%s unrecognized capability code: %d - ignored",
                      peer->host, hdr->code);
         }
           zlog_warn ("%s unrecognized capability code: %d - ignored",
                      peer->host, hdr->code);
         }
-      pnt += hdr->length + 3;
     }
   return 0;
 }
     }
   return 0;
 }
@@ -2476,7 +2475,7 @@ bgp_read_packet (struct peer *peer)
   /* Read packet from fd. */
   nbytes = stream_read_try (peer->ibuf, peer->fd, readsize);
 
   /* Read packet from fd. */
   nbytes = stream_read_try (peer->ibuf, peer->fd, readsize);
 
-  /* If read byte is smaller than zero then error occured. */
+  /* If read byte is smaller than zero then error occurred. */
   if (nbytes < 0) 
     {
       /* Transient error should retry */
   if (nbytes < 0) 
     {
       /* Transient error should retry */