Network Component  Version 6.7.5
MDK-Professional Middleware for IP Networking
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rl_net.h File Reference

Data Structures

struct  SOCKADDR
 Generic Socket Address structure. More...
 
struct  IN_ADDR
 Generic IPv4 Address structure. More...
 
struct  SOCKADDR_IN
 IPv4 Socket Address structure. More...
 
struct  HOSTENT
 BSD Host Entry structure. More...
 
struct  SNMP_MIB
 SNMP-MIB Entry info. More...
 
union  IN_ADDR.__unnamed__
 
struct  IN_ADDR.__unnamed__.__unnamed__
 
struct  IN_ADDR.__unnamed__.__unnamed__
 

Macros

#define ntohl(v)   __builtin_bswap32((uint32_t)(v))
 Network to host byte order conversion. More...
 
#define ntohs(v)   __builtin_bswap16((uint16_t)(v))
 
#define htons(v)   ntohs(v)
 Host to network byte order conversion. More...
 
#define htonl(v)   ntohl(v)
 
#define ETH_ADDR_LEN   6
 General definitions. More...
 
#define IP4_ADDR_LEN   4
 IPv4 Address Length in bytes. More...
 
#define IP6_ADDR_LEN   16
 IPv6 Address Length in bytes. More...
 
#define NETIF_ETH   0
 Network Interfaces. More...
 
#define NETIF_PPP   1
 Network interface: PPP. More...
 
#define NETIF_SLIP   2
 Network interface: SLIP. More...
 
#define NETIF_LOCAL   3
 Network interface: Localhost (loopback) More...
 
#define NETIF_NULL   4
 Network interface: Null (none) More...
 
#define UDP_OPT_SEND_CHECKSUM   0x01
 UDP Options. More...
 
#define UDP_OPT_VERIFY_CHECKSUM   0x02
 Verify Checksum for received UDP frames. More...
 
#define TCP_TYPE_SERVER   0x01
 TCP Socket Types. More...
 
#define TCP_TYPE_CLIENT   0x02
 Socket Type: Client (initiate connect) More...
 
#define TCP_TYPE_CLIENT_SERVER   0x03
 Socket Type: Client and Server. More...
 
#define TCP_TYPE_DELAY_ACK   0x04
 Socket Type: Delayed Acknowledge. More...
 
#define TCP_TYPE_FLOW_CTRL   0x08
 Socket Type: Flow Control. More...
 
#define TCP_TYPE_KEEP_ALIVE   0x10
 Socket Type: Keep Alive. More...
 
#define AF_UNSPEC   0
 BSD Socket Address Family. More...
 
#define AF_INET   1
 Internet Address Family (UDP, TCP) More...
 
#define AF_NETBIOS   2
 NetBios-style addresses. More...
 
#define PF_UNSPEC   0
 BSD Protocol families (same as address families) More...
 
#define PF_INET   1
 Internet Address Family (UDP, TCP) More...
 
#define PF_NETBIOS   2
 NetBios-style addresses. More...
 
#define SOCK_STREAM   1
 BSD Socket Type. More...
 
#define SOCK_DGRAM   2
 Datagram Socket (Connectionless) More...
 
#define IPPROTO_TCP   1
 BSD Socket Protocol. More...
 
#define IPPROTO_UDP   2
 UDP Protocol. More...
 
#define INADDR_ANY   0x00000000
 BSD Internet Addresses. More...
 
#define INADDR_NONE   0xffffffff
 No IP address accepted. More...
 
#define MSG_DONTWAIT   0x01
 BSD Socket flags parameter. More...
 
#define MSG_PEEK   0x02
 Peeks at the incoming data. More...
 
#define FIONBIO   1
 BSD Socket ioctl commands. More...
 
#define FIO_DELAY_ACK   2
 Set DELAY_ACK mode for stream socket. More...
 
#define FIO_KEEP_ALIVE   3
 Set KEEP_ALIVE mode for stream socket. More...
 
#define FIO_FLOW_CTRL   4
 Set FLOW_CTRL mode for stream socket. More...
 
#define BSD_SUCCESS   0
 BSD Socket Return values. More...
 
#define BSD_ERROR   (-1)
 General Error. More...
 
#define BSD_ERROR_SOCKET   (-2)
 Invalid socket descriptor. More...
 
#define BSD_ERROR_PARAMETER   (-3)
 Invalid parameter. More...
 
#define BSD_ERROR_WOULDBLOCK   (-4)
 It would have blocked. More...
 
