root/vic/trunk/net/inet.h
@
921
| Revision 921, 3.8 KB (checked in by piers, 14 years ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | /* |
| 2 | * Copyright (c) 1991-1994 Regents of the University of California. |
| 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 | * 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 the Network Research Group at |
| 17 | * Lawrence Berkeley Laboratory. |
| 18 | * 4. Neither the name of the University nor of the Laboratory may be used |
| 19 | * to endorse or promote products derived from this software without |
| 20 | * specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 32 | * SUCH DAMAGE. |
| 33 | * |
| 34 | * @(#) $Header$ (LBL) |
| 35 | */ |
| 36 | |
| 37 | #ifndef vic_inet_h |
| 38 | #define vic_inet_h |
| 39 | |
| 40 | |
| 41 | #include "config.h" |
| 42 | |
| 43 | #include <sys/types.h> |
| 44 | |
| 45 | #if defined(__osf__) |
| 46 | #include <machine/endian.h> |
| 47 | #endif |
| 48 | |
| 49 | #if defined(__linux__) |
| 50 | #include <endian.h> |
| 51 | #endif |
| 52 | |
| 53 | #ifndef IPPROTO_IP |
| 54 | #if defined(__ultrix__) && defined(__cplusplus) |
| 55 | extern "C" { |
| 56 | #include <netinet/in.h> |
| 57 | } |
| 58 | #else |
| 59 | #include <netinet/in.h> |
| 60 | #endif |
| 61 | #endif |
| 62 | |
| 63 | #ifndef WIN32 |
| 64 | #include <arpa/inet.h> |
| 65 | #endif |
| 66 | |
| 67 | |
| 68 | #ifdef __cplusplus |
| 69 | extern "C" { |
| 70 | #endif |
| 71 | extern char *LookupHostName(u_int32_t addr); |
| 72 | extern char *InetNtoa(u_int32_t addr); |
| 73 | extern u_int32_t LookupLocalAddr(void); |
| 74 | extern u_int32_t LookupHostAddr(const char* host); |
| 75 | extern const char* intoa(u_int32_t addr); |
| 76 | #ifdef __cplusplus |
| 77 | } |
| 78 | #endif |
| 79 | |
| 80 | #ifndef NTOHL |
| 81 | #if BYTE_ORDER==LITTLE_ENDIAN |
| 82 | #define NTOHL(d) ((d) = ntohl((d))) |
| 83 | #define NTOHS(d) ((d) = ntohs((d))) |
| 84 | #define HTONL(d) ((d) = htonl((d))) |
| 85 | #define HTONS(d) ((d) = htons((d))) |
| 86 | #elif BYTE_ORDER==BIG_ENDIAN |
| 87 | #define NTOHL(d) |
| 88 | #define NTOHS(d) |
| 89 | #define HTONL(d) |
| 90 | #define HTONS(d) |
| 91 | #else |
| 92 | #error error - BYTE_ORDER not defined. |
| 93 | #endif |
| 94 | #endif |
| 95 | |
| 96 | #ifndef INADDR_LOOPBACK |
| 97 | #define INADDR_LOOPBACK (u_int32_t)0x7F000001 |
| 98 | #endif |
| 99 | |
| 100 | #if defined(WIN32) |
| 101 | |
| 102 | /* XXX winsock.h should have these !! */ |
| 103 | /* winsock2.h does have these */ |
| 104 | #ifndef _WINSOCK2API_ |
| 105 | |
| 106 | #define IN_CLASSD(i) (((u_long)(i) & ((u_long)0xf0000000)) == \ |
| 107 | ((u_long)0xe0000000)) |
| 108 | #define IN_CLASSD_NET ((u_long)0xf0000000)/* These aren't really */ |
| 109 | #define IN_CLASSD_NSHIFT 28 /* net and host fields,but*/ |
| 110 | #define IN_CLASSD_HOST ((u_long)0x0fffffff)/* routing needn't know. */ |
| 111 | #endif |
| 112 | |
| 113 | #define IN_MULTICAST(i) IN_CLASSD(i) |
| 114 | struct msghdr { |
| 115 | caddr_t msg_name; /* optional address */ |
| 116 | u_int msg_namelen; /* size of address */ |
| 117 | struct iovec *msg_iov; /* scatter/gather array */ |
| 118 | u_int msg_iovlen; /* # elements in msg_iov */ |
| 119 | caddr_t msg_control; /* ancillary data, see below */ |
| 120 | u_int msg_controllen; /* ancillary data buffer len */ |
| 121 | int msg_flags; /* flags on received message */ |
| 122 | }; |
| 123 | #endif |
| 124 | |
| 125 | #endif |
Note: See TracBrowser
for help on using the browser.
