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/ChangeLog b/ChangeLog
index 475f1ed..c3c524c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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.
+
 2005-01-24 Paul Jakma <paul@dishone.st>
 
 	* configure.ac: Bump version to 0.99.0
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index c702946..417e622 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -701,7 +701,7 @@
     }
 
   /* Forward pointer. */
-  stream_forward (peer->ibuf, length);
+  stream_forward_getp (peer->ibuf, length);
 
   /* Set aspath attribute flag. */
   attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);
@@ -789,7 +789,7 @@
      receiving speaker. */
   if (peer_sort (peer) == BGP_PEER_EBGP)
     {
-      stream_forward (peer->ibuf, length);
+      stream_forward_getp (peer->ibuf, length);
       return 0;
     }
 
@@ -859,7 +859,7 @@
     {
       attr->community = 
         community_parse ((u_int32_t *)stream_pnt (peer->ibuf), length);
-      stream_forward (peer->ibuf, length);
+      stream_forward_getp (peer->ibuf, length);
     }
 
   attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
@@ -908,7 +908,7 @@
   attr->cluster = cluster_parse ((struct in_addr *)stream_pnt (peer->ibuf), 
                                  length);
 
-  stream_forward (peer->ibuf, length);;
+  stream_forward_getp (peer->ibuf, length);;
 
   attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST);
 
@@ -991,7 +991,7 @@
   while (snpa_num--)
     {
       snpa_len = stream_getc (s);
-      stream_forward (s, (snpa_len + 1) >> 1);
+      stream_forward_getp (s, (snpa_len + 1) >> 1);
     }
   
   nlri_len = lim - stream_pnt (s);
@@ -1008,7 +1008,7 @@
   mp_update->nlri = stream_pnt (s);
   mp_update->length = nlri_len;
 
-  stream_forward (s, nlri_len);
+  stream_forward_getp (s, nlri_len);
 
   return 0;
 }
@@ -1045,7 +1045,7 @@
   mp_withdraw->nlri = stream_pnt (s);
   mp_withdraw->length = withdraw_len;
 
-  stream_forward (s, withdraw_len);
+  stream_forward_getp (s, withdraw_len);
 
   return 0;
 }
@@ -1061,7 +1061,7 @@
     {
       attr->ecommunity = 
         ecommunity_parse ((u_int8_t *)stream_pnt (peer->ibuf), length);
-      stream_forward (peer->ibuf, length);
+      stream_forward_getp (peer->ibuf, length);
     }
   attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
 
@@ -1085,7 +1085,7 @@
 	  "Unknown attribute type %d length %d is received", type, length);
 
   /* Forward read pointer of input stream. */
-  stream_forward (peer->ibuf, length);
+  stream_forward_getp (peer->ibuf, length);
 
   /* Adjest total length to include type and length. */
   total = length + (CHECK_FLAG (flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3);
@@ -1348,7 +1348,7 @@
     bgp = bgp_get_default ();
 
   /* Remember current pointer. */
-  cp = stream_get_putp (s);
+  cp = stream_get_endp (s);
 
   /* Origin attribute. */
   stream_putc (s, BGP_ATTR_FLAG_TRANS);
@@ -1533,7 +1533,7 @@
 
       stream_putc (s, BGP_ATTR_FLAG_OPTIONAL);
       stream_putc (s, BGP_ATTR_MP_REACH_NLRI);
-      sizep = stream_get_putp (s);
+      sizep = stream_get_endp (s);
       stream_putc (s, 0);	/* Length of this attribute. */
       stream_putw (s, AFI_IP6);	/* AFI */
       stream_putc (s, safi);	/* SAFI */
@@ -1555,7 +1555,7 @@
       stream_put_prefix (s, p);
 
       /* Set MP attribute length. */
-      stream_putc_at (s, sizep, (stream_get_putp (s) - sizep) - 1);
+      stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1);
     }
 #endif /* HAVE_IPV6 */
 
@@ -1565,7 +1565,7 @@
 
       stream_putc (s, BGP_ATTR_FLAG_OPTIONAL);
       stream_putc (s, BGP_ATTR_MP_REACH_NLRI);
-      sizep = stream_get_putp (s);
+      sizep = stream_get_endp (s);
       stream_putc (s, 0);	/* Length of this attribute. */
       stream_putw (s, AFI_IP);	/* AFI */
       stream_putc (s, SAFI_MULTICAST);	/* SAFI */
@@ -1580,7 +1580,7 @@
       stream_put_prefix (s, p);
 
       /* Set MP attribute length. */
-      stream_putc_at (s, sizep, (stream_get_putp (s) - sizep) - 1);
+      stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1);
     }
 
   if (p->family == AF_INET && safi == SAFI_MPLS_VPN)
@@ -1589,7 +1589,7 @@
 
       stream_putc (s, BGP_ATTR_FLAG_OPTIONAL);
       stream_putc (s, BGP_ATTR_MP_REACH_NLRI);
