Nut/OS  4.10.3
API Reference
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$
00080  * Revision 1.6  2009/03/05 22:16:57  freckle
00081  * use __NUT_EMULATION instead of __APPLE__, __linux__, or __CYGWIN__
00082  *
00083  * Revision 1.5  2008/08/11 07:00:23  haraldkipp
00084  * BSD types replaced by stdint types (feature request #1282721).
00085  *
00086  * Revision 1.4  2007/05/02 11:18:32  haraldkipp
00087  * IGMP support added. Incomplete.
00088  *
00089  * Revision 1.3  2005/07/26 15:49:59  haraldkipp
00090  * Cygwin support added.
00091  *
00092  * Revision 1.2  2005/04/04 19:33:55  freckle
00093  * added creation of include/netdb_orig.h, include/sys/socket_orig.h and
00094  * include/netinet/in_orig.h to allow unix emulation to use tcp/ip sockets
00095  *
00096  * Revision 1.1.1.1  2003/05/09 14:41:14  haraldkipp
00097  * Initial using 3.2.1
00098  *
00099  * Revision 1.5  2003/02/04 18:00:45  harald
00100  * Version 3 released
00101  *
00102  * Revision 1.4  2002/06/26 17:29:21  harald
00103  * First pre-release with 2.4 stack
00104  *
00105  */
00106 
00107 #include <sys/types.h>
00108 
00109 /* use native version on unix emulation */
00110 #ifdef __NUT_EMULATION__
00111 #include <netinet/in_orig.h>
00112 /* assure _NETINET_IN_H_ is set */
00113 #undef  _NETINET_IN_H_
00114 #define _NETINET_IN_H_
00115 #else  /* unix emulation */
00116 
00117 #define _NETINET_IN_H_
00118 
00126 /*
00127  * Protocols
00128  */
00129 #define IPPROTO_IP      0   
00130 #define IPPROTO_ICMP    1   
00131 #define IPPROTO_IGMP    2   
00132 #define IPPROTO_TCP     6   
00133 #define IPPROTO_UDP     17  
00135 #define IPPROTO_RAW     255 
00136 #define IPPROTO_MAX     256 
00139 #define IPPORT_RESERVED     1024    
00140 #define IPPORT_USERRESERVED 5000    
00145 #define INADDR_ANY          (uint32_t)0x00000000
00146 
00150 #define INADDR_BROADCAST    (uint32_t)0xffffffff
00151 
00152 /*
00153  * Definitions of bits in internet address integers.
00154  */
00155 #ifdef __BIG_ENDIAN__
00156 #define IN_CLASSA(i)        (((uint32_t)(i) & 0x80000000) == 0)
00157 #define IN_CLASSA_NET       0xff000000
00158 #define IN_CLASSB(i)        (((uint32_t)(i) & 0xc0000000) == 0x80000000)
00159 #define IN_CLASSB_NET       0xffff0000
00160 #define IN_CLASSC(i)        (((uint32_t)(i) & 0xe0000000) == 0xc0000000)
00161 #define IN_CLASSC_NET       0xffffff00
00162 #define IN_CLASSD(i)        (((uint32_t)(i) & 0xf0000000) == 0xe0000000)
00163 #define IN_CLASSD_NET       0xf0000000
00164 #else /* __BIG_ENDIAN__ */
00165 #define IN_CLASSA(i)        (((uint32_t)(i) & 0x00000080) == 0)
00166 #define IN_CLASSA_NET       0x000000ff
00167 #define IN_CLASSB(i)        (((uint32_t)(i) & 0x000000c0) == 0x00000080)
00168 #define IN_CLASSB_NET       0x0000ffff
00169 #define IN_CLASSC(i)        (((uint32_t)(i) & 0x000000e0) == 0x000000c0)
00170 #define IN_CLASSC_NET       0x00ffffff
00171 #define IN_CLASSD(i)        (((uint32_t)(i) & 0x000000f0) == 0x000000e0)
00172 #define IN_CLASSD_NET       0x0000000f
00173 #endif /* __BIG_ENDIAN__ */
00174 
00175 #define IN_MULTICAST(i)     IN_CLASSD(i)
00176 
00177 #ifdef __BIG_ENDIAN__
00178 #define INADDR_UNSPEC_GROUP     (uint32_t)0xe0000000  /* 224.0.0.0 */
00179 #define INADDR_ALLHOSTS_GROUP   (uint32_t)0xe0000001  /* 224.0.0.1 */
00180 #define INADDR_ALLRTRS_GROUP    (uint32_t)0xe0000002  /* 224.0.0.2 */
00181 #define INADDR_ALLRPTS_GROUP    (uint32_t)0xe0000016  /* 224.0.0.22, IGMPv3 */
00182 #define INADDR_CARP_GROUP       (uint32_t)0xe0000012  /* 224.0.0.18 */
00183 #define INADDR_PFSYNC_GROUP     (uint32_t)0xe00000f0  /* 224.0.0.240 */
00184 #define INADDR_ALLMDNS_GROUP    (uint32_t)0xe00000fb  /* 224.0.0.251 */
00185 #define INADDR_MAX_LOCAL_GROUP  (uint32_t)0xe00000ff  /* 224.0.0.255 */
00186 #else /* __BIG_ENDIAN__ */
00187 #define INADDR_UNSPEC_GROUP     (uint32_t)0x000000e0  /* 224.0.0.0 */
00188 #define INADDR_ALLHOSTS_GROUP   (uint32_t)0x010000e0  /* 224.0.0.1 */
00189 #define INADDR_ALLRTRS_GROUP    (uint32_t)0x020000e0  /* 224.0.0.2 */
00190 #define INADDR_ALLRPTS_GROUP    (uint32_t)0x160000e0  /* 224.0.0.22, IGMPv3 */
00191 #define INADDR_CARP_GROUP       (uint32_t)0x120000e0  /* 224.0.0.18 */
00192 #define INADDR_PFSYNC_GROUP     (uint32_t)0xf00000e0  /* 224.0.0.240 */
00193 #define INADDR_ALLMDNS_GROUP    (uint32_t)0xfb0000e0  /* 224.0.0.251 */
00194 #define INADDR_MAX_LOCAL_GROUP  (uint32_t)0xff0000e0  /* 224.0.0.255 */
00195 #endif /* __BIG_ENDIAN__ */
00196 
00197 #ifdef __BIG_ENDIAN__
00198 #define INADDR_LOOPBACK     (uint32_t)0x7f000001
00199 #else /* __BIG_ENDIAN__ */
00200 #define INADDR_LOOPBACK     (uint32_t)0x0100007f
00201 #endif /* __BIG_ENDIAN__ */
00202 
00206 #define IN_LOOPBACKNET      127
00207 #endif /* unix emulation */
00208 
00209 #endif