arp_dump.c 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /****************************************************************************
  2. * net/arp/arp_dump.c
  3. *
  4. * Copyright (C) 2007-2011, 2014 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Based on uIP which also has a BSD style license:
  8. *
  9. * Author: Adam Dunkels <adam@dunkels.com>
  10. * Copyright (c) 2001-2003, Adam Dunkels.
  11. * All rights reserved.
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions
  15. * are met:
  16. *
  17. * 1. Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the distribution.
  22. * 3. The name of the author may not be used to endorse or promote
  23. * products derived from this software without specific prior
  24. * written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  27. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  28. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  30. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  32. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  34. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  35. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  36. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. ****************************************************************************/
  39. /****************************************************************************
  40. * Included Files
  41. ****************************************************************************/
  42. #include <nuttx/config.h>
  43. #include <debug.h>
  44. #include "arp/arp.h"
  45. #ifdef CONFIG_NET_ARP_DUMP
  46. /****************************************************************************
  47. * Public Functions
  48. ****************************************************************************/
  49. /****************************************************************************
  50. * Name: arp_dump
  51. *
  52. * Description:
  53. * Dump the contents of an ARP packet to the SYSLOG device
  54. *
  55. * Input Parameters:
  56. * arp - A reference to the ARP header to be dumped.
  57. *
  58. * Returned Value:
  59. * None
  60. *
  61. ****************************************************************************/
  62. void arp_dump(FAR struct arp_hdr_s *arp)
  63. {
  64. ninfo(" HW type: %04x Protocol: %04x\n",
  65. arp->ah_hwtype, arp->ah_protocol);
  66. ninfo(" HW len: %02x Proto len: %02x Operation: %04x\n",
  67. arp->ah_hwlen, arp->ah_protolen, arp->ah_opcode);
  68. ninfo(" Sender MAC: %02x:%02x:%02x:%02x:%02x:%02x IP: %d.%d.%d.%d\n",
  69. arp->ah_shwaddr[0], arp->ah_shwaddr[1], arp->ah_shwaddr[2],
  70. arp->ah_shwaddr[3], arp->ah_shwaddr[4], arp->ah_shwaddr[5],
  71. arp->ah_sipaddr[0] & 0xff, arp->ah_sipaddr[0] >> 8,
  72. arp->ah_sipaddr[1] & 0xff, arp->ah_sipaddr[1] >> 8);
  73. ninfo(" Dest MAC: %02x:%02x:%02x:%02x:%02x:%02x IP: %d.%d.%d.%d\n",
  74. arp->ah_dhwaddr[0], arp->ah_dhwaddr[1], arp->ah_dhwaddr[2],
  75. arp->ah_dhwaddr[3], arp->ah_dhwaddr[4], arp->ah_dhwaddr[5],
  76. arp->ah_dipaddr[0] & 0xff, arp->ah_dipaddr[0] >> 8,
  77. arp->ah_dipaddr[1] & 0xff, arp->ah_dipaddr[1] >> 8);
  78. }
  79. #endif /* CONFIG_NET_ARP_DUMP */