blob: 796c755111b3e8d79f9f8cd8851b245043a2789c [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
Rajeswara Rao92e3fd42017-10-26 10:47:03 +0530184 BalInterfaceKey stat_key;
185 memset(&stat_key, 0, sizeof(BalInterfaceKey));
186 bal_interface_key__init(&stat_key);
187
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530188#ifndef BAL_STUB
189 /* Interface Type, Interface ID
190 stat_data - Statistics Data */
Rajeswara Rao92e3fd42017-10-26 10:47:03 +0530191 asfvolt16_bal_stats_get(read_stats->intf_type, read_stats->intf_id, &stat_data, &stat_key);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530192#else
193 stub_bal_stats_get(&stat_data);
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530194 ASFVOLT_LOG(ASFVOLT_DEBUG, "Bal Server - Get Stats In BalStubs : Got all the statistics\n");
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530195#endif
196
197 get_stats.data = &stat_data;
Rajeswara Rao92e3fd42017-10-26 10:47:03 +0530198 get_stats.key = &stat_key;
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530199
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530200 ret_val = context->gcc_stream->write(context, &get_stats, 0);
201 is_grpc_write_pending(ret_val);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530202
203 grpc_c_status_t status;
204 status.gcs_code = 0;
205
206 /*
207 * Finish response for RPC
208 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530209 if (context->gcc_stream->finish(context, &status))
210 {
211 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status\n");
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530212 }
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530213}
214
215/*
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530216 * This functions gets invoked whenever bal RPC gets called
217 */
218void bal__bal_cfg_get_cb(grpc_c_context_t *context)
219{
220 BalCfg *get_cfg;
221
222 /*
223 * Read incoming message into get_cfg
224 */
225 if (context->gcc_payload) {
226 context->gcc_stream->read(context, (void **)&get_cfg, 0);
227 }
228
229#ifndef BAL_STUB
230 //asfvolt16_bal_cfg_get(key, get_cfg);
231#endif
232}
233
234/*
235 * This functions gets invoked whenever bal RPC gets called
236 */
237void bal__bal_cfg_set_cb(grpc_c_context_t *context)
238{
239 BalCfg *set_cfg;
240 BalErr bal_err;
241 int ret_val = 0;
242
243 /*
244 * Read incoming message into set_cfg
245 */
246 if (context->gcc_payload) {
247 context->gcc_stream->read(context, (void **)&set_cfg, 0);
248 }
249
250 /*
251 * send it to BAL
252 */
253
254 bal_err__init(&bal_err);
255
256 bal_err.err= 0;
257
258 /*
259 * Write reply back to the client
260 */
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530261
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530262 ret_val = context->gcc_stream->write(context, &bal_err, 0);
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530263 is_grpc_write_pending(ret_val);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530264
265 grpc_c_status_t status;
266 status.gcs_code = 0;
267
268 /*
269 * Finish response for RPC
270 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530271 if (context->gcc_stream->finish(context, &status))
272 {
273 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530274 }
275
276#ifdef BAL_STUB
277 pthread_mutex_lock(&lock);
278
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530279 struct QNode *temp = newNode(set_cfg->hdr->obj_type,
280 BAL_ERRNO__BAL_ERR_OK,
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530281 set_cfg->device_id);
282
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530283 switch(set_cfg->hdr->obj_type)
284 {
285 case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
286 {
287 ASFVOLT_LOG(ASFVOLT_INFO, "\n***************************************************\n");
288 ASFVOLT_LOG(ASFVOLT_INFO, "Received Access Terminal Configuration msg\n");
289 ASFVOLT_LOG(ASFVOLT_INFO, "***************************************************\n");
290 }
291 break;
292 case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
293 {
294 ASFVOLT_LOG(ASFVOLT_INFO, "\n***************************************************\n");
295 ASFVOLT_LOG(ASFVOLT_INFO, "Received PON Interface Configuration msg\n");
296 ASFVOLT_LOG(ASFVOLT_INFO, "***************************************************\n");
297 temp->intf_id = set_cfg->interface->key->intf_id;
298 ASFVOLT_LOG(ASFVOLT_INFO, "Pon ID = %d\n", temp->intf_id);
299 }
300 break;
301 case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
302 {
303 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
304 ASFVOLT_LOG(ASFVOLT_INFO, "Received ONU Activation msg\n");
305 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
306 temp->intf_id = set_cfg->terminal->key->intf_id;
307 temp->onu_id = set_cfg->terminal->key->sub_term_id;
308 memset(temp->vendor_id, 0, BAL_DEVICE_STR_LEN);
309 memcpy(temp->vendor_id,
310 set_cfg->terminal->data->serial_number->vendor_id,
311 strlen(set_cfg->terminal->data->serial_number->vendor_id));
312 memset(temp->vendor_specific, 0, BAL_DEVICE_STR_LEN);
313 memcpy(temp->vendor_specific,
314 set_cfg->terminal->data->serial_number->vendor_specific,
315 strlen(set_cfg->terminal->data->serial_number->vendor_specific));
316 }
317 break;
318 case BAL_OBJ_ID__BAL_OBJ_ID_TM_SCHED:
319 {
320 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
321 ASFVOLT_LOG(ASFVOLT_INFO, "Received TM schedule msg\n");
322 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
323 }
324 break;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530325 case BAL_OBJ_ID__BAL_OBJ_ID_PACKET:
326 {
327 switch(set_cfg->packet->key->packet_send_dest->type)
328 {
329 case BAL_DEST_TYPE__BAL_DEST_TYPE_ITU_OMCI_CHANNEL:
330 {
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530331 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
332 ASFVOLT_LOG(ASFVOLT_INFO, "Received OMCI msg\n");
333 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530334 temp->intf_id = set_cfg->terminal->key->intf_id;
335 temp->onu_id = set_cfg->terminal->key->sub_term_id;
336 }
337 break;
338 default:
339 {
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530340 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
341 ASFVOLT_LOG(ASFVOLT_INFO, "Dest type invalid\n");
342 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530343 }
344 break;
345 }
346 }
347 break;
348 default:
349 {
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530350 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
351 ASFVOLT_LOG(ASFVOLT_INFO, "Received Invalid msg type === %d \n", set_cfg->hdr->obj_type);
352 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
353 pthread_mutex_unlock(&lock);
354 return;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530355 }
356 break;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530357 }
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530358 enQueue(set_cfg->hdr->obj_type, temp);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530359 pthread_mutex_unlock(&lock);
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530360 sleep(2);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530361 pthread_cond_signal(&cv);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530362#else
363 if(BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL == set_cfg->hdr->obj_type)
364 {
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530365 sleep(5); /* enable this if running with gdb */
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530366 }
367 asfvolt16_bal_cfg_set(set_cfg);
368#endif
369}
370
371
372/*
373 * This functions gets invoked whenever bal clear RPC gets called
374 */
375void bal__bal_cfg_clear_cb(grpc_c_context_t *context)
376{
377 BalKey *clear_key;
378
379 /*
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530380 * Read incoming message into clear_key
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530381 */
382 if (context->gcc_payload) {
383 context->gcc_stream->read(context, (void **)&clear_key, 0);
384 }
385
386#ifndef BAL_STUB
387 asfvolt16_bal_cfg_clear(clear_key);
388#endif
389}
390
391
392/*
393 * This functions gets invoked whenever bal Init RPC gets called
394 */
395void bal__bal_api_init_cb(grpc_c_context_t *context)
396{
397 BalInit *bal_init;
398 BalErr bal_err;
399 int ret_val;
400
401 /*
402 * Read incoming message into set_cfg
403 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530404 if (context->gcc_payload)
405 {
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530406 context->gcc_stream->read(context, (void **)&bal_init, 0);
407 }
408
409 /*
410 * send it to BAL
411 */
412
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530413 ASFVOLT_LOG(ASFVOLT_INFO, "\n*****************************************************\n");
414 ASFVOLT_LOG(ASFVOLT_INFO, "Received API Init msg\n");
415 ASFVOLT_LOG(ASFVOLT_INFO, "*****************************************************\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530416
417 bal_err__init(&bal_err);
418
419 bal_err.err= 0;
420
421 /*
422 * Write reply back to the client
423 */
424 ret_val = context->gcc_stream->write(context, &bal_err, 0);
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530425 is_grpc_write_pending(ret_val);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530426
427 grpc_c_status_t status;
428 status.gcs_code = 0;
429
430 /*
431 * Finish response for RPC
432 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530433 if (context->gcc_stream->finish(context, &status))
434 {
435 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530436 }
437
438#ifndef BAL_STUB
439 asfvolt16_bal_init(bal_init, &coreIpPortInfo);
440#else
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530441 ASFVOLT_LOG(ASFVOLT_INFO, "\nRecevied IP Address == %s \n", bal_init->voltha_adapter_ip_port);
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530442 stub_bal_init(bal_init);
443#endif
444
445}
446
447
448/*
449 * This functions gets invoked whenever bal finish RPC gets called
450 */
451void bal__bal_api_finish_cb(grpc_c_context_t *context)
452{
453#if 0
454 void *finish_init;
455
456 /*
457 * Read incoming message into set_cfg
458 */
459 if (context->gcc_payload) {
460 context->gcc_stream->read(context, (void **)&finish_init);
461 }
462#endif
463}
464
465#if 0
466/*
467 * This functions gets invoked whenever bal finish RPC gets called
468 */
469void bal_ind__bal_ind_info_cb(grpc_c_context_t *context)
470{
471#if 0
472 void *finish_init;
473
474 /*
475 * Read incoming message into set_cfg
476 */
477 if (context->gcc_payload) {
478 context->gcc_stream->read(context, (void **)&finish_init);
479 }
480#endif
481}
482#endif
483
484void bal_ind__bal_acc_term_ind_cb(grpc_c_context_t *context)
485{
486}
487void bal_ind__bal_acc_term_oper_sts_cng_ind_cb(grpc_c_context_t *context)
488{
489}
490void bal_ind__bal_flow_oper_sts_cng_cb(grpc_c_context_t *context)
491{
492}
493void bal_ind__bal_flow_ind_cb(grpc_c_context_t *context)
494{
495}
496void bal_ind__bal_group_ind_cb(grpc_c_context_t *context)
497{
498}
499void bal_ind__bal_iface_oper_sts_cng_cb(grpc_c_context_t *context)
500{
501}
502void bal_ind__bal_iface_los_cb(grpc_c_context_t *context)
503{
504}
505void bal_ind__bal_iface_ind_cb(grpc_c_context_t *context)
506{
507}
508void bal_ind__bal_iface_stat_cb(grpc_c_context_t *context)
509{
510}
511void bal_ind__bal_subs_term_oper_sts_cng_cb(grpc_c_context_t *context)
512{
513}
514void bal_ind__bal_subs_term_discovery_ind_cb(grpc_c_context_t *context)
515{
516}
517void bal_ind__bal_subs_term_alarm_ind_cb(grpc_c_context_t *context)
518{
519}
520void bal_ind__bal_subs_term_dgi_ind_cb(grpc_c_context_t *context)
521{
522}
523void bal_ind__bal_subs_term_ind_cb(grpc_c_context_t *context)
524{
525}
526void bal_ind__bal_tm_queue_ind_info_cb(grpc_c_context_t *context)
527{
528}
529void bal_ind__bal_tm_sched_ind_info_cb(grpc_c_context_t *context)
530{
531}
532void bal_ind__bal_pkt_bearer_channel_rx_ind_cb(grpc_c_context_t *context)
533{
534}
535void bal_ind__bal_pkt_omci_channel_rx_ind_cb(grpc_c_context_t *context)
536{
537}
538void bal_ind__bal_pkt_ieee_oam_channel_rx_ind_cb(grpc_c_context_t *context)
539{
540}
A R Karthick1d251032017-09-06 09:38:34 -0700541
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530542
543/*
544 * Takes socket path as argument
545 */
Rajeswara Raoa3efbca2017-09-08 18:01:16 +0530546int main (int argc, char **argv)
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530547{
548 int i = 0;
549 grpc_c_server_t *server = NULL;
550
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530551 if (argc < 6)
552 {
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530553 fprintf(stderr, "Missing socket path argument\n");
554 exit(1);
555 }
556
557 strcpy(coreIpPortInfo.bal_core_arg1, argv[2] /*, strlen(argv[2])*/);
558 strcpy(coreIpPortInfo.bal_core_ip_port, argv[3]/*, strlen(argv[3])*/);
559 strcpy(coreIpPortInfo.bal_core_arg2, argv[4]/*, strlen(argv[4])*/);
560 strcpy(coreIpPortInfo.bal_shared_lib_ip_port, argv[5]/*, strlen(argv[5])*/);
561
562 signal(SIGINT, sigint_handler);
563 /*
564 * Initialize grpc-c library to be used with vanilla gRPC
565 */
566 grpc_c_init(GRPC_THREADS, NULL);
567
568 /*
569 * Create server object
570 */
571 test_server = grpc_c_server_create(argv[1]);
572
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530573 if (test_server == NULL)
574 {
575 ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to create server\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530576 exit(1);
577 }
578
579 /*
580 * Initialize greeter service
581 */
Rajeswara Rao9f1cea12017-10-10 18:25:29 +0530582 ASFVOLT_LOG(ASFVOLT_INFO, "\nvoltha_bal_driver running.....\n");
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530583 bal__service_init(test_server);
584
585 /*
586 * Start server
587 */
588 grpc_c_server_start(test_server);
589
590#ifdef BAL_STUB
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +0530591 create_stub_thread();
592#endif
593
594 /*
595 * Blocks server to wait to completion
596 */
597 grpc_c_server_wait(test_server);
598
599 /* code added for example Makefile to compile grpc-c along with edgecore driver */
600 bal__service_init(server);
601
602}