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.
This commit is contained in:
paul 2005-02-09 15:51:56 +00:00
parent 083ee9d9cd
commit 9985f83ce7
18 changed files with 179 additions and 219 deletions

View File

@ -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> 2005-01-24 Paul Jakma <paul@dishone.st>
* configure.ac: Bump version to 0.99.0 * configure.ac: Bump version to 0.99.0

View File

@ -701,7 +701,7 @@ bgp_attr_aspath (struct peer *peer, bgp_size_t length,
} }
/* Forward pointer. */ /* Forward pointer. */
stream_forward (peer->ibuf, length); stream_forward_getp (peer->ibuf, length);
/* Set aspath attribute flag. */ /* Set aspath attribute flag. */
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH); 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. */ receiving speaker. */
if (peer_sort (peer) == BGP_PEER_EBGP) if (peer_sort (peer) == BGP_PEER_EBGP)
{ {
stream_forward (peer->ibuf, length); stream_forward_getp (peer->ibuf, length);
return 0; return 0;
} }
@ -859,7 +859,7 @@ bgp_attr_community (struct peer *peer, bgp_size_t length,
{ {
attr->community = attr->community =
community_parse ((u_int32_t *)stream_pnt (peer->ibuf), length); 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); 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), attr->cluster = cluster_parse ((struct in_addr *)stream_pnt (peer->ibuf),
length); length);
stream_forward (peer->ibuf, length);; stream_forward_getp (peer->ibuf, length);;
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST); 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--) while (snpa_num--)
{ {
snpa_len = stream_getc (s); 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); 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->nlri = stream_pnt (s);
mp_update->length = nlri_len; mp_update->length = nlri_len;
stream_forward (s, nlri_len); stream_forward_getp (s, nlri_len);
return 0; return 0;
} }
@ -1045,7 +1045,7 @@ bgp_mp_unreach_parse (struct peer *peer, int length,
mp_withdraw->nlri = stream_pnt (s); mp_withdraw->nlri = stream_pnt (s);
mp_withdraw->length = withdraw_len; mp_withdraw->length = withdraw_len;
stream_forward (s, withdraw_len); stream_forward_getp (s, withdraw_len);
return 0; return 0;
} }
@ -1061,7 +1061,7 @@ bgp_attr_ext_communities (struct peer *peer, bgp_size_t length,
{ {
attr->ecommunity = attr->ecommunity =
ecommunity_parse ((u_int8_t *)stream_pnt (peer->ibuf), length); 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); 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); "Unknown attribute type %d length %d is received", type, length);
/* Forward read pointer of input stream. */ /* 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. */ /* Adjest total length to include type and length. */
total = length + (CHECK_FLAG (flag, BGP_ATTR_FLAG_EXTLEN) ? 4 : 3); 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 (); bgp = bgp_get_default ();
/* Remember current pointer. */ /* Remember current pointer. */
cp = stream_get_putp (s); cp = stream_get_endp (s);
/* Origin attribute. */ /* Origin attribute. */
stream_putc (s, BGP_ATTR_FLAG_TRANS); 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_FLAG_OPTIONAL);
stream_putc (s, BGP_ATTR_MP_REACH_NLRI); 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_putc (s, 0); /* Length of this attribute. */
stream_putw (s, AFI_IP6); /* AFI */ stream_putw (s, AFI_IP6); /* AFI */
stream_putc (s, safi); /* SAFI */ stream_putc (s, safi); /* SAFI */
@ -1555,7 +1555,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
stream_put_prefix (s, p); stream_put_prefix (s, p);
/* Set MP attribute length. */ /* 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 */ #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_FLAG_OPTIONAL);
stream_putc (s, BGP_ATTR_MP_REACH_NLRI); 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_putc (s, 0); /* Length of this attribute. */
stream_putw (s, AFI_IP); /* AFI */ stream_putw (s, AFI_IP); /* AFI */
stream_putc (s, SAFI_MULTICAST); /* SAFI */ stream_putc (s, SAFI_MULTICAST); /* SAFI */
@ -1580,7 +1580,7 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
stream_put_prefix (s, p); stream_put_prefix (s, p);
/* Set MP attribute length. */ /* 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) 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_FLAG_OPTIONAL);
stream_putc (s, BGP_ATTR_MP_REACH_NLRI); 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_putc (s, 0); /* Length of this attribute. */
stream_putw (s, AFI_IP); /* AFI */ stream_putw (s, AFI_IP); /* AFI */
stream_putc (s, BGP_SAFI_VPNV4); /* SAFI */ 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)); stream_put (s, &p->u.prefix, PSIZE (p->prefixlen));
/* Set MP attribute length. */ /* 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. */ /* 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); stream_put (s, attr->transit->val, attr->transit->length);
/* Return total size of attribute. */ /* Return total size of attribute. */
return stream_get_putp (s) - cp; return stream_get_endp (s) - cp;
} }
bgp_size_t bgp_size_t
@ -1696,12 +1696,12 @@ bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix *p,
unsigned long attrlen_pnt; unsigned long attrlen_pnt;
bgp_size_t size; 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_FLAG_OPTIONAL);
stream_putc (s, BGP_ATTR_MP_UNREACH_NLRI); 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_putc (s, 0); /* Length of this attribute. */
stream_putw (s, family2afi (p->family)); 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. */ /* 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); stream_putc_at (s, attrlen_pnt, size);
return stream_get_putp (s) - cp; return stream_get_endp (s) - cp;
} }
/* Initialization of attribute. */ /* Initialization of attribute. */
@ -1757,7 +1757,7 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr,
struct aspath *aspath; struct aspath *aspath;
/* Remember current pointer. */ /* Remember current pointer. */
cp = stream_get_putp (s); cp = stream_get_endp (s);
/* Place holder of length. */ /* Place holder of length. */
stream_putw (s, 0); 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_FLAG_OPTIONAL);
stream_putc(s, BGP_ATTR_MP_REACH_NLRI); stream_putc(s, BGP_ATTR_MP_REACH_NLRI);
sizep = stream_get_putp (s); sizep = stream_get_endp (s);
/* MP header */ /* MP header */
stream_putc (s, 0); /* Length of this attribute. */ 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); stream_put_prefix(s, prefix);
/* Set MP attribute length. */ /* 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 */ #endif /* HAVE_IPV6 */
/* Return total size of attribute. */ /* 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); stream_putw_at (s, cp, len);
} }

View File

@ -185,7 +185,7 @@ bgp_dump_header (struct stream *obuf, int type, int subtype)
void void
bgp_dump_set_size (struct stream *s, int type) 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 void
@ -290,7 +290,7 @@ bgp_dump_routes_entry (struct prefix *p, struct bgp_info *info, int afi,
/* Set length. */ /* Set length. */
bgp_dump_set_size (obuf, type); 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); 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); bgp_dump_set_size (obuf, MSG_PROTOCOL_BGP4MP);
/* Write to the stream. */ /* 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); 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); bgp_dump_set_size (obuf, MSG_PROTOCOL_BGP4MP);
/* Write to the stream. */ /* 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); fflush (bgp_dump->fp);
} }

View File

@ -675,15 +675,15 @@ bgp_open_capability_orf (struct stream *s, struct peer *peer,
safi = BGP_SAFI_VPNV4; safi = BGP_SAFI_VPNV4;
stream_putc (s, BGP_OPEN_OPT_CAP); 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, 0); /* Capability Length */
stream_putc (s, code); /* Capability Code */ 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_putc (s, 0); /* ORF Length */
stream_putw (s, afi); stream_putw (s, afi);
stream_putc (s, 0); stream_putc (s, 0);
stream_putc (s, safi); 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 */ stream_putc (s, 0); /* Number of ORFs */
/* Address Prefix ORF */ /* 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); stream_putc_at (s, numberp, number_of_orfs);
/* Total ORF Len. */ /* 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); stream_putc_at (s, orfp, orf_len);
/* Total Capability 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); stream_putc_at (s, capp, cap_len);
} }
@ -735,7 +735,7 @@ bgp_open_capability (struct stream *s, struct peer *peer)
safi_t safi; safi_t safi;
/* Remember current pointer for Opt Parm Len. */ /* Remember current pointer for Opt Parm Len. */
cp = stream_get_putp (s); cp = stream_get_endp (s);
/* Opt Parm Len. */ /* Opt Parm Len. */
stream_putc (s, 0); stream_putc (s, 0);
@ -851,6 +851,6 @@ bgp_open_capability (struct stream *s, struct peer *peer)
} }
/* Total Opt Parm Len. */ /* Total Opt Parm Len. */
len = stream_get_putp (s) - cp - 1; len = stream_get_endp (s) - cp - 1;
stream_putc_at (s, cp, len); stream_putc_at (s, cp, len);
} }