-      sizep = stream_get_putp (s);
+      sizep = stream_get_endp (s);
       stream_putc (s, 0);	/* Length of this attribute. */
       stream_putw (s, AFI_IP);	/* AFI */
       stream_putc (s, BGP_SAFI_VPNV4);	/* SAFI */
@@ -1609,7 +1609,7 @@
       stream_put (s, &p->u.prefix, PSIZE (p->prefixlen));
 
       /* Set MP attribute length. */
-      stream_putc_at (s, sizep, (stream_get_putp (s) - sizep) - 1);
+      stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1);
     }
 
   /* Extended Communities attribute. */
@@ -1684,7 +1684,7 @@
     stream_put (s, attr->transit->val, attr->transit->length);
 
   /* Return total size of attribute. */
-  return stream_get_putp (s) - cp;
+  return stream_get_endp (s) - cp;
 }
 
 bgp_size_t
@@ -1696,12 +1696,12 @@
   unsigned long attrlen_pnt;
   bgp_size_t size;
 
-  cp = stream_get_putp (s);
+  cp = stream_get_endp (s);
 
   stream_putc (s, BGP_ATTR_FLAG_OPTIONAL);
   stream_putc (s, BGP_ATTR_MP_UNREACH_NLRI);
 
-  attrlen_pnt = stream_get_putp (s);
+  attrlen_pnt = stream_get_endp (s);
   stream_putc (s, 0);		/* Length of this attribute. */
 
   stream_putw (s, family2afi (p->family));
@@ -1727,10 +1727,10 @@
     }
 
   /* Set MP attribute length. */
-  size = stream_get_putp (s) - attrlen_pnt - 1;
+  size = stream_get_endp (s) - attrlen_pnt - 1;
   stream_putc_at (s, attrlen_pnt, size);
 
-  return stream_get_putp (s) - cp;
+  return stream_get_endp (s) - cp;
 }
 
 /* Initialization of attribute. */
@@ -1757,7 +1757,7 @@
   struct aspath *aspath;
 
   /* Remember current pointer. */
-  cp = stream_get_putp (s);
+  cp = stream_get_endp (s);
 
   /* Place holder of length. */
   stream_putw (s, 0);
@@ -1861,7 +1861,7 @@
 
       stream_putc(s, BGP_ATTR_FLAG_OPTIONAL);
       stream_putc(s, BGP_ATTR_MP_REACH_NLRI);
-      sizep = stream_get_putp (s);
+      sizep = stream_get_endp (s);
 
       /* MP header */
       stream_putc (s, 0);		/* Length of this attribute. */
@@ -1881,11 +1881,11 @@
       stream_put_prefix(s, prefix);
 
       /* Set MP attribute length. */
-      stream_putc_at (s, sizep, (stream_get_putp (s) - sizep) - 1);
+      stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1);
     }
 #endif /* HAVE_IPV6 */
 
   /* Return total size of attribute. */
-  len = stream_get_putp (s) - cp - 2;
+  len = stream_get_endp (s) - cp - 2;
   stream_putw_at (s, cp, len);
 }
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index 549a4f0..0fb5ed8 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -185,7 +185,7 @@
 void
 bgp_dump_set_size (struct stream *s, int type)
 {
-  stream_putl_at (s, 8, stream_get_putp (s) - BGP_DUMP_HEADER_SIZE);
+  stream_putl_at (s, 8, stream_get_endp (s) - BGP_DUMP_HEADER_SIZE);
 }
 
 void
@@ -290,7 +290,7 @@
   /* Set length. */
   bgp_dump_set_size (obuf, type);
 
-  fwrite (STREAM_DATA (obuf), stream_get_putp (obuf), 1, bgp_dump_routes.fp);
+  fwrite (STREAM_DATA (obuf), stream_get_endp (obuf), 1, bgp_dump_routes.fp);
   fflush (bgp_dump_routes.fp);
 }
 
@@ -416,7 +416,7 @@
   bgp_dump_set_size (obuf, MSG_PROTOCOL_BGP4MP);
 
   /* Write to the stream. */
-  fwrite (STREAM_DATA (obuf), stream_get_putp (obuf), 1, bgp_dump_all.fp);
+  fwrite (STREAM_DATA (obuf), stream_get_endp (obuf), 1, bgp_dump_all.fp);
   fflush (bgp_dump_all.fp);
 }
 
@@ -445,7 +445,7 @@
   bgp_dump_set_size (obuf, MSG_PROTOCOL_BGP4MP);
 
   /* Write to the stream. */
-  fwrite (STREAM_DATA (obuf), stream_get_putp (obuf), 1, bgp_dump->fp);
+  fwrite (STREAM_DATA (obuf), stream_get_endp (obuf), 1, bgp_dump->fp);
   fflush (bgp_dump->fp);
 }
 
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 7250383..b1d0fc1 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -675,15 +675,15 @@
     safi = BGP_SAFI_VPNV4;
 
   stream_putc (s, BGP_OPEN_OPT_CAP);
