blob: c5e7d7bd11931e27756b5a25bf7746466bc87432 [file] [log] [blame]
Kim Kempf72cb33e2017-08-30 12:53:35 -07001/*
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*/
suhasgrao76e8f8c2017-07-12 16:24:33 +053016
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053017#include "bal_msg_type.grpc-c.h"
18#include "bal_osmsg.grpc-c.h"
19#include "bal_model_ids.grpc-c.h"
20#include "bal_obj.grpc-c.h"
21#include "bal_model_types.grpc-c.h"
22#include "bal_errno.grpc-c.h"
23#include "bal_indications.grpc-c.h"
24#include "bal.grpc-c.h"
25
suhasgrao76e8f8c2017-07-12 16:24:33 +053026/* Global definations */
27pthread_cond_t cv;
28pthread_mutex_t lock;
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053029unsigned int is_stub_reboot;
suhasgrao76e8f8c2017-07-12 16:24:33 +053030
31#define IND_USR_DAT_LEN 8
32#define IND_USR_DAT_VAL "brcmOLT"
33#define BALCLIENT "bal_client"
34#define BALSERVER "bal_server"
suhasgrao4b31f402017-07-31 00:01:54 +053035#define BAL_DEVICE_STR_LEN 20
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053036#define ASFVOLT_ERROR 1
37#define ASFVOLT_INFO 2
38#define ASFVOLT_DEBUG 3
suhasgrao76e8f8c2017-07-12 16:24:33 +053039
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053040typedef struct BalCoreIpInfo
41{
42 char bal_core_arg1[4];
43 char bal_core_ip_port[24];
44 char bal_core_arg2[4];
45 char bal_shared_lib_ip_port[24];
46}balCoreIpInfo;
47
suhasgrao76e8f8c2017-07-12 16:24:33 +053048/* A linked list (LL) node to store a queue entry */
49struct QNode
50{
suhasgrao4b31f402017-07-31 00:01:54 +053051 int obj_type;
52 char device_id[BAL_DEVICE_STR_LEN];
53 int status;
54 int intf_id;
55 int onu_id;
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053056 char vendor_id[BAL_DEVICE_STR_LEN];
57 char vendor_specific[BAL_DEVICE_STR_LEN];
suhasgrao4b31f402017-07-31 00:01:54 +053058 struct QNode *next;
suhasgrao76e8f8c2017-07-12 16:24:33 +053059};
60
suhasgrao4b31f402017-07-31 00:01:54 +053061
suhasgrao76e8f8c2017-07-12 16:24:33 +053062/* The queue, front stores the front node of LL and rear stores ths
suhasgrao4b31f402017-07-31 00:01:54 +053063 last node of LL */
suhasgrao76e8f8c2017-07-12 16:24:33 +053064typedef struct Queue
65{
suhasgrao4b31f402017-07-31 00:01:54 +053066 struct QNode *front, *rear;
suhasgrao76e8f8c2017-07-12 16:24:33 +053067}bal_queue;
68
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053069#define ASFVOLT_LOG(log_type, format, args...) \
70 if(log_type) \
71 {\
72 printf("File(%s): Line(%d): ", __FUNCTION__, __LINE__);\
73 printf(format, ## args);\
74 }
75
suhasgrao76e8f8c2017-07-12 16:24:33 +053076/* shared queue */
77bal_queue *shared_queue;
78
Rajeswara Rao9f1cea12017-10-10 18:25:29 +053079void create_stub_thread();
suhasgrao76e8f8c2017-07-12 16:24:33 +053080bal_queue *createQueue();
suhasgrao4b31f402017-07-31 00:01:54 +053081struct QNode* newNode(int objKey, int status, char *device_id);
82void enQueue(int objKey, struct QNode *temp);
suhasgrao76e8f8c2017-07-12 16:24:33 +053083struct QNode *deQueue();
Rajeswara Raof6b4e6c2017-08-31 17:26:27 +053084grpc_c_client_t *client;
85void stub_bal_init(BalInit *bal_init);