ioLibrary for Cortex M series
sockutil.h
Go to the documentation of this file.
1 
12 #ifndef _SOCKUTIL_H
13 #define _SOCKUTIL_H
14 
15 //#include "common/common.h"
16 
44 #define WATCH_SOCK_UDP_SEND 0x01
45 #define WATCH_SOCK_TCP_SEND 0x02
46 #define WATCH_SOCK_CONN_TRY 0x04
47 #define WATCH_SOCK_CLS_TRY 0x08
48 #define WATCH_SOCK_CONN_EVT 0x10
49 #define WATCH_SOCK_CLS_EVT 0x20
50 #define WATCH_SOCK_RECV 0x40
51 #define WATCH_SOCK_MASK_LOW 0x0F
52 #define WATCH_SOCK_MASK_HIGH 0x70
53 #define WATCH_SOCK_ALL_MASK 0x7F
54 
55 typedef void (*watch_cbfunc)(uint8_t id, uint8_t item, int32_t ret);
56 
61 #define WIZCHIP_INIT_WITH_MEMCHK(tx_size_v, rx_size_v) \
62 { \
63  uint8_t _i, *_tx, *_rx, _tx_cnt = 0, _rx_cnt = 0; \
64  if(sizeof(tx_size_v)/sizeof(uint8_t) != _WIZCHIP_SOCK_NUM_ || \
65  sizeof(rx_size_v)/sizeof(uint8_t) != _WIZCHIP_SOCK_NUM_) { \
66  printf("Device Memory Configure fail 1"); \
67  while(1); \
68  } \
69  _tx = (uint8_t*)tx_size_v; \
70  _rx = (uint8_t*)rx_size_v; \
71  for(_i=0; _i<_WIZCHIP_SOCK_NUM_; _i++) { \
72  _tx_cnt += _tx[_i]; \
73  _rx_cnt += _rx[_i]; \
74  } \
75  if(_tx_cnt > _WIZCHIP_SOCK_NUM_*2 || _rx_cnt > _WIZCHIP_SOCK_NUM_*2) { \
76  printf("Device Memory Configure fail 2"); \
77  while(1); \
78  } \
79  wizchip_init(tx_size_v, rx_size_v); \
80 }
81 
82 int8_t sockwatch_open(uint8_t sock, watch_cbfunc cb);
83 int8_t sockwatch_close(uint8_t sock);
84 int8_t sockwatch_set(uint8_t sock, uint8_t item);
85 int8_t sockwatch_clr(uint8_t sock, uint8_t item);
86 int8_t sockwatch_chk(uint8_t sock, uint8_t item);
87 void sockwatch_run(void);
88 int8_t network_init(uint8_t dhcp_sock, void_func ip_update, void_func ip_conflict);
89 void network_disp(wiz_NetInfo *netinfo);
90 int8_t ip_check(int8_t *str, uint8_t *ip);
91 int8_t port_check(int8_t *str, uint16_t *port);
92 int8_t mac_check(int8_t *str, uint8_t *mac);
93 int8_t* inet_ntoa(uint32_t addr);
94 int8_t* inet_ntoa_pad(uint32_t addr);
95 uint32_t inet_addr(uint8_t* addr);
96 uint16_t htons( uint16_t hostshort);
97 uint32_t htonl(uint32_t hostlong);
98 uint32_t ntohs(uint16_t netshort);
99 uint32_t ntohl(uint32_t netlong);
100 
101 #endif //_SOCKUTIL_H
102 
103 
104