2017-07-06 22:03:04 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* net/neighbor/neighbor_dumpentry.c
|
|
|
|
*
|
2021-05-26 09:54:32 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2017-07-06 22:03:04 +02:00
|
|
|
*
|
2021-05-26 09:54:32 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2017-07-06 22:03:04 +02:00
|
|
|
*
|
2021-05-26 09:54:32 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2017-07-06 22:03:04 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2017-07-31 03:10:51 +02:00
|
|
|
#include <stdio.h>
|
2017-07-06 22:03:04 +02:00
|
|
|
#include <debug.h>
|
|
|
|
|
2017-07-07 00:19:10 +02:00
|
|
|
#include <nuttx/net/net.h>
|
2019-11-08 18:15:16 +01:00
|
|
|
#include <nuttx/net/neighbor.h>
|
2017-07-07 00:19:10 +02:00
|
|
|
|
2017-07-06 22:03:04 +02:00
|
|
|
#include "neighbor/neighbor.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_NET_INFO
|
|
|
|
|
2017-07-31 03:10:51 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-01-12 21:17:29 +01:00
|
|
|
/****************************************************************************
|
2017-07-31 15:28:42 +02:00
|
|
|
* Name: neighbor_dump_address
|
2017-07-31 03:10:51 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump a data buffer to the SYSLOG.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2017-07-31 03:10:51 +02:00
|
|
|
* buffer - The buffer to be dumped
|
|
|
|
* buflen - The length of the buffer in bytes.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
2020-01-12 21:17:29 +01:00
|
|
|
****************************************************************************/
|
2017-07-31 03:10:51 +02:00
|
|
|
|
2018-11-09 21:10:18 +01:00
|
|
|
static void neighbor_dump_address(FAR const void *buf, unsigned int buflen)
|
2017-07-31 03:10:51 +02:00
|
|
|
{
|
2019-03-11 19:48:17 +01:00
|
|
|
char outbuf[16 * 3 + 9]; /* 6-byte header header + 16 hex bytes +
|
|
|
|
* 2 space separator + NUL termination */
|
2018-11-09 21:10:18 +01:00
|
|
|
FAR const uint8_t *buffer = buf;
|
2017-07-31 03:10:51 +02:00
|
|
|
FAR char *ptr;
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int j;
|
|
|
|
unsigned int maxj;
|
|
|
|
|
|
|
|
for (i = 0; i < buflen; i += 16)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2018-11-09 21:10:18 +01:00
|
|
|
sprintf(outbuf, " at: ");
|
2017-07-31 03:10:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-09 21:10:18 +01:00
|
|
|
sprintf(outbuf, " ");
|
2017-07-31 03:10:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
maxj = 16;
|
|
|
|
if (i + maxj > buflen)
|
|
|
|
{
|
|
|
|
maxj = buflen - i;
|
|
|
|
}
|
|
|
|
|
2018-11-09 21:10:18 +01:00
|
|
|
ptr = outbuf + 6;
|
2017-07-31 03:10:51 +02:00
|
|
|
for (j = 0; j < maxj; j++)
|
|
|
|
{
|
|
|
|
if (j == 8)
|
|
|
|
{
|
|
|
|
*ptr++ = ' ';
|
|
|
|
*ptr++ = ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(ptr, "%02x ", *buffer++);
|
|
|
|
ptr += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ptr = '\0';
|
2018-11-09 21:10:18 +01:00
|
|
|
ninfo("%s\n", ptr);
|
2017-07-31 03:10:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-06 22:03:04 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: neighbor_dumpentry
|
|
|
|
*
|
|
|
|
* Description:
|
2020-02-23 09:50:23 +01:00
|
|
|
* Dump the contents of an entry Neighbor Table.
|
2017-07-06 22:03:04 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* msg - Message to print with the entry
|
|
|
|
* neighbor - The table entry to dump
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void neighbor_dumpentry(FAR const char *msg,
|
2019-11-08 18:15:16 +01:00
|
|
|
FAR struct neighbor_entry_s *neighbor)
|
2017-07-06 22:03:04 +02:00
|
|
|
{
|
|
|
|
ninfo("%s: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
|
|
|
msg,
|
2022-01-18 08:38:00 +01:00
|
|
|
NTOHS(neighbor->ne_ipaddr[0]), NTOHS(neighbor->ne_ipaddr[1]),
|
|
|
|
NTOHS(neighbor->ne_ipaddr[2]), NTOHS(neighbor->ne_ipaddr[3]),
|
|
|
|
NTOHS(neighbor->ne_ipaddr[4]), NTOHS(neighbor->ne_ipaddr[5]),
|
|
|
|
NTOHS(neighbor->ne_ipaddr[6]), NTOHS(neighbor->ne_ipaddr[7]));
|
2017-07-06 22:03:04 +02:00
|
|
|
|
2018-11-09 21:10:18 +01:00
|
|
|
neighbor_dump_address(&neighbor->ne_addr.u,
|
|
|
|
neighbor->ne_addr.na_llsize);
|
2017-07-06 22:03:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: neighbor_dumpipaddr
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump an IP address.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* msg - Message to print with the entry
|
|
|
|
* ipaddr - The IP address to dump
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void neighbor_dumpipaddr(FAR const char *msg,
|
|
|
|
const net_ipv6addr_t ipaddr)
|
|
|
|
{
|
|
|
|
ninfo("%s: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
|
|
|
msg,
|
2022-01-18 08:38:00 +01:00
|
|
|
NTOHS(ipaddr[0]), NTOHS(ipaddr[1]), NTOHS(ipaddr[2]),
|
|
|
|
NTOHS(ipaddr[3]), NTOHS(ipaddr[4]), NTOHS(ipaddr[5]),
|
|
|
|
NTOHS(ipaddr[6]), NTOHS(ipaddr[7]));
|
2017-07-06 22:03:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_DEBUG_NET_INFO */
|