Host library for controlling a WiConnect enabled Wi-Fi module.

Dependents:   wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers inet.h Source File

inet.h

00001 
00002 /*
00003  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without modification,
00007  * are permitted provided that the following conditions are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright notice,
00010  *    this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright notice,
00012  *    this list of conditions and the following disclaimer in the documentation
00013  *    and/or other materials provided with the distribution.
00014  * 3. The name of the author may not be used to endorse or promote products
00015  *    derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00018  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00020  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00021  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00022  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00025  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00026  * OF SUCH DAMAGE.
00027  *
00028  * This file is part of the lwIP TCP/IP stack.
00029  *
00030  * Author: Adam Dunkels <adam@sics.se>
00031  *
00032  */
00033 #ifndef __LWIP_INET_H__
00034 #define __LWIP_INET_H__
00035 
00036 #include "opt.h"
00037 #include "ip_addr.h"
00038 
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 /** For compatibility with BSD code */
00045 struct in_addr {
00046   u32_t s_addr;
00047 };
00048 
00049 /** 255.255.255.255 */
00050 #define INADDR_NONE         IPADDR_NONE
00051 /** 127.0.0.1 */
00052 #define INADDR_LOOPBACK     IPADDR_LOOPBACK
00053 /** 0.0.0.0 */
00054 #define INADDR_ANY          IPADDR_ANY
00055 /** 255.255.255.255 */
00056 #define INADDR_BROADCAST    IPADDR_BROADCAST
00057 
00058 /* Definitions of the bits in an Internet address integer.
00059 
00060    On subnets, host and network parts are found according to
00061    the subnet mask, not these masks.  */
00062 #define IN_CLASSA(a)        IP_CLASSA(a)
00063 #define IN_CLASSA_NET       IP_CLASSA_NET
00064 #define IN_CLASSA_NSHIFT    IP_CLASSA_NSHIFT
00065 #define IN_CLASSA_HOST      IP_CLASSA_HOST
00066 #define IN_CLASSA_MAX       IP_CLASSA_MAX
00067 
00068 #define IN_CLASSB(b)        IP_CLASSB(b)
00069 #define IN_CLASSB_NET       IP_CLASSB_NET
00070 #define IN_CLASSB_NSHIFT    IP_CLASSB_NSHIFT
00071 #define IN_CLASSB_HOST      IP_CLASSB_HOST
00072 #define IN_CLASSB_MAX       IP_CLASSB_MAX
00073 
00074 #define IN_CLASSC(c)        IP_CLASSC(c)
00075 #define IN_CLASSC_NET       IP_CLASSC_NET
00076 #define IN_CLASSC_NSHIFT    IP_CLASSC_NSHIFT
00077 #define IN_CLASSC_HOST      IP_CLASSC_HOST
00078 #define IN_CLASSC_MAX       IP_CLASSC_MAX
00079 
00080 #define IN_CLASSD(d)        IP_CLASSD(d)
00081 #define IN_CLASSD_NET       IP_CLASSD_NET     /* These ones aren't really */
00082 #define IN_CLASSD_NSHIFT    IP_CLASSD_NSHIFT  /*   net and host fields, but */
00083 #define IN_CLASSD_HOST      IP_CLASSD_HOST    /*   routing needn't know. */
00084 #define IN_CLASSD_MAX       IP_CLASSD_MAX
00085 
00086 #define IN_MULTICAST(a)     IP_MULTICAST(a)
00087 
00088 #define IN_EXPERIMENTAL(a)  IP_EXPERIMENTAL(a)
00089 #define IN_BADCLASS(a)      IP_BADCLASS(a)
00090 
00091 #define IN_LOOPBACKNET      IP_LOOPBACKNET
00092 
00093 #define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
00094 #define inet_addr_to_ipaddr(target_ipaddr, source_inaddr)   (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
00095 /* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */
00096 #define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr)   ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr))
00097 
00098 /* directly map this to the lwip internal functions */
00099 #define inet_addr(cp)         ipaddr_addr(cp)
00100 #define inet_aton(cp, addr)   ipaddr_aton(cp, (ip_addr_t*)addr)
00101 #define inet_ntoa(addr)       ipaddr_ntoa((ip_addr_t*)&(addr))
00102 #define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen)
00103 
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 
00108 #endif /* __LWIP_INET_H__ */