Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1 | /* |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 3 | |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 7 | |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 9 | |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 16 | |
| 17 | #include <iostream> |
| 18 | #include <memory> |
| 19 | #include <string> |
nick | 7be062f | 2018-05-25 17:52:56 -0400 | [diff] [blame] | 20 | #include <time.h> |
Nicolas Palpacuer | 0f19b1a | 2018-06-07 17:29:31 -0400 | [diff] [blame] | 21 | #include <pthread.h> |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 22 | |
| 23 | #include "Queue.h" |
| 24 | #include <iostream> |
| 25 | #include <sstream> |
| 26 | |
| 27 | #include "server.h" |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 28 | #include "core.h" |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 29 | #include "state.h" |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 30 | |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 31 | #include <grpc++/grpc++.h> |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 32 | #include <voltha_protos/openolt.grpc.pb.h> |
| 33 | #include <voltha_protos/tech_profile.grpc.pb.h> |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 34 | |
| 35 | using grpc::Server; |
| 36 | using grpc::ServerBuilder; |
| 37 | using grpc::ServerContext; |
| 38 | using grpc::ServerWriter; |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 39 | using grpc::Status; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 40 | |
| 41 | const char *serverPort = "0.0.0.0:9191"; |
nick | 7be062f | 2018-05-25 17:52:56 -0400 | [diff] [blame] | 42 | int signature; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 43 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 44 | Queue<openolt::Indication> oltIndQ; |
| 45 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 46 | class OpenoltService final : public openolt::Openolt::Service { |
| 47 | |
Nicolas Palpacuer | e3fc0d2 | 2018-08-02 16:51:05 -0400 | [diff] [blame] | 48 | Status DisableOlt( |
| 49 | ServerContext* context, |
| 50 | const openolt::Empty* request, |
| 51 | openolt::Empty* response) override { |
| 52 | return Disable_(); |
| 53 | } |
| 54 | |
| 55 | Status ReenableOlt( |
| 56 | ServerContext* context, |
| 57 | const openolt::Empty* request, |
| 58 | openolt::Empty* response) override { |
| 59 | return Reenable_(); |
| 60 | } |
| 61 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 62 | Status ActivateOnu( |
| 63 | ServerContext* context, |
| 64 | const openolt::Onu* request, |
| 65 | openolt::Empty* response) override { |
| 66 | return ActivateOnu_( |
| 67 | request->intf_id(), |
| 68 | request->onu_id(), |
| 69 | ((request->serial_number()).vendor_id()).c_str(), |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 70 | ((request->serial_number()).vendor_specific()).c_str(), request->pir()); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Jonathan Davis | 70c2181 | 2018-07-19 15:32:10 -0400 | [diff] [blame] | 73 | Status DeactivateOnu( |
| 74 | ServerContext* context, |
| 75 | const openolt::Onu* request, |
| 76 | openolt::Empty* response) override { |
| 77 | return DeactivateOnu_( |
| 78 | request->intf_id(), |
| 79 | request->onu_id(), |
| 80 | ((request->serial_number()).vendor_id()).c_str(), |
| 81 | ((request->serial_number()).vendor_specific()).c_str()); |
| 82 | } |
| 83 | |
| 84 | Status DeleteOnu( |
| 85 | ServerContext* context, |
| 86 | const openolt::Onu* request, |
| 87 | openolt::Empty* response) override { |
| 88 | return DeleteOnu_( |
| 89 | request->intf_id(), |
| 90 | request->onu_id(), |
| 91 | ((request->serial_number()).vendor_id()).c_str(), |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 92 | ((request->serial_number()).vendor_specific()).c_str()); |
Jonathan Davis | 70c2181 | 2018-07-19 15:32:10 -0400 | [diff] [blame] | 93 | } |
| 94 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 95 | Status OmciMsgOut( |
| 96 | ServerContext* context, |
| 97 | const openolt::OmciMsg* request, |
| 98 | openolt::Empty* response) override { |
| 99 | return OmciMsgOut_( |
| 100 | request->intf_id(), |
| 101 | request->onu_id(), |
| 102 | request->pkt()); |
| 103 | } |
| 104 | |
Shad Ansari | f2e27a4 | 2018-04-26 22:37:38 +0000 | [diff] [blame] | 105 | Status OnuPacketOut( |
| 106 | ServerContext* context, |
| 107 | const openolt::OnuPacket* request, |
| 108 | openolt::Empty* response) override { |
| 109 | return OnuPacketOut_( |
| 110 | request->intf_id(), |
| 111 | request->onu_id(), |
Craig Lutgen | 967a1d0 | 2018-11-27 10:41:51 -0600 | [diff] [blame] | 112 | request->port_no(), |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 113 | request->gemport_id(), |
Shad Ansari | f2e27a4 | 2018-04-26 22:37:38 +0000 | [diff] [blame] | 114 | request->pkt()); |
| 115 | } |
| 116 | |
Nicolas Palpacuer | b78def4 | 2018-06-07 12:55:26 -0400 | [diff] [blame] | 117 | Status UplinkPacketOut( |
| 118 | ServerContext* context, |
| 119 | const openolt::UplinkPacket* request, |
| 120 | openolt::Empty* response) override { |
| 121 | return UplinkPacketOut_( |
| 122 | request->intf_id(), |
| 123 | request->pkt()); |
| 124 | } |
| 125 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 126 | Status FlowAdd( |
| 127 | ServerContext* context, |
| 128 | const openolt::Flow* request, |
| 129 | openolt::Empty* response) override { |
| 130 | return FlowAdd_( |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 131 | request->access_intf_id(), |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 132 | request->onu_id(), |
Craig Lutgen | 967a1d0 | 2018-11-27 10:41:51 -0600 | [diff] [blame] | 133 | request->uni_id(), |
| 134 | request->port_no(), |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 135 | request->flow_id(), |
| 136 | request->flow_type(), |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 137 | request->alloc_id(), |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 138 | request->network_intf_id(), |
| 139 | request->gemport_id(), |
| 140 | request->classifier(), |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 141 | request->action(), |
Craig Lutgen | 967a1d0 | 2018-11-27 10:41:51 -0600 | [diff] [blame] | 142 | request->priority(), |
Burak Gurdag | c78b9e1 | 2019-11-29 11:14:51 +0000 | [diff] [blame] | 143 | request->cookie(), |
Burak Gurdag | 2f2618c | 2020-04-23 13:20:30 +0000 | [diff] [blame] | 144 | request->group_id(), |
| 145 | request->tech_profile_id()); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Nicolas Palpacuer | edfaa0c | 2018-07-05 15:05:27 -0400 | [diff] [blame] | 148 | Status FlowRemove( |
| 149 | ServerContext* context, |
| 150 | const openolt::Flow* request, |
| 151 | openolt::Empty* response) override { |
| 152 | return FlowRemove_( |
| 153 | request->flow_id(), |
| 154 | request->flow_type()); |
| 155 | } |
| 156 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 157 | Status EnableIndication( |
| 158 | ServerContext* context, |
| 159 | const ::openolt::Empty* request, |
| 160 | ServerWriter<openolt::Indication>* writer) override { |
Shad Ansari | edef213 | 2018-08-10 22:14:50 +0000 | [diff] [blame] | 161 | |
nick | 7be062f | 2018-05-25 17:52:56 -0400 | [diff] [blame] | 162 | std::cout << "Connection to Voltha established. Indications enabled" |
| 163 | << std::endl; |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 164 | |
Nicolas Palpacuer | fbc0d7d | 2018-08-23 14:46:42 -0400 | [diff] [blame] | 165 | if (state.previsouly_connected()) { |
| 166 | // Reconciliation / recovery case |
Nicolas Palpacuer | 135ce81 | 2018-08-30 09:04:34 -0400 | [diff] [blame] | 167 | std::cout << "Reconciliation / Recovery case" << std::endl; |
Nicolas Palpacuer | fbc0d7d | 2018-08-23 14:46:42 -0400 | [diff] [blame] | 168 | if (state.is_activated()){ |
| 169 | // Adding extra olt indication of current state |
| 170 | openolt::Indication ind; |
| 171 | openolt::OltIndication* oltInd = new openolt::OltIndication(); |
| 172 | if (state.is_activated()) { |
| 173 | oltInd->set_oper_state("up"); |
Nicolas Palpacuer | 135ce81 | 2018-08-30 09:04:34 -0400 | [diff] [blame] | 174 | std::cout << "Extra OLT indication up" << std::endl; |
Nicolas Palpacuer | fbc0d7d | 2018-08-23 14:46:42 -0400 | [diff] [blame] | 175 | } else { |
| 176 | oltInd->set_oper_state("down"); |
Nicolas Palpacuer | 135ce81 | 2018-08-30 09:04:34 -0400 | [diff] [blame] | 177 | std::cout << "Extra OLT indication down" << std::endl; |
Nicolas Palpacuer | fbc0d7d | 2018-08-23 14:46:42 -0400 | [diff] [blame] | 178 | } |
| 179 | ind.set_allocated_olt_ind(oltInd); |
| 180 | oltIndQ.push(ind); |
| 181 | } |
| 182 | } |
| 183 | |
Shad Ansari | edef213 | 2018-08-10 22:14:50 +0000 | [diff] [blame] | 184 | state.connect(); |
| 185 | |
| 186 | while (state.is_connected()) { |
Girish Gowdra | 9646105 | 2019-11-22 20:13:59 +0530 | [diff] [blame] | 187 | std::pair<openolt::Indication, bool> ind = oltIndQ.pop(COLLECTION_PERIOD*1000, 1000); |
Shad Ansari | edef213 | 2018-08-10 22:14:50 +0000 | [diff] [blame] | 188 | if (ind.second == false) { |
| 189 | /* timeout - do lower priority periodic stuff like stats */ |
| 190 | stats_collection(); |
| 191 | continue; |
| 192 | } |
| 193 | openolt::Indication oltInd = ind.first; |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 194 | bool isConnected = writer->Write(oltInd); |
Nicolas Palpacuer | 58d252c | 2018-06-06 11:19:04 -0400 | [diff] [blame] | 195 | if (!isConnected) { |
| 196 | //Lost connectivity to this Voltha instance |
| 197 | //Put the indication back in the queue for next connecting instance |
| 198 | oltIndQ.push(oltInd); |
Shad Ansari | edef213 | 2018-08-10 22:14:50 +0000 | [diff] [blame] | 199 | state.disconnect(); |
Nicolas Palpacuer | 58d252c | 2018-06-06 11:19:04 -0400 | [diff] [blame] | 200 | } |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 201 | //oltInd.release_olt_ind() |
| 202 | } |
Nicolas Palpacuer | 3cad49d | 2018-07-02 14:03:24 -0400 | [diff] [blame] | 203 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 204 | return Status::OK; |
| 205 | } |
nick | 7be062f | 2018-05-25 17:52:56 -0400 | [diff] [blame] | 206 | |
| 207 | Status HeartbeatCheck( |
| 208 | ServerContext* context, |
| 209 | const openolt::Empty* request, |
| 210 | openolt::Heartbeat* response) override { |
| 211 | response->set_heartbeat_signature(signature); |
| 212 | |
| 213 | return Status::OK; |
| 214 | } |
Nicolas Palpacuer | 0f19b1a | 2018-06-07 17:29:31 -0400 | [diff] [blame] | 215 | |
Nicolas Palpacuer | 05ea0ea | 2018-07-06 11:47:21 -0400 | [diff] [blame] | 216 | Status EnablePonIf( |
| 217 | ServerContext* context, |
| 218 | const openolt::Interface* request, |
| 219 | openolt::Empty* response) override { |
| 220 | |
| 221 | return EnablePonIf_(request->intf_id()); |
| 222 | } |
| 223 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 224 | /*Status GetPonIf( |
Shad Ansari | cb20878 | 2019-07-02 20:53:40 +0000 | [diff] [blame] | 225 | ServerContext* context, |
| 226 | const openolt::Interface* request, |
| 227 | openolt::IntfIndication* response) override { |
| 228 | |
| 229 | // TODO - Return the oper status of the pon interface |
| 230 | return Status::OK; |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 231 | }*/ |
Shad Ansari | cb20878 | 2019-07-02 20:53:40 +0000 | [diff] [blame] | 232 | |
Nicolas Palpacuer | 05ea0ea | 2018-07-06 11:47:21 -0400 | [diff] [blame] | 233 | Status DisablePonIf( |
| 234 | ServerContext* context, |
| 235 | const openolt::Interface* request, |
| 236 | openolt::Empty* response) override { |
| 237 | |
| 238 | return DisablePonIf_(request->intf_id()); |
| 239 | } |
Nicolas Palpacuer | 0f19b1a | 2018-06-07 17:29:31 -0400 | [diff] [blame] | 240 | |
Nicolas Palpacuer | 65d0447 | 2018-09-06 15:53:37 -0400 | [diff] [blame] | 241 | Status CollectStatistics( |
| 242 | ServerContext* context, |
| 243 | const openolt::Empty* request, |
| 244 | openolt::Empty* response) override { |
| 245 | |
| 246 | stats_collection(); |
| 247 | |
| 248 | return Status::OK; |
| 249 | } |
| 250 | |
Nicolas Palpacuer | 4518066 | 2018-08-02 14:01:51 -0400 | [diff] [blame] | 251 | Status Reboot( |
| 252 | ServerContext* context, |
| 253 | const openolt::Empty* request, |
| 254 | openolt::Empty* response) override { |
| 255 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 256 | uint8_t ret = system("shutdown -r now"); |
Nicolas Palpacuer | 4518066 | 2018-08-02 14:01:51 -0400 | [diff] [blame] | 257 | |
| 258 | return Status::OK; |
| 259 | |
| 260 | } |
| 261 | |
Nicolas Palpacuer | dff9679 | 2018-09-06 14:59:32 -0400 | [diff] [blame] | 262 | Status GetDeviceInfo( |
| 263 | ServerContext* context, |
| 264 | const openolt::Empty* request, |
| 265 | openolt::DeviceInfo* response) override { |
| 266 | |
| 267 | GetDeviceInfo_(response); |
| 268 | |
| 269 | return Status::OK; |
| 270 | |
| 271 | } |
| 272 | |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 273 | Status CreateTrafficSchedulers( |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 274 | ServerContext* context, |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 275 | const tech_profile::TrafficSchedulers* request, |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 276 | openolt::Empty* response) override { |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 277 | CreateTrafficSchedulers_(request); |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 278 | return Status::OK; |
| 279 | }; |
Nicolas Palpacuer | dff9679 | 2018-09-06 14:59:32 -0400 | [diff] [blame] | 280 | |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 281 | Status RemoveTrafficSchedulers( |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 282 | ServerContext* context, |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 283 | const tech_profile::TrafficSchedulers* request, |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 284 | openolt::Empty* response) override { |
Girish Gowdru | c8ed2ef | 2019-02-13 08:18:44 -0800 | [diff] [blame] | 285 | RemoveTrafficSchedulers_(request); |
| 286 | return Status::OK; |
| 287 | }; |
| 288 | |
| 289 | Status CreateTrafficQueues( |
| 290 | ServerContext* context, |
| 291 | const tech_profile::TrafficQueues* request, |
| 292 | openolt::Empty* response) override { |
| 293 | CreateTrafficQueues_(request); |
| 294 | return Status::OK; |
| 295 | }; |
| 296 | |
| 297 | Status RemoveTrafficQueues( |
| 298 | ServerContext* context, |
| 299 | const tech_profile::TrafficQueues* request, |
| 300 | openolt::Empty* response) override { |
| 301 | RemoveTrafficQueues_(request); |
Girish Gowdru | 7c4ec2d | 2018-10-25 00:29:54 -0700 | [diff] [blame] | 302 | return Status::OK; |
| 303 | }; |
Nicolas Palpacuer | 4518066 | 2018-08-02 14:01:51 -0400 | [diff] [blame] | 304 | |
Burak Gurdag | c78b9e1 | 2019-11-29 11:14:51 +0000 | [diff] [blame] | 305 | Status PerformGroupOperation( |
| 306 | ServerContext* context, |
| 307 | const openolt::Group* request, |
| 308 | openolt::Empty* response) override { |
| 309 | return PerformGroupOperation_(request); |
| 310 | }; |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 311 | |
Burak Gurdag | eb4ca2e | 2020-06-15 07:48:26 +0000 | [diff] [blame^] | 312 | Status DeleteGroup( |
| 313 | ServerContext* context, |
| 314 | const openolt::Group* request, |
| 315 | openolt::Empty* response) override { |
| 316 | return DeleteGroup_(request->group_id()); |
| 317 | }; |
| 318 | |
Jason Huang | 5d9ab1a | 2020-04-15 16:53:49 +0800 | [diff] [blame] | 319 | Status OnuItuPonAlarmSet( |
| 320 | ServerContext* context, |
| 321 | const openolt::OnuItuPonAlarm* request, |
| 322 | openolt::Empty* response) override { |
| 323 | return OnuItuPonAlarmSet_(request); |
| 324 | }; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 325 | }; |
| 326 | |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 327 | void RunServer(int argc, char** argv) { |
| 328 | std::string ipAddress = "0.0.0.0"; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 329 | |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 330 | for (int i = 1; i < argc; ++i) { |
| 331 | if(strcmp(argv[i-1], "--interface") == 0 || (strcmp(argv[i-1], "--intf") == 0)) { |
| 332 | ipAddress = get_ip_address(argv[i]); |
| 333 | break; |
| 334 | } |
| 335 | } |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 336 | |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 337 | serverPort = ipAddress.append(":9191").c_str(); |
| 338 | OpenoltService service; |
| 339 | std::string server_address(serverPort); |
| 340 | ServerBuilder builder; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 341 | |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 342 | builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); |
| 343 | builder.RegisterService(&service); |
nick | 7be062f | 2018-05-25 17:52:56 -0400 | [diff] [blame] | 344 | |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 345 | std::unique_ptr<Server> server(builder.BuildAndStart()); |
nick | 7be062f | 2018-05-25 17:52:56 -0400 | [diff] [blame] | 346 | |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 347 | time_t now; |
| 348 | time(&now); |
| 349 | signature = (int)now; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 350 | |
Thiyagarajan Subramani | 03bc66f | 2020-04-01 15:58:53 +0530 | [diff] [blame] | 351 | std::cout << "Server listening on " << server_address |
| 352 | << ", connection signature : " << signature << std::endl; |
| 353 | |
| 354 | server->Wait(); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 355 | } |