#define BSD_ERROR_NOMEMORY   (-5)
 Not enough memory in memory pool. More...
 
#define BSD_ERROR_CLOSED   (-6)
 Connection is closed or aborted. More...
 
#define BSD_ERROR_LOCKED   (-7)
 Socket is locked by another thread. More...
 
#define BSD_ERROR_TIMEOUT   (-8)
 Socket, Host Resolver timeout. More...
 
#define BSD_ERROR_INPROGRESS   (-9)
 Host Name resolving in progress. More...
 
#define BSD_ERROR_NONAME   (-10)
 Host Name not existing. More...
 
#define MIB_INTEGER   0x02
 SNMP-MIB definitions. More...
 
#define MIB_OCTET_STR   0x04
 MIB entry type OCTET_STRING. More...
 
#define MIB_OBJECT_ID   0x06
 MIB entry type OBJECT_IDENTIFIER. More...
 
#define MIB_IP_ADDR   0x40
 MIB entry type IP ADDRESS (uint8_t[4]) More...
 
#define MIB_COUNTER   0x41
 MIB entry type COUNTER (uint32_t) More...
 
#define MIB_GAUGE   0x42
 MIB entry type GAUGE (uint32_t) More...
 
#define MIB_TIME_TICKS   0x43
 MIB entry type TIME_TICKS. More...
 
#define MIB_ATR_RO   0x80
 MIB entry attribute READ_ONLY. More...
 
#define MIB_OID_SIZE   17
 Max.size of Object ID value. More...
 
#define MIB_STR_SIZE   110
 Max.size of Octet String variable. More...
 
#define MIB_READ   0
 MIB entry Read access. More...
 
#define MIB_WRITE   1
 MIB entry Write access. More...
 
#define MIB_STR(s)   sizeof(s)-1, s
 SNMP-MIB macros. More...
 
#define MIB_INT(o)   sizeof(o), (void *)&o
 
#define MIB_IP(ip)   4, (void *)&ip
 
#define MIB_OID0(f, s)   (f*40 + s)
 
#define SNMP_MIB_SIZE(mib)   (sizeof(mib) / sizeof(SNMP_MIB))
 

Typedefs

typedef void(* net_icmp_cb_t )(icmpEvent event)
 ICMP Event callback function. More...
 
typedef uint32_t(* net_udp_cb_t )(int32_t socket, const uint8_t *ip_addr, uint16_t port, const uint8_t *buf, uint32_t len)
 UDP Event callback function. More...
 
typedef void(* net_sntp_client_cb_t )(uint32_t utc_time)
 SNTP Client callback function. More...
 

Enumerations

enum  ethLinkEvent {
  ethLinkDown = 0,
  ethLinkUp_10MHalfDuplex,
  ethLinkUp_10MFullDuplex,
  ethLinkUp_100MHalfDuplex,
  ethLinkUp_100MFullDuplex,
  ethLinkUp_1GHalfDuplex,
  ethLinkUp_1GFullDuplex
}
 Ethernet Link Callback Events. More...
 
enum  arpCacheType {
  arpCacheFixedIP,
  arpCacheTemporaryIP
}
 ARP Cache Entry types. More...
 
enum  icmpEvent {
  icmpEventSuccess = 0,
  icmpEventTimeout
}
 ICMP (ping) Callback Events. More...
 
enum  dhcpClientOption {
  dhcpClientIPaddress = 0,
  dhcpClientNTPservers = 42,
  dhcpClientBootfileName = 67
}
 DHCP Client Callback Events. More...
 
enum  netStatus {
  netOK = 0,
  netBusy,
  netError,
  netInvalidParameter,
  netWrongState,
  netDriverError,
  netServerError
}
 Network return codes. More...
 
enum  ftpCommand {
  ftpPUT,
  ftpGET,
  ftpAPPEND,
  ftpDELETE,
  ftpLIST,
  ftpRENAME,
  ftpMKDIR,
  ftpRMDIR,
  ftpNLIST
}
 FTP Commands. More...
 
enum  ftpServerEvent {
  ftpServerLogin,
  ftpServerLogout,
  ftpServerLoginFailed,
  ftpServerDownload,
  ftpServerUpload,
  ftpServerDelete,
  ftpServerRename,
  ftpServerMakeDirectory,
  ftpServerRemoveDirectory,
  ftpServerOperationDenied,
  ftpServerLocalFileError,
  ftpServerFileError,
  ftpServerError
}
 FTP Server Events. More...
 
enum  ftpClientRequest {
  ftpClientUsername,
  ftpClientPassword,
  ftpClientPath,
  ftpClientFilename,
  ftpClientNewName,
  ftpClientDirectory,
  ftpClientFilterMask,
  ftpClientList,
  ftpClientLocalFile
}
 FTP Client Requests. More...
 
enum  ftpClientEvent {
  ftpClientSuccess = 0,
  ftpClientTimeout,
  ftpClientLoginFailed,
  ftpClientAccessDenied,
  ftpClientFileNotFound,
  ftpClientInvalidPath,
  ftpClientLocalFileError,
  ftpClientError
}
 FTP Client Events. More...
 
enum  tftpClientEvent {
  tftpClientSuccess = 0,
  tftpClientTimeout,
  tftpClientAccessDenied,
  tftpClientFileNotFound,
  tftpClientDiskFull,
  tftpClientError
}
 TFTP Client Events. More...
 
enum  telnetServerMessage {
  telnetServerWelcome,
  telnetServerPrompt,
  telnetServerLogin,
  telnetServerUsername,
  telnetServerPassword,
  telnetServerLoginFailed,
  telnetServerLoginTimeout,
  telnetServerUnsolicitedMessage
}
 Telnet Server Messages. More...
 
enum  smtpClientRequest {
  smtpClientUsername,
  smtpClientPassword,
  smtpClientSender,
  smtpClientRecipient,
  smtpClientSubject,
  smtpClientBody
}
 SMTP Client Request. More...
 
enum  smtpClientEvent {
  smtpClientSuccess = 0,
  smtpClientTimeout,
  smtpClientError
}
 SMTP Client Events. More...
 

Functions

netStatus net_initialize (void)
 Initialize Network Component, resources and interfaces. More...
 
int net_main (void)
 Run Network Component main function. More...
 
netStatus netif_set_default (uint8_t netif)
 Set default network interface used for internet access. More...
 
int32_t udp_get_socket (uint8_t tos, uint8_t opt, net_udp_cb_t cb_func)
 Allocate a free UDP socket. More...
 
netStatus udp_release_socket (int32_t socket)
 Release UDP socket and free resources. More...
 
netStatus udp_open (int32_t socket, uint16_t port)
 Open UDP socket for communication. More...
 
netStatus udp_close (int32_t socket)
 Stop UDP communication and close socket. More...
 
netStatus udp_multicast_ttl (int32_t socket, uint8_t ttl)
 Set Time To Live value for multicast packets. More...
 
uint8_t * udp_get_buf (uint32_t size)
 Allocate memory for UDP send buffer. More...
 
netStatus udp_send (int32_t socket, const uint8_t *ip_addr, uint16_t port, uint8_t *buf, uint32_t len)
 Send data to a remote node. More...
 
const char * tcp_ntoa (tcpState state)
 Convert TCP socket state into an ASCII string. More...
 
int socket (int family, int type, int protocol)
 Create a communication endpoint called socket. More...
 
int bind (int sock, const SOCKADDR *addr, int addrlen)
 Assign a local address and port to a socket. More...
 
int listen (int sock, int backlog)
 Set a socket in a listening mode. More...
 
int accept (int sock, SOCKADDR *addr, int *addrlen)
 Accept connect request for a listening socket. More...
 
int connect (int sock, SOCKADDR *addr, int addrlen)
 Connect a socket to a remote host. More...
 
int send (int sock, const char *buf, int len, int flags)
 Send data on already connected socket. More...
 
int sendto (int sock, const char *buf, int len, int flags, SOCKADDR *to, int tolen)
 Send data to endpoint node. More...
 
int recv (int sock, char *buf, int len, int flags)
 Receive data on already connected socket. More...
 
int recvfrom (int sock, char *buf, int len, int flags, SOCKADDR *from, int *fromlen)
 Receive data from endpoint node. More...
 
int closesocket (int sock)
 Close socket and release socket descriptor. More...
 
int getpeername (int sock, SOCKADDR *name, int *namelen)
 Retrieve IP address and port number of the endpoint node. More...
 
int getsockname (int sock, SOCKADDR *name, int *namelen)
 Retrieve local IP address and port number. More...
 
int ioctlsocket (int sock, long cmd, unsigned long *argp)
 Control IO mode of a socket. More...
 
HOSTENTgethostbyname (const char *name, int *err)
 Retrieve host IP address from host name. More...
 
