summaryrefslogtreecommitdiffhomepage
path: root/netio.h
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-02-20 23:16:38 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-02-20 23:16:38 +0800
commit364a53577eb33f20bed877fc5d4a54de829707d8 (patch)
tree3006ce1d1a77e50fbb679cd4a8a454423f66d350 /netio.h
parent1b1997bf2da9322c526ec1da4358aae94f7de06e (diff)
Move generic network routines to netio.c
--HG-- branch : fastopen
Diffstat (limited to 'netio.h')
-rw-r--r--netio.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/netio.h b/netio.h
new file mode 100644
index 0000000..3c98d6c
--- /dev/null
+++ b/netio.h
@@ -0,0 +1,46 @@
+#ifndef DROPBEAR_NETIO_H
+#define DROPBEAR_NETIO_H
+
+#include "includes.h"
+#include "buffer.h"
+#include "queue.h"
+
+enum dropbear_prio {
+ DROPBEAR_PRIO_DEFAULT = 10,
+ DROPBEAR_PRIO_LOWDELAY = 11,
+ DROPBEAR_PRIO_BULK = 12,
+};
+
+void set_sock_nodelay(int sock);
+void set_sock_priority(int sock, enum dropbear_prio prio);
+
+void get_socket_address(int fd, char **local_host, char **local_port,
+ char **remote_host, char **remote_port, int host_lookup);
+void getaddrstring(struct sockaddr_storage* addr,
+ char **ret_host, char **ret_port, int host_lookup);
+int dropbear_listen(const char* address, const char* port,
+ int *socks, unsigned int sockcount, char **errstring, int *maxfd);
+
+struct dropbear_progress_connection;
+
+/* result is DROPBEAR_SUCCESS or DROPBEAR_FAILURE.
+errstring is only set on DROPBEAR_FAILURE, returns failure message for the last attempted socket */
+typedef void(*connect_callback)(int result, int sock, void* data, const char* errstring);
+
+struct dropbear_progress_connection * connect_remote (const char* remotehost, const char* remoteport,
+ connect_callback cb, void *cb_data);
+
+void set_connect_fds(fd_set *writefd);
+void handle_connect_fds(fd_set *writefd);
+
+/* Doesn't actually stop the connect, but adds a dummy callback instead */
+void cancel_connect(struct dropbear_progress_connection *c);
+
+void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue *writequeue);
+
+/* TODO: writev #ifdef guard */
+struct iovec * packet_queue_to_iovec(struct Queue *queue, int *ret_iov_count);
+void packet_queue_consume(struct Queue *queue, ssize_t written);
+
+#endif
+