Dependencies:   mbed

Committer:
ICTFBI
Date:
Fri Oct 16 14:28:26 2015 +0000
Revision:
0:4edb816d21e1
Pre-update 16-10-15

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ICTFBI 0:4edb816d21e1 1 /*
ICTFBI 0:4edb816d21e1 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
ICTFBI 0:4edb816d21e1 3 * All rights reserved.
ICTFBI 0:4edb816d21e1 4 *
ICTFBI 0:4edb816d21e1 5 * Redistribution and use in source and binary forms, with or without modification,
ICTFBI 0:4edb816d21e1 6 * are permitted provided that the following conditions are met:
ICTFBI 0:4edb816d21e1 7 *
ICTFBI 0:4edb816d21e1 8 * 1. Redistributions of source code must retain the above copyright notice,
ICTFBI 0:4edb816d21e1 9 * this list of conditions and the following disclaimer.
ICTFBI 0:4edb816d21e1 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
ICTFBI 0:4edb816d21e1 11 * this list of conditions and the following disclaimer in the documentation
ICTFBI 0:4edb816d21e1 12 * and/or other materials provided with the distribution.
ICTFBI 0:4edb816d21e1 13 * 3. The name of the author may not be used to endorse or promote products
ICTFBI 0:4edb816d21e1 14 * derived from this software without specific prior written permission.
ICTFBI 0:4edb816d21e1 15 *
ICTFBI 0:4edb816d21e1 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
ICTFBI 0:4edb816d21e1 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
ICTFBI 0:4edb816d21e1 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
ICTFBI 0:4edb816d21e1 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
ICTFBI 0:4edb816d21e1 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
ICTFBI 0:4edb816d21e1 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
ICTFBI 0:4edb816d21e1 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
ICTFBI 0:4edb816d21e1 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
ICTFBI 0:4edb816d21e1 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
ICTFBI 0:4edb816d21e1 25 * OF SUCH DAMAGE.
ICTFBI 0:4edb816d21e1 26 *
ICTFBI 0:4edb816d21e1 27 * This file is part of the lwIP TCP/IP stack.
ICTFBI 0:4edb816d21e1 28 *
ICTFBI 0:4edb816d21e1 29 * Author: Adam Dunkels <adam@sics.se>
ICTFBI 0:4edb816d21e1 30 *
ICTFBI 0:4edb816d21e1 31 */
ICTFBI 0:4edb816d21e1 32 #ifndef __LWIP_INET_H__
ICTFBI 0:4edb816d21e1 33 #define __LWIP_INET_H__
ICTFBI 0:4edb816d21e1 34
ICTFBI 0:4edb816d21e1 35 #include "lwip/opt.h"
ICTFBI 0:4edb816d21e1 36 #include "lwip/def.h"
ICTFBI 0:4edb816d21e1 37 #include "lwip/ip_addr.h"
ICTFBI 0:4edb816d21e1 38
ICTFBI 0:4edb816d21e1 39 #ifdef __cplusplus
ICTFBI 0:4edb816d21e1 40 extern "C" {
ICTFBI 0:4edb816d21e1 41 #endif
ICTFBI 0:4edb816d21e1 42
ICTFBI 0:4edb816d21e1 43 /* For compatibility with BSD code */
ICTFBI 0:4edb816d21e1 44 struct in_addr {
ICTFBI 0:4edb816d21e1 45 u32_t s_addr;
ICTFBI 0:4edb816d21e1 46 };
ICTFBI 0:4edb816d21e1 47
ICTFBI 0:4edb816d21e1 48 /** 255.255.255.255 */
ICTFBI 0:4edb816d21e1 49 #define INADDR_NONE IPADDR_NONE
ICTFBI 0:4edb816d21e1 50 /** 127.0.0.1 */
ICTFBI 0:4edb816d21e1 51 #define INADDR_LOOPBACK IPADDR_LOOPBACK
ICTFBI 0:4edb816d21e1 52 /** 0.0.0.0 */
ICTFBI 0:4edb816d21e1 53 #define INADDR_ANY IPADDR_ANY
ICTFBI 0:4edb816d21e1 54 /** 255.255.255.255 */
ICTFBI 0:4edb816d21e1 55 #define INADDR_BROADCAST IPADDR_BROADCAST
ICTFBI 0:4edb816d21e1 56
ICTFBI 0:4edb816d21e1 57 /* Definitions of the bits in an Internet address integer.
ICTFBI 0:4edb816d21e1 58
ICTFBI 0:4edb816d21e1 59 On subnets, host and network parts are found according to
ICTFBI 0:4edb816d21e1 60 the subnet mask, not these masks. */
ICTFBI 0:4edb816d21e1 61 #define IN_CLASSA(a) IP_CLASSA(a)
ICTFBI 0:4edb816d21e1 62 #define IN_CLASSA_NET IP_CLASSA_NET
ICTFBI 0:4edb816d21e1 63 #define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT
ICTFBI 0:4edb816d21e1 64 #define IN_CLASSA_HOST IP_CLASSA_HOST
ICTFBI 0:4edb816d21e1 65 #define IN_CLASSA_MAX IP_CLASSA_MAX
ICTFBI 0:4edb816d21e1 66
ICTFBI 0:4edb816d21e1 67 #define IN_CLASSB(b) IP_CLASSB(b)
ICTFBI 0:4edb816d21e1 68 #define IN_CLASSB_NET IP_CLASSB_NET
ICTFBI 0:4edb816d21e1 69 #define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT
ICTFBI 0:4edb816d21e1 70 #define IN_CLASSB_HOST IP_CLASSB_HOST
ICTFBI 0:4edb816d21e1 71 #define IN_CLASSB_MAX IP_CLASSB_MAX
ICTFBI 0:4edb816d21e1 72
ICTFBI 0:4edb816d21e1 73 #define IN_CLASSC(c) IP_CLASSC(c)
ICTFBI 0:4edb816d21e1 74 #define IN_CLASSC_NET IP_CLASSC_NET
ICTFBI 0:4edb816d21e1 75 #define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT
ICTFBI 0:4edb816d21e1 76 #define IN_CLASSC_HOST IP_CLASSC_HOST
ICTFBI 0:4edb816d21e1 77 #define IN_CLASSC_MAX IP_CLASSC_MAX
ICTFBI 0:4edb816d21e1 78
ICTFBI 0:4edb816d21e1 79 #define IN_CLASSD(d) IP_CLASSD(d)
ICTFBI 0:4edb816d21e1 80 #define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */
ICTFBI 0:4edb816d21e1 81 #define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */
ICTFBI 0:4edb816d21e1 82 #define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */
ICTFBI 0:4edb816d21e1 83 #define IN_CLASSD_MAX IP_CLASSD_MAX
ICTFBI 0:4edb816d21e1 84
ICTFBI 0:4edb816d21e1 85 #define IN_MULTICAST(a) IP_MULTICAST(a)
ICTFBI 0:4edb816d21e1 86
ICTFBI 0:4edb816d21e1 87 #define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a)
ICTFBI 0:4edb816d21e1 88 #define IN_BADCLASS(a) IP_BADCLASS(a)
ICTFBI 0:4edb816d21e1 89
ICTFBI 0:4edb816d21e1 90 #define IN_LOOPBACKNET IP_LOOPBACKNET
ICTFBI 0:4edb816d21e1 91
ICTFBI 0:4edb816d21e1 92 #define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
ICTFBI 0:4edb816d21e1 93 #define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
ICTFBI 0:4edb816d21e1 94 /* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */
ICTFBI 0:4edb816d21e1 95 #define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr) ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr))
ICTFBI 0:4edb816d21e1 96
ICTFBI 0:4edb816d21e1 97 /* directly map this to the lwip internal functions */
ICTFBI 0:4edb816d21e1 98 #define inet_addr(cp) ipaddr_addr(cp)
ICTFBI 0:4edb816d21e1 99 #define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr)
ICTFBI 0:4edb816d21e1 100 #define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr))
ICTFBI 0:4edb816d21e1 101 #define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen)
ICTFBI 0:4edb816d21e1 102
ICTFBI 0:4edb816d21e1 103 #ifdef __cplusplus
ICTFBI 0:4edb816d21e1 104 }
ICTFBI 0:4edb816d21e1 105 #endif
ICTFBI 0:4edb816d21e1 106
ICTFBI 0:4edb816d21e1 107 #endif /* __LWIP_INET_H__ */