Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DragonFlyBSD #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions ioctl_list/src/main.cc
Expand Up @@ -15,6 +15,9 @@

#ifdef HAVE_NET_IF_H
# include <net/if.h>
#ifdef __DragonFly__
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason to use this macro instead of using AC_CHECK_HEADERS() in configure.ac?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno how to correctly do that with AC_CHECK_HEADERS, as it only needs to be included on DragonFly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mneumann That's what autoconf takes care of. The autoconf philosophy is to test for features instead of platforms:

they do not normally even need an argument specifying the system type. Instead, they individually test for the presence of each feature that the software package they are for might need

https://www.gnu.org/software/autoconf/manual/autoconf-2.62/html_node/Introduction.html#Introduction

If you're interested, I made some commits on top of your branch that do this with AC_CHECK_HEADERS: https://github.com/dcuddeback/ioctl-rs/compare/feature/dragonfly?expand=1#diff-ecc1a87332cffa717e3a14c626ae27cbL28

# include <net/route.h>
#endif
#endif

#ifdef HAVE_TERMIOS_H
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Expand Up @@ -15,6 +15,9 @@ pub use os::macos::*;
#[cfg(target_os = "freebsd")]
pub use os::freebsd::*;

#[cfg(target_os = "dragonfly")]
pub use os::dragonfly::*;

#[cfg(target_os = "openbsd")]
pub use os::openbsd::*;

Expand Down
74 changes: 74 additions & 0 deletions src/os/dragonfly.rs
@@ -0,0 +1,74 @@
use libc::{c_int,c_ulong};

// socket

pub const FIOSETOWN: c_ulong = 0x8004667c;
pub const SIOCSPGRP: c_ulong = 0x80047308;
pub const FIOGETOWN: c_ulong = 0x4004667b;
pub const SIOCGPGRP: c_ulong = 0x40047309;

// termios

pub const TIOCEXCL: c_ulong = 0x2000740d;
pub const TIOCNXCL: c_ulong = 0x2000740e;
pub const TIOCSCTTY: c_ulong = 0x20007461;
pub const TIOCGPGRP: c_ulong = 0x40047477;
pub const TIOCSPGRP: c_ulong = 0x80047476;
pub const TIOCOUTQ: c_ulong = 0x40047473;
pub const TIOCSTI: c_ulong = 0x80017472;
pub const TIOCGWINSZ: c_ulong = 0x40087468;
pub const TIOCSWINSZ: c_ulong = 0x80087467;
pub const TIOCMGET: c_ulong = 0x4004746a;
pub const TIOCMBIS: c_ulong = 0x8004746c;
pub const TIOCMBIC: c_ulong = 0x8004746b;
pub const TIOCMSET: c_ulong = 0x8004746d;
pub const FIONREAD: c_ulong = 0x4004667f;
pub const TIOCCONS: c_ulong = 0x80047462;
pub const TIOCPKT: c_ulong = 0x80047470;
pub const FIONBIO: c_ulong = 0x8004667e;
pub const TIOCNOTTY: c_ulong = 0x20007471;
pub const TIOCSETD: c_ulong = 0x8004741b;
pub const TIOCGETD: c_ulong = 0x4004741a;
pub const FIONCLEX: c_ulong = 0x20006602;
pub const FIOCLEX: c_ulong = 0x20006601;
pub const FIOASYNC: c_ulong = 0x8004667d;

// sockios

pub const SIOCADDRT: c_ulong = 0x8040720a;
pub const SIOCDELRT: c_ulong = 0x8040720b;
pub const SIOCGIFCONF: c_ulong = 0xc0106924;
pub const SIOCGIFFLAGS: c_ulong = 0xc0206911;
pub const SIOCSIFFLAGS: c_ulong = 0x80206910;
pub const SIOCGIFADDR: c_ulong = 0xc0206921;
pub const SIOCSIFADDR: c_ulong = 0x8020690c;
pub const SIOCGIFDSTADDR: c_ulong = 0xc0206922;
pub const SIOCSIFDSTADDR: c_ulong = 0x8020690e;
pub const SIOCGIFBRDADDR: c_ulong = 0xc0206923;
pub const SIOCSIFBRDADDR: c_ulong = 0x80206913;
pub const SIOCGIFNETMASK: c_ulong = 0xc0206925;
pub const SIOCSIFNETMASK: c_ulong = 0x80206916;
pub const SIOCGIFMETRIC: c_ulong = 0xc0206917;
pub const SIOCSIFMETRIC: c_ulong = 0x80206918;
pub const SIOCGIFMTU: c_ulong = 0xc0206933;
pub const SIOCSIFMTU: c_ulong = 0x80206934;
pub const SIOCADDMULTI: c_ulong = 0x80206931;
pub const SIOCDELMULTI: c_ulong = 0x80206932;

// modem control lines

pub const TIOCM_LE: c_int = 0x00000001;
pub const TIOCM_DTR: c_int = 0x00000002;
pub const TIOCM_RTS: c_int = 0x00000004;
pub const TIOCM_ST: c_int = 0x00000008;
pub const TIOCM_SR: c_int = 0x00000010;
pub const TIOCM_CTS: c_int = 0x00000020;
pub const TIOCM_CAR: c_int = 0x00000040;
pub const TIOCM_CD: c_int = 0x00000040;
pub const TIOCM_RNG: c_int = 0x00000080;
pub const TIOCM_RI: c_int = 0x00000080;
pub const TIOCM_DSR: c_int = 0x00000100;

extern "C" {
pub fn ioctl(fildes: c_int, request: c_ulong, ...) -> c_int;
}
3 changes: 3 additions & 0 deletions src/os/mod.rs
Expand Up @@ -7,5 +7,8 @@ pub mod macos;
#[cfg(target_os = "freebsd")]
pub mod freebsd;

#[cfg(target_os = "dragonfly")]
pub mod dragonfly;

#[cfg(target_os = "openbsd")]
pub mod openbsd;