Skip to content

Commit

Permalink
Rename packages to knet-bindings & nozzle-bindings
Browse files Browse the repository at this point in the history
Also fix ACL bug in the test. Well, work around it - it seems
that having a static & dynamic UDP link to the same host
doesn't really work well if one has ACLs
  • Loading branch information
chrissie-c committed Jun 21, 2021
1 parent fbd7ed1 commit 5e3bf4e
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion libknet/bindings/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This software licensed under LGPL-2.1+

[package]
name = "kronosnet"
name = "knet-bindings"
version = "0.1.0"
authors = ["Christine Caulfield <ccaulfie@redhat.com>"]
edition = "2018"
Expand Down
4 changes: 2 additions & 2 deletions libknet/bindings/rust/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ EXTRA_DIST = \
README

RUST_SHIP_SRCS = \
src/libknet.rs \
src/knet_bindings.rs \
src/lib.rs \
src/sys/mod.rs

Expand All @@ -29,6 +29,6 @@ RUST_BUILT_SRCS = \
src/sys/libknet.rs: ../../libknet.h
$(top_srcdir)/build-aux/rust-regen.sh $^ $@ KNET

all-local: cargo-tree-prep target/$(RUST_TARGET_DIR)/libkronosnet.rlib
all-local: cargo-tree-prep target/$(RUST_TARGET_DIR)/knet_bindings.rlib

clean-local: cargo-clean
File renamed without changes.
9 changes: 4 additions & 5 deletions libknet/bindings/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
// This software licensed under LGPL-2.0+
//

//! This crate provides access to the kronosnet libknet
//! This crate provides access to the kronosnet library 'libknet'
//! from Rust. They are a fairly thin layer around the actual API calls but with Rust data types
//! and iterators.
//!
//! No more information about knet itself will be provided here, it is expected that if
//! you feel you need access to the knet API calls, you know what they do :)
//!
//! # Example
//! extern crate rust_kronosnet as kronosnet;
//! use kronosnet::libknet as knet;
//! use std::net::{SocketAddr, IpAddr,Ipv4Addr};
//! use knet_bindings::knet_bindings as knet;
//! use std::net::{SocketAddr, IpAddr, Ipv4Addr};
//! use std::thread::spawn;
//! use std::sync::mpsc::Receiver;
//! use std::sync::mpsc::channel;
Expand Down Expand Up @@ -72,7 +71,7 @@


mod sys;
pub mod libknet;
pub mod knet_bindings;

#[macro_use]
extern crate lazy_static;
Expand Down
4 changes: 2 additions & 2 deletions libknet/bindings/rust/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This software licensed under GPL-2.0+

[package]
name = "rust-kronosnet-tests"
name = "knet-bindings-tests"
version = "0.1.0"
authors = ["Christine Caulfield <ccaulfie@redhat.com>"]
edition = "2018"
Expand All @@ -14,7 +14,7 @@ edition = "2018"
cc = "1.0"

[dependencies]
kronosnet = { path = ".." }
knet-bindings = { path = ".." }
libc = "0.2.97"

[[bin]]
Expand Down
17 changes: 7 additions & 10 deletions libknet/bindings/rust/tests/src/bin/knet-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// Author: Christine Caulfield (ccaulfi@redhat.com)
//

use kronosnet::libknet as knet;
use std::net::{SocketAddr, IpAddr,Ipv4Addr};
use knet_bindings::knet_bindings as knet;
use std::net::{SocketAddr, IpAddr, Ipv4Addr};
use std::thread::spawn;
use std::sync::mpsc::Receiver;
use std::sync::mpsc::channel;
Expand Down Expand Up @@ -302,8 +302,6 @@ fn configure_link(knet_handle: knet::Handle, our_hostid: &knet::HostId, other_ho
}
}



