diff --git a/include/nsysnet/socket.h b/include/nsysnet/socket.h index e19c2e3..c37e375 100644 --- a/include/nsysnet/socket.h +++ b/include/nsysnet/socket.h @@ -8,7 +8,7 @@ * @{ */ -#define SOL_SOCKET 0xFFFF +#define SOL_SOCKET -1 #define INADDR_ANY 0 @@ -20,6 +20,9 @@ #define AF_INET PF_INET #define AF_INET6 PF_INET6 +#define EAGAIN 6 +#define EWOULDBLOCK 6 + #define SOCK_STREAM 1 #define SOCK_DGRAM 2 @@ -51,6 +54,9 @@ #define SO_RCVLOWAT 0x1004 // receive low-water mark #define SO_TYPE 0x1008 // get socket type #define SO_ERROR 0x1009 // get socket error +#define SO_NBIO 0x1014 // set socket to NON-blocking mode +#define SO_BIO 0x1015 // set socket to blocking mode +#define SO_NONBLOCK 0x1016 // set/get blocking mode via optval param #define FD_SETSIZE (32) #define FD_CLR(n, set) \ @@ -101,6 +107,12 @@ struct sockaddr_in char sin_zero[8]; }; +struct timeval +{ + long tv_sec; + long tv_usec; +}; + struct fd_set { fd_mask fd_bits; @@ -113,6 +125,9 @@ extern "C" { void socket_lib_init(); +void +socket_lib_finish(); + int accept(int sockfd, struct sockaddr *addr, @@ -203,12 +218,27 @@ select(int nfds, fd_set *exceptfds, struct timeval *timeout); -char * +const char * inet_ntoa(struct in_addr in); int inet_aton(const char *cp, struct in_addr *inp); +int +socketlasterr(); + +uint32_t +htonl(uint32_t val); + +uint16_t +htons(uint16_t val); + +uint32_t +ntohl(uint32_t val); + +uint16_t +ntohs(uint16_t val); + #ifdef __cplusplus } #endif diff --git a/rpl/nsysnet/exports.h b/rpl/nsysnet/exports.h index 6b722f4..f4c7fcc 100644 --- a/rpl/nsysnet/exports.h +++ b/rpl/nsysnet/exports.h @@ -1,5 +1,6 @@ // nsysnet/socket.h EXPORT(socket_lib_init); +EXPORT(socket_lib_finish); EXPORT(socket); EXPORT(socketclose); EXPORT(connect); @@ -31,3 +32,4 @@ EXPORT(ntohl); EXPORT(htonl); EXPORT(ntohs); EXPORT(htons); +EXPORT(socketlasterr);