netStatus arp_cache_ip (uint32_t if_num, const uint8_t *ip_addr, arpCacheType type)
 Determine whether the ARP table has MAC address resolved for requested IP address. More...
 
netStatus arp_cache_mac (uint32_t if_num, const uint8_t *mac_addr)
 Determine whether the ARP table has IP address resolved for requested MAC address. More...
 
netStatus arp_get_ip (const uint8_t *mac_addr, uint8_t *ip_addr)
 Get IP address from the ARP cache. More...
 
netStatus arp_get_mac (const uint8_t *ip_addr, uint8_t *mac_addr)
 Get MAC address from the ARP cache. More...
 
netStatus dhcp_disable (uint32_t if_num)
 Disable Dynamic Host Configuration at runtime. More...
 
netStatus igmp_join (uint32_t if_num, const uint8_t *ip_addr)
 Join this host to a host group specified with IP address. More...
 
netStatus igmp_leave (uint32_t if_num, const uint8_t *ip_addr)
 Leave a host group specified with IP address. More...
 
void eth_link_notify (uint32_t if_num, ethLinkEvent event)
 Notify the user of Ethernet link state change event. More...
 
void dhcp_client_notify (uint32_t if_num, dhcpClientOption opt, const uint8_t *val, uint32_t len)
 Notify the user of DHCP event or extended DHCP option. More...
 
netStatus ppp_listen (const char *username, const char *password)
 Start PPP interface to accept incoming PPP connection. More...
 
netStatus ppp_connect (const char *dial_num, const char *username, const char *password)
 Start a dial-up connection to remote PPP server. More...
 
netStatus ppp_close (void)
 Disconnect PPP link between two modems. More...
 
bool ppp_is_up (void)
 Determine the state of PPP link. More...
 
netStatus slip_listen (void)
 Start SLIP interface to accept incoming SLIP connections. More...
 
netStatus slip_connect (const char *dial_num)
 Start a dial-up connection to remote SLIP server. More...
 
netStatus slip_close (void)
 Disconnect SLIP link between two modems. More...
 
bool slip_is_up (void)
 Determine the state of SLIP link. More...
 
netStatus icmp_ping (const uint8_t *ip_addr, net_icmp_cb_t cb_func)
 Start ICMP ping process. More...
 
netStatus get_host_by_name (const char *name, net_dns_client_cb_t cb_func)
 Resolve IP address of a host from a hostname. More...
 
bool ftp_accept_client (const uint8_t *ip_addr, uint16_t port)
 Accept or deny connection from remote FTP client. More...
 
uint8_t ftp_check_username (const char *username)
 Check if an user account exist in the user database. More...
 
bool ftp_check_password (uint8_t user_id, const char *password)
 Check user account password in the user database. More...
 
bool ftp_file_access (uint8_t user_id, const char *fname, uint8_t mode)
 Check if remote user is allowed to access a file on FTP server. More...
 
uint8_t ftp_get_user_id (void)
 Retrieve the user identification. More...
 
void ftp_server_notify (ftpServerEvent event)
 Notify the user application about events in FTP server service. More...
 
void * ftp_server_fopen (const char *fname, const char *mode)
 Open a file for reading or writing in FTP server. More...
 
void ftp_server_fclose (void *file)
 Close a file previously open in FTP server. More...
 
uint32_t ftp_server_fread (void *file, uint8_t *buf, uint32_t len)
 Read block of data from a file in FTP server. More...
 
uint32_t ftp_server_fwrite (void *file, const uint8_t *buf, uint32_t len)
 Write block of data to a file in FTP server. More...
 
bool ftp_server_fdelete (const char *fname)
 Delete a file in FTP server. More...
 
bool ftp_server_frename (const char *fname, const char *newname)
 Rename a file or directory in FTP server. More...
 
bool ftp_server_mkdir (const char *path)
 Make a new directory in FTP server. More...
 
bool ftp_server_rmdir (const char *path)
 Remove an empty directory in FTP server. More...
 
uint32_t ftp_server_ffind (uint8_t code, char *buf, uint32_t buflen, const char *mask)
 Search the file system directory for matching files. More...
 
netStatus ftp_client_connect (const uint8_t *ip_addr, uint16_t port, ftpCommand command)
 Start FTP client file operation session. More...
 
uint32_t ftp_client_request (ftpClientRequest request, char *buf, uint32_t len)
 Request parameters for FTP client session. More...
 