View File

@ -67,7 +67,7 @@ bgp_packet_set_marker (struct stream *s, u_char type)
stream_putc (s, type); stream_putc (s, type);
/* Return current stream size. */ /* 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 /* 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; int cp;
/* Preserve current pointer. */ /* Preserve current pointer. */
cp = stream_get_putp (s); cp = stream_get_endp (s);
stream_set_putp (s, BGP_MARKER_SIZE); stream_putw_at (s, BGP_MARKER_SIZE, cp);
stream_putw (s, cp);
/* Write back current pointer. */
stream_set_putp (s, cp);
return cp; return cp;
} }
@ -112,7 +108,6 @@ bgp_packet_dup (struct stream *s)
new = stream_new (stream_get_endp (s)); new = stream_new (stream_get_endp (s));
new->endp = s->endp; new->endp = s->endp;
new->putp = s->putp;
new->getp = s->getp; new->getp = s->getp;
memcpy (new->data, s->data, stream_get_endp (s)); 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); bgp_packet_set_marker (s, BGP_MSG_UPDATE);
stream_putw (s, 0); stream_putw (s, 0);
pos = stream_get_putp (s); pos = stream_get_endp (s);
stream_putw (s, 0); stream_putw (s, 0);
total_attr_len = bgp_packet_attribute (NULL, peer, s, total_attr_len = bgp_packet_attribute (NULL, peer, s,
adv->baa->attr, 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); stream_put_prefix (s, &rn->p);
else else
{ {
pos = stream_get_putp (s); pos = stream_get_endp (s);
stream_putw (s, 0); stream_putw (s, 0);
total_attr_len total_attr_len
= bgp_packet_withdraw (peer, s, &rn->p, afi, safi, prd, NULL); = 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) if (afi == AFI_IP && safi == SAFI_UNICAST)
{ {
unfeasible_len 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_at (s, BGP_HEADER_SIZE, unfeasible_len);
stream_putw (s, 0); stream_putw (s, 0);
} }
@ -414,7 +409,7 @@ bgp_default_update_send (struct peer *peer, struct attr *attr,
stream_putw (s, 0); stream_putw (s, 0);
/* Make place for total attribute length. */ /* Make place for total attribute length. */
pos = stream_get_putp (s); pos = stream_get_endp (s);
stream_putw (s, 0); stream_putw (s, 0);
total_attr_len = bgp_packet_attribute (NULL, peer, s, attr, &p, afi, safi, from, NULL, NULL); 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); bgp_packet_set_marker (s, BGP_MSG_UPDATE);
/* Unfeasible Routes Length. */; /* Unfeasible Routes Length. */;
cp = stream_get_putp (s); cp = stream_get_endp (s);
stream_putw (s, 0); stream_putw (s, 0);
/* Withdrawn Routes. */ /* Withdrawn Routes. */
@ -487,7 +482,7 @@ bgp_default_withdraw_send (struct peer *peer, afi_t afi, safi_t safi)
{ {
stream_put_prefix (s, &p); stream_put_prefix (s, &p);
unfeasible_len = stream_get_putp (s) - cp - 2; unfeasible_len = stream_get_endp (s) - cp - 2;
/* Set unfeasible len. */ /* Set unfeasible len. */
stream_putw_at (s, cp, 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 else
{ {
pos = stream_get_putp (s); pos = stream_get_endp (s);
stream_putw (s, 0); stream_putw (s, 0);
total_attr_len = bgp_packet_withdraw (peer, s, &p, afi, safi, NULL, NULL); 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) if (num != writenum)
{ {
stream_forward (s, num); stream_forward_getp (s, num);
if (write_errno == EAGAIN) if (write_errno == EAGAIN)
break; break;
@ -1016,7 +1011,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi,
orf_refresh = 1; orf_refresh = 1;
stream_putc (s, when_to_refresh); stream_putc (s, when_to_refresh);
stream_putc (s, orf_type); stream_putc (s, orf_type);
orfp = stream_get_putp (s); orfp = stream_get_endp (s);
stream_putw (s, 0); stream_putw (s, 0);
if (remove) if (remove)
@ -1043,7 +1038,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi,
} }
/* Total ORF Entry Len. */ /* 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); stream_putw_at (s, orfp, orf_len);
} }
@ -1398,7 +1393,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
if (ret < 0) if (ret < 0)
return ret; return ret;
stream_forward (peer->ibuf, optlen); stream_forward_getp (peer->ibuf, optlen);
} }
else else
{ {
@ -1506,7 +1501,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
withdraw.safi = SAFI_UNICAST; withdraw.safi = SAFI_UNICAST;
withdraw.nlri = stream_pnt (s); withdraw.nlri = stream_pnt (s);
withdraw.length = withdraw_len; withdraw.length = withdraw_len;
stream_forward (s, withdraw_len); stream_forward_getp (s, withdraw_len);
} }
/* Attribute total length check. */ /* Attribute total length check. */
@ -1568,7 +1563,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
update.safi = SAFI_UNICAST; update.safi = SAFI_UNICAST;
update.nlri = stream_pnt (s); update.nlri = stream_pnt (s);
update.length = update_len; 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 /* 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] = peer->orf_plist[afi][safi] =
prefix_list_lookup (AFI_ORF_PREFIX, name); prefix_list_lookup (AFI_ORF_PREFIX, name);
} }
stream_forward (s, orf_len); stream_forward_getp (s, orf_len);
} }
if (BGP_DEBUG (normal, NORMAL)) if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s rcvd Refresh %s ORF request", peer->host, zlog_debug ("%s rcvd Refresh %s ORF request", peer->host,
@ -2162,7 +2157,7 @@ bgp_read_packet (struct peer *peer)
int nbytes; int nbytes;
int readsize; 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 size is zero then return. */
if (! readsize) if (! readsize)
@ -2218,7 +2213,7 @@ bgp_read_packet (struct peer *peer)
} }
/* We read partial packet. */ /* We read partial packet. */
if (peer->ibuf->putp != peer->packet_size) if (stream_get_endp (peer->ibuf) != peer->packet_size)
return -1; return -1;
return 0; return 0;
@ -2271,7 +2266,7 @@ bgp_read (struct thread *thread)
if (peer->packet_size == 0) if (peer->packet_size == 0)
peer->packet_size = BGP_HEADER_SIZE; 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); ret = bgp_read_packet (peer);
@ -2280,7 +2275,7 @@ bgp_read (struct thread *thread)
goto done; goto done;
/* Get size and type. */ /* 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); memcpy (notify_data_length, stream_pnt (peer->ibuf), 2);
size = stream_getw (peer->ibuf); size = stream_getw (peer->ibuf);
type = stream_getc (peer->ibuf); type = stream_getc (peer->ibuf);

View File

@ -369,7 +369,6 @@ lsp_update_data (struct isis_lsp *lsp, struct stream *stream,
/* copying only the relevant part of our stream */ /* copying only the relevant part of our stream */
lsp->pdu = stream_new (stream->endp); lsp->pdu = stream_new (stream->endp);
lsp->pdu->putp = stream->putp;
lsp->pdu->getp = stream->getp; lsp->pdu->getp = stream->getp;
lsp->pdu->endp = stream->endp; lsp->pdu->endp = stream->endp;
memcpy (lsp->pdu->data, stream->data, 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->level = level;
lsp->age_out = ZERO_AGE_LIFETIME; 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 */ /* #ifdef EXTREME_DEBUG */
/* logging */ /* 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) if (lsp->tlv_data.nlpids)
tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu); 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); tlv_add_ipv6_reachs (lsp->tlv_data.ipv6_reachs, lsp->pdu);
#endif /* HAVE_IPV6 */ #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; return;
} }
@ -1200,7 +1199,7 @@ lsp_tlv_fit (struct isis_lsp *lsp, struct list **from, struct list **to,
} }
tlv_build_func (*to, lsp->pdu); 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; return;
} }
@ -1319,7 +1318,7 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
/* /*
* Building the zero lsp * 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 * 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 * 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) if (lsp->tlv_data.es_neighs && listcount (lsp->tlv_data.es_neighs) > 0)
tlv_add_is_neighs (lsp->tlv_data.es_neighs, lsp->pdu); 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, iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
ntohs (lsp->lsp_header->pdu_len) - 12, 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 */ /* 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); lsp->pdu->endp = ntohs (lsp->lsp_header->pdu_len);
} }
#endif /* TOPOLOGY_GENERATE */ #endif /* TOPOLOGY_GENERATE */

