ioLibrary for Cortex M series
Functions
Sockutil_module

Functions

int8_t network_init (uint8_t dhcp_sock, void_func ip_update, void_func ip_conflict)
 
void network_disp (wiz_NetInfo *netinfo)
 
int8_t ip_check (int8_t *str, uint8_t *ip)
 
int8_t port_check (int8_t *str, uint16_t *port)
 
int8_t mac_check (int8_t *str, uint8_t *mac)
 
int8_t * inet_ntoa (uint32_t addr)
 
int8_t * inet_ntoa_pad (uint32_t addr)
 
uint32_t inet_addr (uint8_t *addr)
 
uint16_t swaps (uint16_t i)
 
uint32_t swapl (uint32_t l)
 
uint16_t htons (uint16_t hostshort)
 
uint32_t htonl (uint32_t hostlong)
 
uint32_t ntohs (uint16_t netshort)
 
uint32_t ntohl (uint32_t netlong)
 

Detailed Description

Function Documentation

int8_t network_init ( uint8_t  dhcp_sock,
void_func  ip_update,
void_func  ip_conflict 
)

Initialize Network. This function should be called in the main function. If not, you have to handle network initialization manually.

Parameters
dhcp_sockThe socket number which will be used at dhcp action
ip_updateThe hook function to be called back when IP Addr update.
ip_conflictThe hook function to be called back when IP Addr conflict.
Returns
RET_OK: Success
RET_NOK: Error

Definition at line 35 of file sockutil.c.

References DBGA, DEFAULT_MAC_ADDR, wiz_NetInfo_t::dhcp, wiz_NetInfo_t::mac, mac_check(), NETINFO_STATIC, NETINIT_ADDR_SET, network_disp(), RET_NOK, RET_OK, and SetNetInfo().

void network_disp ( wiz_NetInfo netinfo)

Display Current Network Information. Current IP Addr, Subnet Mask, Gateway Addr,
DNS Server Addr, DHCP mode is displayed.

Parameters
netinfoThe wiz_NetInfo struct pointer to display,
if input NULL value, it will display current configuration value.

Definition at line 89 of file sockutil.c.

References GetNetInfo(), wiz_NetInfo_t::gw, wiz_NetInfo_t::ip, LOG, LOGA, wiz_NetInfo_t::mac, and wiz_NetInfo_t::sn.

Referenced by network_init().

int8_t ip_check ( int8_t *  str,
uint8_t *  ip 
)

Check a string is right IP Address, and if right, copy the address to the 'ip' variable as array.

Parameters
strThe string to investigate if it is right IP Address.
ipThe array pointer in which the address will enter when it is right IP address.
Returns
RET_OK: This is right IP Address.
RET_NOK: This is not IP Address.

Definition at line 282 of file sockutil.c.

References RET_NOK, RET_OK, and str_check().

int8_t port_check ( int8_t *  str,
uint16_t *  port 
)

Check a string is right TCP Port number, and if right, copy the number to the 'port' variable.

Parameters
strThe string to investigate if it is right TCP Port.
portThe variable pointer in which the number will enter when it is right TCP Port.
Returns
RET_OK: This is right TCP Port number.
RET_NOK: This is not TCP Port number.

Definition at line 319 of file sockutil.c.

References RET_NOK, and RET_OK.

int8_t mac_check ( int8_t *  str,
uint8_t *  mac 
)

Check a string is right MAC Address, and if right, copy the address to the 'mac' variable as array.

Parameters
strThe string to investigate if it is right MAC Address.
macThe array pointer in which the address will enter when it is right MAC address.
Returns
RET_OK: This is right MAC Address.
RET_NOK: This is not MAC Address.

Definition at line 340 of file sockutil.c.

References RET_NOK, RET_OK, and str_check().

Referenced by network_init().

int8_t* inet_ntoa ( uint32_t  addr)

Convert a 32bit Address into a Dotted Decimal Format string.

Parameters
addr32bit address.
Returns
Dotted Decimal Format string.

Definition at line 373 of file sockutil.c.

int8_t* inet_ntoa_pad ( uint32_t  addr)

Convert a 32bit Address into a Dotted Decimal Format string. This is differ from inet_ntoa in fixed length.

Parameters
addr32bit address.
Returns
Dotted Decimal Format string.

Definition at line 388 of file sockutil.c.

uint32_t inet_addr ( uint8_t *  addr)

Converts a string containing an (Ipv4) Internet Protocol decimal dotted address into a 32bit address.

Parameters
addrDotted Decimal Format string.
Returns
32bit address.

Definition at line 402 of file sockutil.c.

uint16_t swaps ( uint16_t  i)

Swap the byte order of 16bit(short) wide variable.

Parameters
i16bit value to swap
Returns
Swapped value

Definition at line 430 of file sockutil.c.

Referenced by htons().

uint32_t swapl ( uint32_t  l)

Swap the byte order of 32bit(long) wide variable.

Parameters
l32bit value to convert
Returns
Swapped value

Definition at line 444 of file sockutil.c.

Referenced by htonl(), and ntohl().

uint16_t htons ( uint16_t  hostshort)

htons function converts a unsigned short from host to TCP/IP network byte order (which is big-endian).

Parameters
hostshortThe value to convert.
Returns
The value in TCP/IP network byte order.

Definition at line 460 of file sockutil.c.

References swaps().

Referenced by ntohs().

uint32_t htonl ( uint32_t  hostlong)

htonl function converts a unsigned long from host to TCP/IP network byte order (which is big-endian).

Parameters
hostlongThe value to convert.
Returns
The value in TCP/IP network byte order.

Definition at line 476 of file sockutil.c.

References swapl().

uint32_t ntohs ( uint16_t  netshort)

ntohs function converts a unsigned short from TCP/IP network byte order to host byte order (which is little-endian on Intel processors).

Parameters
netshortThe value to convert.
Returns
A 16-bit number in host byte order

Definition at line 493 of file sockutil.c.

References htons().

uint32_t ntohl ( uint32_t  netlong)

converts a unsigned long from TCP/IP network byte order to host byte order (which is little-endian on Intel processors).

Parameters
netlongThe value to convert.
Returns
A 16-bit number in host byte order

Definition at line 509 of file sockutil.c.

References swapl().