summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--bgpd/bgp_attr.c50
-rw-r--r--bgpd/bgp_dump.c8
-rw-r--r--bgpd/bgp_open.c14
-rw-r--r--bgpd/bgp_packet.c47
-rw-r--r--isisd/isis_lsp.c16
-rw-r--r--isisd/isis_network.c12
-rw-r--r--isisd/isis_pdu.c19
-rw-r--r--isisd/isis_tlv.c15
-rw-r--r--lib/ChangeLog8
-rw-r--r--lib/stream.c108
-rw-r--r--lib/stream.h11
-rw-r--r--ospfd/ospf_dump.c8
-rw-r--r--ospfd/ospf_lsa.c4
-rw-r--r--ospfd/ospf_packet.c42
-rw-r--r--ripd/ripd.c2
-rw-r--r--zebra/irdp_packet.c6
-rw-r--r--zebra/zserv.c16
18 files changed, 177 insertions, 217 deletions
diff --git a/ChangeLog b/ChangeLog
index 475f1ed9..c3c524cf 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 c702946b..417e6222 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -701,7 +701,7 @@ bgp_attr_aspath (struct peer *peer, bgp_size_t length,
}
/* 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 @@ bgp_attr_local_pref (struct peer *peer, bgp_size_t length,
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 @@ bgp_attr_community (struct peer *peer, bgp_size_t length,
{
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 @@ bgp_attr_cluster_list (struct peer *peer, bgp_size_t length,
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 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
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 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
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 @@ bgp_mp_unreach_parse (struct peer *peer, int length,
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 @@ bgp_attr_ext_communities (struct peer *peer, bgp_size_t length,
{
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 @@ bgp_attr_unknown (struct peer *peer, struct attr *attr, u_char flag,
"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_packet_attribute (struct bgp *bgp, struct peer *peer,
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 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
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 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
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 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
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 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
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 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
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 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
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 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
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 @@ bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix *p,
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 @@ bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix *p,
}
/* 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 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr,
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 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr,
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 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr,
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 549a4f08..0fb5ed8d 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -185,7 +185,7 @@ bgp_dump_header (struct stream *obuf, int type, int subtype)
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 @@ bgp_dump_routes_entry (struct prefix *p, struct bgp_info *info, int afi,
/* 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_state (struct peer *peer, int status_old, int status_new)
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_packet_func (struct bgp_dump *bgp_dump, struct peer *peer,
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 72503836..b1d0fc14 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -675,15 +675,15 @@ bgp_open_capability_orf (struct stream *s, struct peer *peer,
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 @@ bgp_open_capability_orf (struct stream *s, struct peer *peer,
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 @@ bgp_open_capability (struct stream *s, struct peer *peer)
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 @@ bgp_open_capability (struct stream *s, struct peer *peer)
}
/* 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 201ffbbe..8f7577be 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -67,7 +67,7 @@ bgp_packet_set_marker (struct stream *s, u_char type)
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 @@ bgp_packet_set_size (struct stream *s)
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 @@ bgp_packet_dup (struct stream *s)
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_update_packet (struct peer *peer, afi_t afi, safi_t safi)
{
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 @@ bgp_withdraw_packet (struct peer *peer, afi_t afi, safi_t safi)
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 @@ bgp_withdraw_packet (struct peer *peer, afi_t afi, safi_t safi)
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 @@ bgp_default_update_send (struct peer *peer, struct attr *attr,
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_default_withdraw_send (struct peer *peer, afi_t afi, safi_t safi)
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 @@ bgp_default_withdraw_send (struct peer *peer, afi_t afi, safi_t safi)
{
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 @@ bgp_default_withdraw_send (struct peer *peer, afi_t afi, safi_t safi)
}
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 @@ bgp_write (struct thread *thread)
}
if (num != writenum)
{
- stream_forward (s, num);
+ stream_forward_getp (s, num);
if (write_errno == EAGAIN)
break;
@@ -1016,7 +1011,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi,
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 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi,
}
/* 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 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
if (ret < 0)
return ret;
- stream_forward (peer->ibuf, optlen);
+ stream_forward_getp (peer->ibuf, optlen);
}
else
{
@@ -1506,7 +1501,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
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 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
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 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
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 @@ bgp_read_packet (struct peer *peer)
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 @@ bgp_read_packet (struct peer *peer)
}
/* 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 @@ bgp_read (struct thread *thread)
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 @@ bgp_read (struct thread *thread)
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 8dae147f..52d8884d 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -369,7 +369,6 @@ lsp_update_data (struct isis_lsp *lsp, struct stream *stream,
/* 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_new (u_char * lsp_id, u_int16_t rem_lifetime, u_int32_t seq_num,
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 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
}
}
- 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 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
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 @@ lsp_tlv_fit (struct isis_lsp *lsp, struct list **from, struct list **to,
}
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 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
/*
* 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 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
}
}
- 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 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
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 @@ build_topology_lsp_data (struct isis_lsp *lsp, struct isis_area *area,
}
/* 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 a0df32e3..2e901f1a 100644
--- a/isisd/isis_network.c
+++ b/isisd/isis_network.c
@@ -422,7 +422,6 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
/* 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 @@ isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
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 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
/* 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 @@ isis_send_pdu_p2p (struct isis_circuit *circuit, int level)
/* 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 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
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 @@ isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
return ISIS_WARNING;
}
- circuit->rcv_stream->putp = bytesread;
circuit->rcv_stream->endp = bytesread;
return ISIS_OK;
@@ -641,7 +638,8 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
/* 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 b6a035e1..6dcc75e9 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1938,7 +1938,7 @@ send_hello (struct isis_circuit *circuit, int level)
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 @@ send_hello (struct isis_circuit *circuit, int level)
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 @@ build_csnp (int level, u_char * start, u_char * stop, struct list *lsps,
* 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 @@ build_csnp (int level, u_char * start, u_char * stop, struct list *lsps,
{
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 @@ build_psnp (int level, struct isis_circuit *circuit, struct list *lsps)
/*
* 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 @@ build_psnp (int level, struct isis_circuit *circuit, struct list *lsps)
}
}
- 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 @@ build_link_state (struct isis_lsp *lsp, struct isis_circuit *circuit,
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 @@ send_lsp (struct thread *thread)
}
/* 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 @@ ack_lsp (struct isis_link_state_hdr *hdr, struct isis_circuit *circuit,
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 @@ ack_lsp (struct isis_link_state_hdr *hdr, struct isis_circuit *circuit,
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 84f36c93..bc653632 100644
--- a/isisd/isis_tlv.c
+++ b/isisd/isis_tlv.c
@@ -751,7 +751,7 @@ int
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 @@ tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream)
int
tlv_add_padding (struct stream *stream)
{
- unsigned long putp, endp;
int fullpads, i, left;
/*
@@ -1078,15 +1077,10 @@ tlv_add_padding (struct stream *stream)
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 @@ tlv_add_padding (struct stream *stream)
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 41308ff6..81865fb3 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 1b85b130..7a8bc458 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 @@ stream_get_getp (struct stream *s)
}
unsigned long
-stream_get_putp (struct stream *s)
-{
- return s->putp;
-}
-
-unsigned long
stream_get_endp (struct stream *s)
{
return s->endp;
@@ -97,17 +91,17 @@ stream_set_getp (struct stream *s, unsigned long pos)
s->getp = pos;
}
+/* Forward pointer. */
void
-stream_set_putp (struct stream *s, unsigned long pos)
+stream_forward_getp (struct stream *s, int size)
{
- s->putp = pos;
+ s->getp += size;
}
-/* Forward pointer. */
void
-stream_forward (struct stream *s, int size)
+stream_forward_endp (struct stream *s, int size)
{
- s->getp += size;
+ s->endp += size;
}
/* Copy from stream to destination. */
@@ -194,25 +188,22 @@ stream_put (struct stream *s, void *src, size_t size)
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->endp] = c;
+ s->endp++;
- s->data[s->putp] = c;
- s->putp++;
- if (s->putp > s->endp)
- s->endp = s->putp;
return 1;
}
@@ -220,13 +211,11 @@ stream_putc (struct stream *s, u_char c)
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 @@ stream_putw (struct stream *s, u_int16_t w)
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 @@ stream_putl_at (struct stream *s, unsigned long putp, u_int32_t l)
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 @@ stream_put_ipv4 (struct stream *s, u_int32_t l)
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 @@ stream_put_prefix (struct stream *s, struct prefix *p)
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 @@ stream_read (struct stream *s, int fd, size_t size)
{
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 @@ stream_read_unblock (struct stream *s, int fd, size_t size)
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 @@ stream_write (struct stream *s, u_char *ptr, size_t size)
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 @@ stream_pnt (struct stream *s)
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 @@ stream_empty (struct stream *s)
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 f7a94ea3..c7e4ffbf 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -32,9 +32,6 @@ struct stream
unsigned char *data;
- /* Put pointer. */
- unsigned long putp;
-
/* Get pointer. */
unsigned long getp;
@@ -57,7 +54,7 @@ struct stream_fifo
/* 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 @@ struct stream *stream_new (size_t);
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 dd712c3b..17cf28c7 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -455,7 +455,7 @@ ospf_lsa_header_list_dump (struct stream *s, u_int16_t length)
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 @@ ospf_packet_db_desc_dump (struct stream *s, u_int16_t length)
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 @@ ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length)
break;
}
- stream_forward (s, lsa_len);
+ stream_forward_getp (s, lsa_len);
length -= lsa_len;
count--;
}
@@ -673,7 +673,7 @@ ospf_packet_dump (struct stream *s)
/* 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 fbc56e15..13302dd3 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -407,7 +407,7 @@ lsa_header_set (struct stream *s, u_char options,
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 @@ ospf_router_lsa_body_set (struct stream *s, struct ospf_area *area)
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 44b130b7..c4dc56f0 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -84,13 +84,6 @@ ospf_auth_type (struct ospf_interface *oi)
}
-/* 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 @@ struct stream *
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 @@ ospf_write_frags (int fd, struct ospf_packet *op, struct ip *iph,
}
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 @@ ospf_db_desc_proc (struct stream *s, struct ospf_interface *oi,
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 @@ ospf_ls_upd_list_lsa (struct ospf_neighbor *nbr, struct stream *s,
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 @@ ospf_ls_ack (struct ip *iph, struct ospf_header *ospfh,
/* 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 @@ ospf_read (struct thread *thread)
}
/* 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 @@ ospf_read (struct thread *thread)
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 @@ ospf_make_header (int type, struct ospf_interface *oi, struct stream *s)
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 @@ ospf_make_hello (struct ospf_interface *oi, struct stream *s)
/* 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 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr,
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 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr,
/* 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 @@ ospf_make_ls_req (struct ospf_neighbor *nbr, struct stream *s)
{
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 @@ ospf_make_ls_upd (struct ospf_interface *oi, struct list *update, struct stream
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 @@ ospf_make_ls_upd (struct ospf_interface *oi, struct list *update, struct stream
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 @@ ospf_make_ls_ack (struct ospf_interface *oi, struct list *ack, struct stream *s)
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 c7ae00da..afdcd832 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -994,7 +994,7 @@ rip_auth_md5_ah_write (struct stream *s, struct rip_interface *ri,
* 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 77e559cc..2f448eca 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -305,11 +305,11 @@ send_packet(struct interface *ifp,
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 10616b41..dfaa90e7 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -480,7 +480,7 @@ zsend_route_multipath (int cmd, struct zserv *client, struct prefix *p,
{
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 @@ zsend_ipv6_nexthop_lookup (struct zserv *client, struct in6_addr *addr)
{
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 @@ zsend_ipv4_nexthop_lookup (struct zserv *client, struct in_addr addr)
{
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 @@ zsend_ipv4_import_lookup (struct zserv *client, struct prefix_ipv4 *p)
{
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 @@ zread_ipv4_add (struct zserv *client, u_short length)
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 @@ zread_ipv4_delete (struct zserv *client, u_short length)
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;
}
}