AETHER-3162 Remove magma leftover iptables rule from enodebd

AETHER-3198 Add REUSE compliant to enodebd
AETHER-3196 Support identify IP from X-Real IP in enodebd
AETHER-3229 Documentation of configuration and state machine for enodebd
AETHER-3292 Adding new parameter to support in enodebd Sercomm driver
AETHER-3311 Remove unused protobuf definition from enodebd

Change-Id: Ie69f0141eff70cb3d4447cd9575c8224d42dd5e3
diff --git a/proto_files/orc8r/protos/BUILD.bazel b/proto_files/orc8r/protos/BUILD.bazel
new file mode 100644
index 0000000..10a1060
--- /dev/null
+++ b/proto_files/orc8r/protos/BUILD.bazel
@@ -0,0 +1,129 @@
+# SPDX-FileCopyrightText: 2020 The Magma Authors.
+# SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+load("@rules_proto//proto:defs.bzl", "proto_library")
+load("@rules_proto_grpc//cpp:defs.bzl", "cpp_grpc_library")
+load("@rules_proto_grpc//cpp:defs.bzl", "cpp_proto_library")
+
+package(default_visibility = ["//visibility:public"])
+
+cpp_proto_library(
+    name = "common_cpp_proto",
+    protos = [":common_proto"],
+)
+
+proto_library(
+    name = "common_proto",
+    srcs = ["common.proto"],
+)
+
+cpp_proto_library(
+    name = "digest_cpp_proto",
+    protos = [":digest_proto"],
+)
+
+proto_library(
+    name = "digest_proto",
+    srcs = ["digest.proto"],
+    deps = ["@protobuf//:any_proto"],
+)
+
+cpp_grpc_library(
+    name = "eventd_cpp_grpc",
+    protos = [":eventd_proto"],
+    deps = [":common_cpp_proto"],
+)
+
+proto_library(
+    name = "eventd_proto",
+    srcs = ["eventd.proto"],
+    deps = [":common_proto"],
+)
+
+cpp_grpc_library(
+    name = "directoryd_cpp_grpc",
+    protos = [":directoryd_proto"],
+    deps = [":common_cpp_proto"],
+)
+
+proto_library(
+    name = "directoryd_proto",
+    srcs = ["directoryd.proto"],
+    deps = [":common_proto"],
+)
+
+cpp_proto_library(
+    name = "redis_cpp_proto",
+    protos = [":redis_proto"],
+)
+
+proto_library(
+    name = "redis_proto",
+    srcs = ["redis.proto"],
+)
+
+proto_library(
+    name = "mconfigs_proto",
+    srcs = ["mconfig/mconfigs.proto"],
+    strip_import_prefix = "mconfig/",
+    deps = [":common_proto"],
+)
+
+cpp_proto_library(
+    name = "metrics_cpp_proto",
+    protos = [":metrics_proto"],
+)
+
+proto_library(
+    name = "metrics_proto",
+    srcs = ["prometheus/metrics.proto"],
+    strip_import_prefix = "prometheus/",
+)
+
+cpp_proto_library(
+    name = "metricsd_cpp_proto",
+    protos = [":metricsd_proto"],
+    deps = [
+        ":common_cpp_proto",
+        ":metrics_cpp_proto",
+    ],
+)
+
+proto_library(
+    name = "metricsd_proto",
+    srcs = ["metricsd.proto"],
+    deps = [
+        ":common_proto",
+        ":metrics_proto",
+    ],
+)
+
+cpp_grpc_library(
+    name = "service303_cpp_grpc",
+    protos = [":service303_proto"],
+    deps = [
+        ":common_cpp_proto",
+        ":metricsd_cpp_proto",
+    ],
+)
+
+cpp_proto_library(
+    name = "service303_cpp_proto",
+    protos = [":service303_proto"],
+    deps = [
+        ":common_cpp_proto",
+        ":metricsd_cpp_proto",
+    ],
+)
+
+proto_library(
+    name = "service303_proto",
+    srcs = ["service303.proto"],
+    deps = [
+        ":common_proto",
+        ":metricsd_proto",
+        "@protobuf//:wrappers_proto",
+    ],
+)
diff --git a/proto_files/orc8r/protos/common.proto b/proto_files/orc8r/protos/common.proto
new file mode 100644
index 0000000..43c153b
--- /dev/null
+++ b/proto_files/orc8r/protos/common.proto
@@ -0,0 +1,44 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+package magma.orc8r;
+option go_package = "magma/orc8r/lib/go/protos";
+
+message Void {
+}
+
+// -------------------------------------------------------------------------------
+// Bytes is a special message type used to marshal & unmarshal unknown types as is
+// -------------------------------------------------------------------------------
+message Bytes {
+  bytes val = 1;
+}
+
+// --------------------------------------------------------------------------
+// NetworkID uniquely identifies the network
+// --------------------------------------------------------------------------
+message NetworkID {
+  string id = 1;
+}
+
+// --------------------------------------------------------------------------
+// IDList is a generic definition of an array of IDs (network, gateway, etc.)
+// --------------------------------------------------------------------------
+message IDList {
+  repeated string ids = 1;
+}
+
+// --------------------------------------------------------------------------
+// Logging levels
+// --------------------------------------------------------------------------
+enum LogLevel {
+  DEBUG = 0;
+  INFO = 1;
+  WARNING = 2;
+  ERROR = 3;
+  FATAL = 4;
+}
diff --git a/proto_files/orc8r/protos/eventd.proto b/proto_files/orc8r/protos/eventd.proto
new file mode 100644
index 0000000..eaa5288
--- /dev/null
+++ b/proto_files/orc8r/protos/eventd.proto
@@ -0,0 +1,35 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+import "orc8r/protos/common.proto";
+
+package magma.orc8r;
+
+option go_package = "magma/orc8r/lib/go/protos";
+
+// --------------------------------------------------------------------------
+// EventService provides an interface for structured event logging.
+// --------------------------------------------------------------------------
+service EventService {
+  // Logs an event to FluentBit.
+  rpc LogEvent (Event) returns (Void) {}
+}
+
+// --------------------------------------------------------------------------
+// An Event encapsulates all information regarding an event and it's metadata.
+// --------------------------------------------------------------------------
+message Event {
+  // A user-specified string to categorize events
+  string stream_name = 1;
+  // Denotes the way an event should be deserialized.
+  // This should correspond to an event type in swagger_eventd.v1.yml
+  string event_type = 2;
+  // A user-specified non-unique identifier for events
+  string tag = 3;
+  // The event log serialized as JSON
+  string value = 4;
+}
diff --git a/proto_files/orc8r/protos/magmad.proto b/proto_files/orc8r/protos/magmad.proto
new file mode 100644
index 0000000..41192da
--- /dev/null
+++ b/proto_files/orc8r/protos/magmad.proto
@@ -0,0 +1,147 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+import "orc8r/protos/common.proto";
+import "orc8r/protos/mconfig.proto";
+import "google/protobuf/struct.proto";
+
+package magma.orc8r;
+option go_package = "magma/orc8r/lib/go/protos";
+
+
+message PingParams {
+  string host_or_ip = 1;
+  int32 num_packets = 2;
+}
+
+message TracerouteParams {
+  string host_or_ip = 1;
+  int32 max_hops = 2;
+  int32 bytes_per_packet = 3;
+}
+
+message NetworkTestRequest {
+  repeated PingParams pings = 1;
+  repeated TracerouteParams traceroutes = 2;
+}
+
+message PingResult {
+  string host_or_ip = 1;
+  int32 num_packets = 2;
+  string error = 3;
+  int32 packets_transmitted = 4;
+  int32 packets_received = 5;
+  float avg_response_ms = 6;
+}
+
+message TracerouteProbe {
+  string hostname = 1;
+  string ip = 2;
+  float rtt_ms = 3;
+}
+
+message TracerouteHop {
+  int32 idx = 1;
+  repeated TracerouteProbe probes = 2;
+}
+
+message TracerouteResult {
+  string error = 1;
+  string host_or_ip = 2;
+  repeated TracerouteHop hops = 3;
+}
+
+message NetworkTestResponse {
+  repeated PingResult pings = 1;
+  repeated TracerouteResult traceroutes = 2;
+}
+
+message GetGatewayIdResponse {
+  string gateway_id = 1;
+}
+
+message RestartServicesRequest {
+  repeated string services = 1;
+}
+
+message GenericCommandParams {
+  string command = 1;
+  google.protobuf.Struct params = 2;
+}
+
+message GenericCommandResponse {
+  google.protobuf.Struct response = 1;
+}
+
+message TailLogsRequest {
+  string service = 1;
+}
+
+message LogLine {
+  string line = 1;
+}
+
+message CheckStatelessResponse{
+  enum AGWMode {
+    INVALID = 0;
+    STATELESS = 1;
+    STATEFUL = 2;
+    CORRUPT = 3;
+  }
+  AGWMode agw_mode = 1;
+}
+
+message ConfigureStatelessRequest {
+  enum Cmd {
+    CHECK = 0;
+    DISABLE = 1;
+    ENABLE = 2;
+  }
+  Cmd config_cmd = 1;
+}
+
+// --------------------------------------------------------------------------
+// Magmad service definition.
+// --------------------------------------------------------------------------
+service Magmad {
+
+  // Starts all magma services
+  rpc StartServices (Void) returns (Void) {}
+
+  // Stops all magma services
+  rpc StopServices (Void) returns (Void) {}
+
+  // Reboot the gateway device
+  rpc Reboot (Void) returns (Void) {}
+
+  // Restart specified magma services
+  rpc RestartServices (RestartServicesRequest) returns (Void) {}
+
+  // Updates AG configs and restarts affected AG services
+  rpc SetConfigs (GatewayConfigs) returns (Void) {}
+
+  // Get current AG configs
+  rpc GetConfigs (Void) returns (GatewayConfigs) {}
+
+  // Execute some network commands to check gateway network health
+  rpc RunNetworkTests (NetworkTestRequest) returns (NetworkTestResponse) {}
+
+  // Get gateway hardware ID
+  rpc GetGatewayId (Void) returns (GetGatewayIdResponse) {}
+
+  // Execute generic command
+  rpc GenericCommand (GenericCommandParams) returns (GenericCommandResponse) {}
+
+  // Get stream of logs
+  rpc TailLogs (TailLogsRequest) returns (stream LogLine) {}
+
+  // CheckStateless returns whether AGW is stateless or stateful
+  rpc CheckStateless (Void) returns (CheckStatelessResponse) {}
+
+  // ConfigureStateless configures the stateless mode of AGW
+  rpc ConfigureStateless (ConfigureStatelessRequest) returns (Void) {}
+}
diff --git a/proto_files/orc8r/protos/mconfig.proto b/proto_files/orc8r/protos/mconfig.proto
new file mode 100644
index 0000000..740ab6a
--- /dev/null
+++ b/proto_files/orc8r/protos/mconfig.proto
@@ -0,0 +1,51 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+import "google/protobuf/any.proto";
+
+package magma.orc8r;
+option go_package = "magma/orc8r/lib/go/protos";
+
+// --------------------------------------------------------------------------
+// GatewayConfigs structure is a container for all Access Gateway's (AG) Cloud
+// Managed Configs (CMC). Each and every field of GatewayConfigs represents
+// one AG service config
+// --------------------------------------------------------------------------
+// NOTE: a service config field name (control_proxy, enodebd, etc.) must match
+//       the corresponding gateway service's name exactly
+message GatewayConfigs {
+    map<string, google.protobuf.Any> configs_by_key = 10;
+
+    GatewayConfigsMetadata metadata = 11;
+}
+
+// Deterministic hash of a serialized GatewayConfigs proto
+message GatewayConfigsDigest {
+    // Hexadecimal MD5 hash of the UTF-8-encoded stringified full mconfigs
+    string md5_hex_digest = 1;
+}
+
+// Metadata about the configs.
+message GatewayConfigsMetadata {
+    // Unix timestamp of Cloud at the time of config generation.
+    uint64 created_at = 11;
+    GatewayConfigsDigest digest = 12;
+}
+
+// Wraps a gateway config and a stream offset that the config was computed
+// from
+message OffsetGatewayConfigs {
+    GatewayConfigs configs = 1;
+    int64 offset = 2;
+}
+
+// Stream request passed as extra args to the streaming mconfig streamer policy.
+// Contains a single field, the offset of the mconfig currently stored on
+// the device.
+message MconfigStreamRequest {
+    int64 offset = 1;
+}
diff --git a/proto_files/orc8r/protos/mconfig/mconfigs.proto b/proto_files/orc8r/protos/mconfig/mconfigs.proto
new file mode 100644
index 0000000..9e5acb5
--- /dev/null
+++ b/proto_files/orc8r/protos/mconfig/mconfigs.proto
@@ -0,0 +1,112 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+import "orc8r/protos/common.proto";
+
+package magma.mconfig;
+option go_package = "magma/orc8r/lib/go/protos/mconfig";
+
+// ===========================================================================
+// Service-specific configs
+// ===========================================================================
+
+
+//------------------------------------------------------------------------------
+// Control Proxy configs
+//------------------------------------------------------------------------------
+message ControlProxy {
+    orc8r.LogLevel log_level = 1;
+}
+
+//------------------------------------------------------------------------------
+// MagmaD configs
+//------------------------------------------------------------------------------
+
+message ImageSpec {
+    string name = 1;
+    int64 order = 2;
+}
+
+message MagmaD {
+    orc8r.LogLevel log_level = 1;
+    // Interval for the gateways to send checkin rpc calls to the cloud.
+    int32 checkin_interval = 2;
+    // Checkin rpc timeout
+    int32 checkin_timeout = 3;
+    // Enables autoupgrading of the magma package
+    bool autoupgrade_enabled = 4;
+    // Interval to poll for package upgrades
+    int32 autoupgrade_poll_interval = 5;
+    // The magma package version the gateway should upgrade to
+    string package_version = 6;
+    // List of upgrade images
+    repeated ImageSpec images = 7;
+
+    // For streamer, should be left unused by gateway
+    string tier_id = 8;
+
+    map<string, bool> feature_flags = 9;
+
+    // List of dynamic_services
+    repeated string dynamic_services = 10;
+}
+
+//------------------------------------------------------------------------------
+// EventD configs
+//------------------------------------------------------------------------------
+message EventD {
+    orc8r.LogLevel log_level = 1;
+    // The verbosity level for events.
+    // All events less than or equal to this verbosity will be logged.
+    int32 event_verbosity = 2;
+}
+
+message DirectoryD {
+    orc8r.LogLevel log_level = 1;
+}
+
+//------------------------------------------------------------------------------
+// MetricsD configs
+//------------------------------------------------------------------------------
+message MetricsD {
+    orc8r.LogLevel log_level = 1;
+}
+
+//------------------------------------------------------------------------------
+// State configs
+//------------------------------------------------------------------------------
+message State {
+    orc8r.LogLevel log_level = 1;
+    uint32 sync_interval = 2;
+}
+
+//------------------------------------------------------------------------------
+// Fluent Bit configs
+//------------------------------------------------------------------------------
+message FluentBit {
+    map<string, string> extra_tags = 1;
+
+    uint32 throttle_rate = 10;
+    uint32 throttle_window = 11;
+    string throttle_interval = 12;
+
+    map<string, string> files_by_tag = 20;
+}
+
+//------------------------------------------------------------------------------
+// OpenVPN client configs
+//------------------------------------------------------------------------------
+message OpenVPN {
+    bool enable_shell_access = 1;
+}
+
+//------------------------------------------------------------------------------
+// CtraceD configs
+//------------------------------------------------------------------------------
+message CtraceD {
+    orc8r.LogLevel log_level = 1;
+}
diff --git a/proto_files/orc8r/protos/metricsd.proto b/proto_files/orc8r/protos/metricsd.proto
new file mode 100644
index 0000000..9542201
--- /dev/null
+++ b/proto_files/orc8r/protos/metricsd.proto
@@ -0,0 +1,238 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+package magma.orc8r;
+
+import "metrics.proto";
+import "orc8r/protos/common.proto";
+
+option go_package = "magma/orc8r/lib/go/protos";
+
+// For each metric name tracked, we use an enum
+enum MetricName {
+  // Prometheus metrics
+  process_start_time_seconds     = 0;
+  process_virtual_memory_bytes   = 1;
+  process_resident_memory_bytes  = 2;
+  process_cpu_seconds_total      = 3;
+  process_open_fds               = 4;
+  process_max_fds                = 5;
+
+  // subscriberdb metrics
+  s6a_auth_success               = 6;
+  s6a_auth_failure               = 7;
+  s6a_location_update            = 8;
+  diameter_capabilities_exchange = 9;
+  diameter_watchdog              = 10;
+  diameter_disconnect            = 11;
+
+  // More prometheus metrics
+  python_info                    = 50;
+
+  // Metricsd metrics
+  service_metrics_collected      = 60;
+  process_uptime_seconds         = 61;
+
+  // mobilityd metrics
+  ip_address_allocated           = 100;
+  ip_address_released            = 101;
+  ip_already_allocated           = 102;
+  ip_allocation_failure          = 103;
+
+  // enodebd metrics
+  enodeb_mgmt_connected          = 200;
+  enodeb_opstate_enabled         = 201;
+  enodeb_rf_tx_enabled           = 202;
+  enodeb_gps_connected           = 203;
+  enodeb_ptp_connected           = 204;
+  enodeb_mme_connected           = 205;
+  rrc_estab_attempts             = 206;
+  rrc_estab_successes            = 207;
+  pdcp_user_plane_bytes_ul       = 208;
+  pdcp_user_plane_bytes_dl       = 209;
+  rrc_reestab_attempts           = 210;
+  rrc_reestab_attempts_reconf_fail = 211;
+  rrc_reestab_attempts_ho_fail   = 212;
+  rrc_reestab_attempts_other     = 213;
+  rrc_reestab_successes          = 214;
+  erab_estab_attempts            = 215;
+  erab_estab_successes           = 216;
+  erab_estab_failures            = 217;
+  erab_release_requests          = 218;
+  erab_release_requests_user_inactivity = 219;
+  erab_release_requests_normal   = 220;
+  erab_release_requests_radio_resources_not_available = 221;
+  erab_release_requests_reduce_load = 222;
+  erab_release_requests_fail_in_radio_proc = 223;
+  erab_release_requests_eutran_reas = 224;
+  erab_release_requests_radio_radio_conn_lost = 225;
+  erab_release_requests_oam_intervention = 226;
+  enodeb_mgmt_configured         = 227;
+  enodeb_reboot_timer_active     = 228;
+  enodeb_reboots                 = 229;
+  enodeb_rf_tx_desired           = 230;
+
+  // Kernsnoopd metrics
+  magma_bytes_sent_total         = 260;
+  linux_bytes_sent_total         = 261;
+
+  // Magmad metrics
+  magmad_ping_rtt_ms             = 300;
+  cpu_percent                    = 301;
+  swap_memory_percent            = 302;
+  virtual_memory_percent         = 303;
+  disk_percent                   = 304;
+  bytes_sent                     = 305;
+  bytes_received                 = 306;
+  temperature                    = 307;
+  checkin_status                 = 308;
+  streamer_responses             = 309;
+  mem_total                      = 310;
+  mem_available                  = 311;
+  mem_used                       = 312;
+  mem_free                       = 313;
+  bootstrap_exception            = 314;
+  upgrader2_time_taken           = 315;
+  upgrader2_error                = 316;
+  upgrader2_prepared             = 317;
+  upgrader2_downloaded           = 318;
+  upgrader2_canary               = 319;
+  upgrader2_stable               = 320;
+  upgrader2_idle                 = 321;
+  unexpected_service_restarts    = 322;
+  unattended_upgrade_status      = 323;
+  service_restart_status         = 324;
+
+  // Pipelined metrics
+  dp_send_msg_error              = 350;
+  arp_default_gw_mac_error       = 351;
+  openflow_error_msg             = 352;
+  unknown_pkt_direction          = 353;
+  network_iface_status           = 354;
+  enforcement_rule_install_fail  = 355;
+  enforcement_stats_rule_install_fail = 356;
+
+  ///////////////////////////////
+  // GATEWAY FAILURES & ALERTS //
+  ///////////////////////////////
+  mme_restarted                  = 400;
+  s1_reset_from_enb              = 401;
+
+  // SCTP
+  sctp_reset                     = 410;
+  sctp_shutdown                  = 411;
+
+  // s6a
+  s6a_subscriberdb_connection_failure = 420;
+  s6a_auth_info_response_timer_expired = 421;
+
+  // UE attach, Serivce Request
+  duplicate_attach_request       = 430;
+  initial_context_setup_failure_received = 431;
+  initial_context_setup_request_timer_expired = 432;
+  nas_attach_accept_timer_expired = 433;
+  nas_auth_rsp_timer_expired = 434;
+  nas_security_mode_command_timer_expired = 435;
+  security_mode_reject_received  = 436;
+  authentication_failure         = 437; // cause=mac_failure,resync,amf
+  mme_spgw_create_session_req    = 438;
+  mme_spgw_create_session_rsp    = 439;
+  mme_spgw_delete_session_req    = 440;
+  mme_spgw_delete_session_rsp    = 441;
+
+  // UE S1AP context
+  ue_context_release_request     = 450;
+  ue_context_release_command_timer_expired = 451;
+
+  // Detach
+  implicit_detach_timer_expired  = 452;
+
+  // eNB SCTP shutdown context clean up time
+  enb_sctp_shutdown_ue_clean_up_timer_expired  = 453;
+
+  // Other errors
+  s1ap_error_ind_received        = 480;
+  gtpu_error_ind_received        = 481;
+  nas_non_delivery_indication_received = 482;
+  emm_status_received            = 483;
+  emm_status_sent                = 484;
+
+  ////////////////////////
+  // GATEWAY PROCEDURES //
+  ////////////////////////
+  mme_new_association            = 500;
+  ue_attach                      = 501; // result=failure,accept,complete
+  service_request                = 502;
+  ue_detach                      = 503; // cause=network_initiated,
+                                        // deregister_ue,implicit_detach,
+                                        // ue_initiated
+  spgw_create_session            = 504;
+  spgw_delete_session            = 505;
+  ue_pdn_connection              = 506;
+  tracking_area_update           = 507;
+  s1_setup                       = 508;
+
+  // Generic service metrics
+  service_errors                 = 550;
+}
+
+// Possible labels, used as metric_name{label_name=label_value}
+enum MetricLabelName {
+  result                         = 0;
+  cause                          = 1;
+  tau_type                       = 2;
+  pdn_type                       = 3;
+  action                         = 4;
+  host                           = 5; // magmad_ping_rtt_ms
+  metric                         = 6; // magmad_ping_rtt_ms
+  patchlevel                     = 7; // python_info
+  minor                          = 8; // python_info
+  major                          = 9; // python_info
+  version                        = 10; // python_info
+  implementation                 = 11; // python_info
+  sensor                         = 12; // magmad_temperature
+  error_code                     = 13;
+  error_type                     = 14;
+  iface_name                     = 15; // pipelined network_iface_status
+  service_name                   = 16; // magmad unexpected_service_restarts
+  rule_id                        = 17; // pipelined rule install failures
+  imsi                           = 18; // pipelined rule install failures
+  dest_service                   = 19; // kernsnoopd name of destination service
+  binary_name                    = 20; // kernsnoopd name of linux binary
+}
+
+message MetricsContainer {
+  string gatewayId = 1;
+  // TODO: we should strip this out of metricsd (or duplicate it ourselves)
+  // Prometheus 2 no longer supports protobuf client model
+  repeated io.prometheus.client.MetricFamily family = 2;
+}
+
+message PushedMetric {
+  string   metricName        = 1;
+  double   value             = 2;
+  int64    timestampMS       = 3;
+  repeated LabelPair labels  = 4;
+}
+
+message LabelPair {
+  string name  = 1;
+  string value = 2;
+}
+
+message PushedMetricsContainer {
+  string   networkId = 1;
+  repeated PushedMetric metrics = 2;
+}
+
+service MetricsController {
+  // Report a collection of metrics from a service
+  rpc Collect(MetricsContainer) returns (Void) {}
+
+  // Push a collection of metrics to metricsd
+  rpc Push(PushedMetricsContainer) returns (Void) {}
+}
diff --git a/proto_files/orc8r/protos/prometheus/metrics.proto b/proto_files/orc8r/protos/prometheus/metrics.proto
new file mode 100644
index 0000000..87ae0d7
--- /dev/null
+++ b/proto_files/orc8r/protos/prometheus/metrics.proto
@@ -0,0 +1,82 @@
+// SPDX-FileCopyrightText: 2013 Prometheus Team.
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: Apache-2.0
+
+syntax = "proto2";
+
+package io.prometheus.client;
+option java_package = "io.prometheus.client";
+
+// !!!!!!!!!!!!!
+// DO NOT MODIFY
+// !!!!!!!!!!!!!
+// This file is a copy of the open source prometheus library.
+// https://github.com/prometheus/client_model/blob/master/metrics.proto
+// The 'go_package' change is made locally, and needs to be upstreamed.
+option go_package = "github.com/prometheus/client_model/go";
+
+message LabelPair {
+  optional string name  = 1;
+  optional string value = 2;
+}
+
+enum MetricType {
+  COUNTER    = 0;
+  GAUGE      = 1;
+  SUMMARY    = 2;
+  UNTYPED    = 3;
+  HISTOGRAM  = 4;
+}
+
+message Gauge {
+  optional double value = 1;
+}
+
+message Counter {
+  optional double value = 1;
+}
+
+message Quantile {
+  optional double quantile = 1;
+  optional double value    = 2;
+}
+
+message Summary {
+  optional uint64   sample_count = 1;
+  optional double   sample_sum   = 2;
+  repeated Quantile quantile     = 3;
+}
+
+message Untyped {
+  optional double value = 1;
+}
+
+message Histogram {
+  optional uint64 sample_count = 1;
+  optional double sample_sum   = 2;
+  repeated Bucket bucket       = 3; // Ordered in increasing order of upper_bound, +Inf bucket is optional.
+}
+
+message Bucket {
+  optional uint64 cumulative_count = 1; // Cumulative in increasing order.
+  optional double upper_bound = 2;      // Inclusive.
+}
+
+message Metric {
+  repeated LabelPair label        = 1;
+  optional Gauge     gauge        = 2;
+  optional Counter   counter      = 3;
+  optional Summary   summary      = 4;
+  optional Untyped   untyped      = 5;
+  optional Histogram histogram    = 7;
+  optional int64     timestamp_ms = 6;
+}
+
+message MetricFamily {
+  optional string     name   = 1;
+  optional string     help   = 2;
+  optional MetricType type   = 3;
+  repeated Metric     metric = 4;
+}
diff --git a/proto_files/orc8r/protos/redis.proto b/proto_files/orc8r/protos/redis.proto
new file mode 100644
index 0000000..489cc0d
--- /dev/null
+++ b/proto_files/orc8r/protos/redis.proto
@@ -0,0 +1,16 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+package magma.orc8r;
+option go_package = "magma/orc8r/lib/go/protos";
+
+message RedisState {
+    bytes serialized_msg = 1;
+    uint64 version = 2;
+    bool is_garbage = 3;
+}
+
diff --git a/proto_files/orc8r/protos/service303.proto b/proto_files/orc8r/protos/service303.proto
new file mode 100644
index 0000000..143af45
--- /dev/null
+++ b/proto_files/orc8r/protos/service303.proto
@@ -0,0 +1,132 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+package magma.orc8r;
+
+import "orc8r/protos/common.proto";
+import "orc8r/protos/metricsd.proto";
+import "google/protobuf/wrappers.proto";
+
+option go_package = "magma/orc8r/lib/go/protos";
+
+// --------------------------------------------------------------------------
+// Service status messages
+// --------------------------------------------------------------------------
+
+message EnodebdStatus {
+  // For bools, parameter is not set if result can't be determined
+  google.protobuf.BoolValue enodeb_connected = 1;
+  google.protobuf.BoolValue opstate_enabled = 2;
+  google.protobuf.BoolValue rf_tx_on = 3;
+  google.protobuf.BoolValue gps_connected = 4;
+  google.protobuf.BoolValue ptp_connected = 5;
+  google.protobuf.BoolValue mme_connected = 6;
+  google.protobuf.BoolValue enodeb_configured = 7;
+  google.protobuf.FloatValue gps_latitude = 8;
+  google.protobuf.FloatValue gps_longitude = 9;
+  google.protobuf.BoolValue rf_tx_desired = 10;
+}
+
+message ServiceStatus {
+  // Metadata from the services that will be sent to the cloud through checkin
+  map<string, string> meta = 2;
+}
+
+message ServiceInfo {
+  string name = 1;
+
+  string version = 2;
+
+  enum ServiceState {
+    UNKNOWN = 0;
+    STARTING = 1;
+    ALIVE = 2;
+    STOPPING = 3;
+    STOPPED = 4;
+  }
+  ServiceState state = 3;
+
+  ServiceStatus status = 4;
+
+  // Gives information about whether the application is usable. Though the
+  // process may have started, the connections may not be set up. APP_HEALTHY in
+  // this case means the application is entirely usable
+  enum ApplicationHealth {
+    APP_UNKNOWN = 0;
+    APP_UNHEALTHY = 1;
+    APP_HEALTHY = 2;
+  }
+  ApplicationHealth health = 5;
+
+  // Time when the service was started (in seconds since epoch)
+  uint64 start_time_secs = 6;
+}
+
+message LogLevelMessage {
+    LogLevel level = 1;
+}
+
+message LogVerbosity {
+  int32 verbosity = 1;
+}
+
+message ReloadConfigResponse {
+  enum ReloadConfigResult {
+    RELOAD_UNKNOWN = 0;
+    RELOAD_SUCCESS = 1;
+    RELOAD_FAILURE = 2;
+    RELOAD_UNSUPPORTED = 3;
+  }
+  ReloadConfigResult result = 1;
+}
+
+message State {
+    // Type determines how the value is deserialized and validated on the cloud service side
+    string type = 1;
+    string deviceID = 2;
+    // Value contains the operational state json-serialized.
+    bytes value = 3;
+    uint64 version = 4;
+}
+
+message GetOperationalStatesResponse {
+  repeated State states = 1;
+}
+
+// --------------------------------------------------------------------------
+// Service303 interface definition.
+//
+// Service303 is named after fb303, which was named after TB-303
+// https://en.wikipedia.org/wiki/Roland_TB-303.
+//
+// The Service303 interface implements a set of functionalities which
+// all Magma services expose.
+// --------------------------------------------------------------------------
+service Service303 {
+
+  // Returns the service level info like name, version, state, status, etc.
+  //
+  rpc GetServiceInfo (Void) returns (ServiceInfo) {}
+
+  // Request to stop the service gracefully.
+  //
+  rpc StopService (Void) returns (Void) {}
+
+  // Collects metrics from the service
+  rpc GetMetrics (Void) returns (MetricsContainer) {}
+
+  // Set logging level
+  rpc SetLogLevel (LogLevelMessage) returns (Void) {}
+
+  // Set logging verbosity The larger, the more verbose. default 0
+  rpc SetLogVerbosity (LogVerbosity) returns (Void) {}
+
+  // Requests service reloads config files loaded on startup (<servicename>.yml)
+  rpc ReloadServiceConfig (Void) returns (ReloadConfigResponse) {}
+
+  // Returns the  operational states of devices managed by this service.
+  rpc GetOperationalStates (Void) returns (GetOperationalStatesResponse) {}
+}
diff --git a/proto_files/orc8r/protos/service_status.proto b/proto_files/orc8r/protos/service_status.proto
new file mode 100644
index 0000000..129d889
--- /dev/null
+++ b/proto_files/orc8r/protos/service_status.proto
@@ -0,0 +1,48 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+package magma.orc8r;
+
+option go_package = "magma/orc8r/lib/go/protos";
+
+// --------------------------------------------------------------------------
+// Service exit status
+// --------------------------------------------------------------------------
+
+message ServiceExitStatus {
+  // ServiceResult enumeration as defined in service "result" by systemd
+  enum ServiceResult {
+    UNUSED = 0;
+    SUCCESS = 1;
+    PROTOCOL = 2;
+    TIMEOUT = 3;
+    EXIT_CODE = 4;
+    SIGNAL = 5;
+    CORE_DUMP = 6;
+    WATCHDOG = 7;
+    START_LIMIT_HIT = 8;
+    RESOURCES = 9;
+  }
+  ServiceResult latest_service_result = 1;
+
+  // ExitCode enumeration as defined in service "result" by systemd
+  enum ExitCode {
+    UNUSED_EXIT_CODE = 0;
+    EXITED = 1;
+    KILLED = 2;
+    DUMPED = 3;
+  }
+  ExitCode latest_exit_code = 2;
+
+  // Optional return code returned by the service during exit
+  uint32 latest_rc = 3;
+
+  // Clean exit, e.g. SIGNKILL
+  uint32 num_clean_exits = 4;
+  // Unclean exit e.g. CORE_DUMP or non zero exit code.
+  uint32 num_fail_exits = 5;
+}
\ No newline at end of file
diff --git a/proto_files/orc8r/protos/streamer.proto b/proto_files/orc8r/protos/streamer.proto
new file mode 100644
index 0000000..ac4795b
--- /dev/null
+++ b/proto_files/orc8r/protos/streamer.proto
@@ -0,0 +1,59 @@
+// SPDX-FileCopyrightText: 2020 The Magma Authors.
+// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+syntax = "proto3";
+
+package magma.orc8r;
+
+import "google/protobuf/any.proto";
+
+option go_package = "magma/orc8r/lib/go/protos";
+
+// Streamer provides a pipeline for the cloud to push the updates to the
+// gateway as and when the update happens.
+//
+// The Streamer interface defines the semantics and consistency guarantees
+// between the cloud and the gateway while abstracting the details of how
+// it's implemented in the cloud and what the gateway does with the updates.
+//
+// - The gateways call the GetUpdates() streaming API with a StreamRequest
+//   indicating the stream name and the offset to continue streaming from.
+// - The cloud sends a stream of DataUpdateBatch containing a batch of updates.
+// - If resync is true, then the gateway can cleanup all its data and add
+//   all the keys (the batch is guaranteed to contain only unique keys).
+// - If resync is false, then the gateway can update the keys, or add new
+//   ones if the key is not already present.
+// - Key deletions are not yet supported (#15109350)
+service Streamer {
+  // GetUpdates streams config updates from the cloud.
+  // The RPC call would be kept open to push new updates as they happen.
+  rpc GetUpdates (StreamRequest) returns (stream DataUpdateBatch) {}
+}
+
+message StreamRequest {
+  string gatewayId = 1;
+  // stream_name to attach to.
+  // E.g., subscriberdb, config, etc.
+  string stream_name = 2;
+  // extra_args contain any extra data to send up with the stream request.
+  // This value will be different per stream provider.
+  google.protobuf.Any extra_args = 3;
+}
+
+message DataUpdateBatch {
+  // updates to config values
+  repeated DataUpdate updates = 1;
+  // resync is true iff the updates would be a snapshot of all the contents
+  // in the cloud.
+  bool resync = 2;
+}
+
+message DataUpdate {
+  // key is the unique key for each item
+  string key = 1;
+  // value can be file contents, protobuf serialized message, etc.
+  // For key deletions, the value field would be absent.
+  bytes value = 2;
+}