WIZlib Library API
ver 1.0
WIZlib Library API User Menual
|
Socket Utility. More...
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... | |
Socket Utility.
uint32 htonl | ( | uint32 | hostlong | ) |
htonl function converts a unsigned long from host to TCP/IP network byte order (which is big-endian).
hostlong | The value to convert. |
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).
hostshort | The value to convert. |
Definition at line 458 of file sockutil.c.
uint32 inet_addr | ( | uint8 * | addr | ) |
Converts a string containing an (Ipv4) Internet Protocol decimal dotted address into a 32bit address.
addr | Dotted Decimal Format string. |
Definition at line 400 of file sockutil.c.
int8* inet_ntoa | ( | uint32 | addr | ) |
Convert a 32bit Address into a Dotted Decimal Format string.
addr | 32bit address. |
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.
addr | 32bit address. |
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.
str | The string to investigate if it is right IP Address. |
ip | The array pointer in which the address will enter when it is right 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.
str | The string to investigate if it is right MAC Address. |
mac | The array pointer in which the address will enter when it is right MAC address. |
Definition at line 338 of file sockutil.c.
void network_disp | ( | wiz_NetInfo * | netinfo | ) |
Display Current Network Information.
Current IP Addr, Subnet Mask, Gateway Addr,
DNS Server Addr, DHCP mode is displayed.
netinfo | The wiz_NetInfo struct pointer to display, if input NULL value, it will display current configuration value. |
Definition at line 91 of file sockutil.c.
Initialize Network.
This function should be called in the main function. If not, you have to handle network initialization manually.
dhcp_sock | The socket number which will be used at dhcp action |
ip_update | The hook function to be called back when IP Addr update. |
ip_conflict | The hook function to be called back when IP Addr conflict. |
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).
netlong | The value to convert. |
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).
netshort | The value to convert. |
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.
str | The string to investigate if it is right TCP Port. |
port | The variable pointer in which the number will enter when it is right TCP Port. |
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.
sock | The socket number to clear |
item | The item of event to clear |
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.
sock | The socket number to close |
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.
sock | The socket number to clear |
item | The item of event to clear |
Definition at line 192 of file sockutil.c.
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.
sock | The socket number which is corresponding to 'cb' param |
cb | The callback function to be called when the socket has any completion or event. |
Definition at line 124 of file sockutil.c.
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.
sock | The socket number to watch |
item | The item of event to watch |
Definition at line 169 of file sockutil.c.
uint32 swapl | ( | uint32 | l | ) |
Swap the byte order of 32bit(long) wide variable.
l | 32bit value to convert |
Definition at line 442 of file sockutil.c.
uint16 swaps | ( | uint16 | i | ) |
Swap the byte order of 16bit(short) wide variable.
i | 16bit value to swap |
Definition at line 428 of file sockutil.c.