-  capp = stream_get_putp (s);           /* Set Capability Len Pointer */
+  capp = stream_get_endp (s);           /* Set Capability Len Pointer */
   stream_putc (s, 0);                   /* Capability Length */
   stream_putc (s, code);                /* Capability Code */
-  orfp = stream_get_putp (s);           /* Set ORF Len Pointer */
+  orfp = stream_get_endp (s);           /* Set ORF Len Pointer */
   stream_putc (s, 0);                   /* ORF Length */
   stream_putw (s, afi);
   stream_putc (s, 0);
   stream_putc (s, safi);
-  numberp = stream_get_putp (s);        /* Set Number Pointer */
+  numberp = stream_get_endp (s);        /* Set Number Pointer */
   stream_putc (s, 0);                   /* Number of ORFs */
 
   /* Address Prefix ORF */
@@ -717,11 +717,11 @@
   stream_putc_at (s, numberp, number_of_orfs);
 
   /* Total ORF Len. */
-  orf_len = stream_get_putp (s) - orfp - 1;
+  orf_len = stream_get_endp (s) - orfp - 1;
   stream_putc_at (s, orfp, orf_len);
 
   /* Total Capability Len. */
-  cap_len = stream_get_putp (s) - capp - 1;
+  cap_len = stream_get_endp (s) - capp - 1;
   stream_putc_at (s, capp, cap_len);
 }
 
@@ -735,7 +735,7 @@
   safi_t safi;
 
   /* Remember current pointer for Opt Parm Len. */
-  cp = stream_get_putp (s);
+  cp = stream_get_endp (s);
 
   /* Opt Parm Len. */
   stream_putc (s, 0);
@@ -851,6 +851,6 @@
      }
 
   /* Total Opt Parm Len. */
-  len = stream_get_putp (s) - cp - 1;
+  len = stream_get_endp (s) - cp - 1;
   stream_putc_at (s, cp, len);
 }
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 201ffbb..8f7577b 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -67,7 +67,7 @@
   stream_putc (s, type);
 
   /* Return current stream size. */
-  return stream_get_putp (s);
+  return stream_get_endp (s);
 }
 
 /* Set BGP packet header size entry.  If size is zero then use current
@@ -78,12 +78,8 @@
   int cp;
 
   /* Preserve current pointer. */
-  cp = stream_get_putp (s);
-  stream_set_putp (s, BGP_MARKER_SIZE);
-  stream_putw (s, cp);
-
-  /* Write back current pointer. */
-  stream_set_putp (s, cp);
+  cp = stream_get_endp (s);
+  stream_putw_at (s, BGP_MARKER_SIZE, cp);
 
   return cp;
 }
@@ -112,7 +108,6 @@
   new = stream_new (stream_get_endp (s));
 
   new->endp = s->endp;
-  new->putp = s->putp;
   new->getp = s->getp;
 
   memcpy (new->data, s->data, stream_get_endp (s));
@@ -202,7 +197,7 @@
 	{
 	  bgp_packet_set_marker (s, BGP_MSG_UPDATE);
 	  stream_putw (s, 0);		
-	  pos = stream_get_putp (s);
+	  pos = stream_get_endp (s);
 	  stream_putw (s, 0);
 	  total_attr_len = bgp_packet_attribute (NULL, peer, s, 
 	                                         adv->baa->attr,
@@ -330,7 +325,7 @@
 	stream_put_prefix (s, &rn->p);
       else
 	{
-	  pos = stream_get_putp (s);
+	  pos = stream_get_endp (s);
 	  stream_putw (s, 0);
 	  total_attr_len
 	    = bgp_packet_withdraw (peer, s, &rn->p, afi, safi, prd, NULL);
@@ -359,7 +354,7 @@
       if (afi == AFI_IP && safi == SAFI_UNICAST)
 	{
 	  unfeasible_len 
-	    = stream_get_putp (s) - BGP_HEADER_SIZE - BGP_UNFEASIBLE_LEN;
+	    = stream_get_endp (s) - BGP_HEADER_SIZE - BGP_UNFEASIBLE_LEN;
 	  stream_putw_at (s, BGP_HEADER_SIZE, unfeasible_len);
 	  stream_putw (s, 0);
 	}
@@ -414,7 +409,7 @@
   stream_putw (s, 0);
 
   /* Make place for total attribute length.  */
-  pos = stream_get_putp (s);
+  pos = stream_get_endp (s);
   stream_putw (s, 0);
   total_attr_len = bgp_packet_attribute (NULL, peer, s, attr, &p, afi, safi, from, NULL, NULL);
 
@@ -479,7 +474,7 @@
   bgp_packet_set_marker (s, BGP_MSG_UPDATE);
 
   /* Unfeasible Routes Length. */;
-  cp = stream_get_putp (s);
+  cp = stream_get_endp (s);
   stream_putw (s, 0);
 
   /* Withdrawn Routes. */
@@ -487,7 +482,7 @@
     {
       stream_put_prefix (s, &p);
 
-      unfeasible_len = stream_get_putp (s) - cp - 2;
+      unfeasible_len = stream_get_endp (s) - cp - 2;
 
       /* Set unfeasible len.  */
       stream_putw_at (s, cp, unfeasible_len);
@@ -497,7 +492,7 @@
     }
   else
     {
-      pos = stream_get_putp (s);
+      pos = stream_get_endp (s);
       stream_putw (s, 0);
       total_attr_len = bgp_packet_withdraw (peer, s, &p, afi, safi, NULL, NULL);
 
@@ -665,7 +660,7 @@
 	}
       if (num != writenum)
 	{
-	  stream_forward (s, num);
+	  stream_forward_getp (s, num);
 
 	  if (write_errno == EAGAIN)
 	    break;
@@ -1016,7 +1011,7 @@
 	orf_refresh = 1; 
 	stream_putc (s, when_to_refresh);
 	stream_putc (s, orf_type);
-	orfp = stream_get_putp (s);
+	orfp = stream_get_endp (s);
 	stream_putw (s, 0);
 
 	if (remove)
@@ -1043,7 +1038,7 @@
 	  }
 
 	/* Total ORF Entry Len. */
-	orf_len = stream_get_putp (s) - orfp - 2;
+	orf_len = stream_get_endp (s) - orfp - 2;
 	stream_putw_at (s, orfp, orf_len);
       }
 
@@ -1398,7 +1393,7 @@
       if (ret < 0)
 	return ret;
 
-      stream_forward (peer->ibuf, optlen);
+      stream_forward_getp (peer->ibuf, optlen);
     }
   else
     {
@@ -1506,7 +1501,7 @@
       withdraw.safi = SAFI_UNICAST;
       withdraw.nlri = stream_pnt (s);
       withdraw.length = withdraw_len;
-      stream_forward (s, withdraw_len);
+      stream_forward_getp (s, withdraw_len);
     }
   
   /* Attribute total length check. */
@@ -1568,7 +1563,7 @@
       update.safi = SAFI_UNICAST;
       update.nlri = stream_pnt (s);
       update.length = update_len;
-      stream_forward (s, update_len);
+      stream_forward_getp (s, update_len);
     }
 
   /* NLRI is processed only when the peer is configured specific
@@ -1992,7 +1987,7 @@
 	      peer->orf_plist[afi][safi] =
 			 prefix_list_lookup (AFI_ORF_PREFIX, name);
 	    }
-	  stream_forward (s, orf_len);
+	  stream_forward_getp (s, orf_len);
 	}
       if (BGP_DEBUG (normal, NORMAL))
 	zlog_debug ("%s rcvd Refresh %s ORF request", peer->host,
@@ -2162,7 +2157,7 @@
   int nbytes;
   int readsize;
 
-  readsize = peer->packet_size - peer->ibuf->putp;
+  readsize = peer->packet_size - stream_get_endp (peer->ibuf);
 
   /* If size is zero then return. */
   if (! readsize)
@@ -2218,7 +2213,7 @@
     }
 
   /* We read partial packet. */
-  if (peer->ibuf->putp != peer->packet_size)
+  if (stream_get_endp (peer->ibuf) != peer->packet_size)
     return -1;
 
   return 0;
@@ -2271,7 +2266,7 @@
   if (peer->packet_size == 0)
     peer->packet_size = BGP_HEADER_SIZE;
 
-  if (peer->ibuf->putp < BGP_HEADER_SIZE)
+  if (stream_get_endp (peer->ibuf) < BGP_HEADER_SIZE)
     {
       ret = bgp_read_packet (peer);
 
@@ -2280,7 +2275,7 @@
 	goto done;
 
       /* Get size and type. */
-      stream_forward (peer->ibuf, BGP_MARKER_SIZE);
+      stream_forward_getp (peer->ibuf, BGP_MARKER_SIZE);
       memcpy (notify_data_length, stream_pnt (peer->ibuf), 2);
       size = stream_getw (peer->ibuf);
       type = stream_getc (peer->ibuf);
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;
 
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 41308ff..81865fb 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,11 @@
+2005-02-09 Paul Jakma <paul.jakma@sun.com>
+
+	* 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.
+	  stream.c: Remove/update references to putp.
+	  introduce stream_forward_endp.
+
 2005-02-08 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
 	* zebra.h: Change macro definitions SET_FLAG and UNSET_FLAG
diff --git a/lib/stream.c b/lib/stream.c
index 1b85b13..7a8bc45 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -35,8 +35,8 @@
 */
 
 #define CHECK_SIZE(S, Z) \
-	if (((S)->putp + (Z)) > (S)->size) \
-           (Z) = (S)->size - (S)->putp;
+	if (((S)->endp + (Z)) > (S)->size) \
+           (Z) = (S)->size - (S)->endp;
 
 /* Stream is fixed length buffer for network output/input. */
 
@@ -73,12 +73,6 @@
 }
 
 unsigned long
