-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c79d1bf
commit 8e1ca66
Showing
7 changed files
with
386 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use super::MacAddr; | ||
use crate::{schema::ipv4_nat_entry, SqlU16, SqlU32, Vni}; | ||
use chrono::{DateTime, Utc}; | ||
use uuid::Uuid; | ||
|
||
/// Database representation of an Ipv4 NAT Entry. | ||
#[derive(Insertable, Debug, Clone)] | ||
#[diesel(table_name = ipv4_nat_entry)] | ||
pub struct NewIpv4NatEntry { | ||
pub id: Uuid, | ||
pub external_address: ipnetwork::IpNetwork, | ||
pub first_port: SqlU16, | ||
pub last_port: SqlU16, | ||
pub sled_address: ipnetwork::IpNetwork, | ||
pub vni: Vni, | ||
pub mac: MacAddr, | ||
} | ||
|
||
#[derive(Queryable, Debug, Clone, Selectable)] | ||
#[diesel(table_name = ipv4_nat_entry)] | ||
pub struct Ipv4NatEntry { | ||
pub id: Uuid, | ||
pub external_address: ipnetwork::IpNetwork, | ||
pub first_port: SqlU16, | ||
pub last_port: SqlU16, | ||
pub sled_address: ipnetwork::IpNetwork, | ||
pub vni: Vni, | ||
pub mac: MacAddr, | ||
pub gen: SqlU32, | ||
pub time_created: DateTime<Utc>, | ||
pub time_deleted: Option<DateTime<Utc>>, | ||
} | ||
|
||
impl Ipv4NatEntry { | ||
pub fn first_port(&self) -> u16 { | ||
self.first_port.into() | ||
} | ||
|
||
pub fn last_port(&self) -> u16 { | ||
self.first_port.into() | ||
} | ||
|
||
pub fn gen(&self) -> u32 { | ||
self.gen.into() | ||
} | ||
} |
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
Oops, something went wrong.