extern struct v3_socket_hooks * sock_hooks; \
V3_SOCK sock = 0; \
if ((sock_hooks) && (sock_hooks)->tcp_socket) { \
- sock = (sock_hooks)->tcp_socket(0,0); \
+ sock = (sock_hooks)->tcp_socket(0,0,0); \
} \
sock; \
})
})
-#define V3_Accept_Socket() (-1)
-#define V3_Select_Socket() (-1)
+#define V3_Accept_Socket(sock, ip_ptr) ({ \
+ extern struct v3_socket_hooks * sock_hooks; \
+ int ret = -1; \
+ if ((sock_hooks) && (sock_hooks)->accept) { \
+ ret = (sock_hooks)->accept(sock, ip_ptr); \
+ } \
+ ret; \
+ })
+
+
+#define V3_Select_Socket(rset,wset,eset,tv) ({ \
+ extern struct v3_socket_hooks * sock_hooks; \
+ int ret = -1; \
+ if ((sock_hooks) && (sock_hooks)->select) { \
+ ret = (sock_hooks)->select(rset, wset, eset, tv); \
+ } \
+ ret; \
+ })
struct v3_socket_hooks {
// Socket creation routines
- V3_SOCK (*tcp_socket)(const int bufsize, const int nodelay, const int nonblocking);
+xsxsxsxsxs V3_SOCK (*tcp_socket)(const int bufsize, const int nodelay, const int nonblocking);
V3_SOCK (*udp_socket)(const int bufsize, const int nonblocking);
// Socket Destruction
// Network Server Calls
int (*bind_socket)(const V3_SOCK sock, const int port);
+
+ int (*listen)(const V3_SOCK sock, int backlog);
- int (*accept)(const V3_SOCK const sock, unsigned int * remote_ip);
+ V3_SOCK (*accept)(const V3_SOCK const sock, unsigned int * remote_ip, unsigned int * port);
// This going to suck
int (*select)(struct v3_sock_set * rset, \
struct v3_sock_set * wset, \
};
-void V3_Init_Socket(struct v3_socket_hooks * hooks);
+extern void V3_Init_Sockets(struct v3_socket_hooks * hooks);
#endif