1 /* 2 * Copyright � 2003 Jeremy Nelson 3 * 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 * notices, the above paragraph (the one permitting redistribution), 12 * this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The names of the author(s) may not be used to endorse or promote 15 * products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31 #ifndef __NETWORK_H__ 32 #define __NETWORK_H__ 33 34 /* Used for connect_by_number */ 35 #define SERVICE_SERVER 0 36 #define SERVICE_CLIENT 1 37 38 /* Used from network.c */ 39 #define V0(x) ((SA *)&(x)) 40 #define FAMILY(x) (V0(x)->sa_family) 41 42 #define V4(x) ((ISA *)&(x)) 43 #define V4FAM(x) (V4(x)->sin_family) 44 #define V4ADDR(x) (V4(x)->sin_addr) 45 #define V4PORT(x) (V4(x)->sin_port) 46 47 #define V6(x) ((ISA6 *)&(x)) 48 #define V6FAM(x) (V6(x)->sin6_family) 49 #define V6ADDR(x) (V6(x)->sin6_addr) 50 #define V6PORT(x) (V6(x)->sin6_port) 51 52 int inet_strton (const char *, const char *, SA *, int); 53 int inet_ntostr (SA *, char *, int, char *, int, int); 54 char *inet_hntop (int, const char *, char *, int); 55 char *inet_ptohn (int, const char *, char *, int); 56 char *one_to_another (int, const char *, char *, int); 57 int Accept (int, SA *, int *); 58 char *switch_hostname (const char *); 59 int ip_bindery (int family, u_short port, SS *storage); 60 int client_bind (SA *, socklen_t); 61 int client_connect (SA *, socklen_t, SA *, socklen_t); 62 int connectory (int, const char *, const char *); 63 int inet_vhostsockaddr (int, int, SS *, socklen_t *); 64 65 #define GNI_INTEGER 0x4000 66 67 #endif 68