net/procfs: add udp profs support

add proc node /proc/net/udp to show the active udp connections from procfs

nuttx style:

server> cat /proc/net/udp
UDP sl     local_address          remote_address     flg   txsz   rxsz  (IPv4)
  1:          0.0.0.0:  5285    192.168.31.22:  7779   9      0   1041
  2:          0.0.0.0:  5286    192.168.31.22:  7779   9      0   1041
  3:          0.0.0.0:  5287    192.168.31.22:  7779   9      0   1041

linux kernel:
https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2022-09-09 11:13:15 +08:00
committed by Xiang Xiao
parent 7190e56a14
commit d10cd8d585
4 changed files with 243 additions and 0 deletions
+23
View File
@@ -187,6 +187,29 @@ ssize_t netprocfs_read_tcpstats(FAR struct netprocfs_file_s *priv,
FAR char *buffer, size_t buflen);
#endif
/****************************************************************************
* 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.
*
****************************************************************************/
#ifdef CONFIG_NET_UDP
ssize_t netprocfs_read_udpstats(FAR struct netprocfs_file_s *priv,
FAR char *buffer, size_t buflen);
#endif
/****************************************************************************
* Name: netprocfs_read_routes
*