📄 rom400_netstat.h
字号:
/*---------------------------------------------------------------------------
* Copyright (C) 2003-2004 Dallas Semiconductor Corporation, All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Dallas Semiconductor
* shall not be used except as stated in the Dallas Semiconductor
* Branding Policy.
* ---------------------------------------------------------------------------
*
* This file contains function definitions for the Netstat network statistics
* library for the Dallas Semiconductor DS80C400 processor. This file is intended for
* use with the Keil MicroVision (uVision) C compiler.
*
* ---------------------------------------------------------------------------
*/
#ifndef __rom400_netstat_
#define __rom400_netstat_
/** \file rom400_netstat.h
* \brief Network statistics library for the DS80C400
*
* This library contains functions that return pointers to network information
* tables in the socket library.
*
* Note that the tables and structures returned by these functions are the
* actual, physical tables used by the network stack and should not be
* modified by user applications. Since these are the actual network
* structures, it is possible they might change while an application is
* processing them. Any critical analysis of these structures should be
* protected from interruption.
*
* For detailed information on the DS80C400 please see the
* <a href="http://pdfserv.maxim-ic.com/arpdf/Design/DS80C400UG.pdf">
* High-Speed Microcontroller User's Guide: DS80C400 Supplement</a>.
*
*/
/** Version number associated with this header file. Should be the same as
* the version number returned by the <i>#netstat_version</i> function.
* \sa netstat_version */
#define ROM400_NETSTAT_VERSION 1
/**
* \brief Returns the version number of this NETSTAT library.
*
* \return Version number of this NETSTAT library.
*/
//---------------------------------------------------------------------------
unsigned int netstat_version(void);
#define NETSTAT_ARP_ENTRIES 8 ///< Number of entries in the ARP table
/**
* Structure for a single ARP entry. The netstat_get_arp_table function returns
* a pointer to a table that contains NETSTAT_ARP_ENTRIES of this structure.
* Each entry maps an Ethernet MAC address to an IPv4 address.
*/
typedef struct {
unsigned char flags; ///< Flags: NETSTAT_ARP_USED, NETSTAT_ARP_REPLYPENDING or NETSTAT_ARP_STATIC
unsigned char ttl; ///< Time to live for this entry (in ticks)
unsigned char mac[6]; ///< MAC address associated with this entry
unsigned char ip[4]; ///< IPv4 address for the MAC address
} netstat_arp_entry;
#define NETSTAT_ARP_USED 1 ///< Value for <i>#netstat_arp_entry.flags</i>. Table entry is used
#define NETSTAT_ARP_REPLYPENDING 2 ///< Value for <i>#netstat_arp_entry.flags</i>. Table entry is not yet valid, request has been sent out
#define NETSTAT_ARP_STATIC 4 ///< Value for <i>#netstat_arp_entry.flags</i>. Table entry does not expire
/**
* \brief Returns a pointer to the ARP cache table.
*
* This function returns a pointer to the ARP cache table. There are
* #NETSTAT_ARP_ENTRIES in the ARP cache. Each entry is a
* netstat_arp_entry. The entry is used when its "flags" has the
* #NETSTAT_ARP_USED bit set.
*
* \return Far pointer to the ARP cache table
*/
//---------------------------------------------------------------------------
netstat_arp_entry far *netstat_get_arp_table(void);
/**
* \brief Returns the number of entries in the ARP cache table
*
* This function returns the number of used entries in the ARP cache table
* (entries with the #NETSTAT_ARP_USED flag set).
*
* \return Number of entries in the ARP cache table
*/
//---------------------------------------------------------------------------
unsigned int netstat_num_arp_entries(void);
#define NETSTAT_UDP_ENTRIES 16 ///< Number of entries in the UDP port table
/**
* Structure for a single UDP port table entry. The netstat_get_udp_table function
* returns a pointer to a table that contains #NETSTAT_UDP_ENTRIES of this structure.
*/
typedef struct {
unsigned char flags; ///< Flags: NETSTAT_UDP_USED
unsigned short port; ///< Port number for this entry
unsigned char queue_hpp[5]; ///< Incoming packet queue for this port
unsigned char reserved; ///< (Reserved)
} netstat_udp_entry;
#define NETSTAT_UDP_USED 1 ///< Values for <i>#netstat_udp_entry.flags</i>. Table entry is used
/**
* \brief Returns a pointer to the UDP port table.
*
* This function returns a pointer to the UDP port table. There are
* #NETSTAT_UDP_ENTRIES in the UDP port table. Each entry is a
* netstat_udp_entry. The entry is used when its "flags" has the
* #NETSTAT_UDP_USED bit set.
*
* \return Far pointer to the UDP port table
*/
//---------------------------------------------------------------------------
netstat_udp_entry far *netstat_get_udp_table(void);
/**
* \brief Returns the number of entries in the UDP port table.
*
* This function returns the number of used entries in the UDP port table
* (entries with the #NETSTAT_UDP_USED flag set).
*
* \return Number of entries in the UDP port table
*/
//---------------------------------------------------------------------------
unsigned int netstat_num_udp_entries(void);
#define NETSTAT_TCP_MAXSOCKETS 25 ///< Maxmimum number of sockets supported
/**
* Structure for a TCP socket. The netstat_get_tcp_socket function
* returns a pointer to this structure for a given socket number (up to
* #NETSTAT_TCP_MAXSOCKETS).
*/
typedef struct {
unsigned char flags; ///< Flags: #NETSTAT_TCP_OUTPUT_NEEDED_MASK to #NETSTAT_TCP_SEND_FIN_MASK
unsigned char state; ///< Socket state -- see NETSTAT_TCP_STATE_xxx (e.g. #NETSTAT_TCP_STATE_CLOSED)
unsigned char server_sock; ///< Server socket number (only valid for server)
unsigned char ack_timer; ///< Timer for delayed ACKs
unsigned short remote_port; ///< Remote port (if not a server socket)
unsigned char remote_addr[16]; ///< Remote IP address (if not a server socket)
unsigned short local_port; ///< Local port
unsigned char local_addr[16]; ///< Local IP address (may be the wildcard address 0)
unsigned long sequence_num; ///< Current TCP sequence number
unsigned long ack_num; ///< Last ACK number
unsigned short input_retrieve_ptr; ///< Tail pointer to input queue
unsigned short input_store_ptr; ///< Head pointer to input queue
unsigned char input_buffer_hpp[5]; ///< Input queue
unsigned short output_retrieve_ptr; ///< Tail pointer to output queue
unsigned short output_store_ptr; ///< Head pointer to output queue
unsigned char output_buffer_hpp[5]; ///< Output queue
unsigned short receiver_win_size; ///< Receiver's TCP windows size
unsigned short sender_win_size; ///< Sender's TCP window size
unsigned short receiver_mss; ///< Maximum segment size of receiver
unsigned short sock; ///< Socket number
unsigned long last_ack_received; ///< Largest (usually last) ACK
unsigned short output_ack_ptr; ///< Pointer to last acknowledged byte
unsigned char reload_retry_min; ///< Lower bound on the retry timer reload
unsigned char retry_timer[2]; ///< Retry timer (one byte counter with overflow bit)
unsigned char retry_flags; ///< (Reserved/unused)
unsigned char retry_count; ///< Number of times the last segment has been retried
unsigned char retry_timer_reload; ///< Start value for the retry timer reload
unsigned short death_timer; ///< Time until a forced close of the connection
unsigned char options; ///< TCP option flags -- see NETSTAT_TCP_OPTION_xxx (e.g. #NETSTAT_TCP_OPTION_NAGLE_ENABLED_MASK)
unsigned char unacked_segs; ///< Number of unacknowledged segments
unsigned char max_unacked_segs; ///< Maximum number of unacknowledged segments
unsigned char persist_timer; ///< TCP persist timer
unsigned char persist_timer_cap; ///< Current cap for TCP persist timer
unsigned short send_mss; ///< Maximum segment size for sending
} netstat_tcp_socket;
#define NETSTAT_TCP_OUTPUT_NEEDED_MASK 2 ///< Value for <i>netstat_tcp_socket.flags</i>. Either ACK or data or both
#define NETSTAT_TCP_ACK_NEEDED_MASK 4 ///< Value for <i>netstat_tcp_socket.flags</i>. Need an ACK
#define NETSTAT_TCP_SERVER_MASK 8 ///< Value for <i>netstat_tcp_socket.flags</i>. This is a server connection
#define NETSTAT_TCP_RESERVED_MASK 16 ///< Value for <i>netstat_tcp_socket.flags</i>. (Reserved)
#define NETSTAT_TCP_HAVE_OUTPUT_DATA_MASK 32 ///< Value for <i>netstat_tcp_socket.flags</i>. Have data in output buffer
#define NETSTAT_TCP_HAVE_FIN_MASK 64 ///< Value for <i>netstat_tcp_socket.flags</i>. Set when we receive a FIN
#define NETSTAT_TCP_SEND_FIN_MASK 128 ///< Value for <i>netstat_tcp_socket.flags</i>. Send a FIN after all data sent
#define NETSTAT_TCP_OPTION_NAGLE_ENABLED_MASK 1 ///< Value for <i>netstat_tcp_socket.options</i>. Set when Nagle's algorithm enabled
#define NETSTAT_TCP_OPTION_IPV6_MASK 2 ///< Value for <i>netstat_tcp_socket.options</i>. Set when we should talk IPv6 on the socket
#define NETSTAT_TCP_OPTION_SOCKET_ASSIGNED 4 ///< Value for <i>netstat_tcp_socket.options</i>. Assigned an application socket for this TCB
#define NETSTAT_TCP_STATE_CLOSED 0 ///< Value for <i>netstat_tcp_socket.state</i>. The socket is closed.
#define NETSTAT_TCP_STATE_LISTEN 1 ///< Value for <i>netstat_tcp_socket.state</i>. The socket is listening.
#define NETSTAT_TCP_STATE_SYN_SENT 2 ///< Value for <i>netstat_tcp_socket.state</i>. The socket has sent a SYN.
#define NETSTAT_TCP_STATE_SYN_RECEIVED 3 ///< Value for <i>netstat_tcp_socket.state</i>. The socket had received a SYN.
#define NETSTAT_TCP_STATE_ESTABLISHED 4 ///< Value for <i>netstat_tcp_socket.state</i>. The socket connection has been established.
#define NETSTAT_TCP_STATE_FIN_WAIT_1 5 ///< Value for <i>netstat_tcp_socket.state</i>. The socket has been closed, and is waiting for its peer to close.
#define NETSTAT_TCP_STATE_FIN_WAIT_2 6 ///< Value for <i>netstat_tcp_socket.state</i>. The socket's peer has ACKed a FIN.
#define NETSTAT_TCP_STATE_CLOSE_WAIT 7 ///< Value for <i>netstat_tcp_socket.state</i>. The socket's peer has sent a FIN, the application should now close the socket.
#define NETSTAT_TCP_STATE_LAST_ACK 8 ///< Value for <i>netstat_tcp_socket.state</i>. The socket has closed, and is waiting for it's peer to ACK.
#define NETSTAT_TCP_STATE_CLOSING 9 ///< Value for <i>netstat_tcp_socket.state</i>. Both ends have closed the socket.
#define NETSTAT_TCP_STATE_TIME_WAIT 10 ///< Value for <i>netstat_tcp_socket.state</i>. Timeout wait before returning to closed state.
/**
* \brief Returns a pointer to a TCP socket information block.
*
* This function returns a pointer to a specific TCP socket information
* block of type netstat_tcp_socket. There are at most
* #NETSTAT_TCP_MAXSOCKETS, the function returns NULL when a given
* socket number doesn't exist.
* Note that the actual number of sockets in the socket table might change
* at any time. Table entries are not guaranteed to be contiguous. A user
* application * should therefore call this function for all values from 0 to
* #NETSTAT_TCP_MAXSOCKETS - 1 and discard non-existent entries.
*
* \param conn Socket number
*
* \return Far pointer to the socket's information block (or NULL if the socket
* doesn't exist).
*/
//---------------------------------------------------------------------------
netstat_tcp_socket far *netstat_get_tcp_socket(unsigned int conn);
/**
* \brief Returns the number of entries in the TCP socket table.
*
* This function returns the number of used entries in the TCP socket table.
*
* \return Number of entries in the TCP socket table
*/
//---------------------------------------------------------------------------
unsigned int netstat_num_tcp_sockets(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -