2005-02-09 Paul Jakma <paul.jakma@sun.com>

	* (global) Update code to match stream.h changes.
	  stream_get_putp effectively replaced with stream_get_endp.
	  stream_forward renamed to stream_forward_getp.
	  stream_forward_endp introduced to replace some previous
	  setting/manual twiddling of putp by daemons.
	* lib/stream.h: Remove putp. Update reference to putp with endp.
	  Add stream_forward_endp, which daemons were doing manually.
	  Rename stream_forward to stream_forward_getp.
	  lib/stream.c: Remove/update references to putp.
	  introduce stream_forward_endp.
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index 8dae147..52d8884 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -369,7 +369,6 @@
 
   /* copying only the relevant part of our stream */
   lsp->pdu = stream_new (stream->endp);
-  lsp->pdu->putp = stream->putp;
   lsp->pdu->getp = stream->getp;
   lsp->pdu->endp = stream->endp;
   memcpy (lsp->pdu->data, stream->data, stream->endp);
@@ -509,7 +508,7 @@
   lsp->level = level;
   lsp->age_out = ZERO_AGE_LIFETIME;
 
-  stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
+  stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
 
   /* #ifdef EXTREME_DEBUG */
   /* logging */
@@ -1141,7 +1140,7 @@
 	}
     }
 
-  stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
+  stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
 
   if (lsp->tlv_data.nlpids)
     tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu);
@@ -1159,7 +1158,7 @@
     tlv_add_ipv6_reachs (lsp->tlv_data.ipv6_reachs, lsp->pdu);
 #endif /* HAVE_IPV6 */
 
-  lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));
+  lsp->lsp_header->pdu_len = htons (stream_get_endp (lsp->pdu));
 
   return;
 }
@@ -1200,7 +1199,7 @@
 	}
       tlv_build_func (*to, lsp->pdu);
     }
-  lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));
+  lsp->lsp_header->pdu_len = htons (stream_get_endp (lsp->pdu));
   return;
 }
 
@@ -1319,7 +1318,7 @@
   /*
    * Building the zero lsp
    */
-  stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
+  stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
   /*
    * Add the authentication info if its present
    */
@@ -1929,7 +1928,7 @@
 	}
     }
 
-  stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
+  stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
   /*
    * Add the authentication info if it's present
    */
@@ -1947,7 +1946,7 @@
   if (lsp->tlv_data.es_neighs && listcount (lsp->tlv_data.es_neighs) > 0)
     tlv_add_is_neighs (lsp->tlv_data.es_neighs, lsp->pdu);
 
-  lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));
+  lsp->lsp_header->pdu_len = htons (stream_get_endp (lsp->pdu));
   iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
 		   ntohs (lsp->lsp_header->pdu_len) - 12, 12);
 
@@ -2473,7 +2472,6 @@
     }
 
   /* thanks to hannes, another bug bites the dust */
-  lsp->pdu->putp = ntohs (lsp->lsp_header->pdu_len);
   lsp->pdu->endp = ntohs (lsp->lsp_header->pdu_len);
 }
 #endif /* TOPOLOGY_GENERATE */
diff --git a/isisd/isis_network.c b/isisd/isis_network.c
index a0df32e..2e901f1 100644
--- a/isisd/isis_network.c
+++ b/isisd/isis_network.c
@@ -422,7 +422,6 @@
   /* then we lose the LLC */
   memcpy (STREAM_DATA (circuit->rcv_stream),
 	  sock_buff + LLC_LEN, bytesread - LLC_LEN);
-  circuit->rcv_stream->putp = bytesread - LLC_LEN;
   circuit->rcv_stream->endp = bytesread - LLC_LEN;
 
   memcpy (ssnpa, &s_addr.sll_addr, s_addr.sll_halen);
@@ -453,7 +452,6 @@
       return ISIS_WARNING;
     }
 
