initial commit
diff --git a/config.proto b/config.proto
new file mode 100644
index 0000000..4408a3b
--- /dev/null
+++ b/config.proto
@@ -0,0 +1,22 @@
+syntax = "proto3";
+
+message Config {
+ repeated Switch switch = 1;
+};
+
+message Switch {
+ string name = 1;
+
+ enum Connector {
+ CONNECTOR_INVALID = 0;
+ CONNECTOR_M6220 = 1;
+ CONNECTOR_ARISTA = 2;
+ };
+ Connector connector = 2;
+ string address = 3;
+ repeated SwitchPort managed_port = 4;
+};
+
+message SwitchPort {
+ string name = 1;
+};
diff --git a/control.proto b/control.proto
new file mode 100644
index 0000000..46cd93a
--- /dev/null
+++ b/control.proto
@@ -0,0 +1,64 @@
+syntax = "proto3";
+package connector;
+
+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);
+};
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..0314b7d
--- /dev/null
+++ b/main.go
@@ -0,0 +1,33 @@
+package main
+
+import (
+ "flag"
+ "io/ioutil"
+
+ "github.com/golang/glog"
+ "github.com/golang/protobuf/proto"
+
+ confpb "code.hackerspace.pl/q3k/topo/proto/config"
+)
+
+var (
+ flagConfigPath string
+)
+
+func init() {
+ flag.Set("logtostderr", "true")
+}
+
+func main() {
+ flag.StringVar(&flagConfigPath, "config_path", "./topo.pb.text", "Text proto configuration of Topo (per config.proto)")
+ flag.Parse()
+
+ data, err := ioutil.ReadFile(flagConfigPath)
+ if err != nil {
+ glog.Exitf("Could not read config: %v", err)
+ }
+
+ config := confpb.Config{}
+ proto.UnmarshalText(string(data), &config)
+ glog.Infof("%+v", config)
+}
diff --git a/proto/.gitignore b/proto/.gitignore
new file mode 100644
index 0000000..8a825df
--- /dev/null
+++ b/proto/.gitignore
@@ -0,0 +1,2 @@
+config
+control
diff --git a/proto/generate.go b/proto/generate.go
new file mode 100644
index 0000000..4456a69
--- /dev/null
+++ b/proto/generate.go
@@ -0,0 +1,4 @@
+//go:generate protoc -I.. ../control.proto --go_out=plugins=grpc:control
+//go:generate protoc -I.. ../config.proto --go_out=plugins=grpc:config
+
+package proto
diff --git a/service.go b/service.go
new file mode 100644
index 0000000..ab9e10a
--- /dev/null
+++ b/service.go
@@ -0,0 +1,7 @@
+package main
+
+import confpb "code.hackerspace.pl/q3k/topo/proto/config"
+
+type service struct {
+ config *confpb.Config
+}