net.h revision 135446
1135446Strhodes/*
2135446Strhodes * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3135446Strhodes * Copyright (C) 2000-2002  Internet Software Consortium.
4135446Strhodes *
5135446Strhodes * Permission to use, copy, modify, and distribute this software for any
6135446Strhodes * purpose with or without fee is hereby granted, provided that the above
7135446Strhodes * copyright notice and this permission notice appear in all copies.
8135446Strhodes *
9135446Strhodes * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10135446Strhodes * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11135446Strhodes * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12135446Strhodes * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13135446Strhodes * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14135446Strhodes * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15135446Strhodes * PERFORMANCE OF THIS SOFTWARE.
16135446Strhodes */
17135446Strhodes
18135446Strhodes/* $Id: net.h,v 1.3.12.3 2004/03/08 09:05:12 marka Exp $ */
19135446Strhodes
20135446Strhodes#ifndef LWRES_NET_H
21135446Strhodes#define LWRES_NET_H 1
22135446Strhodes
23135446Strhodes/*****
24135446Strhodes ***** Module Info
25135446Strhodes *****/
26135446Strhodes
27135446Strhodes/*
28135446Strhodes * Basic Networking Types
29135446Strhodes *
30135446Strhodes * This module is responsible for defining the following basic networking
31135446Strhodes * types:
32135446Strhodes *
33135446Strhodes *		struct in_addr
34135446Strhodes *		struct in6_addr
35135446Strhodes *		struct sockaddr
36135446Strhodes *		struct sockaddr_in
37135446Strhodes *		struct sockaddr_in6
38135446Strhodes *
39135446Strhodes * It ensures that the AF_ and PF_ macros are defined.
40135446Strhodes *
41135446Strhodes * It declares ntoh[sl]() and hton[sl]().
42135446Strhodes *
43135446Strhodes * It declares lwres_net_aton(), lwres_net_ntop(), and lwres_net_pton().
44135446Strhodes *
45135446Strhodes * It ensures that INADDR_LOOPBACK, INADDR_ANY and IN6ADDR_ANY_INIT
46135446Strhodes * are defined.
47135446Strhodes */
48135446Strhodes
49135446Strhodes/***
50135446Strhodes *** Imports.
51135446Strhodes ***/
52135446Strhodes
53135446Strhodes#include <lwres/platform.h>	/* Required for LWRES_PLATFORM_*. */
54135446Strhodes
55135446Strhodes#include <unistd.h>
56135446Strhodes#include <sys/types.h>
57135446Strhodes#include <sys/socket.h>		/* Contractual promise. */
58135446Strhodes#include <sys/ioctl.h>
59135446Strhodes#include <sys/time.h>
60135446Strhodes#include <sys/un.h>
61135446Strhodes
62135446Strhodes#include <netinet/in.h>		/* Contractual promise. */
63135446Strhodes#include <arpa/inet.h>		/* Contractual promise. */
64135446Strhodes#ifdef LWRES_PLATFORM_NEEDNETINETIN6H
65135446Strhodes#include <netinet/in6.h>	/* Required on UnixWare. */
66135446Strhodes#endif
67135446Strhodes#ifdef LWRES_PLATFORM_NEEDNETINET6IN6H
68135446Strhodes#include <netinet6/in6.h>	/* Required on BSD/OS for in6_pktinfo. */
69135446Strhodes#endif
70135446Strhodes#include <net/if.h>
71135446Strhodes
72135446Strhodes#include <lwres/lang.h>
73135446Strhodes
74135446Strhodes#ifndef LWRES_PLATFORM_HAVEIPV6
75135446Strhodes#include <lwres/ipv6.h>		/* Contractual promise. */
76135446Strhodes#endif
77135446Strhodes
78135446Strhodes#ifdef LWRES_PLATFORM_HAVEINADDR6
79135446Strhodes#define in6_addr in_addr6	/* Required for pre RFC2133 implementations. */
80135446Strhodes#endif
81135446Strhodes
82135446Strhodes/*
83135446Strhodes * Required for some pre RFC2133 implementations.
84135446Strhodes * IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT were added in
85135446Strhodes * draft-ietf-ipngwg-bsd-api-04.txt or draft-ietf-ipngwg-bsd-api-05.txt.
86135446Strhodes * If 's6_addr' is defined then assume that there is a union and three
87135446Strhodes * levels otherwise assume two levels required.
88135446Strhodes */
89135446Strhodes#ifndef IN6ADDR_ANY_INIT
90135446Strhodes#ifdef s6_addr
91135446Strhodes#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
92135446Strhodes#else
93135446Strhodes#define IN6ADDR_ANY_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }
94135446Strhodes#endif
95135446Strhodes#endif
96135446Strhodes
97135446Strhodes#ifndef IN6ADDR_LOOPBACK_INIT
98135446Strhodes#ifdef s6_addr
99135446Strhodes#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
100135446Strhodes#else
101135446Strhodes#define IN6ADDR_LOOPBACK_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } }
102135446Strhodes#endif
103135446Strhodes#endif
104135446Strhodes
105135446Strhodes#ifndef AF_INET6
106135446Strhodes#define AF_INET6 99
107135446Strhodes#endif
108135446Strhodes
109135446Strhodes#ifndef PF_INET6
110135446Strhodes#define PF_INET6 AF_INET6
111135446Strhodes#endif
112135446Strhodes
113135446Strhodes#ifndef INADDR_LOOPBACK
114135446Strhodes#define INADDR_LOOPBACK 0x7f000001UL
115135446Strhodes#endif
116135446Strhodes
117135446StrhodesLWRES_LANG_BEGINDECLS
118135446Strhodes
119135446Strhodesconst char *
120135446Strhodeslwres_net_ntop(int af, const void *src, char *dst, size_t size);
121135446Strhodes
122135446Strhodesint
123135446Strhodeslwres_net_pton(int af, const char *src, void *dst);
124135446Strhodes
125135446Strhodesint
126135446Strhodeslwres_net_aton(const char *cp, struct in_addr *addr);
127135446Strhodes
128135446StrhodesLWRES_LANG_ENDDECLS
129135446Strhodes
130135446Strhodes#endif /* LWRES_NET_H */
131