VOL-669: Move protos from openolt-api repo to protos directory.

Change-Id: I851c0a97b5c049235adae02206b83fe6afc8ba95
diff --git a/Makefile b/Makefile
index 11060c1..1a65d48 100644
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,6 @@
 	fi;
 onl-force:
 	make -C $(ONL_DIR) $(DEVICE)-$(ONL_KERN_VER_MAJOR)
-clean-onl:
 distclean-onl:
 	sudo rm -rf $(ONL_DIR)
 
@@ -185,8 +184,7 @@
 	mv -f release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz $(BUILD_DIR)
 	mv -f libbal_api_dist.so $(BUILD_DIR)
 	mv -f bal_core_dist $(BUILD_DIR)
-clean-bal: clean-onl
-distclean-bal: distclean-onl
+distclean-bal:
 	sudo rm -rf $(BAL_DIR)
 	rm -f build/release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz
 
@@ -196,19 +194,14 @@
 ##        OpenOLT API
 ##
 ##
-OPENOLT_API_DIR = $(BUILD_DIR)/openolt-api
-OPENOLT_API_LIB = $(OPENOLT_API_DIR)/libopenoltapi.a
-CXXFLAGS += -I./$(OPENOLT_API_DIR) -I $(OPENOLT_API_DIR)/googleapis/gens
-.PHONY: openolt-api
-openolt-api:
-	if [ ! -e "$(OPENOLT_API_DIR)" ]; then \
-		mkdir -p $(BUILD_DIR); \
-		git clone https://gerrit.opencord.org/openolt-api $(OPENOLT_API_DIR); \
-	fi;
-	make -C $(OPENOLT_API_DIR) all
-clean-openolt-api:
-	-make -C $(OPENOLT_API_DIR) clean
-distclean-openolt-api:
+OPENOLT_PROTOS_DIR = ./protos
+OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a
+CXXFLAGS += -I./$(OPENOLT_PROTOS_DIR) -I $(OPENOLT_PROTOS_DIR)/googleapis/gens
+.PHONY: protos
+protos:
+	make -C $(OPENOLT_PROTOS_DIR) all
+clean-protos:
+	-make -C $(OPENOLT_PROTOS_DIR) clean
 
 ########################################################################
 ##
@@ -221,7 +214,7 @@
 DEPS = $(SRCS:.cc=.d)
 .DEFAULT_GOAL := all
 all: $(BUILD_DIR)/openolt
-$(BUILD_DIR)/openolt: openolt-api bal $(OBJS)
+$(BUILD_DIR)/openolt: protos bal $(OBJS)
 	$(CXX) $(OBJS) $(LDFLAGS) $(OPENOLT_API_LIB) -o $@ -L$(BALLIBDIR) -l$(BALLIBNAME)
 	ln -s $(shell ldconfig -p | grep libgrpc.so.6 | tr ' ' '\n' | grep /) $(BUILD_DIR)/libgrpc.so.6
 	ln -s $(shell ldconfig -p | grep libgrpc++.so.1 | tr ' ' '\n' | grep /) $(BUILD_DIR)/libgrpc++.so.1
@@ -230,10 +223,9 @@
 src/%.o: %.cpp
 	$(CXX) -MMD -c $< -o $@
 
-clean: clean-bal
-	rm -f $(OBJS) $(DEPS) $(BUILD_DIR)/openolt
-	rm -rf $(OPENOLT_API_DIR)
+clean: clean-protos
+	rm -f $(OBJS) $(DEPS)
 	rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++_reflection.so.1
-distclean: distclean-openolt-api distclean-bal
+
+distclean:
 	rm -rf $(BUILD_DIR)
