]> git.ipfire.org Git - people/ms/strongswan.git/blame - src/libfreeswan/liblwres/unix/include/lwres/net.h
- started to rebuild source layout
[people/ms/strongswan.git] / src / libfreeswan / liblwres / unix / include / lwres / net.h
CommitLineData
997358a6
MW
1/*
2 * Copyright (C) 2000, 2001 Internet Software Consortium.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
9 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18/* $Id: net.h,v 1.1 2004/03/15 20:35:25 as Exp $ */
19
20#ifndef LWRES_NET_H
21#define LWRES_NET_H 1
22
23/*****
24 ***** Module Info
25 *****/
26
27/*
28 * Basic Networking Types
29 *
30 * This module is responsible for defining the following basic networking
31 * types:
32 *
33 * struct in_addr
34 * struct in6_addr
35 * struct sockaddr
36 * struct sockaddr_in
37 * struct sockaddr_in6
38 *
39 * It ensures that the AF_ and PF_ macros are defined.
40 *
41 * It declares ntoh[sl]() and hton[sl]().
42 *
43 * It declares lwres_net_aton(), lwres_net_ntop(), and lwres_net_pton().
44 *
45 * It ensures that INADDR_LOOPBACK, INADDR_ANY and IN6ADDR_ANY_INIT
46 * are defined.
47 */
48
49/***
50 *** Imports.
51 ***/
52
53#include <lwres/platform.h> /* Required for LWRES_PLATFORM_*. */
54
55#include <sys/types.h>
56#include <sys/socket.h> /* Contractual promise. */
57#include <sys/time.h>
58#include <sys/un.h>
59
60#include <netinet/in.h> /* Contractual promise. */
61#include <arpa/inet.h> /* Contractual promise. */
62#ifdef LWRES_PLATFORM_NEEDNETINETIN6H
63#include <netinet/in6.h> /* Required on UnixWare. */
64#endif
65#ifdef LWRES_PLATFORM_NEEDNETINET6IN6H
66#include <netinet6/in6.h> /* Required on BSD/OS for in6_pktinfo. */
67#endif
68
69#include <lwres/lang.h>
70
71#ifndef LWRES_PLATFORM_HAVEIPV6
72#include <lwres/ipv6.h> /* Contractual promise. */
73#endif
74
75#ifdef LWRES_PLATFORM_HAVEINADDR6
76#define in6_addr in_addr6 /* Required for pre RFC2133 implementations. */
77#endif
78
79/*
80 * Required for some pre RFC2133 implementations.
81 * IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT were added in
82 * draft-ietf-ipngwg-bsd-api-04.txt or draft-ietf-ipngwg-bsd-api-05.txt.
83 * If 's6_addr' is defined then assume that there is a union and three
84 * levels otherwise assume two levels required.
85 */
86#ifndef IN6ADDR_ANY_INIT
87#ifdef s6_addr
88#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
89#else
90#define IN6ADDR_ANY_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }
91#endif
92#endif
93
94#ifndef IN6ADDR_LOOPBACK_INIT
95#ifdef s6_addr
96#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
97#else
98#define IN6ADDR_LOOPBACK_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } }
99#endif
100#endif
101
102#ifndef AF_INET6
103#define AF_INET6 99
104#endif
105
106#ifndef PF_INET6
107#define PF_INET6 AF_INET6
108#endif
109
110#ifndef INADDR_LOOPBACK
111#define INADDR_LOOPBACK 0x7f000001UL
112#endif
113
114LWRES_LANG_BEGINDECLS
115
116const char *
117lwres_net_ntop(int af, const void *src, char *dst, size_t size);
118
119int
120lwres_net_pton(int af, const char *src, void *dst);
121
122int
123lwres_net_aton(const char *cp, struct in_addr *addr);
124
125LWRES_LANG_ENDDECLS
126
127#endif /* LWRES_NET_H */