View File

@ -422,7 +422,6 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
/* then we lose the LLC */ /* then we lose the LLC */
memcpy (STREAM_DATA (circuit->rcv_stream), memcpy (STREAM_DATA (circuit->rcv_stream),
sock_buff + LLC_LEN, bytesread - LLC_LEN); sock_buff + LLC_LEN, bytesread - LLC_LEN);
circuit->rcv_stream->putp = bytesread - LLC_LEN;
circuit->rcv_stream->endp = bytesread - LLC_LEN; circuit->rcv_stream->endp = bytesread - LLC_LEN;
memcpy (ssnpa, &s_addr.sll_addr, s_addr.sll_halen); 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; return ISIS_WARNING;
} }
circuit->rcv_stream->putp = bytesread;
circuit->rcv_stream->endp = bytesread; circuit->rcv_stream->endp = bytesread;
/* If we don't have protocol type 0x00FE which is /* 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 */ /* now we can send this */
written = sendto (circuit->fd, sock_buff, 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)); (struct sockaddr *) &sa, sizeof (struct sockaddr_ll));
return ISIS_OK; return ISIS_OK;
@ -531,7 +529,8 @@ isis_send_pdu_p2p (struct isis_circuit *circuit, int level)
/* lets try correcting the protocol */ /* lets try correcting the protocol */
sa.sll_protocol = htons (0x00FE); sa.sll_protocol = htons (0x00FE);
written = sendto (circuit->fd, circuit->snd_stream->data, 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)); sizeof (struct sockaddr_ll));
return ISIS_OK; return ISIS_OK;
@ -576,7 +575,6 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
memcpy (STREAM_DATA (circuit->rcv_stream), memcpy (STREAM_DATA (circuit->rcv_stream),
readbuff + offset, bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN); 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->endp = bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN;
circuit->rcv_stream->getp = 0; circuit->rcv_stream->getp = 0;
@ -603,7 +601,6 @@ isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
return ISIS_WARNING; return ISIS_WARNING;
} }
circuit->rcv_stream->putp = bytesread;
circuit->rcv_stream->endp = bytesread; circuit->rcv_stream->endp = bytesread;
return ISIS_OK; return ISIS_OK;
@ -641,7 +638,8 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
/* now we can send this */ /* now we can send this */
written = write (circuit->fd, sock_buff, 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; return ISIS_OK;
} }