void ftp_client_notify (ftpClientEvent event)
 Notify the user application when FTP client operation ends. More...
 
void * ftp_client_fopen (const char *fname, const char *mode)
 Open local file for reading or writing in FTP client. More...
 
void ftp_client_fclose (void *file)
 Close local file previously open in FTP client. More...
 
uint32_t ftp_client_fread (void *file, uint8_t *buf, uint32_t len)
 Read block of data from local file in FTP client. More...
 
uint32_t ftp_client_fwrite (void *file, const uint8_t *buf, uint32_t len)
 Write block of data to local file in FTP client. More...
 
bool tftp_accept_client (const uint8_t *ip_addr, uint16_t port)
 Accept or deny connection from remote TFTP client. More...
 
void * tftp_server_fopen (const char *fname, const char *mode)
 Open a file for reading or writing in TFTP server. More...
 
void tftp_server_fclose (void *file)
 Close a file previously open in TFTP server. More...
 
uint32_t tftp_server_fread (void *file, uint8_t *buf, uint32_t len)
 Read block of data from a file in TFTP server. More...
 
uint32_t tftp_server_fwrite (void *file, const uint8_t *buf, uint32_t len)
 Write block of data to a file in TFTP server. More...
 
netStatus tftp_client_put (const uint8_t *ip_addr, uint16_t port, const char *src, const char *dst)
 Put a file to remote TFTP server. More...
 
netStatus tftp_client_get (const uint8_t *ip_addr, uint16_t port, const char *src, const char *dst)
 Retrieve a file from remote TFTP server. More...
 
void tftp_client_notify (tftpClientEvent event)
 Notify the user application when TFTP client operation ends. More...
 
void * tftp_client_fopen (const char *fname, const char *mode)
 Open local file for reading or writing in TFTP client. More...
 
void tftp_client_fclose (void *file)
 Close local file previously open in TFTP client. More...
 
uint32_t tftp_client_fread (void *file, uint8_t *buf, uint32_t len)
 Read block of data from local file in TFTP client. More...
 
uint32_t tftp_client_fwrite (void *file, const uint8_t *buf, uint32_t len)
 Write block of data to local file in TFTP client. More...
 
netStatus telnet_server_set_delay (uint32_t delay)
 Set a delay between two consecutive calls to telnet_server_process function. More...
 
netStatus telnet_server_get_client (uint8_t *ip_addr, uint8_t *mac_addr)
 Get IP and MAC address of connected remote machine. More...
 
int32_t telnet_server_get_session (void)
 Get current session number of Telnet server. More...
 
bool telnet_check_command (const char *cmd, const char *user_cmd)
 Check command string for a command. More...
 
uint32_t telnet_server_message (telnetServerMessage msg, char *buf, uint32_t len)
 Request message for Telnet server session. More...
 
uint32_t telnet_server_process (const char *cmd, char *buf, uint32_t buflen, uint32_t *pvar)
 Process and execute a command requested by the Telnet client. More...
 
bool telnet_server_message_poll (int32_t session)
 Poll the upper-layer user application for unsolicited messages. More...
 
bool telnet_accept_client (const uint8_t *ip_addr, uint16_t port)
 Accept or deny connection from remote Telnet client. More...
 
uint8_t telnet_check_username (const char *username)
 Check if an user account exist in the user database. More...
 
bool telnet_check_password (uint8_t user_id, const char *password)
 Check user account password in the user database. More...
 
uint8_t telnet_get_user_id (void)
 Retrieve the user identification. More...
 
const char * http_get_env_var (const char *env, char *ansi, uint32_t maxlen)
 Process environment variables and convert to ANSI format. More...
 
uint32_t http_utc_time (uint8_t hr, uint8_t min, uint8_t sec, uint8_t day, uint8_t mon, uint16_t year)
 Convert generic time to UTC time format. More...
 
netStatus http_server_get_client (uint8_t *ip_addr, uint8_t *mac_addr)
 Get IP and MAC address of connected remote machine. More...
 
int32_t http_server_get_session (void)
 Get current session number of HTTP server. More...
 
const char * http_server_get_lang (void)
 Retrieve the preferred language setting from the browser. More...
 
const char * http_server_get_content_type (void)
 Get Content-Type HTML header, received in XML post request. More...
 
void cgi_process_query (const char *qstr)
 Process query string received by GET request. More...
 
void cgi_process_data (uint8_t code, const char *data, uint32_t len)
 Process data received by POST request. More...
 
