1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
#ifndef PUTTY_NETWORK_H
#define PUTTY_NETWORK_H
#ifndef DONE_TYPEDEFS
#define DONE_TYPEDEFS
typedef struct conf_tag Conf;
typedef struct backend_tag Backend;
typedef struct terminal_tag Terminal;
#endif
typedef struct SockAddr_tag *SockAddr;
typedef struct socket_function_table **Socket;
typedef struct plug_function_table **Plug;
struct socket_function_table {
Plug(*plug) (Socket s, Plug p);
void (*close) (Socket s);
int (*write) (Socket s, const char *data, int len);
int (*write_oob) (Socket s, const char *data, int len);
void (*write_eof) (Socket s);
void (*flush) (Socket s);
void (*set_frozen) (Socket s, int is_frozen);
const char *(*socket_error) (Socket s);
char *(*peer_info) (Socket s);
};
typedef union { void *p; int i; } accept_ctx_t;
typedef Socket (*accept_fn_t)(accept_ctx_t ctx, Plug plug);
struct plug_function_table {
void (*log)(Plug p, int type, SockAddr addr, int port,
const char *error_msg, int error_code);
void (*closing)
(Plug p, const char *error_msg, int error_code, int calling_back);
void (*receive) (Plug p, int urgent, char *data, int len);
void (*sent) (Plug p, int bufsize);
int (*accepting)(Plug p, accept_fn_t constructor, accept_ctx_t ctx);
};
Socket new_connection(SockAddr addr, const char *hostname,
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf);
Socket new_listener(const char *srcaddr, int port, Plug plug,
int local_host_only, Conf *conf, int addressfamily);
SockAddr name_lookup(const char *host, int port, char **canonicalname,
Conf *conf, int addressfamily, void *frontend_for_logging,
const char *lookup_reason_for_logging);
int proxy_for_destination (SockAddr addr, const char *hostname, int port,
Conf *conf);
Socket platform_new_connection(SockAddr addr, const char *hostname,
int port, int privport,
int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf);
void sk_init(void);
void sk_cleanup(void);
SockAddr sk_namelookup(const char *host, char **canonicalname, int address_family);
SockAddr sk_nonamelookup(const char *host);
void sk_getaddr(SockAddr addr, char *buf, int buflen);
int sk_addr_needs_port(SockAddr addr);
int sk_hostname_is_local(const char *name);
int sk_address_is_local(SockAddr addr);
int sk_address_is_special_local(SockAddr addr);
int sk_addrtype(SockAddr addr);
void sk_addrcopy(SockAddr addr, char *buf);
void sk_addr_free(SockAddr addr);
SockAddr sk_addr_dup(SockAddr addr);
Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
int nodelay, int keepalive, Plug p);
Socket sk_newlistener(const char *srcaddr, int port, Plug plug,
int local_host_only, int address_family);
#define sk_plug(s,p) (((*s)->plug) (s, p))
#define sk_close(s) (((*s)->close) (s))
#define sk_write(s,buf,len) (((*s)->write) (s, buf, len))
#define sk_write_oob(s,buf,len) (((*s)->write_oob) (s, buf, len))
#define sk_write_eof(s) (((*s)->write_eof) (s))
#define sk_flush(s) (((*s)->flush) (s))
#ifdef DEFINE_PLUG_METHOD_MACROS
#define plug_log(p,type,addr,port,msg,code) (((*p)->log) (p, type, addr, port, msg, code))
#define plug_closing(p,msg,code,callback) (((*p)->closing) (p, msg, code, callback))
#define plug_receive(p,urgent,buf,len) (((*p)->receive) (p, urgent, buf, len))
#define plug_sent(p,bufsize) (((*p)->sent) (p, bufsize))
#define plug_accepting(p, constructor, ctx) (((*p)->accepting)(p, constructor, ctx))
#endif
const char *sk_addr_error(SockAddr addr);
#define sk_socket_error(s) (((*s)->socket_error) (s))
#define sk_set_frozen(s, is_frozen) (((*s)->set_frozen) (s, is_frozen))
#define sk_peer_info(s) (((*s)->peer_info) (s))
int net_service_lookup(char *service);
char *get_hostname(void);
Socket new_error_socket(const char *errmsg, Plug plug);
void backend_socket_log(void *frontend, int type, SockAddr addr, int port,
const char *error_msg, int error_code, Conf *conf,
int session_started);
#ifndef BUFCHAIN_TYPEDEF
typedef struct bufchain_tag bufchain;
#define BUFCHAIN_TYPEDEF
#endif
void log_proxy_stderr(Plug plug, bufchain *buf, const void *vdata, int len);
#endif
|