1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use std::net::Ipv4Addr;

use crate::errors;

#[derive(Debug)]
pub enum Protocol {
    PPPoE,
    PPPoA,
}

impl std::convert::TryFrom<String> for Protocol {
    type Error = errors::Error;

    fn try_from(value: String) -> Result<Self, Self::Error> {
        match value.as_ref() {
            "PPPoE" => Ok(Self::PPPoE),
            "PPPoA" => Ok(Self::PPPoA),
            _ => Err(errors::Error::InvalidValue(value)),
        }
    }
}
#[derive(Debug)]
pub struct GatewayInfo {
    pub model: String,
    pub serial_number: String,
    pub hardware_version: String,
    pub software_version: String,
}
#[derive(Debug)]
pub struct ConnectionInfo {
    //pub profilo_tariffario: String,
    //pub mode: String,
    pub protocol: Protocol,
    //pub connection_mode: String,
    pub ip_address: Ipv4Addr,
    //telegestione
    //connessione automatica da modem
    pub primary_dns: Option<Ipv4Addr>,
    pub secondary_dns: Option<Ipv4Addr>,
    pub other_dns: Vec<Ipv4Addr>,
}

#[derive(Debug)]
pub enum Encapsulation {
    ATM,
}

impl std::convert::TryFrom<&str> for Encapsulation {
    type Error = errors::Error;

    fn try_from(v: &str) -> Result<Self, Self::Error> {
        match v {
            "ATM" => Ok(Self::ATM),
            _ => Err(Self::Error::InvalidValue(v.to_owned())),
        }
    }
}

#[derive(Debug)]
pub struct TxRx<T>
where
    T: std::ops::Add,
{
    pub tx: T,
    pub rx: T,
}

#[derive(Debug)]
pub struct LineInfo {
    pub max_speed: TxRx<u32>,
    pub dsl_driver_version: String,
    pub encapsulation: Encapsulation,
    pub power: TxRx<f64>,
    pub snr: TxRx<f64>,
    pub speed: TxRx<u32>,
    pub ses: u64,
    pub uptime: u64,
    pub inp: u8,
    pub attenuation: TxRx<f64>,
}