Skip to main content

PppUnit

Struct PppUnit 

Source
pub struct PppUnit { /* private fields */ }
Expand description

A PPP network interface (pppN) created through /dev/ppp.

The interface exists while this value is alive. Connect a PPP channel to it with connect_channel; PPP control frames are then read from and written to the unit descriptor, while configured network protocols flow through the interface.

Implementations§

Source§

impl PppUnit

Source

pub fn new() -> Result<Self>

Creates a PPP unit with a kernel-chosen index.

Source

pub fn with_index(index: i32) -> Result<Self>

Creates the PPP unit with the given index, failing with EEXIST when it is taken.

Source

pub fn index(&self) -> i32

Returns the unit index, N of pppN.

Source

pub fn ifname(&self) -> &L2tpIfName

Returns the interface name, pppN.

Source

pub fn connect_channel(&self, socket: &PppSocket) -> Result<PppChannel>

Connects a PPP channel to this unit (PPPIOCATTCHAN followed by PPPIOCCONNECT).

The returned PppChannel must stay alive for as long as the channel should remain connected to the unit.

The unit and socket must belong to the same network namespace; otherwise this returns Error::NamespaceMismatch. Attachment runs in that namespace. Calling this from another namespace requires CAP_SYS_ADMIN to enter the owning namespace on a temporary thread; the calling thread is never moved.

Trait Implementations§

Source§

impl AsFd for PppUnit

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
Source§

impl AsRawFd for PppUnit

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl Debug for PppUnit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.