util.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. Created by Devin Bayer on 9/1/10.
  17. */
  18. #ifndef _UTIL_H
  19. #define _UTIL_H
  20. #include <time.h>
  21. #include "bgpdump_attr.h"
  22. void log_to_stderr(void);
  23. void log_to_syslog(void);
  24. void err(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
  25. void warn(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
  26. void debug(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
  27. // system inet_ntop() functions format IPv6 addresses
  28. // inconsistently, so use these versions
  29. char *fmt_ipv4(BGPDUMP_IP_ADDRESS addr, char *buffer);
  30. char *fmt_ipv6(BGPDUMP_IP_ADDRESS addr, char *buffer);
  31. void test_fmt_ip(void);
  32. void time2str(struct tm* date,char *time_str);
  33. int int2str(uint32_t value, char* str);
  34. void test_utils(void);
  35. #endif