Forbid include of soem inet6 header files from wrong place

KAME put INET6 related stuff into sys/netinet6 dir, but IPv6
  standard API(RFC2553) require following files to be under sys/netinet.
    netinet/ip6.h
    netinet/icmp6.h
  Now those header files just include each following files.
    netinet6/ip6.h
    netinet6/icmp6.h

  Also KAME has netinet6/in6.h for easy INET6 common defs
  sharing between different BSDs, but RFC2553 requires only
  netinet/in.h should be included from userland.
  So netinet/in.h also includes netinet6/in6.h inside.

  To keep apps portability, apps should not directly include
  above files from netinet6 dir.
  Ideally, all contents of,
    netinet6/ip6.h
    netinet6/icmp6.h
    netinet6/in6.h
  should be moved into
    netinet/ip6.h
    netinet/icmp6.h
    netinet/in.h
  but to avoid big changes in this stage, add some hack, that
    -Put some special macro define into those files under neitnet
    -Let files under netinet6 cause error if it is included
     from some apps, and, if the specifal macro define is not
     defined.
     (which should have been defined if files under netinet is
     included)
    -And let them print an error message which tells the
     correct name of the include file to be included.

  Also fix apps which includes invalid header files.

Approved by: jkh

Obtained from: KAME project
This commit is contained in:
Yoshinobu Inoue 2000-02-10 19:33:58 +00:00
parent 5bdee2c5d5
commit 1aa540eb03
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=57120
7 changed files with 22 additions and 2 deletions

View File

@ -32,6 +32,8 @@
#ifndef _NETINET_ICMP6_H_
#define _NETINET_ICMP6_H_
#define __KAME_NETINET_ICMP6_H_INCLUDED_
#include <netinet6/icmp6.h>
#undef __KAME_NETINET_ICMP6_H_INCLUDED_
#endif /* !_NETINET_ICMP6_H_ */

View File

@ -442,7 +442,9 @@ struct ip_mreq {
}
/* INET6 stuff */
#define __KAME_NETINET_IN_H_INCLUDED_
#include <netinet6/in6.h>
#undef __KAME_NETINET_IN_H_INCLUDED_
#ifdef _KERNEL
struct ifnet; struct mbuf; /* forward declarations for Standard C */

View File

@ -29,4 +29,6 @@
* $FreeBSD$
*/
#define __KAME_NETINET_IP6_H_INCLUDED_
#include <netinet6/ip6.h>
#undef __KAME_NETINET_IP6_H_INCLUDED_

View File

@ -67,6 +67,10 @@
#ifndef _NETINET6_ICMPV6_H_
#define _NETINET6_ICMPV6_H_
#if !defined(_KERNEL) && !defined(__KAME_NETINET_ICMP6_H_INCLUDED_)
#error "do not include netinet6/icmp6.h directly, include netinet/icmp6.h"
#endif
#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
- sizeof(struct icmp6_hdr) */

View File

@ -66,6 +66,10 @@
#ifndef _NETINET6_IN6_H_
#define _NETINET6_IN6_H_
#if !defined(_KERNEL) && !defined(__KAME_NETINET_IN_H_INCLUDED_)
#error "do not include netinet6/in6.h directly, include netinet/in.h"
#endif
#if !defined(_XOPEN_SOURCE)
#include <sys/queue.h>
#endif

View File

@ -67,6 +67,12 @@
#ifndef _NETINET6_IPV6_H_
#define _NETINET6_IPV6_H_
#if !defined(_KERNEL) && !defined(__KAME_NETINET_IP6_H_INCLUDED_)
#if 0 /* XXX: waiting for contrib/addrtoname.c fix */
#error "do not include netinet6/ip6.h directly, include netinet/ip6.h"
#endif
#endif
/*
* Definition for internet protocol version 6.
* RFC 2460

View File

@ -41,9 +41,9 @@
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet6/ip6.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include <netinet6/icmp6.h>
#include <netinet/icmp6.h>
#include <arpa/inet.h>