procfs: Add support for routing tables.

This commit is contained in:
Gregory Nutt
2017-08-11 14:50:39 -06:00
parent fdca465da6
commit 65698da12d
9 changed files with 300 additions and 122 deletions
+41
View File
@@ -50,6 +50,10 @@
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_FS_PROCFS_EXCLUDE_ROUTE
# undef CONFIG_NET_ROUTE
#endif
/* Determines the size of an intermediate buffer that must be large enough
* to handle the longest line generated by this logic.
*/
@@ -60,6 +64,19 @@
* Public Type Definitions
****************************************************************************/
/* Describes the /net directory entries */
enum netprocfs_entry_e
{
NETPROCFS_SUBDIR_DEV = 0 /* Multiple instances, e.g. /proc/net/eth0 */
#ifdef CONFIG_NET_STATISTICS
, NETPROCFS_SUBDIR_STAT /* /proc/net/stat */
#endif
#ifdef CONFIG_NET_ROUTE
, NETPROCFS_SUBDIR_ROUTE /* /proc/net/route */
#endif
};
/* This structure describes one open "file" */
struct net_driver_s; /* Forward reference */
@@ -70,6 +87,7 @@ struct netprocfs_file_s
uint8_t lineno; /* Line number */
uint8_t linesize; /* Number of valid characters in line[] */
uint8_t offset; /* Offset to first valid character in line[] */
uint8_t entry; /* See enum netprocfs_entry_e */
char line[NET_LINELEN]; /* Pre-allocated buffer for formatted lines */
};
@@ -148,6 +166,29 @@ ssize_t netprocfs_read_netstats(FAR struct netprocfs_file_s *priv,
FAR char *buffer, size_t buflen);
#endif
/****************************************************************************
* 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
/****************************************************************************
* Name: netprocfs_read_devstats
*