comparison dbutil.h @ 1032:0da8ba489c23 fastopen

Move generic network routines to netio.c
author Matt Johnston <matt@ucc.asn.au>
date Fri, 20 Feb 2015 23:16:38 +0800
parents 5ad81aa19c2d
children ca71904cf3ee
comparison
equal deleted inserted replaced
1031:64c0aa01e2b6 1032:0da8ba489c23
61 void printmpint(const char *label, mp_int *mp); 61 void printmpint(const char *label, mp_int *mp);
62 void debug_start_net(); 62 void debug_start_net();
63 extern int debug_trace; 63 extern int debug_trace;
64 #endif 64 #endif
65 65
66 enum dropbear_prio {
67 DROPBEAR_PRIO_DEFAULT = 10,
68 DROPBEAR_PRIO_LOWDELAY = 11,
69 DROPBEAR_PRIO_BULK = 12,
70 };
71
72 char * stripcontrol(const char * text); 66 char * stripcontrol(const char * text);
73 void get_socket_address(int fd, char **local_host, char **local_port,
74 char **remote_host, char **remote_port, int host_lookup);
75 void getaddrstring(struct sockaddr_storage* addr,
76 char **ret_host, char **ret_port, int host_lookup);
77 void set_sock_nodelay(int sock);
78 void set_sock_priority(int sock, enum dropbear_prio prio);
79 67
80 #if defined(__linux__) && HAVE_SENDMSG 68 #if defined(__linux__) && HAVE_SENDMSG
81 #define DROPBEAR_TCP_FAST_OPEN 69 #define DROPBEAR_TCP_FAST_OPEN
82 void set_listen_fast_open(int sock); 70 void set_listen_fast_open(int sock);
83 /* may be supported by kernel but not libc */ 71 /* may be supported by kernel but not libc */
87 #ifndef MSG_FASTOPEN 75 #ifndef MSG_FASTOPEN
88 #define MSG_FASTOPEN 0x20000000 76 #define MSG_FASTOPEN 0x20000000
89 #endif 77 #endif
90 #endif 78 #endif
91 79
92 int dropbear_listen(const char* address, const char* port,
93 int *socks, unsigned int sockcount, char **errstring, int *maxfd);
94 int spawn_command(void(*exec_fn)(void *user_data), void *exec_data, 80 int spawn_command(void(*exec_fn)(void *user_data), void *exec_data,
95 int *writefd, int *readfd, int *errfd, pid_t *pid); 81 int *writefd, int *readfd, int *errfd, pid_t *pid);
96 void run_shell_command(const char* cmd, unsigned int maxfd, char* usershell); 82 void run_shell_command(const char* cmd, unsigned int maxfd, char* usershell);
97 #ifdef ENABLE_CONNECT_UNIX 83 #ifdef ENABLE_CONNECT_UNIX
98 int connect_unix(const char* addr); 84 int connect_unix(const char* addr);
123 a real-world clock */ 109 a real-world clock */
124 time_t monotonic_now(); 110 time_t monotonic_now();
125 111
126 char * expand_tilde(const char *inpath); 112 char * expand_tilde(const char *inpath);
127 113
128 struct dropbear_progress_connection;
129
130 /* result is DROPBEAR_SUCCESS or DROPBEAR_FAILURE.
131 errstring is only set on DROPBEAR_FAILURE, returns failure message for the last attempted socket */
132 typedef void(*connect_callback)(int result, int sock, void* data, const char* errstring);
133
134 struct dropbear_progress_connection * connect_remote (const char* remotehost, const char* remoteport,
135 connect_callback cb, void *cb_data);
136
137 void set_connect_fds(fd_set *writefd);
138 void handle_connect_fds(fd_set *writefd);
139
140 /* Doesn't actually stop the connect, but adds a dummy callback instead */
141 void cancel_connect(struct dropbear_progress_connection *c);
142
143 void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue *writequeue);
144 114
145 #endif /* _DBUTIL_H_ */ 115 #endif /* _DBUTIL_H_ */