uint32_t cgi_script (const char *env, char *buf, uint32_t buflen, uint32_t *pcgi)
 Generate dynamic web data from a script line. More...
 
const char * cgi_content_type (const char *file_ext)
 Add custom MIME type for unsupported file types. More...
 
const char * cgx_content_type (void)
 Override default Content-Type for CGX script files. More...
 
const char * http_encoding (void)
 Override default character encoding in html documents. More...
 
bool http_accept_client (const uint8_t *ip_addr, uint16_t port)
 Accept or deny connection from remote HTTP client. More...
 
uint8_t http_check_account (const char *username, const char *password)
 Check if an user account exist in the user database. More...
 
bool http_file_access (uint8_t user_id, const char *fname)
 Check if remote user is allowed to access a file on HTTP server. More...
 
uint8_t http_get_user_id (void)
 Retrieve the user identification. More...
 
void * http_server_fopen (const char *fname)
 Open a file for reading in HTTP server. More...
 
void http_server_fclose (void *file)
 Close a file previously open in HTTP server. More...
 
uint32_t http_server_fread (void *file, uint8_t *buf, uint32_t len)
 Read block of data from a file in HTTP server. More...
 
char * http_server_fgets (void *file, char *buf, uint32_t size)
 Read a string from a file in HTTP server. More...
 
uint32_t http_server_ftime (const char *fname)
 Retrieve last modification time of a file. More...
 
netStatus smtp_client_connect (const uint8_t *ip_addr, uint16_t port)
 Start SMTP client to send an email. More...
 
uint32_t smtp_client_request (smtpClientRequest request, char *buf, uint32_t buflen, uint32_t *pvar)
 Request parameters for SMTP client session. More...
 
void smtp_client_notify (smtpClientEvent event)
 Notify the user application when SMTP client operation ends. More...
 
bool smtp_client_accept_authentication (const uint8_t *ip_addr)
 Accept or deny authentication requested by SMTP server. More...
 
netStatus sntp_get_time (const uint8_t *ip_addr, net_sntp_client_cb_t cb_func)
 Determine current time from NTP or SNTP time server. More...
 
netStatus snmp_trap (const uint8_t *ip_addr, uint8_t generic, uint8_t specific, const uint16_t *obj_list)
 Send a trap message to the Trap Manager. More...
 
netStatus snmp_set_community (const char *community)
 Change SNMP community to a new community. More...
 
const char * ip4_ntoa (const uint8_t *ip4_addr)
 Convert an IPv4 Network address into an ASCII string. More...
 
bool ip4_aton (const char *cp, uint8_t *ip4_addr)
 Convert a string containing an IPv4 address into a Network address. More...
 
const char * mac_ntoa (const uint8_t *mac_addr)
 Convert a MAC address into an ASCII string. More...
 
bool mac_aton (const char *cp, uint8_t *mac_addr)
 Convert a string containing a MAC address into a binary MAC address. More...
 
int32_t tcp_get_socket (uint8_t type, uint8_t tos, uint32_t tout, net_tcp_cb_t cb_func)
 Allocate a free TCP socket. More...
 
netStatus tcp_release_socket (int32_t socket)
 Release TCP socket and free resources. More...
 
netStatus tcp_listen (int32_t socket, uint16_t port)
 Open TCP socket for incoming connection. More...
 
netStatus tcp_connect (int32_t socket, const uint8_t *ip_addr, uint16_t port, uint16_t local_port)
 Initiate a TCP connection to a remote node. More...
 
uint8_t * tcp_get_buf (uint32_t size)
 Allocate memory for TCP send buffer. More...
 
uint32_t tcp_max_data_size (int32_t socket)
 Determine maximum number of data bytes that can be sent in TCP packet. More...
 
bool tcp_check_send (int32_t socket)
 Check if TCP socket can send data. More...
 
tcpState tcp_get_state (int32_t socket)
 Determine current state of a TCP socket. More...
 
netStatus tcp_send (int32_t socket, uint8_t *buf, uint32_t len)
 Send a data packet to remote node. More...
 
netStatus tcp_close (int32_t socket)
 Stop TCP communication and start closing procedure. More...
 
netStatus tcp_abort (int32_t socket)
 Instantly stop TCP communication. More...
 
netStatus tcp_reset_window (int32_t socket)
 Reset TCP window size to a default value from the configuration. More...
 
