OSDN Git Service

Modify features and documents for 1.98b the urgent security release.
[ffftp/ffftp.git] / contrib / putty / NETWORK.H
diff --git a/contrib/putty/NETWORK.H b/contrib/putty/NETWORK.H
deleted file mode 100644 (file)
index b1b5590..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/*\r
- * Networking abstraction in PuTTY.\r
- *\r
- * The way this works is: a back end can choose to open any number\r
- * of sockets - including zero, which might be necessary in some.\r
- * It can register a bunch of callbacks (most notably for when \r
- * data is received) for each socket, and it can call the networking\r
- * abstraction to send data without having to worry about blocking.\r
- * The stuff behind the abstraction takes care of selects and\r
- * nonblocking writes and all that sort of painful gubbins.\r
- */\r
-\r
-#ifndef PUTTY_NETWORK_H\r
-#define PUTTY_NETWORK_H\r
-\r
-#ifndef DONE_TYPEDEFS\r
-#define DONE_TYPEDEFS\r
-typedef struct config_tag Config;\r
-typedef struct backend_tag Backend;\r
-typedef struct terminal_tag Terminal;\r
-#endif\r
-\r
-typedef struct SockAddr_tag *SockAddr;\r
-/* pay attention to levels of indirection */\r
-typedef struct socket_function_table **Socket;\r
-typedef struct plug_function_table **Plug;\r
-\r
-#ifndef OSSOCKET_DEFINED\r
-typedef void *OSSocket;\r
-#endif\r
-\r
-struct socket_function_table {\r
-    Plug(*plug) (Socket s, Plug p);\r
-    /* use a different plug (return the old one) */\r
-    /* if p is NULL, it doesn't change the plug */\r
-    /* but it does return the one it's using */\r
-    void (*close) (Socket s);\r
-    int (*write) (Socket s, const char *data, int len);\r
-    int (*write_oob) (Socket s, const char *data, int len);\r
-    void (*flush) (Socket s);\r
-    void (*set_private_ptr) (Socket s, void *ptr);\r
-    void *(*get_private_ptr) (Socket s);\r
-    void (*set_frozen) (Socket s, int is_frozen);\r
-    /* ignored by tcp, but vital for ssl */\r
-    const char *(*socket_error) (Socket s);\r
-};\r
-\r
-struct plug_function_table {\r
-    void (*log)(Plug p, int type, SockAddr addr, int port,\r
-               const char *error_msg, int error_code);\r
-    /*\r
-     * Passes the client progress reports on the process of setting\r
-     * up the connection.\r
-     * \r
-     *         - type==0 means we are about to try to connect to address\r
-     *           `addr' (error_msg and error_code are ignored)\r
-     *         - type==1 means we have failed to connect to address `addr'\r
-     *           (error_msg and error_code are supplied). This is not a\r
-     *           fatal error - we may well have other candidate addresses\r
-     *           to fall back to. When it _is_ fatal, the closing()\r
-     *           function will be called.\r
-     */\r
-    int (*closing)\r
-     (Plug p, const char *error_msg, int error_code, int calling_back);\r
-    /* error_msg is NULL iff it is not an error (ie it closed normally) */\r
-    /* calling_back != 0 iff there is a Plug function */\r
-    /* currently running (would cure the fixme in try_send()) */\r
-    int (*receive) (Plug p, int urgent, char *data, int len);\r
-    /*\r
-     *  - urgent==0. `data' points to `len' bytes of perfectly\r
-     *    ordinary data.\r
-     * \r
-     *  - urgent==1. `data' points to `len' bytes of data,\r
-     *    which were read from before an Urgent pointer.\r
-     * \r
-     *  - urgent==2. `data' points to `len' bytes of data,\r
-     *    the first of which was the one at the Urgent mark.\r
-     */\r
-    void (*sent) (Plug p, int bufsize);\r
-    /*\r
-     * The `sent' function is called when the pending send backlog\r
-     * on a socket is cleared or partially cleared. The new backlog\r
-     * size is passed in the `bufsize' parameter.\r
-     */\r
-    int (*accepting)(Plug p, OSSocket sock);\r
-    /*\r
-     * returns 0 if the host at address addr is a valid host for connecting or error\r
-     */\r
-};\r
-\r
-/* proxy indirection layer */\r
-/* NB, control of 'addr' is passed via new_connection, which takes\r
- * responsibility for freeing it */\r
-Socket new_connection(SockAddr addr, char *hostname,\r
-                     int port, int privport,\r
-                     int oobinline, int nodelay, int keepalive,\r
-                     Plug plug, const Config *cfg);\r
-Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only,\r
-                   const Config *cfg, int addressfamily);\r
-SockAddr name_lookup(char *host, int port, char **canonicalname,\r
-                    const Config *cfg, int addressfamily);\r
-\r
-/* platform-dependent callback from new_connection() */\r
-/* (same caveat about addr as new_connection()) */\r
-Socket platform_new_connection(SockAddr addr, char *hostname,\r
-                              int port, int privport,\r
-                              int oobinline, int nodelay, int keepalive,\r
-                              Plug plug, const Config *cfg);\r
-\r
-/* socket functions */\r
-\r
-void sk_init(void);                   /* called once at program startup */\r
-void sk_cleanup(void);                /* called just before program exit */\r
-\r
-SockAddr sk_namelookup(const char *host, char **canonicalname, int address_family);\r
-SockAddr sk_nonamelookup(const char *host);\r
-void sk_getaddr(SockAddr addr, char *buf, int buflen);\r
-int sk_hostname_is_local(char *name);\r
-int sk_address_is_local(SockAddr addr);\r
-int sk_addrtype(SockAddr addr);\r
-void sk_addrcopy(SockAddr addr, char *buf);\r
-void sk_addr_free(SockAddr addr);\r
-/* sk_addr_dup generates another SockAddr which contains the same data\r
- * as the original one and can be freed independently. May not actually\r
- * physically _duplicate_ it: incrementing a reference count so that\r
- * one more free is required before it disappears is an acceptable\r
- * implementation. */\r
-SockAddr sk_addr_dup(SockAddr addr);\r
-\r
-/* NB, control of 'addr' is passed via sk_new, which takes responsibility\r
- * for freeing it, as for new_connection() */\r
-Socket sk_new(SockAddr addr, int port, int privport, int oobinline,\r
-             int nodelay, int keepalive, Plug p);\r
-\r
-Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, int address_family);\r
-\r
-Socket sk_register(OSSocket sock, Plug plug);\r
-\r
-#define sk_plug(s,p) (((*s)->plug) (s, p))\r
-#define sk_close(s) (((*s)->close) (s))\r
-#define sk_write(s,buf,len) (((*s)->write) (s, buf, len))\r
-#define sk_write_oob(s,buf,len) (((*s)->write_oob) (s, buf, len))\r
-#define sk_flush(s) (((*s)->flush) (s))\r
-\r
-#ifdef DEFINE_PLUG_METHOD_MACROS\r
-#define plug_log(p,type,addr,port,msg,code) (((*p)->log) (p, type, addr, port, msg, code))\r
-#define plug_closing(p,msg,code,callback) (((*p)->closing) (p, msg, code, callback))\r
-#define plug_receive(p,urgent,buf,len) (((*p)->receive) (p, urgent, buf, len))\r
-#define plug_sent(p,bufsize) (((*p)->sent) (p, bufsize))\r
-#define plug_accepting(p, sock) (((*p)->accepting)(p, sock))\r
-#endif\r
-\r
-/*\r
- * Each socket abstraction contains a `void *' private field in\r
- * which the client can keep state.\r
- *\r
- * This is perhaps unnecessary now that we have the notion of a plug,\r
- * but there is some existing code that uses it, so it stays.\r
- */\r
-#define sk_set_private_ptr(s, ptr) (((*s)->set_private_ptr) (s, ptr))\r
-#define sk_get_private_ptr(s) (((*s)->get_private_ptr) (s))\r
-\r
-/*\r
- * Special error values are returned from sk_namelookup and sk_new\r
- * if there's a problem. These functions extract an error message,\r
- * or return NULL if there's no problem.\r
- */\r
-const char *sk_addr_error(SockAddr addr);\r
-#define sk_socket_error(s) (((*s)->socket_error) (s))\r
-\r
-/*\r
- * Set the `frozen' flag on a socket. A frozen socket is one in\r
- * which all READABLE notifications are ignored, so that data is\r
- * not accepted from the peer until the socket is unfrozen. This\r
- * exists for two purposes:\r
- * \r
- *  - Port forwarding: when a local listening port receives a\r
- *    connection, we do not want to receive data from the new\r
- *    socket until we have somewhere to send it. Hence, we freeze\r
- *    the socket until its associated SSH channel is ready; then we\r
- *    unfreeze it and pending data is delivered.\r
- * \r
- *  - Socket buffering: if an SSH channel (or the whole connection)\r
- *    backs up or presents a zero window, we must freeze the\r
- *    associated local socket in order to avoid unbounded buffer\r
- *    growth.\r
- */\r
-#define sk_set_frozen(s, is_frozen) (((*s)->set_frozen) (s, is_frozen))\r
-\r
-/*\r
- * Call this after an operation that might have tried to send on a\r
- * socket, to clean up any pending network errors.\r
- */\r
-void net_pending_errors(void);\r
-\r
-/*\r
- * Simple wrapper on getservbyname(), needed by ssh.c. Returns the\r
- * port number, in host byte order (suitable for printf and so on).\r
- * Returns 0 on failure. Any platform not supporting getservbyname\r
- * can just return 0 - this function is not required to handle\r
- * numeric port specifications.\r
- */\r
-int net_service_lookup(char *service);\r
-\r
-/*\r
- * Look up the local hostname; return value needs freeing.\r
- * May return NULL.\r
- */\r
-char *get_hostname(void);\r
-\r
-/********** SSL stuff **********/\r
-\r
-/*\r
- * This section is subject to change, but you get the general idea\r
- * of what it will eventually look like.\r
- */\r
-\r
-typedef struct certificate *Certificate;\r
-typedef struct our_certificate *Our_Certificate;\r
-    /* to be defined somewhere else, somehow */\r
-\r
-typedef struct ssl_client_socket_function_table **SSL_Client_Socket;\r
-typedef struct ssl_client_plug_function_table **SSL_Client_Plug;\r
-\r
-struct ssl_client_socket_function_table {\r
-    struct socket_function_table base;\r
-    void (*renegotiate) (SSL_Client_Socket s);\r
-    /* renegotiate the cipher spec */\r
-};\r
-\r
-struct ssl_client_plug_function_table {\r
-    struct plug_function_table base;\r
-    int (*refuse_cert) (SSL_Client_Plug p, Certificate cert[]);\r
-    /* do we accept this certificate chain?  If not, why not? */\r
-    /* cert[0] is the server's certificate, cert[] is NULL-terminated */\r
-    /* the last certificate may or may not be the root certificate */\r
-     Our_Certificate(*client_cert) (SSL_Client_Plug p);\r
-    /* the server wants us to identify ourselves */\r
-    /* may return NULL if we want anonymity */\r
-};\r
-\r
-SSL_Client_Socket sk_ssl_client_over(Socket s, /* pre-existing (tcp) connection */\r
-                                    SSL_Client_Plug p);\r
-\r
-#define sk_renegotiate(s) (((*s)->renegotiate) (s))\r
-\r
-#endif\r