-stream_get_putp (struct stream *s)
-{
-  return s->putp;
-}
-
-unsigned long
 stream_get_endp (struct stream *s)
 {
   return s->endp;
@@ -97,18 +91,18 @@
   s->getp = pos;
 }
 
-void
-stream_set_putp (struct stream *s, unsigned long pos)
-{
-  s->putp = pos;
-}
-
 /* Forward pointer. */
 void
-stream_forward (struct stream *s, int size)
+stream_forward_getp (struct stream *s, int size)
 {
   s->getp += size;
 }
+
+void
+stream_forward_endp (struct stream *s, int size)
+{
+  s->endp += size;
+}
 
 /* Copy from stream to destination. */
 void
@@ -194,25 +188,22 @@
   CHECK_SIZE(s, size);
 
   if (src)
-    memcpy (s->data + s->putp, src, size);
+    memcpy (s->data + s->endp, src, size);
   else
-    memset (s->data + s->putp, 0, size);
+    memset (s->data + s->endp, 0, size);
 
-  s->putp += size;
-  if (s->putp > s->endp)
-    s->endp = s->putp;
+  s->endp += size;
 }
 
 /* Put character to the stream. */
 int
 stream_putc (struct stream *s, u_char c)
 {
-  if (s->putp >= s->size) return 0;
+  if (s->endp >= s->size) return 0;
 
-  s->data[s->putp] = c;
-  s->putp++;
-  if (s->putp > s->endp)
-    s->endp = s->putp;
+  s->data[s->endp] = c;
+  s->endp++;
+
   return 1;
 }
 
@@ -220,13 +211,11 @@
 int
 stream_putw (struct stream *s, u_int16_t w)
 {
-  if ((s->size - s->putp) < 2) return 0;
+  if ((s->size - s->endp) < 2) return 0;
 
-  s->data[s->putp++] = (u_char)(w >>  8);
-  s->data[s->putp++] = (u_char) w;
+  s->data[s->endp++] = (u_char)(w >>  8);
+  s->data[s->endp++] = (u_char) w;
 
-  if (s->putp > s->endp)
-    s->endp = s->putp;
   return 2;
 }
 
@@ -234,15 +223,13 @@
 int
 stream_putl (struct stream *s, u_int32_t l)
 {
-  if ((s->size - s->putp) < 4) return 0;
+  if ((s->size - s->endp) < 4) return 0;
 
-  s->data[s->putp++] = (u_char)(l >> 24);
-  s->data[s->putp++] = (u_char)(l >> 16);
-  s->data[s->putp++] = (u_char)(l >>  8);
-  s->data[s->putp++] = (u_char)l;
+  s->data[s->endp++] = (u_char)(l >> 24);
+  s->data[s->endp++] = (u_char)(l >> 16);
+  s->data[s->endp++] = (u_char)(l >>  8);
+  s->data[s->endp++] = (u_char)l;
 
-  if (s->putp > s->endp)
-    s->endp = s->putp;
   return 4;
 }
 
@@ -275,14 +262,12 @@
 int
 stream_put_ipv4 (struct stream *s, u_int32_t l)
 {
-  if ((s->size - s->putp) < 4)
+  if ((s->size - s->endp) < 4)
     return 0;
 
-  memcpy (s->data + s->putp, &l, 4);
-  s->putp += 4;
+  memcpy (s->data + s->endp, &l, 4);
+  s->endp += 4;
 
-  if (s->putp > s->endp)
-    s->endp = s->putp;
   return 4;
 }
 
@@ -290,14 +275,12 @@
 int
 stream_put_in_addr (struct stream *s, struct in_addr *addr)
 {
-  if ((s->size - s->putp) < 4)
+  if ((s->size - s->endp) < 4)
     return 0;
 
-  memcpy (s->data + s->putp, addr, 4);
-  s->putp += 4;
+  memcpy (s->data + s->endp, addr, 4);
+  s->endp += 4;
 
-  if (s->putp > s->endp)
-    s->endp = s->putp;
   return 4;
 }
 
@@ -309,15 +292,12 @@
 
   psize = PSIZE (p->prefixlen);
 
-  if ((s->size - s->putp) < psize) return 0;
+  if ((s->size - s->endp) < psize) return 0;
 
   stream_putc (s, p->prefixlen);
-  memcpy (s->data + s->putp, &p->u.prefix, psize);
-  s->putp += psize;
+  memcpy (s->data + s->endp, &p->u.prefix, psize);
+  s->endp += psize;
   
-  if (s->putp > s->endp)
-    s->endp = s->putp;
-
   return psize;
 }
 
@@ -327,13 +307,11 @@
 {
   int nbytes;
 
-  nbytes = readn (fd, s->data + s->putp, size);
+  nbytes = readn (fd, s->data + s->endp, size);
 
   if (nbytes > 0)
-    {
-      s->putp += nbytes;
-      s->endp += nbytes;
-    }
+    s->endp += nbytes;
+  
   return nbytes;
 }
 
