typedef struct socket_function_table **Socket;
typedef struct plug_function_table **Plug;
+#ifndef OSSOCKET_DEFINED
+typedef void *OSSocket;
+#endif
+
struct socket_function_table {
Plug(*plug) (Socket s, Plug p);
/* use a different plug (return the old one) */
* on a socket is cleared or partially cleared. The new backlog
* size is passed in the `bufsize' parameter.
*/
- int (*accepting)(Plug p, void *sock);
+ int (*accepting)(Plug p, OSSocket sock);
/*
* returns 0 if the host at address addr is a valid host for connecting or error
*/
};
/* proxy indirection layer */
+/* NB, control of 'addr' is passed via new_connection, which takes
+ * responsibility for freeing it */
Socket new_connection(SockAddr addr, char *hostname,
int port, int privport,
- int oobinline, int nodelay, Plug plug,
- const Config *cfg);
+ int oobinline, int nodelay, int keepalive,
+ Plug plug, const Config *cfg);
Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only,
const Config *cfg);
SockAddr name_lookup(char *host, int port, char **canonicalname,
const Config *cfg);
+/* platform-dependent callback from new_connection() */
+/* (same caveat about addr as new_connection()) */
+Socket platform_new_connection(SockAddr addr, char *hostname,
+ int port, int privport,
+ int oobinline, int nodelay, int keepalive,
+ Plug plug, const Config *cfg);
+
/* socket functions */
void sk_init(void); /* called once at program startup */
void sk_addrcopy(SockAddr addr, char *buf);
void sk_addr_free(SockAddr addr);
+/* NB, control of 'addr' is passed via sk_new, which takes responsibility
+ * for freeing it, as for new_connection() */
Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
- int nodelay, Plug p);
+ int nodelay, int keepalive, Plug p);
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only);
-Socket sk_register(void *sock, Plug plug);
+Socket sk_register(OSSocket sock, Plug plug);
#define sk_plug(s,p) (((*s)->plug) (s, p))
#define sk_close(s) (((*s)->close) (s))