enum  tcpEvent {
  tcpEventConnect = 0,
  tcpEventEstablished,
  tcpEventClosed,
  tcpEventAbort,
  tcpEventACK,
  tcpEventData
}
 TCP Callback Events. More...
 
enum  tcpState {
  tcpStateUNUSED = 0,
  tcpStateCLOSED,
  tcpStateLISTEN,
  tcpStateSYN_RECEIVED,
  tcpStateSYN_SENT,
  tcpStateFIN_WAIT_1,
  tcpStateFIN_WAIT_2,
  tcpStateCLOSING,
  tcpStateLAST_ACK,
  tcpStateTIME_WAIT,
  tcpStateESTABLISHED
}
 TCP States. More...
 
typedef uint32_t(* net_tcp_cb_t )(int32_t socket, tcpEvent event, const uint8_t *buf, uint32_t len)
 TCP Event callback function. More...
 
enum  dnsClientEvent {
  dnsClientSuccess = 0,
  dnsClientTimeout,
  dnsClientNotResolved,
  dnsClientError
}
 DNS Client Callback Events. More...
 
typedef void(* net_dns_client_cb_t )(dnsClientEvent event, const uint8_t *ip_addr)
 DNS Client Event callback function. More...
 

Macro Definition Documentation

#define AF_INET   1

Internet Address Family (UDP, TCP)

#define AF_NETBIOS   2

NetBios-style addresses.

#define AF_UNSPEC   0

BSD Socket Address Family.

Unspecified

#define BSD_ERROR   (-1)

General Error.

#define BSD_ERROR_CLOSED   (-6)

Connection is closed or aborted.

#define BSD_ERROR_INPROGRESS   (-9)

Host Name resolving in progress.

#define BSD_ERROR_LOCKED   (-7)

Socket is locked by another thread.

#define BSD_ERROR_NOMEMORY   (-5)

Not enough memory in memory pool.

#define BSD_ERROR_NONAME   (-10)

Host Name not existing.

#define BSD_ERROR_PARAMETER   (-3)

Invalid parameter.

#define BSD_ERROR_SOCKET   (-2)

Invalid socket descriptor.

#define BSD_ERROR_TIMEOUT   (-8)

Socket, Host Resolver timeout.

#define BSD_ERROR_WOULDBLOCK   (-4)

It would have blocked.

#define BSD_SUCCESS   0

BSD Socket Return values.

Success

#define ETH_ADDR_LEN   6

General definitions.

Ethernet Address Length in bytes

#define FIO_DELAY_ACK   2

Set DELAY_ACK mode for stream socket.

#define FIO_FLOW_CTRL   4

Set FLOW_CTRL mode for stream socket.

#define FIO_KEEP_ALIVE   3

Set KEEP_ALIVE mode for stream socket.

#define FIONBIO   1

BSD Socket ioctl commands.

Set mode (blocking/non-blocking)

#define htonl (   v)    ntohl(v)
#define htons (   v)    ntohs(v)

Host to network byte order conversion.

#define INADDR_ANY   0x00000000

BSD Internet Addresses.

All IP addresses accepted

#define INADDR_NONE   0xffffffff

No IP address accepted.

#define IP4_ADDR_LEN   4

IPv4 Address Length in bytes.

#define IP6_ADDR_LEN   16

IPv6 Address Length in bytes.

#define IPPROTO_TCP   1

BSD Socket Protocol.

TCP Protocol

#define IPPROTO_UDP   2

UDP Protocol.

#define MIB_ATR_RO   0x80

MIB entry attribute READ_ONLY.

#define MIB_COUNTER   0x41

MIB entry type COUNTER (uint32_t)

#define MIB_GAUGE   0x42

MIB entry type GAUGE (uint32_t)

#define MIB_INT (   o)    sizeof(o), (void *)&o
#define MIB_INTEGER   0x02

SNMP-MIB definitions.

MIB entry type INTEGER

#define MIB_IP (   ip)    4, (void *)&ip
#define MIB_IP_ADDR   0x40

MIB entry type IP ADDRESS (uint8_t[4])

#define MIB_OBJECT_ID   0x06

MIB entry type OBJECT_IDENTIFIER.

#define MIB_OCTET_STR   0x04

MIB entry type OCTET_STRING.

#define MIB_OID0 (   f,
 
)    (f*40 + s)
#define MIB_OID_SIZE   17

Max.size of Object ID value.

#define MIB_READ   0

MIB entry Read access.

#define MIB_STR (   s)    sizeof(s)-1, s

