nsysnet: Add some missing stuff.

This commit is contained in:
James Benton 2017-04-07 01:23:29 +01:00
parent eb74acf209
commit 4dfe8d5ea6
2 changed files with 34 additions and 2 deletions

View File

@ -8,7 +8,7 @@
* @{ * @{
*/ */
#define SOL_SOCKET 0xFFFF #define SOL_SOCKET -1
#define INADDR_ANY 0 #define INADDR_ANY 0
@ -20,6 +20,9 @@
#define AF_INET PF_INET #define AF_INET PF_INET
#define AF_INET6 PF_INET6 #define AF_INET6 PF_INET6
#define EAGAIN 6
#define EWOULDBLOCK 6
#define SOCK_STREAM 1 #define SOCK_STREAM 1
#define SOCK_DGRAM 2 #define SOCK_DGRAM 2
@ -51,6 +54,9 @@
#define SO_RCVLOWAT 0x1004 // receive low-water mark #define SO_RCVLOWAT 0x1004 // receive low-water mark
#define SO_TYPE 0x1008 // get socket type #define SO_TYPE 0x1008 // get socket type
#define SO_ERROR 0x1009 // get socket error #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_SETSIZE (32)
#define FD_CLR(n, set) \ #define FD_CLR(n, set) \
@ -101,6 +107,12 @@ struct sockaddr_in
char sin_zero[8]; char sin_zero[8];
}; };
struct timeval
{
long tv_sec;
long tv_usec;
};
struct fd_set struct fd_set
{ {
fd_mask fd_bits; fd_mask fd_bits;
@ -113,6 +125,9 @@ extern "C" {
void void
socket_lib_init(); socket_lib_init();
void
socket_lib_finish();
int int
accept(int sockfd, accept(int sockfd,
struct sockaddr *addr, struct sockaddr *addr,
@ -203,12 +218,27 @@ select(int nfds,
fd_set *exceptfds, fd_set *exceptfds,
struct timeval *timeout); struct timeval *timeout);
char * const char *
inet_ntoa(struct in_addr in); inet_ntoa(struct in_addr in);
int int
inet_aton(const char *cp, struct in_addr *inp); 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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,5 +1,6 @@
// nsysnet/socket.h // nsysnet/socket.h
EXPORT(socket_lib_init); EXPORT(socket_lib_init);
EXPORT(socket_lib_finish);
EXPORT(socket); EXPORT(socket);
EXPORT(socketclose); EXPORT(socketclose);
EXPORT(connect); EXPORT(connect);
@ -31,3 +32,4 @@ EXPORT(ntohl);
EXPORT(htonl); EXPORT(htonl);
EXPORT(ntohs); EXPORT(ntohs);
EXPORT(htons); EXPORT(htons);
EXPORT(socketlasterr);