@@ -346,14 +324,12 @@
 
   val = fcntl (fd, F_GETFL, 0);
   fcntl (fd, F_SETFL, val|O_NONBLOCK);
-  nbytes = read (fd, s->data + s->putp, size);
+  nbytes = read (fd, s->data + s->endp, size);
   fcntl (fd, F_SETFL, val);
 
   if (nbytes > 0)
-    {
-      s->putp += nbytes;
-      s->endp += nbytes;
-    }
+    s->endp += nbytes;
+  
   return nbytes;
 }
 
@@ -364,10 +340,9 @@
 
   CHECK_SIZE(s, size);
 
-  memcpy (s->data + s->putp, ptr, size);
-  s->putp += size;
-  if (s->putp > s->endp)
-    s->endp = s->putp;
+  memcpy (s->data + s->endp, ptr, size);
+  s->endp += size;
+
   return size;
 }
 
@@ -382,7 +357,7 @@
 int
 stream_empty (struct stream *s)
 {
-  if (s->putp == 0 && s->endp == 0 && s->getp == 0)
+  if (s->endp == 0 && s->getp == 0)
     return 1;
   else
     return 0;
@@ -392,7 +367,6 @@
 void
 stream_reset (struct stream *s)
 {
-  s->putp = 0;
   s->endp = 0;
   s->getp = 0;
 }
diff --git a/lib/stream.h b/lib/stream.h
index f7a94ea..c7e4ffb 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -32,9 +32,6 @@
 
   unsigned char *data;
   
-  /* Put pointer. */
-  unsigned long putp;
-
   /* Get pointer. */
   unsigned long getp;
 
@@ -57,7 +54,7 @@
 /* Utility macros. */
 #define STREAM_PNT(S)   ((S)->data + (S)->getp)
 #define STREAM_SIZE(S)  ((S)->size)
-#define STREAM_REMAIN(S) ((S)->size - (S)->putp)
+#define STREAM_REMAIN(S) ((S)->size - (S)->endp)
 #define STREAM_DATA(S)  ((S)->data)
 
 /* Stream prototypes. */
@@ -65,15 +62,13 @@
 void stream_free (struct stream *);
 
 unsigned long stream_get_getp (struct stream *);
-unsigned long stream_get_putp (struct stream *);
 unsigned long stream_get_endp (struct stream *);
 unsigned long stream_get_size (struct stream *);
 u_char *stream_get_data (struct stream *);
 
 void stream_set_getp (struct stream *, unsigned long);
-void stream_set_putp (struct stream *, unsigned long);
-
-void stream_forward (struct stream *, int);
+void stream_forward_getp (struct stream *, int);
+void stream_forward_endp (struct stream *, int);
 
 void stream_put (struct stream *, void *, size_t);
 int stream_putc (struct stream *, u_char);
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index dd712c3..17cf28c 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -455,7 +455,7 @@
       lsa = (struct lsa_header *) STREAM_PNT (s);
       ospf_lsa_header_dump (lsa);
 
-      stream_forward (s, OSPF_LSA_HEADER_SIZE);
+      stream_forward_getp (s, OSPF_LSA_HEADER_SIZE);
       length -= OSPF_LSA_HEADER_SIZE;
     }
 }
@@ -481,7 +481,7 @@
 
   length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE;
 
-  stream_forward (s, OSPF_DB_DESC_MIN_SIZE);
+  stream_forward_getp (s, OSPF_DB_DESC_MIN_SIZE);
 
   ospf_lsa_header_list_dump (s, length);
 
@@ -577,7 +577,7 @@
 	  break;
 	}
 
-      stream_forward (s, lsa_len);
+      stream_forward_getp (s, lsa_len);
       length -= lsa_len;
       count--;
     }
@@ -673,7 +673,7 @@
 
   /* Show OSPF header detail. */
   ospf_header_dump (ospfh);
-  stream_forward (s, OSPF_HEADER_SIZE);
+  stream_forward_getp (s, OSPF_HEADER_SIZE);
 
   switch (ospfh->type)
     {
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index fbc56e1..13302dd 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -407,7 +407,7 @@
   lsah->adv_router = router_id;
   lsah->ls_seqnum = htonl (OSPF_INITIAL_SEQUENCE_NUMBER);
 
-  ospf_output_forward (s, OSPF_LSA_HEADER_SIZE);
+  stream_forward_endp (s, OSPF_LSA_HEADER_SIZE);
 }
 
 
@@ -710,7 +710,7 @@
   stream_putc (s, 0);
 
   /* Keep pointer to # links. */
-  putp = s->putp;
+  putp = stream_get_endp(s);
 
   /* Forward word */
   stream_putw(s, 0);
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 44b130b..c4dc56f 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -84,13 +84,6 @@
 
 }
 
