forked from meh/rust-tun
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v3' of https://github.com/xmh0511/rust-tun into v3
- Loading branch information
Showing
13 changed files
with
299 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
// Version 2, December 2004 | ||
// | ||
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co | ||
// | ||
// Everyone is permitted to copy and distribute verbatim or modified | ||
// copies of this license document, and changing it is allowed as long | ||
// as the name is changed. | ||
// | ||
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
// | ||
// 0. You just DO WHAT THE FUCK YOU WANT TO. | ||
|
||
//! Linux specific functionality. | ||
|
||
pub mod sys; | ||
|
||
mod device; | ||
pub use self::device::Device; | ||
|
||
use crate::configuration::Configuration; | ||
use crate::error::Result; | ||
|
||
/// FreeBSD-only interface configuration. | ||
#[derive(Copy, Clone, Default, Debug)] | ||
pub struct PlatformConfig; | ||
|
||
use super::Device as DeviceWrapper; | ||
/// Create a TUN device with the given name. | ||
pub fn create(configuration: &Configuration) -> Result<DeviceWrapper> { | ||
Ok(DeviceWrapper(Device::new(configuration)?)) | ||
} | ||
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
// Version 2, December 2004 | ||
// | ||
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co | ||
// | ||
// Everyone is permitted to copy and distribute verbatim or modified | ||
// copies of this license document, and changing it is allowed as long | ||
// as the name is changed. | ||
// | ||
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
// | ||
// 0. You just DO WHAT THE FUCK YOU WANT TO. | ||
|
||
//! Linux specific functionality. | ||
|
||
pub mod sys; | ||
|
||
mod device; | ||
|
||
pub use self::device::Device; | ||
use std::os::fd::{FromRawFd, RawFd}; | ||
|
||
use crate::configuration::Configuration; | ||
use crate::error::Result; | ||
|
||
/// FreeBSD-only interface configuration. | ||
#[derive(Copy, Clone, Default, Debug)] | ||
pub struct PlatformConfig; | ||
|
||
use super::Device as DeviceWrapper; | ||
/// Create a TUN device with the given name. | ||
pub fn create(configuration: &Configuration) -> Result<DeviceWrapper> { | ||
Ok(DeviceWrapper(Device::new(configuration)?)) | ||
} | ||
/// # Safety | ||
/// The fd passed in must be an owned file descriptor; in particular, it must be open. | ||
pub unsafe fn create_with_fd(fd: RawFd) -> Result<DeviceWrapper> { | ||
Ok(DeviceWrapper(Device::from_raw_fd(fd))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.