2015-11-28 03:53:33 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* net/procfs/procfs.h
|
|
|
|
*
|
2021-02-19 19:45:37 +08: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
|
2015-11-28 03:53:33 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-11-28 03:53:33 +08:00
|
|
|
*
|
2021-02-19 19:45:37 +08: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.
|
2015-11-28 03:53:33 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __NET_PROCFS_PROCFS_H
|
|
|
|
#define __NET_PROCFS_PROCFS_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <nuttx/fs/procfs.h>
|
|
|
|
|
|
|
|
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_NET)
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-08-12 04:50:39 +08:00
|
|
|
#ifdef CONFIG_FS_PROCFS_EXCLUDE_ROUTE
|
|
|
|
# undef CONFIG_NET_ROUTE
|
|
|
|
#endif
|
|
|
|
|
2015-11-28 03:53:33 +08:00
|
|
|
/* Determines the size of an intermediate buffer that must be large enough
|
|
|
|
* to handle the longest line generated by this logic.
|
|
|
|
*/
|
|
|
|
|
2017-05-18 15:30:12 +08:00
|
|
|
#define NET_LINELEN 80
|
2015-11-28 03:53:33 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* This structure describes one open "file" */
|
|
|
|
|
2015-11-28 06:39:14 +08:00
|
|
|
struct net_driver_s; /* Forward reference */
|
2015-11-28 03:53:33 +08:00
|
|
|
struct netprocfs_file_s
|
|
|
|
{
|
|
|
|
struct procfs_file_s base; /* Base open file structure */
|
2015-11-28 06:39:14 +08:00
|
|
|
FAR struct net_driver_s *dev; /* Current network device */
|
2015-11-28 03:53:33 +08:00
|
|
|
uint8_t lineno; /* Line number */
|
|
|
|
uint8_t linesize; /* Number of valid characters in line[] */
|
|
|
|
uint8_t offset; /* Offset to first valid character in line[] */
|
2022-09-04 21:39:06 +08:00
|
|
|
uint8_t entry; /* Entry index of netprocfs_entry_s */
|
2015-11-28 03:53:33 +08:00
|
|
|
char line[NET_LINELEN]; /* Pre-allocated buffer for formatted lines */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Level 1 is the directory of attributes */
|
|
|
|
|
|
|
|
struct netprocfs_level1_s
|
|
|
|
{
|
|
|
|
struct procfs_dir_priv_s base; /* Base directory private data */
|
2015-11-28 06:39:14 +08:00
|
|
|
char name[NAME_MAX + 1]; /* Name of last node visited */
|
2018-06-26 07:42:56 +08:00
|
|
|
#ifdef CONFIG_NETDEV_IFINDEX
|
|
|
|
uint8_t ifindex; /* Next ifindex to visit */
|
|
|
|
#endif
|
2015-11-28 03:53:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Line generating function type */
|
|
|
|
|
|
|
|
typedef int (*linegen_t)(FAR struct netprocfs_file_s *netfile);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
# define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
# define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-11-28 06:39:14 +08:00
|
|
|
* Name: netprocfs_read_linegen
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read and format procfs data using a line generation table.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* priv - A reference to the network procfs file structure
|
|
|
|
* buffer - The user-provided buffer into which device status will be
|
|
|
|
* returned.
|
|
|
|
* buflen - The size in bytes of the user provided buffer.
|
|
|
|
* gentab - Table of line generation functions
|
|
|
|
* nelems - The number of elements in the table
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned
|
|
|
|
* on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
ssize_t netprocfs_read_linegen(FAR struct netprocfs_file_s *priv,
|
|
|
|
FAR char *buffer, size_t buflen,
|
|
|
|
FAR const linegen_t *gentab, int nelems);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: netprocfs_read_netstats
|
2015-11-28 03:53:33 +08:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read and format network layer statistics.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* priv - A reference to the network procfs file structure
|
|
|
|
* buffer - The user-provided buffer into which network status will be
|
|
|
|
* returned.
|
|
|
|
* bulen - The size in bytes of the user provided buffer.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned
|
|
|
|
* on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_STATISTICS
|
2015-11-28 06:39:14 +08:00
|
|
|
ssize_t netprocfs_read_netstats(FAR struct netprocfs_file_s *priv,
|
|
|
|
FAR char *buffer, size_t buflen);
|
2015-11-28 03:53:33 +08:00
|
|
|
#endif
|
|
|
|
|
2018-11-07 00:42:53 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netprocfs_read_mldstats
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read and format MLD statistics.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* priv - A reference to the network procfs file structure
|
|
|
|
* buffer - The user-provided buffer into which network status will be
|
|
|
|
* returned.
|
|
|
|
* bulen - The size in bytes of the user provided buffer.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned
|
|
|
|
* on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(CONFIG_NET_STATISTICS) && defined(CONFIG_NET_MLD)
|
|
|
|
ssize_t netprocfs_read_mldstats(FAR struct netprocfs_file_s *priv,
|
|
|
|
FAR char *buffer, size_t buflen);
|
|
|
|
#endif
|
|
|
|
|
2022-09-05 17:06:05 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netprocfs_read_tcpstats
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read and format TCP statistics.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* priv - A reference to the network procfs file structure
|
|
|
|
* buffer - The user-provided buffer into which network status will be
|
|
|
|
* returned.
|
|
|
|
* bulen - The size in bytes of the user provided buffer.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned
|
|
|
|
* on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-09-19 12:36:15 +08:00
|
|
|
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
|
2022-09-05 17:06:05 +08:00
|
|
|
ssize_t netprocfs_read_tcpstats(FAR struct netprocfs_file_s *priv,
|
|
|
|
FAR char *buffer, size_t buflen);
|
|
|
|
#endif
|
|
|
|
|
2022-09-09 11:13:15 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netprocfs_read_udpstats
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read and format UDP statistics.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* priv - A reference to the network procfs file structure
|
|
|
|
* buffer - The user-provided buffer into which network status will be
|
|
|
|
* returned.
|
|
|
|
* bulen - The size in bytes of the user provided buffer.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned
|
|
|
|
* on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-09-19 12:36:15 +08:00
|
|
|
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
|
2022-09-09 11:13:15 +08:00
|
|
|
ssize_t netprocfs_read_udpstats(FAR struct netprocfs_file_s *priv,
|
|
|
|
FAR char *buffer, size_t buflen);
|
|
|
|
#endif
|
|
|
|
|
2017-08-12 04:50:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netprocfs_read_routes
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read and format routing table entries.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* priv - A reference to the network procfs file structure
|
|
|
|
* buffer - The user-provided buffer into which network status will be
|
|
|
|
* returned.
|
|
|
|
* bulen - The size in bytes of the user provided buffer.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned
|
|
|
|
* on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ROUTE
|
|
|
|
ssize_t netprocfs_read_routes(FAR struct netprocfs_file_s *priv,
|
|
|
|
FAR char *buffer, size_t buflen);
|
|
|
|
#endif
|
|
|
|
|
2015-11-28 06:39:14 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: netprocfs_read_devstats
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read and format network device statistics.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* priv - A reference to the network procfs file structure
|
|
|
|
* buffer - The user-provided buffer into which device status will be
|
|
|
|
* returned.
|
|
|
|
* bulen - The size in bytes of the user provided buffer.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned
|
|
|
|
* on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
ssize_t netprocfs_read_devstats(FAR struct netprocfs_file_s *priv,
|
|
|
|
FAR char *buffer, size_t buflen);
|
|
|
|
|
2015-11-28 03:53:33 +08:00
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_NET */
|
|
|
|
#endif /* __NET_PROCFS_PROCFS_H */
|