-/* forward output pointer. */
-void
-ospf_output_forward (struct stream *s, int size)
-{
-  s->putp += size;
-}
-
 struct ospf_packet *
 ospf_packet_new (size_t size)
 {
@@ -225,7 +218,6 @@
 ospf_stream_copy (struct stream *new, struct stream *s)
 {
   new->endp = s->endp;
-  new->putp = s->putp;
   new->getp = s->getp;
 
   memcpy (new->data, s->data, stream_get_endp (s));
@@ -571,7 +563,7 @@
         }
       
       iph->ip_off += offset;
-      stream_forward (op->s, iovp->iov_len);
+      stream_forward_getp (op->s, iovp->iov_len);
       iovp->iov_base = STREAM_PNT (op->s); 
     }
     
@@ -997,12 +989,12 @@
   struct ospf_lsa *new, *find;
   struct lsa_header *lsah;
 
-  stream_forward (s, OSPF_DB_DESC_MIN_SIZE);
+  stream_forward_getp (s, OSPF_DB_DESC_MIN_SIZE);
   for (size -= OSPF_DB_DESC_MIN_SIZE;
        size >= OSPF_LSA_HEADER_SIZE; size -= OSPF_LSA_HEADER_SIZE) 
     {
       lsah = (struct lsa_header *) STREAM_PNT (s);
-      stream_forward (s, OSPF_LSA_HEADER_SIZE);
+      stream_forward_getp (s, OSPF_LSA_HEADER_SIZE);
 
       /* Unknown LS type. */
       if (lsah->type < OSPF_MIN_LSA || lsah->type >= OSPF_MAX_LSA)
@@ -1492,7 +1484,7 @@
   size -= OSPF_LS_UPD_MIN_SIZE; /* # LSAs */
 
   for (; size >= OSPF_LSA_HEADER_SIZE && count > 0;
-       size -= length, stream_forward (s, length), count--)
+       size -= length, stream_forward_getp (s, length), count--)
     {
       lsah = (struct lsa_header *) STREAM_PNT (s);
       length = ntohs (lsah->length);
@@ -2016,7 +2008,7 @@
 
       /* lsah = (struct lsa_header *) STREAM_PNT (s); */
       size -= OSPF_LSA_HEADER_SIZE;
-      stream_forward (s, OSPF_LSA_HEADER_SIZE);
+      stream_forward_getp (s, OSPF_LSA_HEADER_SIZE);
 
       if (lsa->data->type < OSPF_MIN_LSA || lsa->data->type >= OSPF_MAX_LSA)
 	{
@@ -2402,7 +2394,7 @@
     }
 
   /* Adjust size to message length. */
-  stream_forward (ibuf, iph->ip_hl * 4);
+  stream_forward_getp (ibuf, iph->ip_hl * 4);
   
   /* Get ospf packet header. */
   ospfh = (struct ospf_header *) STREAM_PNT (ibuf);
@@ -2510,7 +2502,7 @@
       return ret;
     }
 
-  stream_forward (ibuf, OSPF_HEADER_SIZE);
+  stream_forward_getp (ibuf, OSPF_HEADER_SIZE);
 
   /* Adjust size to message length. */
   length = ntohs (ospfh->length) - OSPF_HEADER_SIZE;
@@ -2563,7 +2555,7 @@
 
   memset (ospfh->u.auth_data, 0, OSPF_AUTH_SIMPLE_SIZE);
 
-  ospf_output_forward (s, OSPF_HEADER_SIZE);
+  stream_forward_endp (s, OSPF_HEADER_SIZE);
 }
 
 /* Make Authentication Data. */
@@ -2665,7 +2657,7 @@
   /* Set Designated Router. */
   stream_put_ipv4 (s, DR (oi).s_addr);
 
-  p = stream_get_putp (s);
+  p = stream_get_endp (s);
 
   /* Set Backup Designated Router. */
   stream_put_ipv4 (s, BDR (oi).s_addr);
@@ -2736,7 +2728,7 @@
   stream_putc (s, options);
 
   /* Keep pointer to flags. */
-  pp = stream_get_putp (s);
+  pp = stream_get_endp (s);
   stream_putc (s, nbr->dd_flags);
 
   /* Set DD Sequence Number. */
@@ -2786,7 +2778,7 @@
 		
 		/* Keep pointer to LS age. */
 		lsah = (struct lsa_header *) (STREAM_DATA (s) +
-					      stream_get_putp (s));
+					      stream_get_endp (s));
 		
 		/* Proceed stream pointer. */
 		stream_put (s, lsa->data, OSPF_LSA_HEADER_SIZE);
