2005-05-03 Paul Jakma <paul@dishone.st>
* (general) More cleaning up of stream abuse, isisd should be
back to previous functionality. Replace various XMALLOC+memset's
with XCALLOC
* isis_tlv.c: (tlv_add_padding) use stream_put to clear the stream
rather than forward endp, as isisd reuses streams.
* isis_pdu.c: (process_lsp) cleanup direct reference to stream endp
(send_lsp) manual copy of a stream cleaned up to use stream_copy.
* isis_network.c: (isis_recv_pdu_bcast) replace direct memcpy with
stream_write
(isis_recv_pdu_p2p) replace recvfrom directly into stream with
stream_recvfrom. Remove dangerous and now unneeded manual update
of endp.
(isis_recv_pdu_bcast / non-GNU_LINUX) Replace direct memcpy with
stream_write.
(isis_recv_pdu_p2p) replace read direct into stream with
stream_read_try, and hence remove the manual update of endp.
* isis_lsp.c: (lsp_update_data) manual stream dup replaced with
stream_dup.
(lsppdu_realloc) mempcy into stream data replaced with stream_put.
(lsp_build_nonpseudo) remove mysterious stream_forward_endp's -
which were originally stream_set_putp - shouldn't be needed
now that all the manual fiddling of private stream data has been
corrected.
(build_topology_lsp_data) remove unneeded twiddling of endp,
appears to be due to lsppdu_realloc(), but it appears to sort of
do the right thing wrt streams.
diff --git a/isisd/isis_network.c b/isisd/isis_network.c
index 2e901f1..466a917 100644
--- a/isisd/isis_network.c
+++ b/isisd/isis_network.c
@@ -420,9 +420,7 @@
(struct sockaddr *) &s_addr, (socklen_t *) &addr_len);
/* then we lose the LLC */
- memcpy (STREAM_DATA (circuit->rcv_stream),
- sock_buff + LLC_LEN, bytesread - LLC_LEN);
- circuit->rcv_stream->endp = bytesread - LLC_LEN;
+ stream_write (circuit->rcv_stream, sock_buff + LLC_LEN, bytesread - LLC_LEN);
memcpy (ssnpa, &s_addr.sll_addr, s_addr.sll_halen);
@@ -439,9 +437,10 @@
addr_len = sizeof (s_addr);
/* we can read directly to the stream */
- bytesread = recvfrom (circuit->fd, STREAM_DATA (circuit->rcv_stream),
- circuit->interface->mtu, 0,
- (struct sockaddr *) &s_addr, (socklen_t *) &addr_len);
+ bytesread = stream_recvfrom (circuit->rcv_stream, circuit->fd,
+ circuit->interface->mtu, 0,
+ (struct sockaddr *) &s_addr,
+ (socklen_t *) &addr_len);
if (s_addr.sll_pkttype == PACKET_OUTGOING)
{
@@ -452,8 +451,6 @@
return ISIS_WARNING;
}
- circuit->rcv_stream->endp = bytesread;
-
/* If we don't have protocol type 0x00FE which is
* ISO over GRE we exit with pain :)
*/
@@ -572,11 +569,9 @@
offset = bpf_hdr->bh_hdrlen + LLC_LEN + ETHER_HDR_LEN;
/* then we lose the BPF, LLC and ethernet headers */
- memcpy (STREAM_DATA (circuit->rcv_stream),
- readbuff + offset, 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;
+ stream_write (circuit->rcv_stream, readbuff + offset,
+ bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN);
+ stream_set_getp (circuit->rcv_stream, 0);
memcpy (ssnpa, readbuff + bpf_hdr->bh_hdrlen + ETHER_ADDR_LEN,
ETHER_ADDR_LEN);
@@ -592,8 +587,8 @@
{
int bytesread;
- bytesread = read (circuit->fd, STREAM_DATA (circuit->rcv_stream),
- circuit->interface->mtu);
+ bytesread = stream_read (circuit->rcv_stream, circuit->fd,
+ circuit->interface->mtu);
if (bytesread < 0)
{
@@ -601,8 +596,6 @@
return ISIS_WARNING;
}
- circuit->rcv_stream->endp = bytesread;
-
return ISIS_OK;
}