Skip to content
Snippets Groups Projects
Commit eb2fe793 authored by jD91mZM2's avatar jD91mZM2
Browse files

Merge branch 'master' into 'master'

Updated url, implemented missing functions in header/arpa_inet/mod.rs

See merge request !161
parents 50c03f28 e688d9c4
No related branches found
No related tags found
1 merge request!161Updated url, implemented missing functions in header/arpa_inet/mod.rs
Pipeline #1226 failed
//! arpa/inet implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/arpainet.h.html //! arpa/inet implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xns/arpainet.h.html
use core::str::FromStr; use core::str::FromStr;
use core::{ptr, slice, str}; use core::{ptr, slice, str};
use header::errno::*; use header::errno::*;
use header::netinet_in::{in_addr, in_addr_t}; use header::netinet_in::{in_addr, in_addr_t, INADDR_NONE};
use header::sys_socket::constants::*; use header::sys_socket::constants::*;
use header::sys_socket::socklen_t; use header::sys_socket::socklen_t;
use platform; use platform;
...@@ -99,27 +99,62 @@ pub unsafe extern "C" fn inet_ntop( ...@@ -99,27 +99,62 @@ pub unsafe extern "C" fn inet_ntop(
} }
} }
//#[no_mangle] #[no_mangle]
pub extern "C" fn inet_addr(cp: *const c_char) -> in_addr_t { pub extern "C" fn inet_addr(cp: *const c_char) -> in_addr_t {
unimplemented!(); let mut val: in_addr = in_addr {
s_addr: 0,
};
if unsafe { inet_aton(cp, &mut val) } > 0 {
val.s_addr
} else {
INADDR_NONE
}
} }
//#[no_mangle] #[no_mangle]
pub extern "C" fn inet_lnaof(_in: in_addr) -> in_addr_t { pub extern "C" fn inet_lnaof(input: in_addr) -> in_addr_t {
unimplemented!(); if input.s_addr>>24 < 128 {
input.s_addr & 0xffffff
} else if input.s_addr>>24 < 192 {
input.s_addr & 0xffff
} else {
input.s_addr & 0xff
}
} }
//#[no_mangle] #[no_mangle]
pub extern "C" fn inet_makeaddr(net: in_addr_t, lna: in_addr_t) -> in_addr { pub extern "C" fn inet_makeaddr(net: in_addr_t, host: in_addr_t) -> in_addr {
unimplemented!(); let mut output: in_addr = in_addr {
s_addr: 0,
};
if net < 256 {
output.s_addr = host | net<<24;
} else if net < 65536 {
output.s_addr = host | net<<16;
} else {
output.s_addr = host | net<<8;
}
output
} }
//#[no_mangle] #[no_mangle]
pub extern "C" fn inet_netof(_in: in_addr) -> in_addr_t { pub extern "C" fn inet_netof(input: in_addr) -> in_addr_t {
unimplemented!(); if input.s_addr>>24 < 128 {
input.s_addr & 0xffffff
} else if input.s_addr>>24 < 192 {
input.s_addr & 0xffff
} else {
input.s_addr & 0xff
}
} }
//#[no_mangle]
pub extern "C" fn inet_network(cp: *const c_char) -> in_addr_t {
unimplemented!(); #[no_mangle]
pub extern "C" fn inet_network(cp: *mut c_char) -> in_addr_t {
ntohl(inet_addr(cp))
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment