syntax = "proto3";
package infra;

message GetPortsRequest {
};

message SwitchPort {
    enum Speed {
        SPEED_INVALID = 0;
        SPEED_100M = 1;
        SPEED_1G = 2;
        SPEED_10G = 3;
    };
    string name = 1;
    Speed speed = 2;
    enum LinkState {
        LINKSTATE_INVALID = 0;
        LINKSTATE_DOWN = 1;
        LINKSTATE_UP = 2;
    };
    LinkState link_state = 3;
    enum PortMode {
        PORTMODE_INVALID = 0;
        // Interface is bridged to a VLAN, untagged.
        PORTMODE_SWITCHPORT_UNTAGGED = 1;
        // Interfaces is bridged to several tagged 802.1q VLANs.
        PORTMODE_SWITCHPORT_TAGGED = 2;
        // Interface is in 'generic', both tagged 802.1q and untagged mode.
        PORTMODE_SWITCHPORT_GENERIC = 3;
        // Interface is routed, ie routes packets from a separate L3 network
        // and the Switch is the default gateway for machines in this network.
        PORTMODE_ROUTED = 4;
        // Interface is in a configuration state that cannot be clearly stated
        // in terms of this enum, and should be reconfigured.
        PORTMODE_MANGLED = 5;
    };
    PortMode port_mode = 4;
    // For PORTMODE_SWITCHPORT_UNTAGGED and PORTMODE_SWITCHPORT_GENERIC, the
    // VLAN ID that this interface is natively bridged to.
    int32 vlan_native = 5;
    // For PORTMODE_SWITCHPORT_TAGGED and PORTMODE_SWITCHPORT_GENERIC, the VLAN
    // IDs that the interface is bridged to using 802.1q tags.
    repeated int32 vlan_tagged = 6;
    // For PORTMODE_ROUTED
    repeated string prefixes = 7;
    // Interface MTU
    int32 mtu = 8;
    enum SpanningTreeMode {
        SPANNING_TREE_MODE_INVALID = 0;
        // Send STP BPDU, on timeout switch to Forwarding.
        SPANNING_TREE_MODE_AUTO_PORTFAST = 1;
        // Switch to Forwarding immediately on link up.
        SPANNING_TREE_MODE_PORTFAST = 2;
    };
    SpanningTreeMode spanning_tree_mode = 9;
};

message GetPortsResponse {
    repeated SwitchPort ports = 1;
};

service SwitchControl {
    rpc GetPorts(GetPortsRequest) returns (GetPortsResponse);
};
