• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/emulate/inet.h

00001 /*
00002  * Copyright (c) 1991-1994 Regents of the University of California.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. All advertising materials mentioning features or use of this software
00014  *    must display the following acknowledgement:
00015  *      This product includes software developed by the University of
00016  *      California, Berkeley and the Network Research Group at
00017  *      Lawrence Berkeley Laboratory.
00018  * 4. Neither the name of the University nor of the Laboratory may be used
00019  *    to endorse or promote products derived from this software without
00020  *    specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * @(#) $Header: /cvsroot/nsnam/ns-2/emulate/inet.h,v 1.3 2003/02/15 00:55:31 buchheim Exp $ (LBL)
00035  */
00036 
00037 #ifndef ns_inet_h
00038 #define ns_inet_h
00039 
00040 #include <sys/types.h>
00041 #ifdef WIN32
00042 #include <winsock.h>
00043 #endif
00044 #if defined(__osf__)
00045 #include <machine/endian.h>
00046 #endif
00047 #if defined(__linux__)
00048 #include <endian.h>
00049 #endif
00050 #ifndef IPPROTO_IP
00051 #if defined(__ultrix__) && defined(__cplusplus)
00052 extern "C" {
00053 #include <netinet/in.h>
00054 }
00055 #else
00056 #include <netinet/in.h>
00057 #endif
00058 #endif
00059 #ifndef WIN32
00060 #include <arpa/inet.h>
00061 #endif
00062 
00063 #include "config.h"
00064 
00065 #ifdef __cplusplus
00066 extern "C" {
00067 #endif
00068 extern char *LookupHostName(u_int32_t addr);
00069 extern char *InetNtoa(u_int32_t addr);
00070 extern u_int32_t LookupLocalAddr(void);
00071 extern u_int32_t LookupHostAddr(const char* host);
00072 extern const char* intoa(u_int32_t addr);
00073 extern u_short in_cksum(u_short*, int);
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077 
00078 #ifndef NTOHL
00079 #if BYTE_ORDER==LITTLE_ENDIAN
00080 #define NTOHL(d) ((d) = ntohl((d)))
00081 #define NTOHS(d) ((d) = ntohs((d)))
00082 #define HTONL(d) ((d) = htonl((d)))
00083 #define HTONS(d) ((d) = htons((d)))
00084 #elif BYTE_ORDER==BIG_ENDIAN
00085 #define NTOHL(d)
00086 #define NTOHS(d)
00087 #define HTONL(d)
00088 #define HTONS(d)
00089 #else
00090 #error error - BYTE_ORDER not defined.
00091 #endif
00092 #endif
00093 
00094 #ifndef INADDR_LOOPBACK
00095 #define INADDR_LOOPBACK (u_int32_t)0x7F000001
00096 #endif
00097 
00098 #if defined(WIN32)
00099 struct msghdr {
00100         caddr_t msg_name;               /* optional address */
00101         u_int   msg_namelen;            /* size of address */
00102         struct  iovec *msg_iov;         /* scatter/gather array */
00103         u_int   msg_iovlen;             /* # elements in msg_iov */
00104         caddr_t msg_control;            /* ancillary data, see below */
00105         u_int   msg_controllen;         /* ancillary data buffer len */
00106         int     msg_flags;              /* flags on received message */
00107 };
00108 #endif
00109 
00110 /* XXX winsock.h should have these !! */
00111 #ifdef WIN32
00112 #define IN_CLASSD(i)            (((u_long)(i) & ((u_long)0xf0000000)) == \
00113                                   ((u_long)0xe0000000))
00114 #define IN_CLASSD_NET           ((u_long)0xf0000000)/* These aren't really    */
00115 #define IN_CLASSD_NSHIFT        28                  /* net and host fields,but*/
00116 #define IN_CLASSD_HOST          ((u_long)0x0fffffff)/* routing needn't know.  */
00117 #define IN_MULTICAST(i)         IN_CLASSD(i)
00118 #endif
00119 
00120 /* for systems without socklen_t (such as Darwin/Mac OS X) */
00121 #ifndef HAVE_SOCKLEN_T
00122 typedef int socklen_t;
00123 #endif
00124 
00125 
00126 #endif
00127 

Generated on Tue Aug 10 2010 16:16:07 for ns-2.33 by  doxygen 1.7.1