Skip to content
Snippets Groups Projects
Commit 16e82636 authored by Dan Robertson's avatar Dan Robertson
Browse files

Add basic structures for netinet/in.h crate

Add the basic structures for the netinet/in.h header.
parent 01081729
No related branches found
No related tags found
No related merge requests found
...@@ -139,6 +139,14 @@ dependencies = [ ...@@ -139,6 +139,14 @@ dependencies = [
"platform 0.1.0", "platform 0.1.0",
] ]
[[package]]
name = "in_h"
version = "0.1.0"
dependencies = [
"cbindgen 0.5.2",
"platform 0.1.0",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "0.3.4" version = "0.3.4"
...@@ -182,6 +190,13 @@ dependencies = [ ...@@ -182,6 +190,13 @@ dependencies = [
"platform 0.1.0", "platform 0.1.0",
] ]
[[package]]
name = "netinet"
version = "0.1.0"
dependencies = [
"in_h 0.1.0",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.1" version = "0.2.1"
...@@ -259,6 +274,7 @@ dependencies = [ ...@@ -259,6 +274,7 @@ dependencies = [
"float 0.1.0", "float 0.1.0",
"grp 0.1.0", "grp 0.1.0",
"mman 0.1.0", "mman 0.1.0",
"netinet 0.1.0",
"platform 0.1.0", "platform 0.1.0",
"resource 0.1.0", "resource 0.1.0",
"semaphore 0.1.0", "semaphore 0.1.0",
......
...@@ -19,6 +19,7 @@ fenv = { path = "src/fenv" } ...@@ -19,6 +19,7 @@ fenv = { path = "src/fenv" }
float = { path = "src/float" } float = { path = "src/float" }
grp = { path = "src/grp" } grp = { path = "src/grp" }
mman = { path = "src/mman" } mman = { path = "src/mman" }
netinet = { path = "src/netinet" }
platform = { path = "src/platform" } platform = { path = "src/platform" }
resource = { path = "src/resource" } resource = { path = "src/resource" }
semaphore = { path = "src/semaphore" } semaphore = { path = "src/semaphore" }
......
...@@ -11,6 +11,7 @@ extern crate fenv; ...@@ -11,6 +11,7 @@ extern crate fenv;
extern crate float; extern crate float;
extern crate grp; extern crate grp;
extern crate mman; extern crate mman;
extern crate netinet;
extern crate resource; extern crate resource;
extern crate semaphore; extern crate semaphore;
extern crate socket; extern crate socket;
......
[package]
name = "netinet"
version = "0.1.0"
authors = ["Dan Robertson <danlrobertson89@gmail.com>"]
[dependencies]
in_h = { path = "in" }
[package]
name = "in_h"
version = "0.1.0"
authors = ["Dan Robertson <danlrobertson89@gmail.com>"]
build = "build.rs"
[build-dependencies]
cbindgen = { path = "../../../cbindgen" }
[dependencies]
platform = { path = "../../platform" }
socket = { path = "../../socket" }
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");
fs::create_dir_all("../../../target/include/netinet").expect("failed to create include directory");
cbindgen::generate(crate_dir)
.expect("failed to generate bindings")
.write_to_file("../../../target/include/netinet/in.h");
}
sys_includes = ["sys/types.h", "sys/socket.h"]
include_guard = "_NETINET_IN_H"
style = "Tag"
language = "C"
[export]
include = ["sockaddr_in6", "sockaddr_in", "ipv6_mreq"]
[enum]
prefix_with_name = true
#![no_std]
#![allow(non_camel_case_types)]
extern crate platform;
extern crate socket;
use platform::types::*;
use socket::sa_family_t;
pub type in_addr_t = u32;
pub type in_port_t = u16;
#[repr(C)]
#[derive(Debug)]
pub struct in_addr {
pub s_addr: in_addr_t
}
#[repr(C)]
pub struct in6_addr {
pub s6_addr: [u8; 16]
}
#[repr(C)]
pub struct sockaddr_in {
pub sa_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr
}
#[repr(C)]
pub struct sockaddr_in6 {
pub sin6_family: sa_family_t,
pub sin6_port: in_port_t,
pub sin6_flowinfo: u32,
pub sin6_addr: in6_addr,
pub sin6_scope_id: u32
}
#[repr(C)]
pub struct ipv6_mreq {
pub ipv6mr_multiaddr: in6_addr,
pub ipv6mr_interface: u32,
}
// Address String Lengths
pub const INET_ADDRSTRLEN: c_int = 16;
pub const INET6_ADDRSTRLEN: c_int = 46;
// Protocol Numbers
pub const IPPROTO_IP: u8 = 0x00;
pub const IPPROTO_ICMP: u8 = 0x01;
pub const IPPROTO_TCP: u8 = 0x06;
pub const IPPROTO_UDP: u8 = 0x11;
pub const IPPROTO_IPV6: u8 = 0x29;
pub const IPPROTO_RAW: u8 = 0xff;
pub const IPPROTO_MAX: u8 = 0xff;
#![no_std]
extern crate in_h;
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