TCP/IP protocol library. More...
Data Structures | |
struct | adapter_t |
struct | in_struct |
Incoming protocol information. More... | |
struct | out_struct |
Outgoing protocol information. More... | |
struct | SOCKET |
Unique description of a bidirectional network communication channel. More... | |
struct | addr_type |
Hardware MAC / IP address pair description. More... | |
struct | arp_list_type |
Hardware address cache description. More... | |
struct | direntry_type |
Embedded File System directory. More... | |
struct | user_type |
User authentication and directory specification. More... | |
Macros | |
#define | NULL ((void *)_MAKE_32(0)) |
#define | null ((void *)_MAKE_32(0)) |
#define | true TRUE |
#define | false FALSE |
#define | UDP_MAX_PACKET_SIZE 1472L |
#define | TCP_MAX_PACKET_SIZE 1460L |
#define | IS_LINKLOCAL(a) ((a & 0xffff0000) == 0xfea90000 ) |
#define | _FSYS_DEF |
#define | MAX_USER 10 |
#define | MAX_DIR 200 |
#define | MAX_NAME_LEN 60 |
#define | MAX_USERNAME_LEN 30 |
#define | MAX_PASS_LEN 30 |
#define | EFS_TERMINATION (_MAKE_32(0)) |
#define | tpOutputFunc tpOutputFunc |
Adapter | |
adapter_t is a user-defined global structure for required network parameter such as IP address, MAC address, gateway etc. | |
#define | adapter_t |
Adapter type | |
#define | ETH8900 1 /* CS8900 */ |
#define | ETH91C111 2 /* SMSC91C111 */ |
#define | ETHEMAC 3 /* DM642,DM648,L137,C6657 */ |
#define | ETHAX88783 4 /* AX88783 */ |
#define | ETHDM9010B 5 /* DM9010B */ |
#define | ETHKSZ8851 6 /* KSZ8851 */ |
#define | ETHDM9016 7 /* DM9016 */ |
Operation Mode | |
Operation mode parameter for d91c111_ext_init() or DM2_EmacInit() | |
#define | FULL_DUPLEX 0x01 |
#define | HALF_DUPLEX 0x00 |
#define | SPEED_10 0x00 |
#define | SPEED_100 0x04 |
#define | AUTO_NEG 0x08 |
#define | SPEED_1000 0x20 |
#define | FDX_100 (FULL_DUPLEX | SPEED_100 ) |
#define | FDX_10 (FULL_DUPLEX | SPEED_10 ) |
#define | HDX_100 (HALF_DUPLEX | SPEED_100 ) |
#define | HDX_10 (HALF_DUPLEX | SPEED_10 ) |
#define | FDX_1000 (FULL_DUPLEX | SPEED_1000) |
#define | FIBER_MODE 0x10 |
Service Mode | |
Service mode parameter for net_init() | |
#define | DHCP_ENABLE |
#define | DNS_ENABLE |
Socket Error Codes | |
Socket Error Codes, read with socket_struct ->error_code
| |
#define | SO_NO_ERROR 0x00000000 /* no error */ |
#define | SO_TRANSMIT_ERROR 0x00000001 /* Transmit error */ |
#define | SO_NO_ARP_ADDRESS 0x00000002 /* Unresolved destination MAC */ |
#define | SO_TIMED_OUT 0x00000003 /* transfer function timed out */ |
#define | SO_IN_USE 0x00000004 /* TCP only: not ready */ |
#define | SO_NOT_ESTABLISHED 0x00000005 /* TCP only: not connected */ |
#define | SO_CONNECTION_RESET 0x00000006 /* TCP only: connection reset by remote host */ |
#define | SO_WRONG_CHECKSUM 0x00000007 /* net_recv():: data checksum failed */ |
#define | SO_BUFFER_TOO_SMALL 0x00000008 /* net_recv():: data > maxdatalen received */ |
#define | SO_NO_INPUT_BUFFER 0x00000009 /* net_recv():: NULL pointer given as data buffer */ |
#define | SO_NOT_OPEN 0x0000000a /* Socket is not open */ |
#define | SO_CONNECTION_CLOSED 0x0000000c /* TCP only: connection closed */ |
#define | SO_WINDOW_ERR 0x0000000d /* TCP only: window size zero received */ |
#define | SO_CONNECTION_ESTABLISHED 0x0000000e /* TCP only: connected */ |
#define | SO_MMU_ERROR 0x0000000f /* SMCS91c111: MMU error */ |
#define | SO_SEND_PENDING 0x00000010 /* Send pending */ |
#define | SO_NO_LINK 0x00000011 /* No valid link */ |
#define | SO_DNS_ERR 0x00000012 /* Name resolution missing or pending */ |
#define | SO_NO_TCP_MEM 0x00000013 /* TCP out of memory */ |
#define | SO_ERROR_MASK 0x7fffffff /* socket error mask */ |
Socket data and protocol types | |
Use with socket_open() | |
#define | DATATYPE_CHAR 0x1 |
#define | DATATYPE_SHORT 0x2 |
#define | DATATYPE_INT 0x4 |
#define | IPT_TCP |
#define | IPT_UDP |
#define | TCP_INIT_FUNC |
#define | UDP_INIT_FUNC |
#define | ICMP_INIT_FUNC |
Well known addresses | |
#define | ANY_ADDRESS "0.0.0.0" /* Any IP address */ |
#define | BROADCAST "255.255.255.255" /* Broadcast IP address */ |
Well known ports | |
#define | ANY_PORT 0 |
#define | ECHO_PORT 0x07 |
#define | TIME_SERVER_PORT 0x0D |
#define | FTP_DATA_PORT 0x14 |
#define | FTP_CONTROL_PORT 0x15 |
#define | TELNET_PORT 0x17 |
#define | DNS_SERVER_PORT 0x35 |
#define | DHCP_SERVER_PORT 0x43 |
#define | DHCP_CLIENT_PORT 0x44 |
#define | TFTP_SERVER_PORT 0x45 |
Socket Configuration Failure | |
socket_open() return value in case of insufficient memory or illegal configuration parameters | |
#define | INVALID_SOCKET NULL |
Socket Option | |
Use with set_socket_option() | |
#define | SO_UDP_NO_CHECKSUM 0x00000004 /* UDP w/o checksum */ |
#define | SO_TCP_STATE_CLOSED 0x00000008 /* use TCP state closed */ |
#define | SO_TCP_NO_RETRANS 0x00000020 /* disable TCP retransmit */ |
#define | SO_TCP_NO_FAST_RETRANS 0x00000040 /* disable fast TCP retransmit */ |
#define | SO_USE_PROXY 0x00000200 /* use proxy server */ |
Socket Failure | |
Socket Error, net_recv() and net_send() return code | |
#define | SOCKET_ERROR (_MAKE_32(-1)) |
Socket callback function return parameter | |
#define | SOCKET_CB_OK (_MAKE_32(1)) |
#define | SOCKET_CB_CLOSED (_MAKE_32(-1)) |
net_send() return value | |
#define | NET_SEND_PENDING (0L) /* net_send() pending, check error code */ |
#define | NET_SEND_SUCCESS (1L) /* net_send() success */ |
#define | NET_SEND_ERROR (-1L) /* net_send() fatal error */ |
net_recv() return value | |
#define | NET_RECV_EVENT (-1L) /* net_recv() event */ |
TCP state | |
use with tcp_get_state() | |
#define | TCP_CLOSED 0 |
#define | TCP_LISTEN 1 |
#define | TCP_SYN_SENT 2 |
#define | TCP_SYN_RECEIVED 3 |
#define | TCP_ESTABLISHED 4 |
TCP options | |
use with tcp_set_option() | |
#define | TCP_UNA_SEG 1 /* TCP unacknowledged segment size */ |
#define | TCP_RETRANS_DELAY 2 /* TCP retransmit delay time */ |
Multicast check | |
Macro for testing multicast messages | |
#define | IS_MULTICAST(a) ((a & 0x00f00000) == 0x00e00000 ) |
Access Permission | |
use with direntry_type.access | |
#define | FTP_READ 1 |
#define | FTP_CREATE 2 |
#define | FTP_WRITE 4 |
#define | FTP_RW (FTP_READ | FTP_WRITE) |
#define | FTP_RAM 8 |
#define | FTP_FAT 16 |
#define | HTTP_GZIP 512 |
Flags | |
Use with fsys_send_all() | |
#define | FSYS_SEND_ALL 0x00000010 |
#define | FSYS_WRITE_BOOT_SECTOR 0x00000020 |
#define | FSYS_ERASE_SECTOR 0x00000040 |
Return codes | |
Use with fsys_send_all() | |
#define | FSYS_BIOS_PROTECT_ERROR -1 |
#define | FSYS_CHECKSUM_ERROR -2 |
#define | FSYS_INTEL_HEX_ERROR -3 |
#define | FSYS_SECTOR_ERASE_ERROR -4 |
#define | FSYS_FLASH_PROGRAM_ERROR -5 |
#define | FSYS_BUFFER_UNDERRUN_ERROR -6 |
#define | FSYS_OUT_OF_MEMORY_ERROR -7 |
#define | FSYS_OUT_OF_RANGE_ERROR -8 |
Typedefs | |
typedef int(* | tpOutputFunc) (const char *format,...) |
Functions | |
int32_t | net_init (char *ip, char *subnet, char *gateway, uint32_t(*dhcp_func)(char *, uint16_t), char *dns, uint32_t(*dns_func)(void)) |
Main network initialization function. More... | |
SOCKET * | socket_open (char *dest_addr, uint16_t dest_port, uint16_t src_port, uint8_t data_type, int32_t(*init_func)(SOCKET *)) |
Create a new socket. More... | |
int32_t | socket_close (SOCKET *so) |
Close a socket and free all associated memory. More... | |
void | socket_define_callback (SOCKET *so, int32_t(*call_back_function)(SOCKET *, void *, uint32_t, uint32_t), void *data, uint16_t maxdata) |
Install a user callback function for a specific socket. More... | |
void * | socket_get_data_pointer (SOCKET *so) |
Retrieve a data pointer from socket. More... | |
uint32_t | set_socket_option (SOCKET *so, uint32_t option) |
Modify socket options. More... | |
arp_list_type * | arp_check_ip_address (uint32_t ip, uint16_t dev_nr) |
Perform MAC address lookup in local ARP cache to find MAC address for specified IP address. More... | |
arp_list_type * | check_arp_address (SOCKET *so, uint32_t request_time) |
Perform address resolution. More... | |
void | arp_clear_cache (void) |
Invalidate ARP cache. More... | |
void | arp_set_timeout (uint32_t val) |
Set timebase for ARP cache. More... | |
void | arp_invalid_ip_address (uint32_t ip) |
Invalidates specific IP address. More... | |
int16_t | send_ip (SOCKET *so, addr_type *dest, uint16_t len, uint16_t id) |
Low-level send function for sending RAW IP packets. More... | |
int32_t | net_send (SOCKET *so, void *data, uint16_t len) |
Send a message via the specified socket. More... | |
int32_t | net_send_string (SOCKET *so, char *data) |
Send a zero terminated string via the specified socket. More... | |
int32_t | net_send_ready (SOCKET *so, void *data, uint32_t len, uint32_t timeout) |
Send a message via the specified socket, wait until message is successfully transmitted or a timeout occurred. More... | |
int32_t | net_recv (SOCKET *so, void *data, uint16_t maxdatasize) |
Receive data via the specified socket. More... | |
int32_t | set_recv_buffer (SOCKET *so, void *data, uint16_t maxdatasize) |
Define a socket buffer. More... | |
int32_t | net_recv_ready (SOCKET *so, void *data, int32_t *len, uint32_t timeout) |
Receive data via the specified socket, wait until message is successfully received and connection closed from sender or a timeout occurred. More... | |
void | net_isq (void) |
The main polling function for processing sockets, must be periodically called in the main application. More... | |
SOCKET * | install_icmp_socket (uint16_t size) |
Install an ICMP socket for ping and messages. More... | |
int32_t | connect (SOCKET *so, void *data, uint32_t send_max, int32_t timeout) |
Actively establish a connection. More... | |
int32_t | shutdown (SOCKET *so, int32_t timeout) |
Active shut-down of a TCP connection. More... | |
SOCKET * | accept (SOCKET *so) |
Check TCP state; if connection established, the socket descriptor is returned else NULL. More... | |
int32_t | tcp_listen (SOCKET *so) |
Switch socket to listening state. More... | |
uint16_t | tcp_set_option (SOCKET *so, uint32_t option, uint32_t val) |
Set a TCP option. More... | |
int16_t | tcp_get_state (SOCKET *so) |
Determine tcp state. More... | |
uint16_t | tcp_tx_complete (SOCKET *so) |
Test if the last TCP transmission was acknowledged. More... | |
uint32_t | tcp_pending_window (SOCKET *so) |
returns the number of unacknowledged bytes More... | |
uint16_t | tcp_force_retransmit (SOCKET *so) |
force a retransmit More... | |
int16_t | tcp_set_keep_alive_time (SOCKET *so, uint32_t time) |
Set keep alive time. More... | |
void | tcp_send_zero_window (void *so) |
send a zero window packet More... | |
void | tcp_send_window_update (void *so) |
update window size More... | |
uint32_t | gethostbyname (char *hostname, int32_t *timeout) |
Get the ip address of clients specified by name. More... | |
uint32_t | net_set_gateway (char *ip, char *sub_mask) |
Configure a gateway. More... | |
char * | get_netlib_ver (char *buffer) |
Retrieve netlib revision string. More... | |
char * | net_allocate_aligned_buffer (int32_t size) |
Allocate a data buffer, aligned to the processors cache line size. More... | |
addr_type * | get_address_offset (uint16_t dev_nr) |
Get current offset of MAC + IP address structure. More... | |
uint32_t | get_ip_address (uint16_t dev_nr) |
Get configured IP address. More... | |
uint32_t | set_ip_address (uint16_t dev_nr, char *addr_str) |
Set IP address. More... | |
uint32_t | get_mac_address (uint16_t dev_nr, uint16_t *dest) |
Get MAC address. More... | |
void | net_print_stat (uint16_t dev_nr, tpOutputFunc pLog) |
Print statistic TCP stack information. More... | |
char * | inet_ntoa (uint32_t i_addr, char *s) |
Convert IP-address from 0xbbaaddcc to "aaa.bbb.ccc.ddd". More... | |
uint32_t | inet_aton (char *s) |
Converts zero terminated IP-address string from "aaa.bbb.ccc.ddd" to integer in network byte order. More... | |
static uint16_t | htons (uint16_t val) |
Convert a short int from host to network byte order. More... | |
static uint16_t | ntohs (uint16_t val) |
Convert a short int from network to host byte order. More... | |
static uint32_t | htonl (uint32_t val) |
Convert a long int from host to network byte order. More... | |
static uint32_t | ntohl (uint32_t val) |
Convert a long int from network to host byte order. More... | |
static uint32_t | nstohl (uint16_t val1, uint16_t val2) |
Convert two network short int to long host int. More... | |
static uint32_t | nstonl (uint16_t val1, uint16_t val2) |
Convert two network short int to long. More... | |
int32_t | multicast_join_group (SOCKET *so, char *maddr, uint16_t mport) |
Join a multicast group. More... | |
int32_t | multicast_leave_group (SOCKET *so, char *maddr, uint16_t mport) |
Leave a multicast group. More... | |
int32_t | fsys_init_dir (user_type *user_list, mmc_function_type *mmc_func) |
Initialize all directories specified in user_list. More... | |
int32_t | fsys_init_file (direntry_type *fp, uint32_t offset, int32_t size) |
This function initializes all necessary internal parameters for a specific user file. More... | |
int32_t | fsys_get_file_size (direntry_type *fp) |
Determine file size of specified file. More... | |
direntry_type * | fsys_send_all (direntry_type *fp, int32_t size, int32_t send_all) |
File transmission function. More... | |
void | fsys_init_flash (void) |
Initialize FLASH-sectors. More... | |
void * | DM2_EmacInit (uint8_t mode, char *mac_addr_str, void(*link_status)(unsigned char)) |
Initialize EMAC module. More... | |
Variables | |
uint32_t | net_initialized |
arp_list_type * | arp_head [] |
const char | netlib_ver [] |
_ _ _ __| | ___(_) ____ _ __ | |_ / _` | / __| |/ _` | '_ \| __| | (_| | _ \__ \ | (_| | | | | |_ \__,_|(_) ___/_|\__, |_| |_|\__| Signalprocessing |___/ Technology
#define NULL ((void *)_MAKE_32(0)) |
revision string for start-up message
#define null ((void *)_MAKE_32(0)) |
#define true TRUE |
#define false FALSE |
#define tpOutputFunc tpOutputFunc |
typedef int(* tpOutputFunc) (const char *format,...) |
Message log function. E.g. printf() or CPrintf() Use with net_print_stat()