blob: ad530a345b5b6d8009c4eaef6058482e58977dda [file] [log] [blame]
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +05301/*
2** Copyright 2017-present Open Networking Foundation
3**
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
7**
8** http://www.apache.org/licenses/LICENSE-2.0
9**
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*/
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053016#include <signal.h>
17#include <stdio.h>
18#include <unistd.h>
19#include <sys/time.h>
20#include "bal_msg_type.grpc-c.h"
21#include "bal_osmsg.grpc-c.h"
22#include "bal_model_ids.grpc-c.h"
23#include "bal_obj.grpc-c.h"
24#include "bal_model_types.grpc-c.h"
25#include "bal_errno.grpc-c.h"
26#include "bal.grpc-c.h"
27
28#ifdef BAL_STUB
29#include "bal_stub.h"
30#else
31#include "asfvolt16_driver.h"
32#endif
33
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053034#include <unistd.h>
35#include <sys/reboot.h>
36
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053037/* Global varibles */
38balCoreIpInfo coreIpPortInfo;
39
40static grpc_c_server_t *test_server;
41
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053042static void sigint_handler (int x) {
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053043 grpc_c_server_destroy(test_server);
44 exit(0);
45}
46
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053047void is_grpc_write_pending(int return_value)
48{
49 if (return_value != GRPC_C_WRITE_OK)
50 {
51 if(return_value == GRPC_C_WRITE_PENDING)
52 {
53 /* TODO: Register call back with grpc-c which will give an indication whenever write was succussful */
54 ASFVOLT_LOG(ASFVOLT_INFO, "write(%d) is pending, sleep for 5 sec\n", return_value);
55 sleep(5);
56 }
57 else
58 {
59 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write %d \n", return_value);
60 }
61 }
62
63}
64
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053065/*
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053066 * This functions gets invoked whenever bal Heartbeat RPC gets called
67 */
68void bal__bal_api_heartbeat_cb(grpc_c_context_t *context)
69{
70 BalHeartbeat *bal_hb;
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053071 BalRebootState bal_reboot;
Rajeswara Raob2e441c2017-09-20 16:40:21 +053072 int ret_val;
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053073 /*
74 * Read incoming message into set_cfg
75 */
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053076 if (context->gcc_payload) {
77 context->gcc_stream->read(context, (void **)&bal_hb, 0);
78 }
79
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053080 bal_reboot_state__init(&bal_reboot);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053081
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053082 bal_reboot.has_is_reboot = 1;
83#ifndef BAL_STUB
84 bal_reboot.is_reboot = is_reboot;
85#else
86 bal_reboot.is_reboot = is_stub_reboot;
87#endif
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053088
89 /*
90 * Write reply back to the client
91 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053092 ret_val = context->gcc_stream->write(context, &bal_reboot, 0);
93 is_grpc_write_pending(ret_val);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053094
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053095 grpc_c_status_t status;
96 status.gcs_code = 0;
Rajeswara Raoa3efbca2017-09-08 18:01:16 +053097
98 /*
99 * Finish response for RPC
100 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530101 if (context->gcc_stream->finish(context, &status))
102 {
103 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status\n");
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530104 }
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530105}
106
107/*
108 * This functions gets invoked whenever Bal reboot gets called
109 */
110void bal__bal_api_reboot_cb(grpc_c_context_t *context)
111{
112 BalReboot *read_device;
113 BalErr bal_err;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530114 int ret_val;
115
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530116 /*
117 * Read incoming message into get_cfg
118 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530119 if (context->gcc_payload)
120 {
121 context->gcc_stream->read(context, (void **)&read_device, 0);
122 }
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530123
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530124 ASFVOLT_LOG(ASFVOLT_INFO, "Bal Server - Reboot : ======Entering Function Reboot ==============================\n");
125 ASFVOLT_LOG(ASFVOLT_INFO, "Bal Server - Reboot : Device ID is %s\n",read_device->device_id);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530126
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530127 /*
128 * send it to BAL
129 */
130
131 bal_err__init(&bal_err);
132
133 bal_err.err= 0;
134
135 /*
136 * Write reply back to the client
137 */
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530138 ret_val = context->gcc_stream->write(context, &bal_err, 0);
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530139 is_grpc_write_pending(ret_val);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530140
141 grpc_c_status_t status;
142 status.gcs_code = 0;
143
144 /*
145 * Finish response for RPC
146 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530147 if (context->gcc_stream->finish(context, &status))
148 {
149 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status\n");
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530150 }
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530151
152 system("shutdown -r now");
153 sleep(30); /* allow system to shutdown gracefully */
154 sync(); /* force shutdown if graceful did not work */
155 reboot(RB_AUTOBOOT);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530156}
157
158/*
159 * This functions gets invoked whenever Bal Stats gets called
160 */
161void bal__bal_cfg_stat_get_cb(grpc_c_context_t *context)
162{
163 BalInterfaceKey *read_stats;
Rajeswara Raob2e441c2017-09-20 16:40:21 +0530164 int ret_val;
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530165
166 /*
167 * Read incoming message into get_cfg
168 */
169 if (context->gcc_payload) {
170 context->gcc_stream->read(context, (void **)&read_stats, 0);
171 }
172
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530173 ASFVOLT_LOG(ASFVOLT_DEBUG, "Bal Server - Get Stats :======Entering Function Get Stats ============\n");
174 ASFVOLT_LOG(ASFVOLT_DEBUG, "Bal Server - Get Stats :NNI port is %d\n",read_stats->intf_id);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530175
176 BalInterfaceStat get_stats;
177 memset(&get_stats, 0, sizeof(BalInterfaceStat));
178 bal_interface_stat__init(&get_stats);
179
180 BalInterfaceStatData stat_data;
181 memset(&stat_data, 0, sizeof(BalInterfaceStatData));
182 bal_interface_stat_data__init(&stat_data);
183
184#ifndef BAL_STUB
185 /* Interface Type, Interface ID
186 stat_data - Statistics Data */
187 asfvolt16_bal_stats_get(read_stats->intf_type, read_stats->intf_id, &stat_data);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530188#else
189 stub_bal_stats_get(&stat_data);
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530190 ASFVOLT_LOG(ASFVOLT_DEBUG, "Bal Server - Get Stats In BalStubs : Got all the statistics\n");
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530191#endif
192
193 get_stats.data = &stat_data;
194
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530195 ret_val = context->gcc_stream->write(context, &get_stats, 0);
196 is_grpc_write_pending(ret_val);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530197
198 grpc_c_status_t status;
199 status.gcs_code = 0;
200
201 /*
202 * Finish response for RPC
203 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530204 if (context->gcc_stream->finish(context, &status))
205 {
206 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status\n");
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530207 }
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530208}
209
210/*
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530211 * This functions gets invoked whenever bal RPC gets called
212 */
213void bal__bal_cfg_get_cb(grpc_c_context_t *context)
214{
215 BalCfg *get_cfg;
216
217 /*
218 * Read incoming message into get_cfg
219 */
220 if (context->gcc_payload) {
221 context->gcc_stream->read(context, (void **)&get_cfg, 0);
222 }
223
224#ifndef BAL_STUB
225 //asfvolt16_bal_cfg_get(key, get_cfg);
226#endif
227}
228
229/*
230 * This functions gets invoked whenever bal RPC gets called
231 */
232void bal__bal_cfg_set_cb(grpc_c_context_t *context)
233{
234 BalCfg *set_cfg;
235 BalErr bal_err;
236 int ret_val = 0;
237
238 /*
239 * Read incoming message into set_cfg
240 */
241 if (context->gcc_payload) {
242 context->gcc_stream->read(context, (void **)&set_cfg, 0);
243 }
244
245 /*
246 * send it to BAL
247 */
248
249 bal_err__init(&bal_err);
250
251 bal_err.err= 0;
252
253 /*
254 * Write reply back to the client
255 */
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530256
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530257 ret_val = context->gcc_stream->write(context, &bal_err, 0);
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530258 is_grpc_write_pending(ret_val);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530259
260 grpc_c_status_t status;
261 status.gcs_code = 0;
262
263 /*
264 * Finish response for RPC
265 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530266 if (context->gcc_stream->finish(context, &status))
267 {
268 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530269 }
270
271#ifdef BAL_STUB
272 pthread_mutex_lock(&lock);
273
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530274 struct QNode *temp = newNode(set_cfg->hdr->obj_type,
275 BAL_ERRNO__BAL_ERR_OK,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530276 set_cfg->device_id);
277
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530278 switch(set_cfg->hdr->obj_type)
279 {
280 case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
281 {
282 ASFVOLT_LOG(ASFVOLT_INFO, "\n***************************************************\n");
283 ASFVOLT_LOG(ASFVOLT_INFO, "Received Access Terminal Configuration msg\n");
284 ASFVOLT_LOG(ASFVOLT_INFO, "***************************************************\n");
285 }
286 break;
287 case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
288 {
289 ASFVOLT_LOG(ASFVOLT_INFO, "\n***************************************************\n");
290 ASFVOLT_LOG(ASFVOLT_INFO, "Received PON Interface Configuration msg\n");
291 ASFVOLT_LOG(ASFVOLT_INFO, "***************************************************\n");
292 temp->intf_id = set_cfg->interface->key->intf_id;
293 ASFVOLT_LOG(ASFVOLT_INFO, "Pon ID = %d\n", temp->intf_id);
294 }
295 break;
296 case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
297 {
298 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
299 ASFVOLT_LOG(ASFVOLT_INFO, "Received ONU Activation msg\n");
300 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
301 temp->intf_id = set_cfg->terminal->key->intf_id;
302 temp->onu_id = set_cfg->terminal->key->sub_term_id;
303 memset(temp->vendor_id, 0, BAL_DEVICE_STR_LEN);
304 memcpy(temp->vendor_id,
305 set_cfg->terminal->data->serial_number->vendor_id,
306 strlen(set_cfg->terminal->data->serial_number->vendor_id));
307 memset(temp->vendor_specific, 0, BAL_DEVICE_STR_LEN);
308 memcpy(temp->vendor_specific,
309 set_cfg->terminal->data->serial_number->vendor_specific,
310 strlen(set_cfg->terminal->data->serial_number->vendor_specific));
311 }
312 break;
313 case BAL_OBJ_ID__BAL_OBJ_ID_TM_SCHED:
314 {
315 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
316 ASFVOLT_LOG(ASFVOLT_INFO, "Received TM schedule msg\n");
317 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
318 }
319 break;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530320 case BAL_OBJ_ID__BAL_OBJ_ID_PACKET:
321 {
322 switch(set_cfg->packet->key->packet_send_dest->type)
323 {
324 case BAL_DEST_TYPE__BAL_DEST_TYPE_ITU_OMCI_CHANNEL:
325 {
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530326 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
327 ASFVOLT_LOG(ASFVOLT_INFO, "Received OMCI msg\n");
328 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530329 temp->intf_id = set_cfg->terminal->key->intf_id;
330 temp->onu_id = set_cfg->terminal->key->sub_term_id;
331 }
332 break;
333 default:
334 {
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530335 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
336 ASFVOLT_LOG(ASFVOLT_INFO, "Dest type invalid\n");
337 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530338 }
339 break;
340 }
341 }
342 break;
343 default:
344 {
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530345 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
346 ASFVOLT_LOG(ASFVOLT_INFO, "Received Invalid msg type === %d \n", set_cfg->hdr->obj_type);
347 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
348 pthread_mutex_unlock(&lock);
349 return;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530350 }
351 break;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530352 }
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530353 enQueue(set_cfg->hdr->obj_type, temp);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530354 pthread_mutex_unlock(&lock);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530355 sleep(2);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530356 pthread_cond_signal(&cv);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530357#else
358 if(BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL == set_cfg->hdr->obj_type)
359 {
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530360 sleep(5); /* enable this if running with gdb */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530361 }
362 asfvolt16_bal_cfg_set(set_cfg);
363#endif
364}
365
366
367/*
368 * This functions gets invoked whenever bal clear RPC gets called
369 */
370void bal__bal_cfg_clear_cb(grpc_c_context_t *context)
371{
372 BalKey *clear_key;
373
374 /*
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530375 * Read incoming message into clear_key
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530376 */
377 if (context->gcc_payload) {
378 context->gcc_stream->read(context, (void **)&clear_key, 0);
379 }
380
381#ifndef BAL_STUB
382 asfvolt16_bal_cfg_clear(clear_key);
383#endif
384}
385
386
387/*
388 * This functions gets invoked whenever bal Init RPC gets called
389 */
390void bal__bal_api_init_cb(grpc_c_context_t *context)
391{
392 BalInit *bal_init;
393 BalErr bal_err;
394 int ret_val;
395
396 /*
397 * Read incoming message into set_cfg
398 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530399 if (context->gcc_payload)
400 {
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530401 context->gcc_stream->read(context, (void **)&bal_init, 0);
402 }
403
404 /*
405 * send it to BAL
406 */
407
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530408 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
409 ASFVOLT_LOG(ASFVOLT_INFO, "Received API Init msg\n");
410 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530411
412 bal_err__init(&bal_err);
413
414 bal_err.err= 0;
415
416 /*
417 * Write reply back to the client
418 */
419 ret_val = context->gcc_stream->write(context, &bal_err, 0);
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530420 is_grpc_write_pending(ret_val);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530421
422 grpc_c_status_t status;
423 status.gcs_code = 0;
424
425 /*
426 * Finish response for RPC
427 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530428 if (context->gcc_stream->finish(context, &status))
429 {
430 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530431 }
432
433#ifndef BAL_STUB
434 asfvolt16_bal_init(bal_init, &coreIpPortInfo);
435#else
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530436 ASFVOLT_LOG(ASFVOLT_INFO, "\nRecevied IP Address == %s \n", bal_init->voltha_adapter_ip_port);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530437 stub_bal_init(bal_init);
438#endif
439
440}
441
442
443/*
444 * This functions gets invoked whenever bal finish RPC gets called
445 */
446void bal__bal_api_finish_cb(grpc_c_context_t *context)
447{
448#if 0
449 void *finish_init;
450
451 /*
452 * Read incoming message into set_cfg
453 */
454 if (context->gcc_payload) {
455 context->gcc_stream->read(context, (void **)&finish_init);
456 }
457#endif
458}
459
460#if 0
461/*
462 * This functions gets invoked whenever bal finish RPC gets called
463 */
464void bal_ind__bal_ind_info_cb(grpc_c_context_t *context)
465{
466#if 0
467 void *finish_init;
468
469 /*
470 * Read incoming message into set_cfg
471 */
472 if (context->gcc_payload) {
473 context->gcc_stream->read(context, (void **)&finish_init);
474 }
475#endif
476}
477#endif
478
479void bal_ind__bal_acc_term_ind_cb(grpc_c_context_t *context)
480{
481}
482void bal_ind__bal_acc_term_oper_sts_cng_ind_cb(grpc_c_context_t *context)
483{
484}
485void bal_ind__bal_flow_oper_sts_cng_cb(grpc_c_context_t *context)
486{
487}
488void bal_ind__bal_flow_ind_cb(grpc_c_context_t *context)
489{
490}
491void bal_ind__bal_group_ind_cb(grpc_c_context_t *context)
492{
493}
494void bal_ind__bal_iface_oper_sts_cng_cb(grpc_c_context_t *context)
495{
496}
497void bal_ind__bal_iface_los_cb(grpc_c_context_t *context)
498{
499}
500void bal_ind__bal_iface_ind_cb(grpc_c_context_t *context)
501{
502}
503void bal_ind__bal_iface_stat_cb(grpc_c_context_t *context)
504{
505}
506void bal_ind__bal_subs_term_oper_sts_cng_cb(grpc_c_context_t *context)
507{
508}
509void bal_ind__bal_subs_term_discovery_ind_cb(grpc_c_context_t *context)
510{
511}
512void bal_ind__bal_subs_term_alarm_ind_cb(grpc_c_context_t *context)
513{
514}
515void bal_ind__bal_subs_term_dgi_ind_cb(grpc_c_context_t *context)
516{
517}
518void bal_ind__bal_subs_term_ind_cb(grpc_c_context_t *context)
519{
520}
521void bal_ind__bal_tm_queue_ind_info_cb(grpc_c_context_t *context)
522{
523}
524void bal_ind__bal_tm_sched_ind_info_cb(grpc_c_context_t *context)
525{
526}
527void bal_ind__bal_pkt_bearer_channel_rx_ind_cb(grpc_c_context_t *context)
528{
529}
530void bal_ind__bal_pkt_omci_channel_rx_ind_cb(grpc_c_context_t *context)
531{
532}
533void bal_ind__bal_pkt_ieee_oam_channel_rx_ind_cb(grpc_c_context_t *context)
534{
535}
A R Karthick1d251032017-09-06 09:38:34 -0700536
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530537
538/*
539 * Takes socket path as argument
540 */
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530541int main (int argc, char **argv)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530542{
543 int i = 0;
544 grpc_c_server_t *server = NULL;
545
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530546 if (argc < 6)
547 {
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530548 fprintf(stderr, "Missing socket path argument\n");
549 exit(1);
550 }
551
552 strcpy(coreIpPortInfo.bal_core_arg1, argv[2] /*, strlen(argv[2])*/);
553 strcpy(coreIpPortInfo.bal_core_ip_port, argv[3]/*, strlen(argv[3])*/);
554 strcpy(coreIpPortInfo.bal_core_arg2, argv[4]/*, strlen(argv[4])*/);
555 strcpy(coreIpPortInfo.bal_shared_lib_ip_port, argv[5]/*, strlen(argv[5])*/);
556
557 signal(SIGINT, sigint_handler);
558 /*
559 * Initialize grpc-c library to be used with vanilla gRPC
560 */
561 grpc_c_init(GRPC_THREADS, NULL);
562
563 /*
564 * Create server object
565 */
566 test_server = grpc_c_server_create(argv[1]);
567
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530568 if (test_server == NULL)
569 {
570 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to create server\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530571 exit(1);
572 }
573
574 /*
575 * Initialize greeter service
576 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530577 ASFVOLT_LOG(ASFVOLT_INFO, "\nvoltha_bal_driver running.....\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530578 bal__service_init(test_server);
579
580 /*
581 * Start server
582 */
583 grpc_c_server_start(test_server);
584
585#ifdef BAL_STUB
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530586 create_stub_thread();
587#endif
588
589 /*
590 * Blocks server to wait to completion
591 */
592 grpc_c_server_wait(test_server);
593
594 /* code added for example Makefile to compile grpc-c along with edgecore driver */
595 bal__service_init(server);
596
597}