View File

@ -1938,7 +1938,7 @@ send_hello (struct isis_circuit *circuit, int level)
hello_hdr.hold_time = htons ((u_int16_t) interval); hello_hdr.hold_time = htons ((u_int16_t) interval);
hello_hdr.pdu_len = 0; /* Update the PDU Length later */ 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 */ /* copy the shared part of the hello to the p2p hello if needed */
if (circuit->circ_type == CIRCUIT_T_P2P) 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)) if (tlv_add_padding (circuit->snd_stream))
return ISIS_WARNING; return ISIS_WARNING;
length = stream_get_putp (circuit->snd_stream); length = stream_get_endp (circuit->snd_stream);
/* Update PDU length */ /* Update PDU length */
stream_putw_at (circuit->snd_stream, len_pointer, (u_int16_t) 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 * 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 */ 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 */ /* 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); 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); 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); assert (length >= ISIS_CSNP_HDRLEN);
/* Update PU length */ /* Update PU length */
stream_putw_at (circuit->snd_stream, lenp, 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 * 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_putw (circuit->snd_stream, 0); /* PDU length - when we know it */
stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN); stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
stream_putc (circuit->snd_stream, circuit->idx); 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); assert (length >= ISIS_PSNP_HDRLEN);
/* Update PDU length */ /* Update PDU length */
stream_putw_at (circuit->snd_stream, lenp, 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; unsigned long length;
stream_put (stream, lsp->pdu, ntohs (lsp->lsp_header->pdu_len)); stream_put (stream, lsp->pdu, ntohs (lsp->lsp_header->pdu_len));
length = stream_get_putp (stream); length = stream_get_endp (stream);
return; return;
} */ } */
@ -2501,7 +2501,6 @@ send_lsp (struct thread *thread)
} }
/* copy our lsp to the send buffer */ /* copy our lsp to the send buffer */
circuit->snd_stream->getp = lsp->pdu->getp; circuit->snd_stream->getp = lsp->pdu->getp;
circuit->snd_stream->putp = lsp->pdu->putp;
circuit->snd_stream->endp = lsp->pdu->endp; circuit->snd_stream->endp = lsp->pdu->endp;
memcpy (circuit->snd_stream->data, lsp->pdu->data, 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); 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_putw (circuit->snd_stream, 0); /* PDU length */
stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN); stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
stream_putc (circuit->snd_stream, circuit->idx); 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_putl (circuit->snd_stream, ntohl (hdr->seq_num));
stream_putw (circuit->snd_stream, ntohs (hdr->checksum)); 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 */ /* Update PDU length */
stream_putw_at (circuit->snd_stream, lenp, length); stream_putw_at (circuit->snd_stream, lenp, length);

