in.h

Go to the documentation of this file.
00001 #ifndef _NETINET_IN_H_
00002 
00003 /*
00004  * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 3. Neither the name of the copyright holders nor the names of
00016  *    contributors may be used to endorse or promote products derived
00017  *    from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00023  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00026  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00027  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00028  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00029  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  * For additional information see http://www.ethernut.de/
00033  *
00034  * -
00035  * Portions Copyright (C) 2000 David J. Hudson <dave@humbug.demon.co.uk>
00036  *
00037  * This file is distributed in the hope that it will be useful, but WITHOUT
00038  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00039  * FITNESS FOR A PARTICULAR PURPOSE.
00040  *
00041  * You can redistribute this file and/or modify it under the terms of the GNU
00042  * General Public License (GPL) as published by the Free Software Foundation;
00043  * either version 2 of the License, or (at your discretion) any later version.
00044  * See the accompanying file "copying-gpl.txt" for more details.
00045  *
00046  * As a special exception to the GPL, permission is granted for additional
00047  * uses of the text contained in this file.  See the accompanying file
00048  * "copying-liquorice.txt" for details.
00049  * -
00050  * Portions Copyright (c) 1983, 1993 by
00051  *  The Regents of the University of California.  All rights reserved.
00052  *
00053  * Redistribution and use in source and binary forms, with or without
00054  * modification, are permitted provided that the following conditions
00055  * are met:
00056  * 1. Redistributions of source code must retain the above copyright
00057  *    notice, this list of conditions and the following disclaimer.
00058  * 2. Redistributions in binary form must reproduce the above copyright
00059  *    notice, this list of conditions and the following disclaimer in the
00060  *    documentation and/or other materials provided with the distribution.
00061  * 3. Neither the name of the University nor the names of its contributors
00062  *    may be used to endorse or promote products derived from this software
00063  *    without specific prior written permission.
00064  *
00065  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00066  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00067  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00068  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00069  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00070  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00071  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00072  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00073  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00074  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00075  * SUCH DAMAGE.
00076  */
00077 
00078 /*
00079  * $Log: in.h,v $
00080  * Revision 1.4  2007/05/02 11:18:32  haraldkipp
00081  * IGMP support added. Incomplete.
00082  *
00083  * Revision 1.3  2005/07/26 15:49:59  haraldkipp
00084  * Cygwin support added.
00085  *
00086  * Revision 1.2  2005/04/04 19:33:55  freckle
00087  * added creation of include/netdb_orig.h, include/sys/socket_orig.h and
00088  * include/netinet/in_orig.h to allow unix emulation to use tcp/ip sockets
00089  *
00090  * Revision 1.1.1.1  2003/05/09 14:41:14  haraldkipp
00091  * Initial using 3.2.1
00092  *
00093  * Revision 1.5  2003/02/04 18:00:45  harald
00094  * Version 3 released
00095  *
00096  * Revision 1.4  2002/06/26 17:29:21  harald
00097  * First pre-release with 2.4 stack
00098  *
00099  */
00100 
00101 #include <sys/types.h>
00102 
00103 /* use native version on unix emulation */
00104 #if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__)
00105 #include <netinet/in_orig.h>
00106 /* assure _NETINET_IN_H_ is set */
00107 #undef  _NETINET_IN_H_
00108 #define _NETINET_IN_H_
00109 #else  /* unix emulation */
00110 
00111 #define _NETINET_IN_H_
00112 
00120 /*
00121  * Protocols
00122  */
00123 #define IPPROTO_IP      0   
00124 #define IPPROTO_ICMP    1   
00125 #define IPPROTO_IGMP    2   
00126 #define IPPROTO_TCP     6   
00127 #define IPPROTO_UDP     17  
00129 #define IPPROTO_RAW     255 
00130 #define IPPROTO_MAX     256 
00133 #define IPPORT_RESERVED     1024    
00134 #define IPPORT_USERRESERVED 5000    
00139 #define INADDR_ANY          (u_long)0x00000000
00140 
00144 #define INADDR_BROADCAST    (u_long)0xffffffff
00145 
00146 /*
00147  * Definitions of bits in internet address integers.
00148  */
00149 #ifdef __BIG_ENDIAN__
00150 #define IN_CLASSA(i)        (((u_long)(i) & 0x80000000) == 0)
00151 #define IN_CLASSA_NET       0xff000000
00152 #define IN_CLASSB(i)        (((u_long)(i) & 0xc0000000) == 0x80000000)
00153 #define IN_CLASSB_NET       0xffff0000
00154 #define IN_CLASSC(i)        (((u_long)(i) & 0xe0000000) == 0xc0000000)
00155 #define IN_CLASSC_NET       0xffffff00
00156 #define IN_CLASSD(i)        (((u_long)(i) & 0xf0000000) == 0xe0000000)
00157 #define IN_CLASSD_NET       0xf0000000
00158 #else /* __BIG_ENDIAN__ */
00159 #define IN_CLASSA(i)        (((u_long)(i) & 0x00000080) == 0)
00160 #define IN_CLASSA_NET       0x000000ff
00161 #define IN_CLASSB(i)        (((u_long)(i) & 0x000000c0) == 0x00000080)
00162 #define IN_CLASSB_NET       0x0000ffff
00163 #define IN_CLASSC(i)        (((u_long)(i) & 0x000000e0) == 0x000000c0)
00164 #define IN_CLASSC_NET       0x00ffffff
00165 #define IN_CLASSD(i)        (((u_long)(i) & 0x000000f0) == 0x000000e0)
00166 #define IN_CLASSD_NET       0x0000000f
00167 #endif /* __BIG_ENDIAN__ */
00168 
00169 #define IN_MULTICAST(i)     IN_CLASSD(i)
00170 
00171 #ifdef __BIG_ENDIAN__
00172 #define INADDR_UNSPEC_GROUP     (u_long)0xe0000000  /* 224.0.0.0 */
00173 #define INADDR_ALLHOSTS_GROUP   (u_long)0xe0000001  /* 224.0.0.1 */
00174 #define INADDR_ALLRTRS_GROUP    (u_long)0xe0000002  /* 224.0.0.2 */
00175 #define INADDR_ALLRPTS_GROUP    (u_long)0xe0000016  /* 224.0.0.22, IGMPv3 */
00176 #define INADDR_CARP_GROUP       (u_long)0xe0000012  /* 224.0.0.18 */
00177 #define INADDR_PFSYNC_GROUP     (u_long)0xe00000f0  /* 224.0.0.240 */
00178 #define INADDR_ALLMDNS_GROUP    (u_long)0xe00000fb  /* 224.0.0.251 */
00179 #define INADDR_MAX_LOCAL_GROUP  (u_long)0xe00000ff  /* 224.0.0.255 */
00180 #else /* __BIG_ENDIAN__ */
00181 #define INADDR_UNSPEC_GROUP     (u_long)0x000000e0  /* 224.0.0.0 */
00182 #define INADDR_ALLHOSTS_GROUP   (u_long)0x010000e0  /* 224.0.0.1 */
00183 #define INADDR_ALLRTRS_GROUP    (u_long)0x020000e0  /* 224.0.0.2 */
00184 #define INADDR_ALLRPTS_GROUP    (u_long)0x160000e0  /* 224.0.0.22, IGMPv3 */
00185 #define INADDR_CARP_GROUP       (u_long)0x120000e0  /* 224.0.0.18 */
00186 #define INADDR_PFSYNC_GROUP     (u_long)0xf00000e0  /* 224.0.0.240 */
00187 #define INADDR_ALLMDNS_GROUP    (u_long)0xfb0000e0  /* 224.0.0.251 */
00188 #define INADDR_MAX_LOCAL_GROUP  (u_long)0xff0000e0  /* 224.0.0.255 */
00189 #endif /* __BIG_ENDIAN__ */
00190 
00191 #ifdef __BIG_ENDIAN__
00192 #define INADDR_LOOPBACK     (u_long)0x7f000001
00193 #else /* __BIG_ENDIAN__ */
00194 #define INADDR_LOOPBACK     (u_long)0x0100007f
00195 #endif /* __BIG_ENDIAN__ */
00196 
00200 #define IN_LOOPBACKNET      127
00201 #endif /* unix emulation */
00202 
00203 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/