snap_control/model.rs
1// Copyright 2025 Anapaya Systems
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//! SNAP control plane models.
15
16use std::net::SocketAddr;
17
18#[cfg(test)]
19use mockall::{automock, predicate::*};
20use sciparse::identifier::isd_asn::IsdAsn;
21
22/// List the available data planes.
23#[cfg_attr(test, automock)]
24pub trait UnderlayDiscovery: Send + Sync {
25 /// List all SNAP data planes.
26 fn list_snap_underlays(&self) -> Vec<SnapUnderlay>;
27 /// List all UDP data planes.
28 fn list_udp_underlays(&self) -> Vec<UdpUnderlay>;
29}
30
31#[derive(Clone)]
32/// SNAP data plane information.
33pub struct SnapUnderlay {
34 /// The listener address of the data plane.
35 pub address: SocketAddr,
36 /// The ISD-ASes of the data plane.
37 pub isd_ases: Vec<IsdAsn>,
38}
39
40#[derive(Clone)]
41/// UDP data plane information.
42pub struct UdpUnderlay {
43 /// The UDP socket address of the data plane.
44 pub endpoint: SocketAddr,
45 /// The ISD-ASes and their associated interfaces for this UDP data plane.
46 pub isd_ases: Vec<IsdAsInterfaces>,
47}
48
49#[derive(Clone)]
50/// The interface IDs for an ISD-AS.
51pub struct IsdAsInterfaces {
52 /// The ISD-AS identifier
53 pub isd_as: IsdAsn,
54 /// The interface IDs for this ISD-AS
55 pub interfaces: Vec<u16>,
56}