openenvutils/commandshell/shell/inc/tcp.h
changeset 0 2e3d3ce01487
child 4 0fdb7f6b0309
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 //
       
     2 // © Portions Copyright (c) Symbian Software Ltd 2007. All rights reserved.
       
     3 //
       
     4 /*
       
     5  * tcp.h - builtin FTP client
       
     6  *
       
     7  * This file is part of zsh, the Z shell.
       
     8  *
       
     9  * Copyright (c) 1998-2001 Peter Stephenson
       
    10  * All rights reserved.
       
    11  *
       
    12  * Permission is hereby granted, without written agreement and without
       
    13  * license or royalty fees, to use, copy, modify, and distribute this
       
    14  * software and to distribute modified versions of this software for any
       
    15  * purpose, provided that the above copyright notice and the following
       
    16  * two paragraphs appear in all copies of this software.
       
    17  *
       
    18  * In no event shall Peter Stephenson or the Zsh Development
       
    19  * Group be liable to any party for direct, indirect, special, incidental,
       
    20  * or consequential damages arising out of the use of this software and
       
    21  * its documentation, even if Peter Stephenson, and the Zsh
       
    22  * Development Group have been advised of the possibility of such damage.
       
    23  *
       
    24  * Peter Stephenson and the Zsh Development Group specifically
       
    25  * disclaim any warranties, including, but not limited to, the implied
       
    26  * warranties of merchantability and fitness for a particular purpose.  The
       
    27  * software provided hereunder is on an "as is" basis, and Peter Stephenson
       
    28  * and the Zsh Development Group have no obligation to provide maintenance,
       
    29  * support, updates, enhancements, or modifications.
       
    30  *
       
    31  */
       
    32 
       
    33 /*
       
    34  * We need to include the zsh headers later to avoid clashes with
       
    35  * the definitions on some systems, however we need the configuration
       
    36  * file to decide whether we can include netinet/in_systm.h, which
       
    37  * doesn't exist on cygwin.
       
    38  */
       
    39 #include "config.h"
       
    40 
       
    41 #include <sys/types.h>
       
    42 #include <sys/socket.h>
       
    43 #include <netdb.h>
       
    44 
       
    45 /*
       
    46  * For some reason, configure doesn't always detect netinet/in_systm.h.
       
    47  * On some systems, including linux, this seems to be because gcc is
       
    48  * throwing up a warning message about the redefinition of
       
    49  * __USE_LARGEFILE.  This means the problem is somewhere in the
       
    50  * header files where we can't get at it.  For now, revert to
       
    51  * not including this file only on systems where we know it's missing.
       
    52  * Currently this is just some older versions of cygwin.
       
    53  */
       
    54 #if defined(HAVE_NETINET_IN_SYSTM_H) || !defined(__CYGWIN__)
       
    55 #ifndef __SYMBIAN32__
       
    56 # include <netinet/in_systm.h> 
       
    57 #endif
       
    58 #endif
       
    59 #include <stdapis/netinet/in.h>
       
    60 //#include <netinet/ip.h>
       
    61 #include <stdapis/arpa/inet.h>
       
    62 
       
    63 /* Is IPv6 supported by the library? */
       
    64 
       
    65 #if defined(AF_INET6) && defined(IN6ADDR_LOOPBACK_INIT) \
       
    66 	&& defined(HAVE_INET_NTOP) && defined(HAVE_INET_PTON)
       
    67 # define SUPPORT_IPV6 1
       
    68 #endif
       
    69 
       
    70 union tcp_sockaddr {
       
    71     struct sockaddr a;
       
    72     struct sockaddr_in in;
       
    73 #ifdef SUPPORT_IPV6
       
    74     struct sockaddr_in6 in6;
       
    75 #endif
       
    76 };
       
    77 
       
    78 typedef struct tcp_session *Tcp_session;
       
    79 
       
    80 #define ZTCP_LISTEN  1
       
    81 #define ZTCP_INBOUND 2
       
    82 #define ZTCP_ZFTP    16
       
    83 
       
    84 struct tcp_session {
       
    85     int fd;				/* file descriptor */
       
    86     union tcp_sockaddr sock;  	/* local address   */
       
    87     union tcp_sockaddr peer;  	/* remote address  */
       
    88     int flags;
       
    89 };
       
    90 
       
    91 #include "tcp.pro"
       
    92 
       
    93 #ifndef INET_ADDRSTRLEN
       
    94 # define INET_ADDRSTRLEN 16
       
    95 #endif
       
    96 
       
    97 #ifndef INET6_ADDRSTRLEN
       
    98 # define INET6_ADDRSTRLEN 46
       
    99 #endif