summaryrefslogtreecommitdiffstats
path: root/lib/stream.c
Commit message (Collapse)AuthorAgeFilesLines
* *: make sure zebra.h is always included firstDavid Lamparter2015-10-161-1/+1
| | | | | | | | zebra.h pulls in config.h, which results in fiddling with things like __FILE_OFFSET_BITS. It must always be included first, in order to set flags that influence the compiler via <features.h>. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib, stream: fix stream sanity checksWenjian Ma2015-06-211-1/+1
| | | | | | Because operator "!" has higher priority than "&&", So we put the "&&" expression in "()" to check both getp and endp. Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: use void * for printing pointersDavid Lamparter2015-04-211-1/+1
| | | | | | | | | On higher warning levels, compilers expect %p printf arguments to be void *. Since format string / argument warnings can be useful otherwise, let's get rid of this noise by sprinkling casts to void * over printf calls. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* stream: remove unused stream_read_unblockStephen Hemminger2014-10-271-26/+0
| | | | | | The one place this was being used in BGP is now gone, can remove deprecated interface. Acked-by: Feng Lu <lu.feng@6wind.com>
* *: nuke ^L (page feed)David Lamparter2014-06-041-5/+5
| | | | | | | | | | | | | | Quagga sources have inherited a slew of Page Feed (^L, \xC) characters from ancient history. Among other things, these break patchwork's XML-RPC API because \xC is not a valid character in XML documents. Nuke them from high orbit. Patches can be adapted simply by: sed -e 's%^L%%' -i filename.patch (you can type page feeds in some environments with Ctrl-V Ctrl-L) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: efficient NLRI packing for AFs != ipv4-unicastPradosh Mohapatra2014-06-031-0/+19
| | | | | | | | | | | | | | | | | | | | | ISSUE: Currently, for non-ipv4-unicast address families where prefixes are encoded in MP_REACH/MP_UNREACH attributes, BGP ends up sending one prefix per UPDATE message. This is quite inefficient. The patch addresses the issue. PATCH: We introduce a scratch buffer in the peer structure that stores the MP_REACH/MP_UNREACH attributes for non-ipv4-unicast families. This enables us to encode multiple prefixes. In the end, the two buffers are merged to create the UPDATE packet. Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com> [DL: removed no longer existing bgp_packet_withdraw prototype] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: fix possible off-by-one in stream_put_prefix()Jorge Boncompte [DTI2]2014-04-011-2/+2
| | | | | | | | | | | | | | | The STREAM_WRITEABLE() call only checks if there is space for the prefix in the stream but does not account for the prefixlen. The stream_putc() call reduces available space by 1 and we can end copying one byte too much and with "endp" off by one if we are near the buffer end. Instead of moving the stream_putc() call before STREAM_WRITEABLE(), we check before hand for the required space, and open-code it. This avoids a function call and verifying again the stream buffer. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: improve sanity checks in stream_set_endp()Avneesh Sachdev2012-10-251-2/+12
| | | | | | * lib/stream.c: (stream_set_endp) Add checks to make sure that the supplied 'endp' is within the 'size' of the stream, and that the current read pointer 'getp' is not beyond the specified 'endp'.
* lib: add stream_set_endp()Subbaiah Venkata2012-04-071-3/+17
| | | | | | | | | | | | | * lib/stream.[ch]: - Add stream_set_endp(). This can be used to trim data (for example, padding) at the end of a stream. - Fix swapped 'getp' and 'endp' parameters in STREAM_WARN_OFFSETS. From: Subbaiah Venkata <svenkata@google.com> Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@diac24.net>
* [lib] trivial: add const qualifier to stream_put/writePaul Jakma2008-06-071-2/+2
| | | | | | | 2008-06-07 Paul Jakma <paul@jakma.org> * stream.{c,h}: (stream_{put,write}) add const qualifier to source argument. Change u_char to void *.
* [lib/stream] small compile fix, use uint64_t, not u_int64_t.paul2006-01-191-1/+1
| | | | | | | | 2006-01-19 Paul Jakma <paul.jakma@sun.com> * stream.c: (stream_getq_from) should use POSIX uint64_t not u_int64_t. Latter is neither a traditional BSD type, nor a POSIX type.
* [stream] Add quad-word support and stream_resizepaul2006-01-101-1/+133
| | | | | | | | | | | | 2006-01-10 Paul Jakma <paul.jakma@sun.com> * stream.c: (stream_new) Allocate stream data as seperate object. (stream_free) free the data. (stream_resize) new function, resize stream to new size. (stream_{get,put}q*) new functions to get/put quad word size types. * stream.h: (struct stream) make data seperate from the stream. Export new stream_resize and quad-word get/put functions.
* 2005-05-03 Paul Jakma <paul@dishone.st>paul2005-05-031-2/+36
| | | | | | | | | | | * stream.h: Add comment about the special zero-ing ability of stream_put. (stream_recvmsg, stream_write) should return ssize_t and size_t respectively. Should both be extern linkage. (stream_recvfrom) Stream aware wrapper around recvfrom, in style of stream_read_try. * stream.c: (stream_recvfrom) new function, wrapper around recvfrom. (stream_recvmsg, stream_write) ssize_t and size_t return values
* 2005-02-24 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-02-241-2/+5
| | | | | | | * stream.c: (stream_read_try) Log a warning message if a fatal I/O error occurs. (stream_fifo_new) Fix prototype. * stream.h: Fix prototype for stream_fifo_new (need void arg).
* 2005-02-19 Paul Jakma <paul.jakma@sun.com>paul2005-02-191-1/+1
| | | | * stream.c: (stream_new) fix dumb mistake.
* 2005-02-17 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-02-171-2/+1
| | | | * stream.c: (stream_read_try) Use new ERRNO_IO_RETRY macro.
* 2005-02-16 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-02-161-1/+28
| | | | | | | | | | * stream.h: Declare new function stream_read_try suitable for use with non-blocking file descriptors. Indicate that stream_read and stream_read_unblock are deprecated. * stream.c: (stream_read_try) New function for use with non-blocking I/O. (stream_recvmsg) Should return -1 if the stream is too small to contain the data.
* 2005-02-14 Paul Jakma <paul.jakma@sun.com>paul2005-02-141-58/+376
| | | | | | | | | | | | | | | | | | | | * stream.h: Unsigned long updated to size_t * stream.c: ditto * stream.h: Add stream_copy, stream_dup, stream_recvmsg. Add comment describing struct stream abstraction, and various other comments. Deprecate several unsafe/ambigious macros. Add STREAM_WRITEABLE and STREAM_READABLE. Add (stream_getl_from) for symmetry. Update stream_forward_{endp,getp} to use size_t offset. Make stream data a 0 length array, rather than a seperate malloc. * stream.c: Add consistency checks. Update to follow stream.h changes. (stream_new) Alloc stream+data in one go. (stream_copy) new function, copy a stream. (stream_dup) new function, dup a stream. (stream_recvmsg) new function, recvmsg data into a stream. (stream_empty) no need to check getp == 0.
* 2005-02-12 Paul Jakma <paul.jakma@sun.com>paul2005-02-121-9/+9
| | | | | * stream.h: Unsigned long updated to size_t * stream.c: ditto
* 2005-02-09 Paul Jakma <paul.jakma@sun.com>paul2005-02-091-67/+41
| | | | | | | | | | | | | * (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.
* 2004-12-21 Paul Jakma <paul.jakma@sun.com>paul2004-12-221-0/+5
| | | | * stream.c: Dont allocate streams with 0 sized data buffers
* Initial revisionpaul2002-12-131-0/+479