Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

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