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