Kim Kempf | 72cb33e | 2017-08-30 12:53:35 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 16 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 17 | #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 | |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 26 | /* Global definations */ |
| 27 | pthread_cond_t cv; |
| 28 | pthread_mutex_t lock; |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 29 | unsigned int is_stub_reboot; |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 30 | |
| 31 | #define IND_USR_DAT_LEN 8 |
| 32 | #define IND_USR_DAT_VAL "brcmOLT" |
| 33 | #define BALCLIENT "bal_client" |
| 34 | #define BALSERVER "bal_server" |
suhasgrao | 4b31f40 | 2017-07-31 00:01:54 +0530 | [diff] [blame] | 35 | #define BAL_DEVICE_STR_LEN 20 |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 36 | #define ASFVOLT_ERROR 1 |
| 37 | #define ASFVOLT_INFO 2 |
| 38 | #define ASFVOLT_DEBUG 3 |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 39 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 40 | typedef 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 | |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 48 | /* A linked list (LL) node to store a queue entry */ |
| 49 | struct QNode |
| 50 | { |
suhasgrao | 4b31f40 | 2017-07-31 00:01:54 +0530 | [diff] [blame] | 51 | int obj_type; |
| 52 | char device_id[BAL_DEVICE_STR_LEN]; |
| 53 | int status; |
| 54 | int intf_id; |
| 55 | int onu_id; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 56 | char vendor_id[BAL_DEVICE_STR_LEN]; |
| 57 | char vendor_specific[BAL_DEVICE_STR_LEN]; |
suhasgrao | 4b31f40 | 2017-07-31 00:01:54 +0530 | [diff] [blame] | 58 | struct QNode *next; |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 59 | }; |
| 60 | |
suhasgrao | 4b31f40 | 2017-07-31 00:01:54 +0530 | [diff] [blame] | 61 | |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 62 | /* The queue, front stores the front node of LL and rear stores ths |
suhasgrao | 4b31f40 | 2017-07-31 00:01:54 +0530 | [diff] [blame] | 63 | last node of LL */ |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 64 | typedef struct Queue |
| 65 | { |
suhasgrao | 4b31f40 | 2017-07-31 00:01:54 +0530 | [diff] [blame] | 66 | struct QNode *front, *rear; |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 67 | }bal_queue; |
| 68 | |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 69 | #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 | |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 76 | /* shared queue */ |
| 77 | bal_queue *shared_queue; |
| 78 | |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 79 | void create_stub_thread(); |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 80 | bal_queue *createQueue(); |
suhasgrao | 4b31f40 | 2017-07-31 00:01:54 +0530 | [diff] [blame] | 81 | struct QNode* newNode(int objKey, int status, char *device_id); |
| 82 | void enQueue(int objKey, struct QNode *temp); |
suhasgrao | 76e8f8c | 2017-07-12 16:24:33 +0530 | [diff] [blame] | 83 | struct QNode *deQueue(); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 84 | grpc_c_client_t *client; |
| 85 | void stub_bal_init(BalInit *bal_init); |