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