iwyu: n2n.h

There is still cleanup work to be done in the headers, but this
concludes the major include-what-you-use refactoring.  No functional
change is intended or expected and all tests are passing.

It is now a lot easier to see what is used from each header and work on
possible refactoring in the future.

The include-what-you-use tool is awkward to use with the current state
of the build system - and will always be difficult to use in a
multi-platform safe way.  However, I hope to provide a non manual
process for running with the tool in the future.
This commit is contained in:
Hamish Coleman 2023-06-18 11:51:56 +01:00
parent 771fdec013
commit 585b3cec59
3 changed files with 23 additions and 74 deletions

View File

@ -47,106 +47,51 @@
#undef N2N_HAVE_DAEMON #undef N2N_HAVE_DAEMON
#undef N2N_HAVE_TCP /* as explained on https://github.com/ntop/n2n/pull/627#issuecomment-782093706 */ #undef N2N_HAVE_TCP /* as explained on https://github.com/ntop/n2n/pull/627#issuecomment-782093706 */
#undef N2N_HAVE_SETUID #undef N2N_HAVE_SETUID
#endif #endif /* WIN32 */
#include <stdio.h> // for size_t, FILE
#include "n2n_define.h"
#include "n2n_typedefs.h"
#include <time.h> #ifdef WIN32
#include <ctype.h> #include <lmaccess.h> /* for privilege check in tools/n2n-route */
#include <stdlib.h> #include <lmapibuf.h> /* for privilege check in tools/n2n-route */
#include <sys/stat.h>
#include <windows.h> /* for privilege check in tools/n2n-route */
#include <winsock2.h> /* for tcp */
#include "wintap.h"
#define SHUT_RDWR SD_BOTH /* for tcp */
#endif /* #ifdef WIN32 */
#ifndef WIN32 #ifndef WIN32
#include <netdb.h> #include <netinet/in.h> // for in_addr (ptr only), in_addr_t
#endif #include <pwd.h>
#include <stdint.h> // for uint8_t, uint64_t, uint32_t, uint16_t
#ifndef _MSC_VER #include <sys/types.h> // for time_t
#include <getopt.h> #include <unistd.h> // for close
#endif /* #ifndef _MSC_VER */ #define closesocket(a) close(a)
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <time.h>
#ifndef WIN32
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <pthread.h>
#ifdef __linux__ #ifdef __linux__
#define N2N_CAN_NAME_IFACE 1 #define N2N_CAN_NAME_IFACE 1
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <unistd.h>
#include <net/if_arp.h>
#include <net/if.h>
#include <linux/if_tun.h>
#include <net/route.h>
#endif /* #ifdef __linux__ */ #endif /* #ifdef __linux__ */
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <netinet/in_systm.h> #include <netinet/in_systm.h>
#endif /* #ifdef __FreeBSD__ */ #endif /* #ifdef __FreeBSD__ */
#include <syslog.h>
#include <sys/wait.h>
#ifdef HAVE_ZSTD #ifdef HAVE_ZSTD
#include <zstd.h> #include <zstd.h>
#endif #endif
#include <netinet/in.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <sys/stat.h>
#include <stdint.h>
#if defined (HAVE_OPENSSL_1_1) #if defined (HAVE_OPENSSL_1_1)
#include <openssl/opensslv.h> #include <openssl/opensslv.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#endif #endif
#define closesocket(a) close(a)
#endif /* #ifndef WIN32 */ #endif /* #ifndef WIN32 */
#include "minilzo.h"
#include <signal.h>
#include <string.h>
#include <stdarg.h>
#include "lzoconf.h"
#include "uthash.h"
#include "n2n_define.h"
#include "n2n_typedefs.h"
#ifdef WIN32
#include <windows.h> /* for privilege check in tools/n2n-route */
#include <lmaccess.h> /* for privilege check in tools/n2n-route */
#include <lmapibuf.h> /* for privilege check in tools/n2n-route */
#include <winsock2.h> /* for tcp */
#define SHUT_RDWR SD_BOTH /* for tcp */
#include "wintap.h"
#include <sys/stat.h>
#else
#include <pwd.h>
#endif /* #ifdef WIN32 */
#include "n2n_wire.h"
#include "portable_endian.h"
#include "aes.h"
#include "curve25519.h"
#include "n2n_regex.h"
#include "sn_selection.h"
#include "network_traffic_filter.h"
#include "n2n_port_mapping.h"
/* ************************************** */ /* ************************************** */

View File

@ -17,6 +17,7 @@
*/ */
#include <fcntl.h>
#include "n2n.h" #include "n2n.h"

View File

@ -16,8 +16,11 @@
* *
*/ */
#include <errno.h> // for errno
#include <pcap.h> #include <pcap.h>
#include <signal.h> // for signal, SIGINT, SIGTERM
#include "n2n.h" #include "n2n.h"
#include "n2n_wire.h"
#define SNAPLEN 1500 #define SNAPLEN 1500
#define TIMEOUT 200 #define TIMEOUT 200