summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-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
4 files changed, 57 insertions, 62 deletions
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);