--include $(DEPS)
diff --git a/protos/Makefile b/protos/Makefile
new file mode 100644
index 0000000..ba9591f
--- /dev/null
+++ b/protos/Makefile
@@ -0,0 +1,59 @@
+# Copyright (c) 2018 Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
+SYSTEM ?= $(HOST_SYSTEM)
+CXX = g++
+CPPFLAGS += `pkg-config --cflags protobuf grpc` -I googleapis/gens
+CXXFLAGS += -std=c++11
+ifeq ($(SYSTEM),Darwin)
+LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
+           -lgrpc++_reflection\
+           -ldl
+else
+LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\
+           -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
+           -ldl
+endif
+PROTOC = protoc
+GRPC_CPP_PLUGIN = grpc_cpp_plugin
+GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
+
+OBJS = openolt.pb.o openolt.grpc.pb.o ./googleapis/gens/google/api/annotations.grpc.pb.o ./googleapis/gens/google/api/annotations.pb.o ./googleapis/gens/google/api/http.pb.o
+
+all: googleapis libopenoltapi.a
+
+libopenoltapi.a: $(OBJS)
+	ar ru $@ $^
+	ranlib $@
+
+googleapis:
+	if [ ! -e "googleapis" ]; then \
+		git clone git@github.com:googleapis/googleapis.git; \
+		make -C googleapis LANGUAGE=cpp all; \
+	fi;
+
+.PRECIOUS: %.grpc.pb.cc
+%.grpc.pb.cc: %.proto
+	$(PROTOC) --proto_path=. -I./googleapis --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
+
+.PRECIOUS: %.pb.cc
+%.pb.cc: %.proto
+	$(PROTOC) --proto_path=. -I./googleapis --cpp_out=. $<
+
+clean:
+	rm -f *.o *.pb.cc *.pb.h *.a
+
+distclean: clean
+	rm -rf googleapis
diff --git a/protos/README.md b/protos/README.md
new file mode 100644
index 0000000..5214f86
--- /dev/null
+++ b/protos/README.md
@@ -0,0 +1,3 @@
+### openolt-api
+
+**openolt-api** is the protobuf definition of the gRPC service implemented by [OpenOLT](https://github.com/OpenOLT). See [openolt](https://github.com/OpenOLT/openolt) and [openasf](https://github.com/OpenOLT/openasf).
diff --git a/protos/generate.go b/protos/generate.go
new file mode 100644
index 0000000..47889c4
--- /dev/null
+++ b/protos/generate.go
@@ -0,0 +1,17 @@
+// Copyright (c) 2018 Open Networking Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at:
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//go:generate protoc openolt.proto --go_out=plugins=grpc:.
+
+package openolt;
diff --git a/protos/openolt.proto b/protos/openolt.proto
new file mode 100644
index 0000000..c9f6d98
--- /dev/null
+++ b/protos/openolt.proto
@@ -0,0 +1,172 @@
+// Copyright (c) 2018 Open Networking Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at:
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+package openolt;
+import "google/api/annotations.proto";
+
+service Openolt {
+
+    rpc ActivateOnu(Onu) returns (Empty) {
+        option (google.api.http) = {
+          post: "/v1/EnableOnu"
+          body: "*"
+        };
+    }
+
+    rpc OmciMsgOut(OmciMsg) returns (Empty) {
+        option (google.api.http) = {
+          post: "/v1/OmciMsgOut"
+          body: "*"
+        };
+    }
+
+    rpc OnuPacketOut(OnuPacket) returns (Empty) {
+        option (google.api.http) = {
+          post: "/v1/OnuPacketOut"
+          body: "*"
+        };
+    }
+
+    rpc FlowAdd(Flow) returns (Empty) {
+        option (google.api.http) = {
+          post: "/v1/FlowAdd"
+          body: "*"
+        };
+    }
+
+    rpc EnableIndication(Empty) returns (stream Indication) {}
+}
+
+message Indication {
+    oneof data {
+        OltIndication olt_ind = 1;
+        IntfIndication intf_ind = 2;
+        IntfOperIndication intf_oper_ind = 3;
+        OnuDiscIndication onu_disc_ind = 4;
+        OnuIndication onu_ind = 5;
+        OmciIndication omci_ind = 6;
+        PacketIndication pkt_ind = 7;
+    }
+}
+
+message OltIndication {
+    string oper_state = 1;	// up, down
+}
+
+message IntfIndication {
+    fixed32 intf_id = 1;
+    string oper_state = 2;      // up, down
+}
+
+message OnuDiscIndication {
+    fixed32 intf_id = 1;
+    SerialNumber serial_number = 2;
+}
+
+message OnuIndication {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    string oper_state = 3;      // up, down
+    SerialNumber serial_number = 4;
+}
+
+message IntfOperIndication {
+    string type = 1;		// nni, pon
+    fixed32 intf_id = 2;
+    string oper_state = 3;      // up, down
+}
+
+message OmciIndication {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    bytes pkt = 3;
+}
+
+message PacketIndication {
+    fixed32 intf_id = 1;
+    fixed32 gemport_id = 2;
+    fixed32 flow_id = 3;
+    bytes pkt = 4;
+}
+
+message Onu {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    SerialNumber serial_number = 3;
+}
+
+message OmciMsg {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    bytes pkt = 3;
+}
+
+message OnuPacket {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    bytes pkt = 3;
+}
+
+message Classifier {
+    fixed32 o_tpid = 1;
+    fixed32 o_vid = 2;
+    fixed32 i_tpid = 3;
+    fixed32 i_vid = 4;
+    fixed32 o_pbits = 5;
+    fixed32 i_pbits = 6;
+    fixed32 eth_type = 7;
+    bytes dst_mac = 8;
+    bytes src_mac = 9;
+    fixed32 ip_proto = 10;
+    fixed32 dst_ip = 11;
+    fixed32 src_ip = 12;
+    fixed32 src_port = 13;
+    fixed32 dst_port = 14;
+    string pkt_tag_type = 15;	// untagged, single_tag, double_tag
+}
+
+message ActionCmd {
+    bool add_outer_tag = 1;
+    bool remove_outer_tag = 2;
+    bool trap_to_host = 3;
+}
+
+message Action {
+    ActionCmd cmd = 1;
+    fixed32 o_vid = 2;
+    fixed32 o_pbits = 3;
+    fixed32 o_tpid = 4;
+    fixed32 i_vid = 5;
+    fixed32 i_pbits = 6;
+    fixed32 i_tpid = 7;
+}
+
+message Flow {
+    fixed32 access_intf_id = 1;
+    fixed32 onu_id = 2;
+    fixed32 flow_id = 3;
+    string flow_type = 4;	// upstream, downstream, broadcast, multicast
+    fixed32 network_intf_id = 5;
+    fixed32 gemport_id = 6;
+    Classifier classifier = 7;
+    Action action = 8;
+}
+
+message SerialNumber {
+    bytes vendor_id = 1;
+    bytes vendor_specific = 2;
+}
+
+message Empty {}