SNMP-MIB macros.

#define MIB_STR_SIZE   110

Max.size of Octet String variable.

#define MIB_TIME_TICKS   0x43

MIB entry type TIME_TICKS.

#define MIB_WRITE   1

MIB entry Write access.

#define MSG_DONTWAIT   0x01

BSD Socket flags parameter.

Enables non-blocking operation

#define MSG_PEEK   0x02

Peeks at the incoming data.

#define NETIF_ETH   0

Network Interfaces.

Network interface: Ethernet

#define NETIF_LOCAL   3

Network interface: Localhost (loopback)

#define NETIF_NULL   4

Network interface: Null (none)

#define NETIF_PPP   1

Network interface: PPP.

#define NETIF_SLIP   2

Network interface: SLIP.

#define ntohl (   v)    __builtin_bswap32((uint32_t)(v))

Network to host byte order conversion.

#define ntohs (   v)    __builtin_bswap16((uint16_t)(v))
#define PF_INET   1

Internet Address Family (UDP, TCP)

#define PF_NETBIOS   2

NetBios-style addresses.

#define PF_UNSPEC   0

BSD Protocol families (same as address families)

Unspecified

#define SNMP_MIB_SIZE (   mib)    (sizeof(mib) / sizeof(SNMP_MIB))
#define SOCK_DGRAM   2

Datagram Socket (Connectionless)

#define SOCK_STREAM   1

BSD Socket Type.

Stream Socket (Connection oriented)

#define TCP_TYPE_CLIENT   0x02

Socket Type: Client (initiate connect)

#define TCP_TYPE_CLIENT_SERVER   0x03

Socket Type: Client and Server.

#define TCP_TYPE_DELAY_ACK   0x04

Socket Type: Delayed Acknowledge.

#define TCP_TYPE_FLOW_CTRL   0x08

Socket Type: Flow Control.

#define TCP_TYPE_KEEP_ALIVE   0x10

Socket Type: Keep Alive.

#define TCP_TYPE_SERVER   0x01

TCP Socket Types.

Socket Type: Server (open for listening)

#define UDP_OPT_SEND_CHECKSUM   0x01

UDP Options.

Calculate Checksum for UDP send frames

#define UDP_OPT_VERIFY_CHECKSUM   0x02

Verify Checksum for received UDP frames.

Enumeration Type Documentation

enum netStatus

Network return codes.

Enumerator
netOK 

Operation succeeded.

netBusy 

Process is busy.

netError 

Unspecified error.

netInvalidParameter 

Invalid parameter specified.

netWrongState 

Wrong state error.

netDriverError 

Driver error.

netServerError 

DNS/SNTP server error.

Function Documentation

bool ftp_server_mkdir ( const char *  path)

Make a new directory in FTP server.

Parameters
[in]pathdirectory path to create.
Returns
  • true = Directory successfully created.
  • false = Failed to create a directory.
bool ftp_server_rmdir ( const char *  path)

Remove an empty directory in FTP server.

Parameters
[in]pathdirectory path to remove.
Returns
  • true = Directory successfully removed.
  • false = Failed to remove a directory.
bool ip4_aton ( const char *  cp,
uint8_t *  ip4_addr 
)

Convert a string containing an IPv4 address into a Network address.

Parameters
[in]cpaddress string in dotted-decimal notation.
[out]ip4_addrIPv4 address.
Returns
  • true = Conversion successful.
  • false = Conversion failed.
const char* ip4_ntoa ( const uint8_t *  ip4_addr)

Convert an IPv4 Network address into an ASCII string.

Parameters
[in]ip4_addrIPv4 address.
Returns
pointer to a static buffer containing address string in dotted-decimal notation.
bool mac_aton ( const char *  cp,
uint8_t *  mac_addr 
)

Convert a string containing a MAC address into a binary MAC address.

Parameters
[in]cpaddress string in hyphen MAC-address notation.
[out]mac_addrMAC address.
Returns
  • true = Conversion successful.
  • false = Conversion failed.
const char* mac_ntoa ( const uint8_t *  mac_addr)

Convert a MAC address into an ASCII string.

Parameters
[in]mac_addrMAC address.
Returns
pointer to a static buffer containing address string in hyphen MAC-address notation.
const char* tcp_ntoa ( tcpState  state)

Convert TCP socket state into an ASCII string.

Parameters
[in]statesocket state as defined with tcpState
Returns
pointer to a buffer containing the text representation of a socket state.