passt: Drop <linux/ipv6.h> include, carry own ipv6hdr and opt_hdr definitions

This is the only remaining Linux-specific include -- drop it to avoid
clang-tidy warnings and to make code more portable.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2022-01-25 19:03:44 +01:00
parent f6d9787d30
commit b93c2c1713
16 changed files with 28 additions and 24 deletions

2
arp.c
View file

@ -23,8 +23,6 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "arp.h" #include "arp.h"
#include "dhcp.h" #include "dhcp.h"

2
conf.c
View file

@ -31,8 +31,6 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "passt.h" #include "passt.h"
#include "netlink.h" #include "netlink.h"

2
dhcp.c
View file

@ -23,8 +23,6 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "checksum.h" #include "checksum.h"
#include "passt.h" #include "passt.h"

View file

@ -25,8 +25,6 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "passt.h" #include "passt.h"
#include "tap.h" #include "tap.h"

1
icmp.c
View file

@ -30,7 +30,6 @@
#include <time.h> #include <time.h>
#include <linux/icmpv6.h> #include <linux/icmpv6.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "passt.h" #include "passt.h"

1
ndp.c
View file

@ -24,7 +24,6 @@
#include <net/if_arp.h> #include <net/if_arp.h>
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <linux/ipv6.h>
#include <linux/icmpv6.h> #include <linux/icmpv6.h>
#include "checksum.h" #include "checksum.h"

View file

@ -25,7 +25,6 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <linux/ipv6.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>

View file

@ -54,7 +54,6 @@
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/filter.h> #include <linux/filter.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/ipv6.h>
#include <linux/icmpv6.h> #include <linux/icmpv6.h>
#include "seccomp.h" #include "seccomp.h"

View file

@ -35,8 +35,6 @@
#include <net/ethernet.h> #include <net/ethernet.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "passt.h" #include "passt.h"
#include "netlink.h" #include "netlink.h"

2
pcap.c
View file

@ -28,8 +28,6 @@
#include <unistd.h> #include <unistd.h>
#include <net/if.h> #include <net/if.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "passt.h" #include "passt.h"

2
qrap.c
View file

@ -26,8 +26,6 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "passt.h" #include "passt.h"
#include "arp.h" #include "arp.h"

1
tap.c
View file

@ -40,7 +40,6 @@
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <linux/if_tun.h> #include <linux/if_tun.h>
#include <linux/ipv6.h>
#include <linux/icmpv6.h> #include <linux/icmpv6.h>
#include "checksum.h" #include "checksum.h"

1
tcp.c
View file

@ -328,7 +328,6 @@
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <linux/ipv6.h>
#include <linux/tcp.h> /* For struct tcp_info */ #include <linux/tcp.h> /* For struct tcp_info */
#include "checksum.h" #include "checksum.h"

2
udp.c
View file

@ -110,8 +110,6 @@
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <linux/ipv6.h>
#include "checksum.h" #include "checksum.h"
#include "util.h" #include "util.h"
#include "passt.h" #include "passt.h"

2
util.c
View file

@ -32,8 +32,6 @@
#include <time.h> #include <time.h>
#include <errno.h> #include <errno.h>
#include <linux/ipv6.h>
#include "util.h" #include "util.h"
#include "passt.h" #include "passt.h"

28
util.h
View file

@ -149,6 +149,34 @@ enum bind_type {
struct ctx; struct ctx;
struct ipv6hdr {
#pragma GCC diagnostic ignored "-Wpedantic"
#if __BYTE_ORDER == __BIG_ENDIAN
__u8 version:4,
priority:4;
#else
uint8_t priority:4,
version:4;
#endif
#pragma GCC diagnostic pop
uint8_t flow_lbl[3];
__be16 payload_len;
__u8 nexthdr;
__u8 hop_limit;
struct in6_addr saddr;
struct in6_addr daddr;
};
struct ipv6_opt_hdr {
__u8 nexthdr;
__u8 hdrlen;
/*
* TLV encoded option data follows.
*/
} __attribute__((packed)); /* required for some archs */
__attribute__ ((weak)) int ffsl(long int i) { return __builtin_ffsl(i); } __attribute__ ((weak)) int ffsl(long int i) { return __builtin_ffsl(i); }
void __openlog(const char *ident, int option, int facility); void __openlog(const char *ident, int option, int facility);
void passt_vsyslog(int pri, const char *format, va_list ap); void passt_vsyslog(int pri, const char *format, va_list ap);