match knet::link_get_enable(knet_handle, other_hostid, 0) {
Ok(b) => if !b {
println!("link not enabled (according to link_get_enable()");
Expand Down Expand Up @@ -751,22 +749,22 @@ fn test_acl(handle: knet::Handle, host: &knet::HostId) -> Result<()>
if let Err(e) = knet::link_add_acl(handle, host, 1,
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8003_u16),
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8003_u16),
knet::AclCheckType::Address, knet::AclAcceptReject::Accept) {
knet::AclCheckType::Address, knet::AclAcceptReject::Reject) {
println!("Error from link_add_acl: {:?}", e);
return Err(e);
}
if let Err(e) = knet::link_insert_acl(handle, host, 1,
0,
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)), 8003_u16),
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)), 8003_u16),
knet::AclCheckType::Address, knet::AclAcceptReject::Accept) {
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)), 8004_u16),
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)), 8004_u16),
knet::AclCheckType::Address, knet::AclAcceptReject::Reject) {
println!("Error from link_add_acl: {:?}", e);
return Err(e);
}
if let Err(e) = knet::link_rm_acl(handle, host, 1,
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8003_u16),
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8003_u16),
knet::AclCheckType::Address, knet::AclAcceptReject::Accept) {
knet::AclCheckType::Address, knet::AclAcceptReject::Reject) {
println!("Error from link_rm_acl: {:?}", e);
return Err(e);
}
Expand All @@ -781,7 +779,6 @@ fn test_acl(handle: knet::Handle, host: &knet::HostId) -> Result<()>
return Err(e);
}


Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion libknet/tests/api-test-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ deliberately_missing="knet_strtoaddr knet_addrtostr knet_get_transport_name_by_i
rustapicalls=$numapicalls
for i in $headerapicalls; do
rustcall=`echo $i|awk '{print substr($0, 6)}'`
grep "^pub fn ${rustcall}(" $1/libknet/bindings/rust/src/libknet.rs > /dev/null 2>/dev/null
grep "^pub fn ${rustcall}(" $1/libknet/bindings/rust/src/knet_bindings.rs > /dev/null 2>/dev/null
if [ $? = 0 ]
then
rust_found=$((rust_found+1))
Expand Down
2 changes: 1 addition & 1 deletion libnozzle/bindings/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This software licensed under LGPL-2.1+

[package]
name = "nozzle"
name = "nozzle-bindings"
version = "0.1.0"
authors = ["Christine Caulfield <ccaulfie@redhat.com>"]
edition = "2018"
Expand Down
4 changes: 2 additions & 2 deletions libnozzle/bindings/rust/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ EXTRA_DIST = \
README

RUST_SHIP_SRCS = \
src/libnozzle.rs \
src/nozzle_bindings.rs \
src/lib.rs \
src/sys/mod.rs

Expand All @@ -29,6 +29,6 @@ RUST_BUILT_SRCS = \
src/sys/libnozzle.rs: ../../libnozzle.h
$(top_srcdir)/build-aux/rust-regen.sh $^ $@ NOZZLE

all-local: cargo-tree-prep target/$(RUST_TARGET_DIR)/libnozzle.rlib
all-local: cargo-tree-prep target/$(RUST_TARGET_DIR)/nozzle_bindings.rlib

clean-local: cargo-clean
5 changes: 2 additions & 3 deletions libnozzle/bindings/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
//! you feel you need access to the knet API calls, you know what they do :)
//!
//! # Example
//! extern crate rust_kronosnet as kronosnet;
//! use kronosnet::libnozzle as nozzle;
//! use nozzle_bindings::nozzle_bindings as nozzle;
//! use std::io::{Result};
//! use std::env;
//! use std::{thread, time};
Expand Down Expand Up @@ -48,7 +47,7 @@


mod sys;
pub mod libnozzle;
pub mod nozzle_bindings;

use std::os::raw::c_char;
use std::ptr::copy_nonoverlapping;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions libnozzle/bindings/rust/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
# This software licensed under GPL-2.0+

[package]
name = "rust-kronosnet-tests"
name = "nozzle-bindings-tests"
version = "0.1.0"
authors = ["Christine Caulfield <ccaulfie@redhat.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
nozzle = { path = ".." }
nozzle-bindings = { path = ".." }
libc = "0.2.93"
tempfile = "3"

Expand Down
2 changes: 1 addition & 1 deletion libnozzle/bindings/rust/tests/src/bin/nozzle-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Author: Christine Caulfield (ccaulfi@redhat.com)
//

use nozzle::libnozzle as nozzle;
use nozzle_bindings::nozzle_bindings as nozzle;
use std::io::{Result, Error, ErrorKind, BufWriter, Write};
use std::fmt::Write as fmtwrite;
use std::{thread, time};
Expand Down
2 changes: 1 addition & 1 deletion libnozzle/tests/api-test-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ deliberately_missing=""
rustapicalls=$numapicalls
for i in $headerapicalls; do
rustcall=`echo $i|awk '{print substr($0, 8)}'`
grep "^pub fn ${rustcall}(" $1/libnozzle/bindings/rust/src/libnozzle.rs > /dev/null 2>/dev/null
grep "^pub fn ${rustcall}(" $1/libnozzle/bindings/rust/src/nozzle_bindings.rs > /dev/null 2>/dev/null
if [ $? = 0 ]
then
rust_found=$((rust_found+1))
Expand Down

0 comments on commit 5e3bf4e

Please sign in to comment.