1 /*- 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)extern.h 8.2 (Berkeley) 4/4/94 34 * $FreeBSD: src/libexec/ftpd/extern.h,v 1.19 2002/02/04 01:23:44 kris Exp $ 35 */ 36 37 #include <sys/types.h> 38 #include <sys/socket.h> 39 40 void blkfree(char **); 41 char **copyblk(char **); 42 void cwd(char *); 43 void delete(char *); 44 void dologout(int); 45 void fatalerror(char *); 46 void feat(void); 47 void ftpd_logwtmp(char *, char *, struct sockaddr *addr); 48 int ftpd_pclose(FILE *); 49 FILE *ftpd_popen(char *, char *); 50 char *get_line(char *, int, FILE *); 51 void lreply(int, const char *, ...); 52 void makedir(char *); 53 void nack(char *); 54 void pass(char *); 55 void passive(void); 56 void long_passive(char *, int); 57 void perror_reply(int, char *); 58 void pwd(void); 59 void removedir(char *); 60 void renamecmd(char *, char *); 61 char *renamefrom(char *); 62 void reply(int, const char *, ...); 63 void retrieve(char *, char *); 64 void send_file_list(char *); 65 #ifdef OLD_SETPROCTITLE 66 void setproctitle(const char *, ...); 67 #endif 68 void statcmd(void); 69 void statfilecmd(char *); 70 void store(char *, char *, int); 71 void synterr(char *); 72 void upper(char *); 73 void user(char *); 74 void yyerror(char *); 75 int yyparse(void); 76 #if defined(INTERNAL_LS) 77 int ls_main(int, char **); 78 #endif 79 80 /* 81 * Important note for porting to other platforms: 82 * sockunion is dependent on the definition of the system's sockaddr_in and 83 * sockaddr_in6, because it MUST keep the order of their members. There are 84 * several known definitions of sockaddr_in and sockaddr_in6. 85 * 86 * FreeBSD (4.8/5.0): 87 * struct sockaddr_in { 88 * uint8_t sin_len; 89 * sa_family_t sin_family; 90 * in_port_t sin_port; 91 * struct in_addr sin_addr; 92 * char sin_zero[8]; 93 * }; 94 * struct sockaddr_in6 { 95 * uint8_t sin6_len; 96 * sa_family_t sin6_family; 97 * in_port_t sin6_port; 98 * uint32_t sin6_flowinfo; 99 * struct in6_addr sin6_addr; 100 * uint32_t sin6_scope_id; 101 * }; 102 * 103 * OpenBSD: sockaddr_[in|in6] has the same definition except that some 104 * integer types has different names (u_int8_t instead of uint8_t and u_int32_t 105 * instead of uint32_t) and member sin_zero[8] of sockaddr_in has type int8_t 106 * instead of char. 107 * 108 * Linux (glibc-2.2.5): 109 * struct sockaddr_in { 110 * sa_family_t sin_family; 111 * uint16_t sin_port; 112 * struct in_addr sin_addr; 113 * unsigned char sin_zero[sizeof (struct sockaddr) - 114 * sizeof (sa_family_t) - 115 * sizeof (uint16_t) - 116 * sizeof (struct in_addr)]; 117 * }; 118 * struct sockaddr_in6 { 119 * sa_family_t sin6_family; 120 * uint16_t sin6_port; 121 * uint32_t sin6_flowinfo; 122 * struct in6_addr sin6_addr; 123 * }; 124 */ 125 union sockunion { 126 struct sockinet { 127 /* If we don't have the sin_len member, but we want to use si_len, we must put 128 * si_len at the end. WARNING! In this case we must to initialize si_len by the 129 * value of sizeof(struct sockaddr_in) or sizeof(struct sockaddr_in6) every 130 * time than it will be initialized by correspondent library function in 131 * sin_len-aware systems. 132 */ 133 #ifndef LINUX /* BSD source */ 134 u_char si_len; 135 u_char si_family; 136 u_short si_port; 137 #else /* Linux port */ 138 sa_family_t si_family; 139 unsigned short int si_port; 140 #ifdef INET6 141 char padding[sizeof(struct sockaddr_in6) - sizeof(sa_family_t) - 142 sizeof(unsigned short int)]; 143 #else /* !INET6 */ 144 char padding[sizeof(struct sockaddr_in) - sizeof(sa_family_t) - 145 sizeof(unsigned short int)]; 146 #endif /* INET6 */ 147 /* Uncomment next line only if you really want to use si_len */ 148 /* u_char si_len;*/ 149 #endif /* Linux port */ 150 } su_si; 151 struct sockaddr_in su_sin; 152 #ifdef INET6 153 struct sockaddr_in6 su_sin6; 154 #endif /* INET6 */ 155 }; 156 157 #define su_len su_si.si_len 158 #define su_family su_si.si_family 159 #define su_port su_si.si_port 160