-  circuit->rcv_stream->putp = bytesread;
   circuit->rcv_stream->endp = bytesread;
 
   /* If we don't have protocol type 0x00FE which is
@@ -503,7 +501,7 @@
 
   /* now we can send this */
   written = sendto (circuit->fd, sock_buff,
-		    circuit->snd_stream->putp + LLC_LEN, 0,
+		    stream_get_endp(circuit->snd_stream) + LLC_LEN, 0,
 		    (struct sockaddr *) &sa, sizeof (struct sockaddr_ll));
 
   return ISIS_OK;
@@ -531,7 +529,8 @@
   /* lets try correcting the protocol */
   sa.sll_protocol = htons (0x00FE);
   written = sendto (circuit->fd, circuit->snd_stream->data,
-		    circuit->snd_stream->putp, 0, (struct sockaddr *) &sa,
+		    stream_get_endp (circuit->snd_stream), 0, 
+		    (struct sockaddr *) &sa,
 		    sizeof (struct sockaddr_ll));
 
   return ISIS_OK;
@@ -576,7 +575,6 @@
   memcpy (STREAM_DATA (circuit->rcv_stream),
 	  readbuff + offset, bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN);
 
-  circuit->rcv_stream->putp = bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN;
   circuit->rcv_stream->endp = bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN;
   circuit->rcv_stream->getp = 0;
 
@@ -603,7 +601,6 @@
       return ISIS_WARNING;
     }
 
-  circuit->rcv_stream->putp = bytesread;
   circuit->rcv_stream->endp = bytesread;
 
   return ISIS_OK;
@@ -641,7 +638,8 @@
 
   /* now we can send this */
   written = write (circuit->fd, sock_buff,
-		   circuit->snd_stream->putp + LLC_LEN + ETHER_HDR_LEN);
+		   stream_get_endp (circuit->snd_stream) 
+		    + LLC_LEN + ETHER_HDR_LEN);
 
   return ISIS_OK;
 }
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index b6a035e..6dcc75e 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1938,7 +1938,7 @@
   hello_hdr.hold_time = htons ((u_int16_t) interval);
 
   hello_hdr.pdu_len = 0;	/* Update the PDU Length later */
-  len_pointer = stream_get_putp (circuit->snd_stream) + 3 + ISIS_SYS_ID_LEN;
+  len_pointer = stream_get_endp (circuit->snd_stream) + 3 + ISIS_SYS_ID_LEN;
 
   /* copy the shared part of the hello to the p2p hello if needed */
   if (circuit->circ_type == CIRCUIT_T_P2P)
@@ -2012,7 +2012,7 @@
     if (tlv_add_padding (circuit->snd_stream))
       return ISIS_WARNING;
 
-  length = stream_get_putp (circuit->snd_stream);
+  length = stream_get_endp (circuit->snd_stream);
   /* Update PDU length */
   stream_putw_at (circuit->snd_stream, len_pointer, (u_int16_t) length);
 
@@ -2132,7 +2132,7 @@
    * Fill Level 1 or 2 Complete Sequence Numbers header
    */
 
-  lenp = stream_get_putp (circuit->snd_stream);
+  lenp = stream_get_endp (circuit->snd_stream);
   stream_putw (circuit->snd_stream, 0);	/* PDU length - when we know it */
   /* no need to send the source here, it is always us if we csnp */
   stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
@@ -2159,7 +2159,7 @@
     {
       retval = tlv_add_lsp_entries (lsps, circuit->snd_stream);
     }
-  length = (u_int16_t) stream_get_putp (circuit->snd_stream);
+  length = (u_int16_t) stream_get_endp (circuit->snd_stream);
   assert (length >= ISIS_CSNP_HDRLEN);
   /* Update PU length */
   stream_putw_at (circuit->snd_stream, lenp, length);
@@ -2287,7 +2287,7 @@
   /*
    * Fill Level 1 or 2 Partial Sequence Numbers header
    */
-  lenp = stream_get_putp (circuit->snd_stream);
+  lenp = stream_get_endp (circuit->snd_stream);
   stream_putw (circuit->snd_stream, 0);	/* PDU length - when we know it */
   stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
   stream_putc (circuit->snd_stream, circuit->idx);
