1
0

bgpdump_mstream.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. Copyright (c) 2007 - 2010 RIPE NCC - All Rights Reserved
  3. Permission to use, copy, modify, and distribute this software and its
  4. documentation for any purpose and without fee is hereby granted, provided
  5. that the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation, and that the name of the author not be used in advertising or
  8. publicity pertaining to distribution of the software without specific,
  9. written prior permission.
  10. THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  11. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
  12. AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
  13. DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  14. AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. Parts of this code have been engineered after analiyzing GNU Zebra's
  17. source code and therefore might contain declarations/code from GNU
  18. Zebra, Copyright (C) 1999 Kunihiro Ishiguro. Zebra is a free routing
  19. software, distributed under the GNU General Public License. A copy of
  20. this license is included with libbgpdump.
  21. Original Author: Dan Ardelean (dan@ripe.net)
  22. */
  23. #ifndef _BGPDUMP_MSTREAM_H
  24. #define _BGPDUMP_MSTREAM_H
  25. #include <sys/types.h>
  26. #include <netinet/in.h>
  27. typedef struct mstream {
  28. u_char *start;
  29. u_int32_t position;
  30. u_int32_t len;
  31. } mstream_t;
  32. void mstream_init(struct mstream *s, u_char *buffer,u_int32_t len);
  33. u_char mstream_getc(struct mstream *s, u_char *d);
  34. u_int16_t mstream_getw(struct mstream *s, u_int16_t *d);
  35. u_int32_t mstream_getl(struct mstream *s, u_int32_t *d);
  36. struct in_addr mstream_get_ipv4(struct mstream *s);
  37. u_int32_t mstream_can_read(struct mstream *s);
  38. u_int32_t mstream_get (struct mstream *s, void *d, u_int32_t len);
  39. mstream_t mstream_copy(mstream_t *s, int len);
  40. #endif