Merge branch 'move-conversion-functions' into 'master'
move 4 conversion functions from netinet_in to arpa_inet See merge request redox-os/relibc!1110
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# Spec quotations relating to includes:
|
||||
# - "The <arpa/inet.h> header shall define the in_port_t and in_addr_t types as described in <netinet/in.h> and the socklen_t type as defined in <sys/socket.h>."
|
||||
# - "The <arpa/inet.h> header shall define the in_addr structure as described in <netinet/in.h>."
|
||||
# - "The <arpa/inet.h> header shall define the INET_ADDRSTRLEN [IP6]  and INET6_ADDRSTRLEN  macros as described in <netinet/in.h>."
|
||||
# - "The <arpa/inet.h> header shall define the INET_ADDRSTRLEN [IP6] and INET6_ADDRSTRLEN macros as described in <netinet/in.h>."
|
||||
# - "The <arpa/inet.h> header shall define the uint32_t and uint16_t types as described in <inttypes.h>."
|
||||
# - "Inclusion of the <arpa/inet.h> header may also make visible all symbols from <netinet/in.h> and <inttypes.h>."
|
||||
#
|
||||
|
||||
@@ -12,12 +12,12 @@ use crate::{
|
||||
header::{
|
||||
bits_socklen_t::socklen_t,
|
||||
errno::{EAFNOSUPPORT, ENOSPC},
|
||||
netinet_in::{INADDR_NONE, in_addr, in_addr_t, ntohl},
|
||||
netinet_in::{INADDR_NONE, in_addr, in_addr_t},
|
||||
sys_socket::constants::AF_INET,
|
||||
},
|
||||
platform::{
|
||||
self,
|
||||
types::{c_char, c_int, c_void},
|
||||
types::{c_char, c_int, c_void, uint16_t, uint32_t},
|
||||
},
|
||||
raw_cell::RawCell,
|
||||
};
|
||||
@@ -231,3 +231,27 @@ pub unsafe extern "C" fn inet_pton(af: c_int, src: *const c_char, dst: *mut c_vo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/htonl.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htonl(hostlong: uint32_t) -> uint32_t {
|
||||
hostlong.to_be()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/htonl.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htons(hostshort: uint16_t) -> uint16_t {
|
||||
hostshort.to_be()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/htonl.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn ntohl(netlong: uint32_t) -> uint32_t {
|
||||
u32::from_be(netlong)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/htonl.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn ntohs(netshort: uint16_t) -> uint16_t {
|
||||
u16::from_be(netshort)
|
||||
}
|
||||
|
||||
@@ -10,10 +10,11 @@ use crate::{
|
||||
};
|
||||
|
||||
use crate::header::{
|
||||
arpa_inet::htons,
|
||||
bits_socklen_t::socklen_t,
|
||||
bits_time::timespec,
|
||||
errno::*,
|
||||
netinet_in::{IPPROTO_UDP, htons, in_addr, sockaddr_in},
|
||||
netinet_in::{IPPROTO_UDP, in_addr, sockaddr_in},
|
||||
sys_socket::{
|
||||
self,
|
||||
constants::{AF_INET, SOCK_DGRAM},
|
||||
|
||||
@@ -12,11 +12,11 @@ use crate::{
|
||||
c_str::{CStr, CString},
|
||||
error::ResultExt,
|
||||
header::{
|
||||
arpa_inet::inet_aton,
|
||||
arpa_inet::{htons, inet_aton, ntohl},
|
||||
bits_socklen_t::socklen_t,
|
||||
errno::*,
|
||||
fcntl::O_RDONLY,
|
||||
netinet_in::{htons, in_addr, ntohl, sockaddr_in, sockaddr_in6},
|
||||
netinet_in::{in_addr, sockaddr_in, sockaddr_in6},
|
||||
stdlib::atoi,
|
||||
strings::strcasecmp,
|
||||
sys_socket::{constants::AF_INET, sa_family_t, sockaddr},
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use crate::{
|
||||
header::sys_socket::{sa_family_t, sockaddr_storage},
|
||||
platform::types::{c_char, c_int, uint16_t, uint32_t},
|
||||
platform::types::{c_char, c_int},
|
||||
};
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/netinet_in.h.html>.
|
||||
@@ -175,27 +175,3 @@ pub static in6addr_any: in6_addr = in6_addr {
|
||||
pub static in6addr_loopback: in6_addr = in6_addr {
|
||||
s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
|
||||
};
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/htonl.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htonl(hostlong: uint32_t) -> uint32_t {
|
||||
hostlong.to_be()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/htonl.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn htons(hostshort: uint16_t) -> uint16_t {
|
||||
hostshort.to_be()
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/htonl.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn ntohl(netlong: uint32_t) -> uint32_t {
|
||||
u32::from_be(netlong)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/htonl.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn ntohs(netshort: uint16_t) -> uint16_t {
|
||||
u16::from_be(netshort)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user