From: Dr. Michael Lauer Date: Mon, 24 May 2021 14:50:24 +0000 (+0200) Subject: linux: Substitute linux/if.h with net/if.h X-Git-Tag: 0.53.1~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ab2b4402c7073c760b04b297e1db553e6dd1548;p=thirdparty%2Fvala.git linux: Substitute linux/if.h with net/if.h There is an age-old conflict between linux/if.h (the kernel header) and net/if.h (the userland header) that leads to compile errors due to redeclaration of certain network-related structures, see e.g. the following links: - https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/673073 - https://lists.debian.org/debian-kernel/2017/06/msg00003.html - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=824442 FWIW, it still seems to be a very current problem which I just stumbled over _again_. By now all the relevant structures should have counterparts in net/if.h, so let's try to just not include the kernel header, but use the userland header instead. --- diff --git a/vapi/linux.vapi b/vapi/linux.vapi index 49e792ea4..b6fd9efa1 100644 --- a/vapi/linux.vapi +++ b/vapi/linux.vapi @@ -1418,7 +1418,7 @@ namespace Linux { namespace Network { // interface consts, structs, and methods - [CCode (cname = "IFNAMSIZ", cheader_filename = "sys/socket.h,linux/if.h")] + [CCode (cname = "IFNAMSIZ", cheader_filename = "sys/socket.h,net/if.h")] public const int INTERFACE_NAME_SIZE; [CCode (cheader_filename = "net/if.h")] @@ -1428,7 +1428,7 @@ namespace Linux { [CCode (cheader_filename = "net/if.h")] public IfNameindex if_nameindex (); - [CCode (cname = "int", cprefix = "IFF_", has_type_id = false, cheader_filename = "sys/socket.h,linux/if.h")] + [CCode (cname = "int", cprefix = "IFF_", has_type_id = false, cheader_filename = "sys/socket.h,net/if.h")] public enum IfFlag { UP, BROADCAST, @@ -1447,13 +1447,13 @@ namespace Linux { DYNAMIC } - [CCode (cname = "struct if_nameindex", has_type_id = false, cheader_filename = "sys/socket.h,linux/if.h", destroy_function = "if_freenameindex")] + [CCode (cname = "struct if_nameindex", has_type_id = false, cheader_filename = "sys/socket.h,net/if.h", destroy_function = "if_freenameindex")] public struct IfNameindex { public uint if_index; public string if_name; } - [CCode (cname = "struct ifmap", has_type_id = false, cheader_filename = "sys/socket.h,linux/if.h", destroy_function = "")] + [CCode (cname = "struct ifmap", has_type_id = false, cheader_filename = "sys/socket.h,net/if.h", destroy_function = "")] public struct IfMap { public ulong mem_start; public ulong mem_end; @@ -1463,7 +1463,7 @@ namespace Linux { public uchar port; } - [CCode (cname = "struct ifreq", has_type_id = false, cheader_filename = "netinet/in.h,linux/if.h", destroy_function = "")] + [CCode (cname = "struct ifreq", has_type_id = false, cheader_filename = "netinet/in.h,net/if.h", destroy_function = "")] public struct IfReq { [CCode (array_length = false)] public char[] ifr_name; @@ -1484,7 +1484,7 @@ namespace Linux { public char[] ifr_newname; } - [CCode (cname = "struct ifconf", has_type_id = false, cheader_filename = "sys/socket.h,linux/if.h", destroy_function = "")] + [CCode (cname = "struct ifconf", has_type_id = false, cheader_filename = "sys/socket.h,net/if.h", destroy_function = "")] public struct IfConf { public int ifc_len; public string ifc_buf;