Fix a few things with openssl

This commit is contained in:
jD91mZM2
2018-07-25 14:04:36 +02:00
parent 0e48937991
commit 992e50ef0f
9 changed files with 75 additions and 14 deletions
Generated
+10
View File
@@ -322,6 +322,7 @@ dependencies = [
"sys_socket 0.1.0",
"sys_stat 0.1.0",
"sys_time 0.1.0",
"sys_un 0.1.0",
"sys_utsname 0.1.0",
"sys_wait 0.1.0",
"time 0.1.0",
@@ -533,6 +534,15 @@ dependencies = [
"platform 0.1.0",
]
[[package]]
name = "sys_un"
version = "0.1.0"
dependencies = [
"cbindgen 0.5.2",
"platform 0.1.0",
"sys_socket 0.1.0",
]
[[package]]
name = "sys_utsname"
version = "0.1.0"
+2 -1
View File
@@ -25,8 +25,8 @@ inttypes = { path = "src/inttypes" }
locale = { path = "src/locale" }
netinet = { path = "src/netinet" }
platform = { path = "src/platform" }
setjmp = { path = "src/setjmp" }
semaphore = { path = "src/semaphore" }
setjmp = { path = "src/setjmp" }
signal = { path = "src/signal" }
stdio = { path = "src/stdio" }
stdlib = { path = "src/stdlib" }
@@ -37,6 +37,7 @@ sys_resource = { path = "src/sys_resource" }
sys_socket = { path = "src/sys_socket" }
sys_stat = { path = "src/sys_stat" }
sys_time = { path = "src/sys_time" }
sys_un = { path = "src/sys_un" }
sys_utsname = { path = "src/sys_utsname" }
sys_wait = { path = "src/sys_wait" }
time = { path = "src/time" }
+1
View File
@@ -27,6 +27,7 @@ pub extern crate sys_resource;
pub extern crate sys_socket;
pub extern crate sys_stat;
pub extern crate sys_time;
pub extern crate sys_un;
pub extern crate sys_utsname;
pub extern crate sys_wait;
pub extern crate time;
+13 -3
View File
@@ -6,13 +6,13 @@ extern crate platform;
extern crate sys_socket;
use platform::types::*;
use sys_socket::sa_family_t;
use sys_socket::{sa_family_t, sockaddr};
pub type in_addr_t = u32;
pub type in_port_t = u16;
#[repr(C)]
#[derive(Debug)]
#[derive(Debug, Clone, Copy)]
pub struct in_addr {
pub s_addr: in_addr_t
}
@@ -24,7 +24,7 @@ pub struct in6_addr {
#[repr(C)]
pub struct sockaddr_in {
pub sa_family: sa_family_t,
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr
}
@@ -56,3 +56,13 @@ pub const IPPROTO_UDP: u8 = 0x11;
pub const IPPROTO_IPV6: u8 = 0x29;
pub const IPPROTO_RAW: u8 = 0xff;
pub const IPPROTO_MAX: u8 = 0xff;
pub const INADDR_ANY: u32 = 0; // Can't use in_addr_t alias because cbindgen :(
pub const INADDR_BROADCAST: u32 = 0xFFFFFFFF; // Can't use core::u32::MAX because cbindgen :(
pub const INADDR_NONE: u32 = 0xFFFFFFFF;
pub const INADDR_LOOPBACK: u32 = 0x7F000001;
pub const INADDR_UNSPEC_GROUP: u32 = 0xE0000000;
pub const INADDR_ALLHOSTS_GROUP: u32 = 0xE0000001;
pub const INADDR_ALLRTRS_GROUP: u32 = 0xE0000002;
pub const INADDR_MAX_LOCAL_GROUP: u32 = 0xE00000FF;
+3 -10
View File
@@ -21,13 +21,6 @@ extern "C" fn sig_handler(sig: usize) {
}
}
#[repr(C)]
struct SockData {
port: in_port_t,
addr: in_addr_t,
_pad: [c_char; 8],
}
fn e(sys: Result<usize>) -> usize {
match sys {
Ok(ok) => ok,
@@ -56,9 +49,9 @@ macro_rules! bind_or_connect {
errno = syscall::EINVAL;
return -1;
}
let data: &SockData = mem::transmute(&(*$address).data);
let addr = &data.addr;
let port = in_port_t::from_be(data.port); // This is transmuted from bytes in BigEndian order
let data = &*($address as *const sockaddr_in);
let addr = &data.sin_addr.s_addr;
let port = in_port_t::from_be(data.sin_port); // This is transmuted from bytes in BigEndian order
let path = format!(bind_or_connect!($mode "{}.{}.{}.{}:{}"), addr[0], addr[1], addr[2], addr[3], port);
// Duplicate the socket, and then duplicate the copy back to the original fd
+12
View File
@@ -0,0 +1,12 @@
[package]
name = "sys_un"
version = "0.1.0"
authors = ["jD91mZM2 <me@krake.one>"]
build = "build.rs"
[build-dependencies]
cbindgen = { path = "../../cbindgen" }
[dependencies]
platform = { path = "../platform" }
sys_socket = { path = "../sys_socket" }
+11
View File
@@ -0,0 +1,11 @@
extern crate cbindgen;
use std::{env, fs};
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
fs::create_dir_all("../../target/include").expect("failed to create include directory");
cbindgen::generate(crate_dir)
.expect("failed to generate bindings")
.write_to_file("../../target/include/sys/un.h");
}
+10
View File
@@ -0,0 +1,10 @@
sys_includes = ["sys/socket.h"]
include_guard = "_SYS_UN_H"
language = "C"
style = "Tag"
[export]
include = ["sockaddr_un"]
[enum]
prefix_with_name = true
+13
View File
@@ -0,0 +1,13 @@
#![no_std]
extern crate platform;
extern crate sys_socket;
use platform::types::*;
use sys_socket::sa_family_t;
#[repr(C)]
pub struct sockaddr_un {
sun_family: sa_family_t,
sun_path: [c_char; 108]
}