57 #define HOSTNAME_MAX_LENGTH (230) // 230 bytes + header shouldn't exceed 8 bit value
68 #define SOCK_RAW 3 // Raw sockets allow new IPv4 protocols to be implemented in user space. A raw socket receives or sends the raw datagram not including link level headers
70 #define SOCK_SEQPACKET 5
74 #define IPPROTO_IP 0 // dummy for IP
75 #define IPPROTO_ICMP 1 // control message protocol
76 #define IPPROTO_IPV4 IPPROTO_IP // IP inside IP
77 #define IPPROTO_TCP 6 // tcp
78 #define IPPROTO_UDP 17 // user datagram protocol
79 #define IPPROTO_IPV6 41 // IPv6 in IPv6
80 #define IPPROTO_NONE 59 // No next header
81 #define IPPROTO_RAW 255 // raw IP packet
82 #define IPPROTO_MAX 256
86 #define SOC_ERROR (-1) // error
87 #define SOC_IN_PROGRESS (-2) // socket in progress
90 #define SOL_SOCKET 0xffff // socket level
91 #define SOCKOPT_RECV_NONBLOCK 0 // recv non block mode, set SOCK_ON or SOCK_OFF (default block mode)
92 #define SOCKOPT_RECV_TIMEOUT 1 // optname to configure recv and recvfromtimeout
93 #define SOCKOPT_ACCEPT_NONBLOCK 2 // accept non block mode, set SOCK_ON or SOCK_OFF (default block mode)
94 #define SOCK_ON 0 // socket non-blocking mode is enabled
95 #define SOCK_OFF 1 // socket blocking mode is enabled
97 #define MAX_PACKET_SIZE 1500
98 #define MAX_LISTEN_QUEUE 4
100 #define IOCTL_SOCKET_EVENTMASK
102 #define ENOBUFS 55 // No buffer space available
104 #define __FD_SETSIZE 32
106 #define ASIC_ADDR_LEN 8
108 #define NO_QUERY_RECIVED -3
136 #define __NFDBITS (8 * sizeof (__fd_mask))
137 #define __FDELT(d) ((d) / __NFDBITS)
138 #define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))
144 #define __FDS_BITS(set) ((set)->fds_bits)
149 #define __FD_ZERO(set) \
152 fd_set *__arr = (set); \
153 for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
154 __FDS_BITS (__arr)[__i] = 0; \
156 #define __FD_SET(d, set) (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
157 #define __FD_CLR(d, set) (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d))
158 #define __FD_ISSET(d, set) (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d))
161 #define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
162 #define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
163 #define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
164 #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
168 #define htonl(A) ((((unsigned long)(A) & 0xff000000) >> 24) | \
169 (((unsigned long)(A) & 0x00ff0000) >> 8) | \
170 (((unsigned long)(A) & 0x0000ff00) << 8) | \
171 (((unsigned long)(A) & 0x000000ff) << 24))
176 #define htons(A) ((((unsigned long)(A) & 0xff00) >> 8) | \
177 (((unsigned long)(A) & 0x00ff) << 8))
183 #define SET_mDNS_ADD(sockaddr) sockaddr.sa_data[0] = 0x14; \
184 sockaddr.sa_data[1] = 0xe9; \
185 sockaddr.sa_data[2] = 0xe0; \
186 sockaddr.sa_data[3] = 0x0; \
187 sockaddr.sa_data[4] = 0x0; \
188 sockaddr.sa_data[5] = 0xfb;
218 extern int socket(
long domain,
long type,
long protocol);
301 extern long bind(
long sd,
const sockaddr *addr,
long addrlen);
325 extern long listen(
long sd,
long backlog);
345 #ifndef CC3000_TINY_DRIVER
346 extern int gethostbyname(
char * hostname,
unsigned short usNameLen,
unsigned long* out_ip_addr);
466 #ifndef CC3000_TINY_DRIVER
467 extern int setsockopt(
long sd,
long level,
long optname,
const void *optval,
516 extern int getsockopt(
long sd,
long level,
long optname,
void *optval,
540 extern int recv(
long sd,
void *buf,
long len,
long flags);
570 extern int recvfrom(
long sd,
void *buf,
long len,
long flags,
sockaddr *from,
595 extern int send(
long sd,
const void *buf,
long len,
long flags);
623 extern int sendto(
long sd,
const void *buf,
long len,
long flags,
624 const sockaddr *to, socklen_t tolen);
642 extern int mdnsAdvertiser(
unsigned short mdnsEnabled,
char * deviceServiceName,
unsigned short deviceServiceNameLength);
659 #endif // __cplusplus
661 #endif // __SOCKET_H__