WIZlib Library API  ver 1.0
WIZlib Library API User Menual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions

Socket Utility. More...

Collaboration diagram for Sockutil:

Macros

#define WATCH_SOCK_UDP_SEND   0x01
 Indicate that 'UDP SEND' completion of this socket has to be watched.
 
#define WATCH_SOCK_TCP_SEND   0x02
 Indicate that 'TCP SEND' completion of this socket has to be watched.
 
#define WATCH_SOCK_CONN_TRY   0x04
 Indicate that 'CONNECT' completion of this socket has to be watched.
 
#define WATCH_SOCK_CONN_EVT   0x10
 Indicate that 'CONNECT' event of this socket has to be watched.
 
#define WATCH_SOCK_CLS_TRY   0x08
 Indicate that 'CLOSE' completion of this socket has to be watched.
 
#define WATCH_SOCK_CLS_EVT   0x20
 Indicate that 'CLOSE' event of this socket has to be watched.
 
#define WATCH_SOCK_RECV   0x40
 Indicate that 'RECEIVE' event of this socket has to be watched.
 
#define WATCH_SOCK_MASK_LOW   0x0F
 Mask all Completions of the socket.
 
#define WATCH_SOCK_MASK_HIGH   0x70
 Mask all Events of the socket.
 
#define WATCH_SOCK_ALL_MASK   0x7F
 Mask all Completions and Events.
 

Typedefs

typedef void(* watch_cbfunc )(uint8 id, uint8 item, int32 ret)
 Watch call back function form.
 

Functions

int8 network_init (uint8 dhcp_sock, void_func ip_update, void_func ip_conflict)
 Initialize Network. More...
 
void network_disp (wiz_NetInfo *netinfo)
 Display Current Network Information. More...
 
int8 sockwatch_open (uint8 sock, watch_cbfunc cb)
 Assign a callback function to a socket. More...
 
int8 sockwatch_close (uint8 sock)
 Remove callback function from a socket and Stop to watch all event. More...
 
int8 sockwatch_set (uint8 sock, uint8 item)
 Set a item of event to watch at sockwatch_run. More...
 
int8 sockwatch_clr (uint8 sock, uint8 item)
 Clear a item of event which you don't care anymore. More...
 
int8 sockwatch_chk (uint8 sock, uint8 item)
 Check a item of event has been set on the socket. More...
 
void sockwatch_run (void)
 Sockwatch Module Handler If you use Sockwatch Module, this should run in the main loop.
 
int8 ip_check (int8 *str, uint8 *ip)
 Check a string is right IP Address, and if right, copy the address to the 'ip' variable as array. More...
 
int8 port_check (int8 *str, uint16 *port)
 Check a string is right TCP Port number, and if right, copy the number to the 'port' variable. More...
 
int8 mac_check (int8 *str, uint8 *mac)
 Check a string is right MAC Address, and if right, copy the address to the 'mac' variable as array. More...
 
int8 * inet_ntoa (uint32 addr)
 Convert a 32bit Address into a Dotted Decimal Format string. More...
 
int8 * inet_ntoa_pad (uint32 addr)
 Convert a 32bit Address into a Dotted Decimal Format string. More...
 
uint32 inet_addr (uint8 *addr)
 Converts a string containing an (Ipv4) Internet Protocol decimal dotted address into a 32bit address. More...
 
uint16 swaps (uint16 i)
 Swap the byte order of 16bit(short) wide variable. More...
 
uint32 swapl (uint32 l)
 Swap the byte order of 32bit(long) wide variable. More...
 
uint16 htons (uint16 hostshort)
 htons function converts a unsigned short from host to TCP/IP network byte order (which is big-endian). More...
 
uint32 htonl (uint32 hostlong)
 htonl function converts a unsigned long from host to TCP/IP network byte order (which is big-endian). More...
 
uint32 ntohs (uint16 netshort)
 ntohs function converts a unsigned short from TCP/IP network byte order to host byte order (which is little-endian on Intel processors). More...
 
uint32 ntohl (uint32 netlong)
 converts a unsigned long from TCP/IP network byte order to host byte order (which is little-endian on Intel processors). More...
 

Detailed Description

Socket Utility.

Function Documentation

uint32 htonl ( uint32  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 474 of file sockutil.c.

uint16 htons ( uint16  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 458 of file sockutil.c.

Here is the caller graph for this function:

uint32 inet_addr ( uint8 *  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 400 of file sockutil.c.

int8* inet_ntoa ( uint32  addr)

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

Parameters
addr32bit address.
Returns
Dotted Decimal Format string.

Definition at line 371 of file sockutil.c.

int8* inet_ntoa_pad ( uint32  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 386 of file sockutil.c.

int8 ip_check ( int8 *  str,
uint8 *  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 280 of file sockutil.c.

int8 mac_check ( int8 *  str,
uint8 *  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 338 of file sockutil.c.

Here is the caller graph for this function:

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 91 of file sockutil.c.

Here is the caller graph for this function:

int8 network_init ( uint8  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 37 of file sockutil.c.

uint32 ntohl ( uint32  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 507 of file sockutil.c.

uint32 ntohs ( uint16  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 491 of file sockutil.c.

int8 port_check ( int8 *  str,
uint16 *  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 317 of file sockutil.c.

int8 sockwatch_chk ( uint8  sock,
uint8  item 
)

Check a item of event has been set on the socket.

Parameters
sockThe socket number to clear
itemThe item of event to clear
Returns
RET_OK: There is the item queried on the socket.
RET_NOK: There is not the item queried on the socket.

Definition at line 213 of file sockutil.c.

int8 sockwatch_close ( uint8  sock)

Remove callback function from a socket and Stop to watch all event.

Parameters
sockThe socket number to close
Returns
RET_OK: Success
RET_NOK: Error

Definition at line 144 of file sockutil.c.

int8 sockwatch_clr ( uint8  sock,
uint8  item 
)

Clear a item of event which you don't care anymore.

sockwatch_run stop to detect the item on the socket. It is possible to set plural item of event at the same time.

Parameters
sockThe socket number to clear
itemThe item of event to clear
Returns
RET_OK: Success
RET_NOK: Error

Definition at line 192 of file sockutil.c.

Here is the caller graph for this function:

int8 sockwatch_open ( uint8  sock,
watch_cbfunc  cb 
)

Assign a callback function to a socket.

When sockwatch_run function detected a event,
this callback function will be called.

Parameters
sockThe socket number which is corresponding to 'cb' param
cbThe callback function to be called when
the socket has any completion or event.
Returns
RET_OK: Success
RET_NOK: Error

Definition at line 124 of file sockutil.c.

Here is the caller graph for this function:

int8 sockwatch_set ( uint8  sock,
uint8  item 
)

Set a item of event to watch at sockwatch_run.

Once opened a socket by sockwatch_open,
you have to register events for watching that using this function. It is possible to set plural item of event at the same time.

Parameters
sockThe socket number to watch
itemThe item of event to watch
Returns
RET_OK: Success
RET_NOK: Error

Definition at line 169 of file sockutil.c.

uint32 swapl ( uint32  l)

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

Parameters
l32bit value to convert
Returns
Swapped value

Definition at line 442 of file sockutil.c.

Here is the caller graph for this function:

uint16 swaps ( uint16  i)

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

Parameters
i16bit value to swap
Returns
Swapped value

Definition at line 428 of file sockutil.c.

Here is the caller graph for this function: