]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
linux: Substitute linux/if.h with net/if.h
authorDr. Michael Lauer <mickey@vanille-media.de>
Mon, 24 May 2021 14:50:24 +0000 (16:50 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 19 Jul 2021 11:52:41 +0000 (13:52 +0200)
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.

vapi/linux.vapi

index 37441b0faf5f1c4889a2ab393fca35daea458870..a09b6423aae78cc3e5679412fe0d22f9ff7c3a3e 100644 (file)
@@ -1302,7 +1302,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")]
@@ -1312,7 +1312,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,
@@ -1331,13 +1331,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;
@@ -1347,7 +1347,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;
@@ -1368,7 +1368,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;