fakepcap.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* $Id$ */
  2. /*
  3. * Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
  4. * Copyright (c) 2013-2018 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  5. *
  6. * The Tcpreplay Suite of tools is free software: you can redistribute it
  7. * and/or modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or with the authors permission any later version.
  10. *
  11. * The Tcpreplay Suite is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the Tcpreplay Suite. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /*
  20. * This file implements missing libpcap functions which only exist in really
  21. * recent versions of libpcap. We assume the user has at least 0.6, so anything
  22. * after that needs to be re-implimented here unless we want to start
  23. * requiring a newer version
  24. */
  25. #include "config.h"
  26. #include "defines.h"
  27. #include "common.h"
  28. #include <stdlib.h>
  29. #ifndef HAVE_DLT_VAL_TO_DESC
  30. /**
  31. * replacement for libpcap's pcap_datalink_val_to_description()
  32. * which doesn't exist in all versions
  33. */
  34. const char *
  35. pcap_datalink_val_to_description(int dlt)
  36. {
  37. if (dlt > DLT2DESC_LEN)
  38. return "Unknown";
  39. return dlt2desc[dlt];
  40. }
  41. /**
  42. * replacement for libpcap's pcap_datalink_val_to_name()
  43. * which doesn't exist in all versions
  44. */
  45. const char *
  46. pcap_datalink_val_to_name(int dlt)
  47. {
  48. if (dlt > DLT2NAME_LEN)
  49. return "Unknown";
  50. return dlt2name[dlt];
  51. }
  52. #endif