View File

@ -751,7 +751,7 @@ int
add_tlv (u_char tag, u_char len, u_char * value, struct stream *stream) 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); zlog_warn ("No room for TLV of type %d", tag);
return ISIS_WARNING; return ISIS_WARNING;
@ -1065,7 +1065,6 @@ tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream)
int int
tlv_add_padding (struct stream *stream) tlv_add_padding (struct stream *stream)
{ {
unsigned long putp, endp;
int fullpads, i, left; int fullpads, i, left;
/* /*
@ -1078,15 +1077,10 @@ tlv_add_padding (struct stream *stream)
goto err; goto err;
if (!stream_putc (stream, (u_char) 255)) /* LENGHT */ if (!stream_putc (stream, (u_char) 255)) /* LENGHT */
goto err; goto err;
endp = stream_get_endp (stream); stream_forward_endp (stream, 255); /* VALUE */
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;
} }
left = STREAM_SIZE (stream) - stream_get_putp (stream); left = STREAM_SIZE (stream) - stream_get_endp (stream);
if (left < 2) if (left < 2)
return ISIS_OK; return ISIS_OK;
@ -1100,8 +1094,7 @@ tlv_add_padding (struct stream *stream)
stream_putc (stream, PADDING); stream_putc (stream, PADDING);
stream_putc (stream, left - 2); stream_putc (stream, left - 2);
stream_set_putp (stream, stream_get_putp (stream) + left - 2); stream_forward_endp (stream, left - 2);
stream->endp = stream->putp;
return ISIS_OK; return ISIS_OK;

View File

@ -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> 2005-02-08 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Change macro definitions SET_FLAG and UNSET_FLAG * zebra.h: Change macro definitions SET_FLAG and UNSET_FLAG

View File