@@ -2835,7 +2827,7 @@
 {
   struct ospf_lsa *lsa;
   u_int16_t length = OSPF_LS_REQ_MIN_SIZE;
-  unsigned long delta = stream_get_putp(s)+12;
+  unsigned long delta = stream_get_endp(s)+12;
   struct route_table *table;
   struct route_node *rn;
   int i;
@@ -2874,15 +2866,15 @@
   struct listnode *node;
   u_int16_t length = OSPF_LS_UPD_MIN_SIZE;
   unsigned int size_noauth;
-  unsigned long delta = stream_get_putp (s);
+  unsigned long delta = stream_get_endp (s);
   unsigned long pp;
   int count = 0;
 
   if (IS_DEBUG_OSPF_EVENT)
     zlog_debug ("ospf_make_ls_upd: Start");
 
-  pp = stream_get_putp (s);
-  ospf_output_forward (s, OSPF_LS_UPD_MIN_SIZE);
+  pp = stream_get_endp (s);
+  stream_forward_endp (s, OSPF_LS_UPD_MIN_SIZE);
 
   /* Calculate amount of packet usable for data. */
   size_noauth = stream_get_size(s) - ospf_packet_authspace(oi);
@@ -2904,7 +2896,7 @@
         break;
 
       /* Keep pointer to LS age. */
-      lsah = (struct lsa_header *) (STREAM_DATA (s) + stream_get_putp (s));
+      lsah = (struct lsa_header *) (STREAM_DATA (s) + stream_get_endp (s));
 
       /* Put LSA to Link State Request. */
       stream_put (s, lsa->data, ntohs (lsa->data->length));
@@ -2936,7 +2928,7 @@
   struct list *rm_list;
   struct listnode *node;
   u_int16_t length = OSPF_LS_ACK_MIN_SIZE;
-  unsigned long delta = stream_get_putp(s) + 24;
+  unsigned long delta = stream_get_endp(s) + 24;
   struct ospf_lsa *lsa;
 
   rm_list = list_new ();
diff --git a/ripd/ripd.c b/ripd/ripd.c
index c7ae00d..afdcd83 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -994,7 +994,7 @@
    * Set to placeholder value here, to true value when RIP-2 Packet length
    * is known.  Actual value is set in .....().
    */
-  len = stream_get_putp(s);
+  len = stream_get_endp(s);
   stream_putw (s, 0);
 
   /* Key ID. */
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index 77e559c..2f448ec 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -305,11 +305,11 @@
   icmp = (struct icmphdr *) (buf + sizeof (struct ip));
 
   /* Merge IP header with icmp packet */
-
-  stream_get(icmp, s, s->putp);
+  assert (stream_get_endp(s) < (sizeof (buf) - sizeof (struct ip)));
+  stream_get(icmp, s, stream_get_endp(s));
 
   /* icmp->checksum is already calculated */
-  ip->ip_len  = sizeof(struct ip) + s->putp;
+  ip->ip_len  = sizeof(struct ip) + stream_get_endp(s);
   stream_free(s); 
 
   on = 1;
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 10616b4..dfaa90e 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -480,7 +480,7 @@
     {
       if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
         {
-          nhnummark = stream_get_putp (s);
+          nhnummark = stream_get_endp (s);
           stream_putc (s, 1); /* placeholder */
           nhnum++;
 
@@ -562,7 +562,7 @@
     {
       stream_putl (s, rib->metric);
       num = 0;
-      nump = s->putp;
+      nump = stream_get_endp(s);
       stream_putc (s, 0);
       for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
 	if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
@@ -629,7 +629,7 @@
     {
       stream_putl (s, rib->metric);
       num = 0;
-      nump = s->putp;
+      nump = stream_get_endp(s);
       stream_putc (s, 0);
       for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
 	if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
@@ -690,7 +690,7 @@
     {
       stream_putl (s, rib->metric);
       num = 0;
-      nump = s->putp;
+      nump = stream_get_endp(s);
       stream_putc (s, 0);
       for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
 	if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
@@ -853,14 +853,14 @@
 	      break;
 	    case ZEBRA_NEXTHOP_IFNAME:
 	      ifname_len = stream_getc (s);
-	      stream_forward (s, ifname_len);
+	      stream_forward_getp (s, ifname_len);
 	      break;
 	    case ZEBRA_NEXTHOP_IPV4:
 	      nexthop.s_addr = stream_get_ipv4 (s);
 	      nexthop_ipv4_add (rib, &nexthop);
 	      break;
 	    case ZEBRA_NEXTHOP_IPV6:
-	      stream_forward (s, IPV6_MAX_BYTELEN);
+	      stream_forward_getp (s, IPV6_MAX_BYTELEN);
 	      break;
       case ZEBRA_NEXTHOP_BLACKHOLE:
         nexthop_blackhole_add (rib);
@@ -925,13 +925,13 @@
 	      break;
 	    case ZEBRA_NEXTHOP_IFNAME:
 	      ifname_len = stream_getc (s);
-	      stream_forward (s, ifname_len);
+	      stream_forward_getp (s, ifname_len);
 	      break;
 	    case ZEBRA_NEXTHOP_IPV4:
 	      nexthop.s_addr = stream_get_ipv4 (s);
 	      break;
 	    case ZEBRA_NEXTHOP_IPV6:
-	      stream_forward (s, IPV6_MAX_BYTELEN);
+	      stream_forward_getp (s, IPV6_MAX_BYTELEN);
 	      break;
 	    }
 	}