@@ -2325,7 +2325,7 @@
       }
     }
 
-  length = (u_int16_t) stream_get_putp (circuit->snd_stream);
+  length = (u_int16_t) stream_get_endp (circuit->snd_stream);
   assert (length >= ISIS_PSNP_HDRLEN);
   /* Update PDU length */
   stream_putw_at (circuit->snd_stream, lenp, length);
@@ -2446,7 +2446,7 @@
   unsigned long length;
 
   stream_put (stream, lsp->pdu, ntohs (lsp->lsp_header->pdu_len));
-  length = stream_get_putp (stream);
+  length = stream_get_endp (stream);
 
   return;
 } */
@@ -2501,7 +2501,6 @@
 	    }
 	  /* copy our lsp to the send buffer */
 	  circuit->snd_stream->getp = lsp->pdu->getp;
-	  circuit->snd_stream->putp = lsp->pdu->putp;
 	  circuit->snd_stream->endp = lsp->pdu->endp;
 	  memcpy (circuit->snd_stream->data, lsp->pdu->data, lsp->pdu->endp);
 
@@ -2577,7 +2576,7 @@
 			      circuit->snd_stream);
 
 
-  lenp = stream_get_putp (circuit->snd_stream);
+  lenp = stream_get_endp (circuit->snd_stream);
   stream_putw (circuit->snd_stream, 0);	/* PDU length  */
   stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
   stream_putc (circuit->snd_stream, circuit->idx);
@@ -2589,7 +2588,7 @@
   stream_putl (circuit->snd_stream, ntohl (hdr->seq_num));
   stream_putw (circuit->snd_stream, ntohs (hdr->checksum));
 
-  length = (u_int16_t) stream_get_putp (circuit->snd_stream);
+  length = (u_int16_t) stream_get_endp (circuit->snd_stream);
   /* Update PDU length */
   stream_putw_at (circuit->snd_stream, lenp, length);
 
diff --git a/isisd/isis_tlv.c b/isisd/isis_tlv.c
index 84f36c9..bc65363 100644
--- a/isisd/isis_tlv.c
+++ b/isisd/isis_tlv.c
@@ -751,7 +751,7 @@
 add_tlv (u_char tag, u_char len, u_char * value, struct stream *stream)
 {
 
-  if (STREAM_SIZE (stream) - stream_get_putp (stream) < (unsigned) len + 2)
+  if (STREAM_SIZE (stream) - stream_get_endp (stream) < (unsigned) len + 2)
     {
       zlog_warn ("No room for TLV of type %d", tag);
       return ISIS_WARNING;
@@ -1065,7 +1065,6 @@
 int
 tlv_add_padding (struct stream *stream)
 {
-  unsigned long putp, endp;
   int fullpads, i, left;
 
   /*
@@ -1078,15 +1077,10 @@
 	goto err;
       if (!stream_putc (stream, (u_char) 255))	/* LENGHT */
 	goto err;
-      endp = stream_get_endp (stream);
-      putp = stream_get_putp (stream);
-      if (putp != endp)
-	zlog_warn ("tvl_add_padding endp %ld while putp %ld", endp, putp);
-      stream_set_putp (stream, putp + 255);	/* VALUE */
-      stream->endp = stream->putp;
+      stream_forward_endp (stream, 255);	/* VALUE */
     }
 
-  left = STREAM_SIZE (stream) - stream_get_putp (stream);
+  left = STREAM_SIZE (stream) - stream_get_endp (stream);
 
   if (left < 2)
     return ISIS_OK;
@@ -1100,8 +1094,7 @@
 
   stream_putc (stream, PADDING);
   stream_putc (stream, left - 2);
-  stream_set_putp (stream, stream_get_putp (stream) + left - 2);
-  stream->endp = stream->putp;
+  stream_forward_endp (stream, left - 2);
 
   return ISIS_OK;