@ -35,8 +35,8 @@
*/ */
#define CHECK_SIZE(S, Z) \ #define CHECK_SIZE(S, Z) \
if (((S)->putp + (Z)) > (S)->size) \ if (((S)->endp + (Z)) > (S)->size) \
(Z) = (S)->size - (S)->putp; (Z) = (S)->size - (S)->endp;
/* Stream is fixed length buffer for network output/input. */ /* Stream is fixed length buffer for network output/input. */
@ -72,12 +72,6 @@ stream_get_getp (struct stream *s)
return s->getp; return s->getp;
} }
unsigned long
stream_get_putp (struct stream *s)
{
return s->putp;
}
unsigned long unsigned long
stream_get_endp (struct stream *s) stream_get_endp (struct stream *s)
{ {
@ -97,18 +91,18 @@ stream_set_getp (struct stream *s, unsigned long pos)
s->getp = pos; s->getp = pos;
} }
void
stream_set_putp (struct stream *s, unsigned long pos)
{
s->putp = pos;
}
/* Forward pointer. */ /* Forward pointer. */
void void
stream_forward (struct stream *s, int size) stream_forward_getp (struct stream *s, int size)
{ {
s->getp += size; s->getp += size;
} }
void
stream_forward_endp (struct stream *s, int size)
{
s->endp += size;
}
/* Copy from stream to destination. */ /* Copy from stream to destination. */
void void
@ -194,25 +188,22 @@ stream_put (struct stream *s, void *src, size_t size)
CHECK_SIZE(s, size); CHECK_SIZE(s, size);
if (src) if (src)
memcpy (s->data + s->putp, src, size); memcpy (s->data + s->endp, src, size);
else else
memset (s->data + s->putp, 0, size); memset (s->data + s->endp, 0, size);
s->putp += size; s->endp += size;
if (s->putp > s->endp)
s->endp = s->putp;
} }
/* Put character to the stream. */ /* Put character to the stream. */
int int
stream_putc (struct stream *s, u_char c) 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; return 1;
} }
@ -220,13 +211,11 @@ stream_putc (struct stream *s, u_char c)
int int
stream_putw (struct stream *s, u_int16_t w) 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->endp++] = (u_char)(w >> 8);
s->data[s->putp++] = (u_char) w; s->data[s->endp++] = (u_char) w;
if (s->putp > s->endp)
s->endp = s->putp;
return 2; return 2;
} }
@ -234,15 +223,13 @@ stream_putw (struct stream *s, u_int16_t w)
int int
stream_putl (struct stream *s, u_int32_t l) 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->endp++] = (u_char)(l >> 24);
s->data[s->putp++] = (u_char)(l >> 16); s->data[s->endp++] = (u_char)(l >> 16);
s->data[s->putp++] = (u_char)(l >> 8); s->data[s->endp++] = (u_char)(l >> 8);
s->data[s->putp++] = (u_char)l; s->data[s->endp++] = (u_char)l;
if (s->putp > s->endp)
s->endp = s->putp;
return 4; return 4;
} }
@ -275,14 +262,12 @@ stream_putl_at (struct stream *s, unsigned long putp, u_int32_t l)
int int
stream_put_ipv4 (struct stream *s, u_int32_t l) stream_put_ipv4 (struct stream *s, u_int32_t l)
{ {
if ((s->size - s->putp) < 4) if ((s->size - s->endp) < 4)
return 0; return 0;
memcpy (s->data + s->putp, &l, 4); memcpy (s->data + s->endp, &l, 4);
s->putp += 4; s->endp += 4;
if (s->putp > s->endp)
s->endp = s->putp;
return 4; return 4;
} }
@ -290,14 +275,12 @@ stream_put_ipv4 (struct stream *s, u_int32_t l)
int int
stream_put_in_addr (struct stream *s, struct in_addr *addr) 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; return 0;
memcpy (s->data + s->putp, addr, 4); memcpy (s->data + s->endp, addr, 4);
s->putp += 4; s->endp += 4;
if (s->putp > s->endp)
s->endp = s->putp;
return 4; return 4;
} }
@ -309,14 +292,11 @@ stream_put_prefix (struct stream *s, struct prefix *p)
psize = PSIZE (p->prefixlen); 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); stream_putc (s, p->prefixlen);
memcpy (s->data + s->putp, &p->u.prefix, psize); memcpy (s->data + s->endp, &p->u.prefix, psize);
s->putp += psize; s->endp += psize;
if (s->putp > s->endp)
s->endp = s->putp;
return psize; return psize;
} }
@ -327,13 +307,11 @@ stream_read (struct stream *s, int fd, size_t size)
{ {
int nbytes; int nbytes;
nbytes = readn (fd, s->data + s->putp, size); nbytes = readn (fd, s->data + s->endp, size);
if (nbytes > 0) if (nbytes > 0)
{ s->endp += nbytes;
s->putp += nbytes;
s->endp += nbytes;
}
return nbytes; return nbytes;
} }
@ -346,14 +324,12 @@ stream_read_unblock (struct stream *s, int fd, size_t size)
val = fcntl (fd, F_GETFL, 0); val = fcntl (fd, F_GETFL, 0);
fcntl (fd, F_SETFL, val|O_NONBLOCK); 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); fcntl (fd, F_SETFL, val);
if (nbytes > 0) if (nbytes > 0)
{ s->endp += nbytes;
s->putp += nbytes;
s->endp += nbytes;
}
return nbytes; return nbytes;
} }
@ -364,10 +340,9 @@ stream_write (struct stream *s, u_char *ptr, size_t size)
CHECK_SIZE(s, size); CHECK_SIZE(s, size);
memcpy (s->data + s->putp, ptr, size); memcpy (s->data + s->endp, ptr, size);
s->putp += size; s->endp += size;
if (s->putp > s->endp)
s->endp = s->putp;
return size; return size;
} }
@ -382,7 +357,7 @@ stream_pnt (struct stream *s)
int int
stream_empty (struct stream *s) stream_empty (struct stream *s)
{ {
if (s->putp == 0 && s->endp == 0 && s->getp == 0) if (s->endp == 0 && s->getp == 0)
return 1; return 1;
else else
return 0; return 0;
@ -392,7 +367,6 @@ stream_empty (struct stream *s)
void void
stream_reset (struct stream *s) stream_reset (struct stream *s)
{ {
s->putp = 0;
s->endp = 0; s->endp = 0;
s->getp = 0; s->getp = 0;
} }

View File

@ -32,9 +32,6 @@ struct stream
unsigned char *data; unsigned char *data;
/* Put pointer. */
unsigned long putp;
/* Get pointer. */ /* Get pointer. */
unsigned long getp; unsigned long getp;
@ -57,7 +54,7 @@ struct stream_fifo
/* Utility macros. */ /* Utility macros. */
#define STREAM_PNT(S) ((S)->data + (S)->getp) #define STREAM_PNT(S) ((S)->data + (S)->getp)
#define STREAM_SIZE(S) ((S)->size) #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) #define STREAM_DATA(S) ((S)->data)
/* Stream prototypes. */ /* Stream prototypes. */
@ -65,15 +62,13 @@ struct stream *stream_new (size_t);
void stream_free (struct stream *); void stream_free (struct stream *);
unsigned long stream_get_getp (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_endp (struct stream *);
unsigned long stream_get_size (struct stream *); unsigned long stream_get_size (struct stream *);
u_char *stream_get_data (struct stream *); u_char *stream_get_data (struct stream *);
void stream_set_getp (struct stream *, unsigned long); void stream_set_getp (struct stream *, unsigned long);
void stream_set_putp (struct stream *, unsigned long); void stream_forward_getp (struct stream *, int);
void stream_forward_endp (struct stream *, int);
void stream_forward (struct stream *, int);
void stream_put (struct stream *, void *, size_t); void stream_put (struct stream *, void *, size_t);
int stream_putc (struct stream *, u_char); int stream_putc (struct stream *, u_char);

View File

@ -455,7 +455,7 @@ ospf_lsa_header_list_dump (struct stream *s, u_int16_t length)
lsa = (struct lsa_header *) STREAM_PNT (s); lsa = (struct lsa_header *) STREAM_PNT (s);
ospf_lsa_header_dump (lsa); 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; 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; 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); ospf_lsa_header_list_dump (s, length);
@ -577,7 +577,7 @@ ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length)
break; break;
} }
stream_forward (s, lsa_len); stream_forward_getp (s, lsa_len);
length -= lsa_len; length -= lsa_len;
count--; count--;
} }
@ -673,7 +673,7 @@ ospf_packet_dump (struct stream *s)
/* Show OSPF header detail. */ /* Show OSPF header detail. */
ospf_header_dump (ospfh); ospf_header_dump (ospfh);
stream_forward (s, OSPF_HEADER_SIZE); stream_forward_getp (s, OSPF_HEADER_SIZE);
switch (ospfh->type) switch (ospfh->type)
{ {

View File

@ -407,7 +407,7 @@ lsa_header_set (struct stream *s, u_char options,
lsah->adv_router = router_id; lsah->adv_router = router_id;
lsah->ls_seqnum = htonl (OSPF_INITIAL_SEQUENCE_NUMBER); 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); stream_putc (s, 0);
/* Keep pointer to # links. */ /* Keep pointer to # links. */
putp = s->putp; putp = stream_get_endp(s);
/* Forward word */ /* Forward word */
stream_putw(s, 0); stream_putw(s, 0);

View File

@ -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 * struct ospf_packet *
ospf_packet_new (size_t size) ospf_packet_new (size_t size)
{ {
@ -225,7 +218,6 @@ struct stream *
ospf_stream_copy (struct stream *new, struct stream *s) ospf_stream_copy (struct stream *new, struct stream *s)
{ {
new->endp = s->endp; new->endp = s->endp;
new->putp = s->putp;
new->getp = s->getp; new->getp = s->getp;
memcpy (new->data, s->data, stream_get_endp (s)); 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; 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); 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 ospf_lsa *new, *find;
struct lsa_header *lsah; 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; for (size -= OSPF_DB_DESC_MIN_SIZE;
size >= OSPF_LSA_HEADER_SIZE; size -= OSPF_LSA_HEADER_SIZE) size >= OSPF_LSA_HEADER_SIZE; size -= OSPF_LSA_HEADER_SIZE)
{ {
lsah = (struct lsa_header *) STREAM_PNT (s); 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. */ /* Unknown LS type. */
if (lsah->type < OSPF_MIN_LSA || lsah->type >= OSPF_MAX_LSA) 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 */ size -= OSPF_LS_UPD_MIN_SIZE; /* # LSAs */
for (; size >= OSPF_LSA_HEADER_SIZE && count > 0; 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); lsah = (struct lsa_header *) STREAM_PNT (s);
length = ntohs (lsah->length); 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); */ /* lsah = (struct lsa_header *) STREAM_PNT (s); */
size -= OSPF_LSA_HEADER_SIZE; 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) 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. */ /* Adjust size to message length. */
stream_forward (ibuf, iph->ip_hl * 4); stream_forward_getp (ibuf, iph->ip_hl * 4);
/* Get ospf packet header. */ /* Get ospf packet header. */
ospfh = (struct ospf_header *) STREAM_PNT (ibuf); ospfh = (struct ospf_header *) STREAM_PNT (ibuf);
@ -2510,7 +2502,7 @@ ospf_read (struct thread *thread)
return ret; return ret;
} }
stream_forward (ibuf, OSPF_HEADER_SIZE); stream_forward_getp (ibuf, OSPF_HEADER_SIZE);
/* Adjust size to message length. */ /* Adjust size to message length. */
length = ntohs (ospfh->length) - OSPF_HEADER_SIZE; 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); 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. */ /* Make Authentication Data. */
@ -2665,7 +2657,7 @@ ospf_make_hello (struct ospf_interface *oi, struct stream *s)
/* Set Designated Router. */ /* Set Designated Router. */
stream_put_ipv4 (s, DR (oi).s_addr); stream_put_ipv4 (s, DR (oi).s_addr);
p = stream_get_putp (s); p = stream_get_endp (s);
/* Set Backup Designated Router. */ /* Set Backup Designated Router. */
stream_put_ipv4 (s, BDR (oi).s_addr); 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); stream_putc (s, options);
/* Keep pointer to flags. */ /* Keep pointer to flags. */
pp = stream_get_putp (s); pp = stream_get_endp (s);
stream_putc (s, nbr->dd_flags); stream_putc (s, nbr->dd_flags);
/* Set DD Sequence Number. */ /* 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. */ /* Keep pointer to LS age. */
lsah = (struct lsa_header *) (STREAM_DATA (s) + lsah = (struct lsa_header *) (STREAM_DATA (s) +
stream_get_putp (s)); stream_get_endp (s));
/* Proceed stream pointer. */ /* Proceed stream pointer. */
stream_put (s, lsa->data, OSPF_LSA_HEADER_SIZE); 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; struct ospf_lsa *lsa;
u_int16_t length = OSPF_LS_REQ_MIN_SIZE; 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_table *table;
struct route_node *rn; struct route_node *rn;
int i; int i;
@ -2874,15 +2866,15 @@ ospf_make_ls_upd (struct ospf_interface *oi, struct list *update, struct stream
struct listnode *node; struct listnode *node;
u_int16_t length = OSPF_LS_UPD_MIN_SIZE; u_int16_t length = OSPF_LS_UPD_MIN_SIZE;
unsigned int size_noauth; unsigned int size_noauth;
unsigned long delta = stream_get_putp (s); unsigned long delta = stream_get_endp (s);
unsigned long pp; unsigned long pp;
int count = 0; int count = 0;
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_make_ls_upd: Start"); zlog_debug ("ospf_make_ls_upd: Start");
pp = stream_get_putp (s); pp = stream_get_endp (s);
ospf_output_forward (s, OSPF_LS_UPD_MIN_SIZE); stream_forward_endp (s, OSPF_LS_UPD_MIN_SIZE);
/* Calculate amount of packet usable for data. */ /* Calculate amount of packet usable for data. */
size_noauth = stream_get_size(s) - ospf_packet_authspace(oi); 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; break;
/* Keep pointer to LS age. */ /* 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. */ /* Put LSA to Link State Request. */
stream_put (s, lsa->data, ntohs (lsa->data->length)); 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 list *rm_list;
struct listnode *node; struct listnode *node;
u_int16_t length = OSPF_LS_ACK_MIN_SIZE; 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; struct ospf_lsa *lsa;
rm_list = list_new (); rm_list = list_new ();

View File

@ -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 * Set to placeholder value here, to true value when RIP-2 Packet length
* is known. Actual value is set in .....(). * is known. Actual value is set in .....().
*/ */
len = stream_get_putp(s); len = stream_get_endp(s);
stream_putw (s, 0); stream_putw (s, 0);
/* Key ID. */ /* Key ID. */

View File

@ -305,11 +305,11 @@ send_packet(struct interface *ifp,
icmp = (struct icmphdr *) (buf + sizeof (struct ip)); icmp = (struct icmphdr *) (buf + sizeof (struct ip));
/* Merge IP header with icmp packet */ /* Merge IP header with icmp packet */
assert (stream_get_endp(s) < (sizeof (buf) - sizeof (struct ip)));
stream_get(icmp, s, s->putp); stream_get(icmp, s, stream_get_endp(s));
/* icmp->checksum is already calculated */ /* 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); stream_free(s);
on = 1; on = 1;

View File

@ -480,7 +480,7 @@ zsend_route_multipath (int cmd, struct zserv *client, struct prefix *p,
{ {
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
{ {
nhnummark = stream_get_putp (s); nhnummark = stream_get_endp (s);
stream_putc (s, 1); /* placeholder */ stream_putc (s, 1); /* placeholder */
nhnum++; nhnum++;
@ -562,7 +562,7 @@ zsend_ipv6_nexthop_lookup (struct zserv *client, struct in6_addr *addr)
{ {
stream_putl (s, rib->metric); stream_putl (s, rib->metric);
num = 0; num = 0;
nump = s->putp; nump = stream_get_endp(s);
stream_putc (s, 0); stream_putc (s, 0);
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) 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); stream_putl (s, rib->metric);
num = 0; num = 0;
nump = s->putp; nump = stream_get_endp(s);
stream_putc (s, 0); stream_putc (s, 0);
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) 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); stream_putl (s, rib->metric);
num = 0; num = 0;
nump = s->putp; nump = stream_get_endp(s);
stream_putc (s, 0); stream_putc (s, 0);
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
@ -853,14 +853,14 @@ zread_ipv4_add (struct zserv *client, u_short length)
break; break;
case ZEBRA_NEXTHOP_IFNAME: case ZEBRA_NEXTHOP_IFNAME:
ifname_len = stream_getc (s); ifname_len = stream_getc (s);
stream_forward (s, ifname_len); stream_forward_getp (s, ifname_len);
break; break;
case ZEBRA_NEXTHOP_IPV4: case ZEBRA_NEXTHOP_IPV4:
nexthop.s_addr = stream_get_ipv4 (s); nexthop.s_addr = stream_get_ipv4 (s);
nexthop_ipv4_add (rib, &nexthop); nexthop_ipv4_add (rib, &nexthop);
break; break;
case ZEBRA_NEXTHOP_IPV6: case ZEBRA_NEXTHOP_IPV6:
stream_forward (s, IPV6_MAX_BYTELEN); stream_forward_getp (s, IPV6_MAX_BYTELEN);
break; break;
case ZEBRA_NEXTHOP_BLACKHOLE: case ZEBRA_NEXTHOP_BLACKHOLE:
nexthop_blackhole_add (rib); nexthop_blackhole_add (rib);
@ -925,13 +925,13 @@ zread_ipv4_delete (struct zserv *client, u_short length)
break; break;
case ZEBRA_NEXTHOP_IFNAME: case ZEBRA_NEXTHOP_IFNAME:
ifname_len = stream_getc (s); ifname_len = stream_getc (s);
stream_forward (s, ifname_len); stream_forward_getp (s, ifname_len);
break; break;
case ZEBRA_NEXTHOP_IPV4: case ZEBRA_NEXTHOP_IPV4:
nexthop.s_addr = stream_get_ipv4 (s); nexthop.s_addr = stream_get_ipv4 (s);
break; break;
case ZEBRA_NEXTHOP_IPV6: case ZEBRA_NEXTHOP_IPV6:
stream_forward (s, IPV6_MAX_BYTELEN); stream_forward_getp (s, IPV6_MAX_BYTELEN);
break; break;
} }
} }