netstack-lwip's People
Forkers
dumpmemory worstass ytflow watfaq bingyunxl vvhh2002 teoncom taiwanspring edsburke tladesignz yewenyu liuxc0116 sllt icodein ccddee1228 sail-tunnel jvimal-eg afula linguohua xutianyi1999 sun00108 netconndev spongebob888 jiayang007 scannme youcaihuaf paulzql mokhtarabadi archerst awrheaven chen2ding roasternetwork songxiaoxi lemos1235 imorteza legndbugartist zhouzunetstack-lwip's Issues
考虑Pin<Box<UdpSocket>>结构替代Box<UdpSocket>
用Pin将UdpSocket固定,保证其不会被move
请问如何使用tcp客户端连接到协议栈
發佈了個 lwip 倉庫到 crates.io
Hi @eycorsican
我將你的代碼複製了一遍,然後發佈到 crates.io 去了, 並未加以測試, 未經真機檢驗。如果你不嫌麻煩,我希望將你添加成 合作貢獻者 和 發佈者。
意下如何?
這個發佈版的原則是,不改動上游原始代碼,方便直接合併上游,如果發現bug 或需要添加功能,則直接聯繫上游開發者。以保持代碼一致性。
https://github.com/ssrlive/lwip/tree/rust
其他走過路過的朋友,也一併歡迎。
ios compile failed, see here.
如果 iOS 编译失败,请将这个库的 build.rs 改成下面的代码,直接复制黏贴即可,
修改完成后可以用 BINDINGS_GEN=1 cargo build --target=x86_64-apple-ios -vv
脚本编译试试。
use std::{
env,
path::{Path, PathBuf},
process::Command,
};
fn sdk_include_path_for(sdk: &str) -> String {
// sdk path find by `xcrun --sdk {iphoneos|macosx} --show-sdk-path`
let output = Command::new("xcrun")
.arg("--sdk")
.arg(sdk)
.arg("--show-sdk-path")
.output()
.expect("failed to execute xcrun");
let inc_path = Path::new(String::from_utf8_lossy(&output.stdout).trim()).join("usr/include");
inc_path.to_str().expect("invalid include path").to_string()
}
fn sdk_include_path() -> Option<String> {
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
match os.as_str() {
"ios" => Some(sdk_include_path_for("iphoneos")),
"macos" => Some(sdk_include_path_for("macosx")),
_ => None,
}
}
fn compile_lwip() {
println!("cargo:rerun-if-changed=src/lwip");
let mut build = cc::Build::new();
build
.file("src/lwip/core/init.c")
.file("src/lwip/core/def.c")
// .file("src/lwip/core/dns.c")
.file("src/lwip/core/inet_chksum.c")
.file("src/lwip/core/ip.c")
.file("src/lwip/core/mem.c")
.file("src/lwip/core/memp.c")
.file("src/lwip/core/netif.c")
.file("src/lwip/core/pbuf.c")
.file("src/lwip/core/raw.c")
// .file("src/lwip/core/stats.c")
// .file("src/lwip/core/sys.c")
.file("src/lwip/core/tcp.c")
.file("src/lwip/core/tcp_in.c")
.file("src/lwip/core/tcp_out.c")
.file("src/lwip/core/timeouts.c")
.file("src/lwip/core/udp.c")
// .file("src/lwip/core/ipv4/autoip.c")
// .file("src/lwip/core/ipv4/dhcp.c")
// .file("src/lwip/core/ipv4/etharp.c")
.file("src/lwip/core/ipv4/icmp.c")
// .file("src/lwip/core/ipv4/igmp.c")
.file("src/lwip/core/ipv4/ip4_frag.c")
.file("src/lwip/core/ipv4/ip4.c")
.file("src/lwip/core/ipv4/ip4_addr.c")
// .file("src/lwip/core/ipv6/dhcp6.c")
// .file("src/lwip/core/ipv6/ethip6.c")
.file("src/lwip/core/ipv6/icmp6.c")
// .file("src/lwip/core/ipv6/inet6.c")
.file("src/lwip/core/ipv6/ip6.c")
.file("src/lwip/core/ipv6/ip6_addr.c")
.file("src/lwip/core/ipv6/ip6_frag.c")
// .file("src/lwip/core/ipv6/mld6.c")
.file("src/lwip/core/ipv6/nd6.c")
.file("src/lwip/custom/sys_arch.c")
.include("src/lwip/custom")
.include("src/lwip/include")
.warnings(false)
.flag_if_supported("-Wno-everything");
// ios not need below include path
// if let Some(sdk_include_path) = sdk_include_path() {
// build.include(sdk_include_path);
// }
build.compile("liblwip.a");
}
fn generate_lwip_bindings() {
println!("cargo:rustc-link-lib=lwip");
// println!("cargo:rerun-if-changed=src/wrapper.h");
println!("cargo:include=src/lwip/include");
let sdk_include_path = sdk_include_path();
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let mut builder = bindgen::Builder::default()
.header("src/wrapper.h")
.clang_arg("-I./src/lwip/include")
.clang_arg("-I./src/lwip/custom")
.clang_arg("-Wno-everything")
.layout_tests(false)
.parse_callbacks(Box::new(bindgen::CargoCallbacks));
if arch == "aarch64" && os == "ios" {
// https://github.com/rust-lang/rust-bindgen/issues/1211
builder = builder.clang_arg("--target=arm64-apple-ios");
}
if let Some(sdk_include_path) = sdk_include_path {
builder = builder.clang_arg(format!("-I {}", sdk_include_path)); // this place need a space between -I and {}
}
let bindings = builder.generate().expect("Unable to generate bindings");
let mut out_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
out_path = out_path.join("src");
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}
fn main() {
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
if os == "ios" || os == "android" || os == "linux" || os == "macos" {
compile_lwip();
}
if env::var("BINDINGS_GEN").is_ok()
&& (os == "ios" || os == "android" || os == "linux" || os == "macos")
{
generate_lwip_bindings();
}
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.