feat: added static linking against libnl

libnl will be used to help understand kernel routing tables
This commit is contained in:
Andrew Rioux
2023-04-30 23:04:53 -04:00
parent 9ebf4b931b
commit 2fc1916273
9 changed files with 68 additions and 17 deletions

View File

@@ -6,4 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = "0.2.142"
libc = "0.2.142"
[build-dependencies]
autotools = "0.2"

24
nl-sys/build.rs Normal file
View File

@@ -0,0 +1,24 @@
// Copyright (C) 2023 Andrew Rioux
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
fn main() {
let dst = autotools::Config::new("libnl")
.reconf("-vi")
.build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
println!("cargo:rustc-link-lib=static=nl-3");
println!("cargo:rustc-link-lib=static=nl-route-3");
}

1
nl-sys/libnl Submodule

Submodule nl-sys/libnl added at cbafad9ddf

View File

@@ -1,14 +0,0 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

24
nl-sys/src/main.rs Normal file
View File

@@ -0,0 +1,24 @@
// Copyright (C) 2023 Andrew Rioux
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
enum nl_sock {}
extern {
fn nl_socket_alloc() -> nl_sock;
}
fn main() {
unsafe { nl_socket_alloc(); }
}