Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [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 | */ |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 16 | #include <signal.h> |
| 17 | #include <stdio.h> |
root | 85905d1 | 2018-03-21 16:18:51 +0530 | [diff] [blame] | 18 | #include <string.h> |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 19 | #include <unistd.h> |
root | 5be94e5 | 2018-02-15 22:30:14 +0530 | [diff] [blame] | 20 | #include <string.h> |
| 21 | #include <stdlib.h> |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 22 | #include <stdbool.h> |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 23 | #include <sys/time.h> |
| 24 | #include "bal_msg_type.grpc-c.h" |
| 25 | #include "bal_osmsg.grpc-c.h" |
| 26 | #include "bal_model_ids.grpc-c.h" |
| 27 | #include "bal_obj.grpc-c.h" |
| 28 | #include "bal_model_types.grpc-c.h" |
| 29 | #include "bal_errno.grpc-c.h" |
| 30 | #include "bal.grpc-c.h" |
root | 5be94e5 | 2018-02-15 22:30:14 +0530 | [diff] [blame] | 31 | #include "asfvolt.grpc-c.h" |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 32 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 33 | #include "asfvolt16_driver.h" |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 34 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 35 | #include <sys/reboot.h> |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 36 | #include "bal_indications_queue.h" |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 37 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 38 | /* Global varibles */ |
| 39 | balCoreIpInfo coreIpPortInfo; |
| 40 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 41 | /* extern variables*/ |
| 42 | list_node *bal_ind_queue_tail = NULL; |
| 43 | list_node *bal_ind_queue_head = NULL; |
| 44 | pthread_mutex_t bal_ind_queue_lock; |
| 45 | unsigned int num_of_nodes = 0; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 46 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 47 | /* static variables*/ |
| 48 | static grpc_c_server_t *test_server; |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 49 | static void sigint_handler (int x) { |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 50 | grpc_c_server_destroy(test_server); |
| 51 | exit(0); |
| 52 | } |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 53 | static bool is_init_done = false; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 54 | |
root | 5be94e5 | 2018-02-15 22:30:14 +0530 | [diff] [blame] | 55 | /*MACRO Definitions*/ |
root | 85905d1 | 2018-03-21 16:18:51 +0530 | [diff] [blame] | 56 | #define ASFVOLT_FIELD_LEN 200 |
root | 5be94e5 | 2018-02-15 22:30:14 +0530 | [diff] [blame] | 57 | |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 58 | void is_grpc_write_pending(int return_value) |
| 59 | { |
| 60 | if (return_value != GRPC_C_WRITE_OK) |
| 61 | { |
| 62 | if(return_value == GRPC_C_WRITE_PENDING) |
| 63 | { |
| 64 | /* TODO: Register call back with grpc-c which will give an indication whenever write was succussful */ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 65 | ASFVOLT_LOG(ASFVOLT_INFO, "write(%d) is pending, sleep for 5 sec", return_value); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 66 | sleep(5); |
| 67 | } |
| 68 | else |
| 69 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 70 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write %d", return_value); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 71 | } |
| 72 | } |
| 73 | |
| 74 | } |
| 75 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 76 | /* |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 77 | * This functions gets invoked whenever bal Heartbeat RPC gets called |
| 78 | */ |
| 79 | void bal__bal_api_heartbeat_cb(grpc_c_context_t *context) |
| 80 | { |
| 81 | BalHeartbeat *bal_hb; |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 82 | BalRebootState bal_reboot; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 83 | int ret_val; |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 84 | /* |
| 85 | * Read incoming message into set_cfg |
| 86 | */ |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 87 | if (context->gcc_payload) { |
| 88 | context->gcc_stream->read(context, (void **)&bal_hb, 0); |
| 89 | } |
| 90 | |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 91 | bal_reboot_state__init(&bal_reboot); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 92 | |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 93 | bal_reboot.has_is_reboot = 1; |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 94 | bal_reboot.is_reboot = is_reboot; |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 95 | |
| 96 | /* |
| 97 | * Write reply back to the client |
| 98 | */ |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 99 | ret_val = context->gcc_stream->write(context, &bal_reboot, -1); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 100 | is_grpc_write_pending(ret_val); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 101 | |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 102 | grpc_c_status_t status; |
| 103 | status.gcs_code = 0; |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * Finish response for RPC |
| 107 | */ |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 108 | if (context->gcc_stream->finish(context, &status)) |
| 109 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 110 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 111 | } |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /* |
| 115 | * This functions gets invoked whenever Bal reboot gets called |
| 116 | */ |
| 117 | void bal__bal_api_reboot_cb(grpc_c_context_t *context) |
| 118 | { |
| 119 | BalReboot *read_device; |
| 120 | BalErr bal_err; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 121 | int ret_val; |
| 122 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 123 | /* |
| 124 | * Read incoming message into get_cfg |
| 125 | */ |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 126 | if (context->gcc_payload) |
| 127 | { |
| 128 | context->gcc_stream->read(context, (void **)&read_device, 0); |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 129 | ASFVOLT_LOG(ASFVOLT_INFO, "Bal Server - Reboot : Device ID is %s",read_device->device_id); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 130 | } |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 131 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 132 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 133 | /* |
| 134 | * send it to BAL |
| 135 | */ |
| 136 | |
| 137 | bal_err__init(&bal_err); |
| 138 | |
| 139 | bal_err.err= 0; |
| 140 | |
| 141 | /* |
| 142 | * Write reply back to the client |
| 143 | */ |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 144 | ret_val = context->gcc_stream->write(context, &bal_err, -1); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 145 | is_grpc_write_pending(ret_val); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 146 | |
| 147 | grpc_c_status_t status; |
| 148 | status.gcs_code = 0; |
| 149 | |
| 150 | /* |
| 151 | * Finish response for RPC |
| 152 | */ |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 153 | if (context->gcc_stream->finish(context, &status)) |
| 154 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 155 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 156 | } |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 157 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 158 | ret_val = system("shutdown -r now"); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 159 | sleep(30); /* allow system to shutdown gracefully */ |
| 160 | sync(); /* force shutdown if graceful did not work */ |
| 161 | reboot(RB_AUTOBOOT); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | /* |
root | 5be94e5 | 2018-02-15 22:30:14 +0530 | [diff] [blame] | 165 | This function reads the specified field from the 'onldump -o' command. |
| 166 | If the field was successfully read, it returns the field value. |
| 167 | If it failed to read the field, then null charecter is returned |
| 168 | */ |
| 169 | char* asfvolt_read_sysinfo(char* field_name, char* field_val) |
| 170 | { |
| 171 | FILE *fp; |
| 172 | /* Prepare the command*/ |
| 173 | char command[150]; |
| 174 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 175 | snprintf(command, sizeof command, "bash -l -c \"onlpdump -s\" | perl -ne 'print $1 if /%s: (\\S+)/'", field_name); |
root | 5be94e5 | 2018-02-15 22:30:14 +0530 | [diff] [blame] | 176 | /* Open the command for reading. */ |
| 177 | fp = popen(command, "r"); |
| 178 | if (fp == NULL) { |
| 179 | /*The client has to check for a Null mac address in this case*/ |
| 180 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to query the mac address"); |
| 181 | return field_val; |
| 182 | } |
| 183 | |
| 184 | /*Read the field value*/ |
| 185 | if (fp) { |
| 186 | fread(field_val, ASFVOLT_FIELD_LEN, 1, fp); |
| 187 | pclose(fp); |
| 188 | } |
| 189 | return field_val; |
| 190 | } |
| 191 | |
| 192 | /* |
| 193 | * This functions gets invoked whenever AsfvoltGetSystemInfo RPC gets called |
| 194 | */ |
| 195 | void asfvolt__asfvolt_get_system_info_cb(grpc_c_context_t *context) |
| 196 | { |
| 197 | BalDefault *dummy; |
| 198 | AsfSystemInfo asf_system_info; |
| 199 | char product_name[ASFVOLT_FIELD_LEN] = "\0"; |
| 200 | char part_num[ASFVOLT_FIELD_LEN] = "\0"; |
| 201 | char serial_num[ASFVOLT_FIELD_LEN] = "\0"; |
| 202 | char mac_address[ASFVOLT_FIELD_LEN] = "\0"; |
| 203 | char mac_range[ASFVOLT_FIELD_LEN] = "\0"; |
| 204 | char manufacturer[ASFVOLT_FIELD_LEN] = "\0"; |
| 205 | char manufacturer_date[ASFVOLT_FIELD_LEN] = "\0"; |
| 206 | char vendor[ASFVOLT_FIELD_LEN] = "\0"; |
| 207 | char platform_name[ASFVOLT_FIELD_LEN] = "\0"; |
| 208 | char label_revision[ASFVOLT_FIELD_LEN] = "\0"; |
| 209 | char coutry_code[ASFVOLT_FIELD_LEN] = "\0"; |
| 210 | char diag_version[ASFVOLT_FIELD_LEN] = "\0"; |
| 211 | char onie_version[ASFVOLT_FIELD_LEN] = "\0"; |
| 212 | int ret_val; |
| 213 | |
| 214 | if (context->gcc_payload) { |
| 215 | context->gcc_stream->read(context, (void **)&dummy, 0); |
| 216 | } |
| 217 | |
| 218 | asf_system_info__init(&asf_system_info); |
| 219 | |
| 220 | asf_system_info.product_name = asfvolt_read_sysinfo("Product Name", product_name); |
| 221 | asf_system_info.part_num = asfvolt_read_sysinfo("Part Number", part_num); |
| 222 | asf_system_info.serial_num = asfvolt_read_sysinfo("Serial Number", serial_num); |
| 223 | asf_system_info.mac_address = asfvolt_read_sysinfo("MAC", mac_address); |
| 224 | asf_system_info.mac_range = asfvolt_read_sysinfo("MAC Range", mac_range); |
| 225 | asf_system_info.manufacturer = asfvolt_read_sysinfo("Manufacturer", manufacturer); |
| 226 | asf_system_info.manufacture_date = asfvolt_read_sysinfo("Manufacture Date", manufacturer_date); |
| 227 | asf_system_info.vendor = asfvolt_read_sysinfo("Vendor", vendor); |
| 228 | asf_system_info.platform_name = asfvolt_read_sysinfo("Platform Name", platform_name); |
| 229 | asf_system_info.label_revision = asfvolt_read_sysinfo("Label Revision", label_revision); |
| 230 | asf_system_info.country_code = asfvolt_read_sysinfo("Country Code", coutry_code); |
| 231 | asf_system_info.diag_version = asfvolt_read_sysinfo("Diag Version", diag_version); |
| 232 | asf_system_info.onie_version = asfvolt_read_sysinfo("ONIE Version", onie_version); |
| 233 | |
| 234 | /* |
| 235 | * Write reply back to the client |
| 236 | */ |
| 237 | ret_val = context->gcc_stream->write(context, &asf_system_info, -1); |
| 238 | is_grpc_write_pending(ret_val); |
| 239 | |
| 240 | grpc_c_status_t status; |
| 241 | status.gcs_code = 0; |
| 242 | |
| 243 | /* |
| 244 | * Finish response for RPC |
| 245 | */ |
| 246 | if (context->gcc_stream->finish(context, &status)) |
| 247 | { |
| 248 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | /* |
root | 85905d1 | 2018-03-21 16:18:51 +0530 | [diff] [blame] | 253 | This function reads the SFP presence map information from 'onlpdump -p' system command |
| 254 | and returns a bitmap with the presence information. |
| 255 | */ |
| 256 | unsigned int asfvolt_read_sfp_presence_bitmap(void) |
| 257 | { |
| 258 | char command[150]; |
| 259 | char sfp_presence_output[ASFVOLT_FIELD_LEN]; |
| 260 | unsigned int sfp_presence_bitmap = 0; |
| 261 | char delim[2] = " "; |
| 262 | char *field = NULL; |
| 263 | FILE *fp; |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 264 | snprintf(command, sizeof command, "bash -l -c \"onlpdump -p\" | perl -ne 'print $1 if /Presence: ([0-9 ]+)/'"); |
root | 85905d1 | 2018-03-21 16:18:51 +0530 | [diff] [blame] | 265 | /* Open the command for reading. */ |
| 266 | fp = popen(command, "r"); |
| 267 | if (fp == NULL) { |
| 268 | /*The client has to check for a Null mac address in this case*/ |
| 269 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to query the sfp presence map"); |
| 270 | return sfp_presence_bitmap; |
| 271 | } |
| 272 | |
| 273 | /*Read the field value*/ |
| 274 | fread(sfp_presence_output, ASFVOLT_FIELD_LEN, 1, fp); |
| 275 | pclose(fp); |
| 276 | |
| 277 | field = strtok(sfp_presence_output, delim); |
| 278 | while (field != NULL) { |
| 279 | sfp_presence_bitmap |= (1 << atoi(field)); |
| 280 | field = strtok(NULL, delim); |
| 281 | } |
| 282 | |
| 283 | return sfp_presence_bitmap; |
| 284 | } |
| 285 | |
| 286 | /* |
| 287 | * This functions gets invoked whenever AsfvoltGetSfpPresenceBitmap RPC gets called |
| 288 | */ |
| 289 | void asfvolt__asfvolt_get_sfp_presence_bitmap_cb(grpc_c_context_t *context) |
| 290 | { |
| 291 | BalDefault *dummy; |
| 292 | AsfSfpPresenceBitmap sfp_presence_bitmap; |
| 293 | int ret_val; |
| 294 | |
| 295 | if (context->gcc_payload) { |
| 296 | context->gcc_stream->read(context, (void **)&dummy, 0); |
| 297 | } |
| 298 | |
| 299 | asf_sfp_presence_bitmap__init(&sfp_presence_bitmap); |
| 300 | |
| 301 | sfp_presence_bitmap.bitmap = asfvolt_read_sfp_presence_bitmap(); |
| 302 | sfp_presence_bitmap.has_bitmap = true; |
| 303 | |
| 304 | /* |
| 305 | * Write reply back to the client |
| 306 | */ |
| 307 | ret_val = context->gcc_stream->write(context, &sfp_presence_bitmap, -1); |
| 308 | is_grpc_write_pending(ret_val); |
| 309 | |
| 310 | grpc_c_status_t status; |
| 311 | status.gcs_code = 0; |
| 312 | |
| 313 | /* |
| 314 | * Finish response for RPC |
| 315 | */ |
| 316 | if (context->gcc_stream->finish(context, &status)) |
| 317 | { |
| 318 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | /* |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 323 | * This functions gets invoked whenever Bal Stats gets called |
| 324 | */ |
| 325 | void bal__bal_cfg_stat_get_cb(grpc_c_context_t *context) |
| 326 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 327 | BalInterfaceKey *read_stats = 0; |
Rajeswara Rao | b2e441c | 2017-09-20 16:40:21 +0530 | [diff] [blame] | 328 | int ret_val; |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 329 | |
| 330 | /* |
| 331 | * Read incoming message into get_cfg |
| 332 | */ |
| 333 | if (context->gcc_payload) { |
| 334 | context->gcc_stream->read(context, (void **)&read_stats, 0); |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 335 | ASFVOLT_LOG(ASFVOLT_DEBUG, "Bal Server - Get Stats :NNI port is %d",read_stats->intf_id); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 336 | } |
| 337 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 338 | |
| 339 | BalInterfaceStat get_stats; |
| 340 | memset(&get_stats, 0, sizeof(BalInterfaceStat)); |
| 341 | bal_interface_stat__init(&get_stats); |
| 342 | |
| 343 | BalInterfaceStatData stat_data; |
| 344 | memset(&stat_data, 0, sizeof(BalInterfaceStatData)); |
| 345 | bal_interface_stat_data__init(&stat_data); |
| 346 | |
Rajeswara Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 347 | BalInterfaceKey stat_key; |
| 348 | memset(&stat_key, 0, sizeof(BalInterfaceKey)); |
| 349 | bal_interface_key__init(&stat_key); |
| 350 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 351 | /* Interface Type, Interface ID |
| 352 | stat_data - Statistics Data */ |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 353 | if ((read_stats) && (is_init_done == true)) { |
| 354 | asfvolt16_bal_stats_get(read_stats->intf_type, read_stats->intf_id, &stat_data, &stat_key); |
| 355 | } |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 356 | |
| 357 | get_stats.data = &stat_data; |
Rajeswara Rao | 92e3fd4 | 2017-10-26 10:47:03 +0530 | [diff] [blame] | 358 | get_stats.key = &stat_key; |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 359 | |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 360 | ret_val = context->gcc_stream->write(context, &get_stats, -1); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 361 | is_grpc_write_pending(ret_val); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 362 | |
| 363 | grpc_c_status_t status; |
| 364 | status.gcs_code = 0; |
| 365 | |
| 366 | /* |
| 367 | * Finish response for RPC |
| 368 | */ |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 369 | if (context->gcc_stream->finish(context, &status)) |
| 370 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 371 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 372 | } |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 373 | } |
| 374 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 375 | void bal_cfg_get__free_mem_sub_term_cfg_get(BalCfg *balCfgRsp) |
| 376 | { |
| 377 | free(balCfgRsp->terminal->data->password); |
| 378 | free(balCfgRsp->terminal->data->registration_id); |
| 379 | free(balCfgRsp->terminal->data->serial_number->vendor_id); |
| 380 | free(balCfgRsp->terminal->data->serial_number->vendor_specific); |
| 381 | free(balCfgRsp->terminal->data->serial_number); |
| 382 | } |
| 383 | |
| 384 | void bal_cfg_get__free_mem(BalCfg *balCfgRsp) |
| 385 | { |
| 386 | switch (balCfgRsp->hdr->obj_type) |
| 387 | { |
| 388 | case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL: |
| 389 | break; |
| 390 | |
| 391 | case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE: |
| 392 | break; |
| 393 | |
| 394 | case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL: |
| 395 | bal_cfg_get__free_mem_sub_term_cfg_get(balCfgRsp); |
| 396 | break; |
| 397 | |
| 398 | default: |
| 399 | break; |
| 400 | } |
| 401 | } |
| 402 | |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 403 | /* |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 404 | * This functions gets invoked whenever bal RPC gets called |
| 405 | */ |
| 406 | void bal__bal_cfg_get_cb(grpc_c_context_t *context) |
| 407 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 408 | BalKey *bal_key = 0; |
| 409 | int ret_val; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 410 | |
| 411 | /* |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 412 | * Read incoming message into bal_key |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 413 | */ |
| 414 | if (context->gcc_payload) { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 415 | context->gcc_stream->read(context, (void **)&bal_key, 0); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 416 | } |
| 417 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 418 | /* |
| 419 | * send it to BAL |
| 420 | */ |
| 421 | BalCfg get_cfg_resp; |
| 422 | memset(&get_cfg_resp, 0, sizeof(BalCfg)); |
| 423 | bal_cfg__init(&get_cfg_resp); |
| 424 | |
| 425 | BalObj hdr_cfg; |
| 426 | memset(&hdr_cfg, 0, sizeof(BalObj)); |
| 427 | bal_obj__init(&hdr_cfg); |
| 428 | get_cfg_resp.hdr = &hdr_cfg; |
| 429 | |
| 430 | BalCommMsgHdr comm_hdr; |
| 431 | memset(&comm_hdr, 0, sizeof(BalCommMsgHdr)); |
| 432 | bal_comm_msg_hdr__init(&comm_hdr); |
| 433 | get_cfg_resp.hdr->comm_hdr = &comm_hdr; |
| 434 | |
| 435 | if (bal_key) { |
| 436 | switch(bal_key->hdr->obj_type) |
| 437 | { |
| 438 | case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL: |
| 439 | { |
| 440 | ASFVOLT_LOG(ASFVOLT_ERROR, "Bal Get For Access Terminal Received\n"); |
| 441 | |
| 442 | get_cfg_resp.obj_case = BAL_CFG__OBJ_CFG; |
| 443 | |
| 444 | get_cfg_resp.hdr->obj_type = BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL; |
| 445 | |
| 446 | BalAccessTerminalCfg access_term_cfg; |
| 447 | memset(&access_term_cfg, 0, sizeof(BalAccessTerminalCfg)); |
| 448 | bal_access_terminal_cfg__init(&access_term_cfg); |
| 449 | get_cfg_resp.cfg = &access_term_cfg; |
| 450 | |
| 451 | BalAccessTerminalCfgData access_term_cfg_data; |
| 452 | memset(&access_term_cfg_data, 0, sizeof(BalAccessTerminalCfgData)); |
| 453 | bal_access_terminal_cfg_data__init(&access_term_cfg_data); |
| 454 | get_cfg_resp.cfg->data = &access_term_cfg_data; |
| 455 | |
| 456 | BalTopology access_term_cfg_data_topology; |
| 457 | memset(&access_term_cfg_data_topology, 0, sizeof(BalTopology)); |
| 458 | bal_topology__init(&access_term_cfg_data_topology); |
| 459 | get_cfg_resp.cfg->data->topology = &access_term_cfg_data_topology; |
| 460 | |
| 461 | BalSwVersion access_term_cfg_data_sw_version; |
| 462 | memset(&access_term_cfg_data_sw_version, 0, sizeof(BalSwVersion)); |
| 463 | bal_sw_version__init(&access_term_cfg_data_sw_version); |
| 464 | get_cfg_resp.cfg->data->sw_version = &access_term_cfg_data_sw_version; |
| 465 | |
| 466 | BalAccessTerminalKey access_term_key; |
| 467 | memset(&access_term_key, 0, sizeof(BalAccessTerminalKey)); |
| 468 | bal_access_terminal_key__init(&access_term_key); |
| 469 | get_cfg_resp.cfg->key = &access_term_key; |
| 470 | |
| 471 | if (is_init_done == true) { |
| 472 | asfvolt16_bal_cfg_get(&get_cfg_resp); |
| 473 | } |
| 474 | } |
| 475 | break; |
| 476 | |
| 477 | case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE: |
| 478 | { |
| 479 | BalInterfaceCfg intf_cfg; |
| 480 | memset(&intf_cfg, 0, sizeof(BalInterfaceCfg)); |
| 481 | bal_interface_cfg__init(&intf_cfg); |
| 482 | get_cfg_resp.interface = &intf_cfg; |
| 483 | |
| 484 | BalInterfaceCfgData intf_cfg_data; |
| 485 | memset(&intf_cfg_data, 0, sizeof(BalInterfaceCfgData)); |
| 486 | bal_interface_cfg_data__init(&intf_cfg_data); |
| 487 | get_cfg_resp.interface->data = &intf_cfg_data; |
| 488 | |
| 489 | BalInterfaceKey intf_key; |
| 490 | memset(&intf_key, 0, sizeof(BalInterfaceKey)); |
| 491 | bal_interface_key__init(&intf_key); |
| 492 | get_cfg_resp.interface->key = &intf_key; |
| 493 | |
| 494 | if (is_init_done == true) { |
| 495 | asfvolt16_bal_cfg_get(&get_cfg_resp); |
| 496 | } |
| 497 | } |
| 498 | break; |
| 499 | |
| 500 | case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL: |
| 501 | { |
| 502 | ASFVOLT_LOG(ASFVOLT_ERROR, "Bal Get For Subscriber Terminal Received\n"); |
| 503 | |
| 504 | get_cfg_resp.obj_case = BAL_CFG__OBJ_TERMINAL; |
| 505 | |
| 506 | get_cfg_resp.hdr->obj_type = BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL; |
| 507 | |
| 508 | BalSubscriberTerminalCfg sub_term_cfg; |
| 509 | memset(&sub_term_cfg, 0, sizeof(BalSubscriberTerminalCfg)); |
| 510 | bal_subscriber_terminal_cfg__init(&sub_term_cfg); |
| 511 | get_cfg_resp.terminal = &sub_term_cfg; |
| 512 | |
| 513 | BalSubscriberTerminalCfgData sub_term_cfg_data; |
| 514 | memset(&sub_term_cfg_data, 0, sizeof(BalSubscriberTerminalCfgData)); |
| 515 | bal_subscriber_terminal_cfg_data__init(&sub_term_cfg_data); |
| 516 | get_cfg_resp.terminal->data = &sub_term_cfg_data; |
| 517 | |
| 518 | BalSerialNumber serial_number; |
| 519 | memset(&serial_number, 0, sizeof(BalSerialNumber)); |
| 520 | bal_serial_number__init(&serial_number); |
| 521 | get_cfg_resp.terminal->data->serial_number = &serial_number; |
| 522 | |
| 523 | BalSubscriberTerminalKey sub_term_key; |
| 524 | memset(&sub_term_key, 0, sizeof(BalSubscriberTerminalKey)); |
| 525 | bal_subscriber_terminal_key__init(&sub_term_key); |
| 526 | get_cfg_resp.terminal->key = &sub_term_key; |
| 527 | |
| 528 | get_cfg_resp.terminal->key->has_sub_term_id = true; |
| 529 | get_cfg_resp.terminal->key->sub_term_id = bal_key->terminal_key->sub_term_id; |
| 530 | |
| 531 | get_cfg_resp.terminal->key->has_intf_id = true; |
| 532 | get_cfg_resp.terminal->key->intf_id = bal_key->terminal_key->intf_id; |
| 533 | |
| 534 | if (is_init_done == true) { |
| 535 | asfvolt16_bal_cfg_get(&get_cfg_resp); |
| 536 | } |
| 537 | } |
| 538 | break; |
| 539 | default: |
| 540 | { |
| 541 | ASFVOLT_LOG(ASFVOLT_ERROR, "Bal Get not implemented for %d object type", bal_key->hdr->obj_type); |
| 542 | } |
| 543 | break; |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | /* |
| 548 | * Write reply back to the client |
| 549 | */ |
| 550 | ret_val = context->gcc_stream->write(context, &get_cfg_resp, -1); |
| 551 | is_grpc_write_pending(ret_val); |
| 552 | |
| 553 | grpc_c_status_t status; |
| 554 | status.gcs_code = 0; |
| 555 | |
| 556 | /* |
| 557 | * Finish response for RPC |
| 558 | */ |
| 559 | if (context->gcc_stream->finish(context, &status)) |
| 560 | { |
| 561 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
| 562 | } |
| 563 | bal_cfg_get__free_mem(&get_cfg_resp); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | /* |
| 567 | * This functions gets invoked whenever bal RPC gets called |
| 568 | */ |
| 569 | void bal__bal_cfg_set_cb(grpc_c_context_t *context) |
| 570 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 571 | BalCfg *set_cfg = 0; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 572 | BalErr bal_err; |
| 573 | int ret_val = 0; |
| 574 | |
| 575 | /* |
| 576 | * Read incoming message into set_cfg |
| 577 | */ |
| 578 | if (context->gcc_payload) { |
| 579 | context->gcc_stream->read(context, (void **)&set_cfg, 0); |
| 580 | } |
| 581 | |
| 582 | /* |
| 583 | * send it to BAL |
| 584 | */ |
| 585 | |
| 586 | bal_err__init(&bal_err); |
| 587 | |
| 588 | bal_err.err= 0; |
| 589 | |
| 590 | /* |
| 591 | * Write reply back to the client |
| 592 | */ |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 593 | |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 594 | ret_val = context->gcc_stream->write(context, &bal_err, -1); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 595 | is_grpc_write_pending(ret_val); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 596 | |
| 597 | grpc_c_status_t status; |
| 598 | status.gcs_code = 0; |
| 599 | |
| 600 | /* |
| 601 | * Finish response for RPC |
| 602 | */ |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 603 | if (context->gcc_stream->finish(context, &status)) |
| 604 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 605 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 606 | } |
| 607 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 608 | if (set_cfg) { |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 609 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 610 | if(BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL == set_cfg->hdr->obj_type) |
| 611 | { |
| 612 | sleep(5); /* enable this if running with gdb */ |
| 613 | } |
| 614 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 615 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 616 | asfvolt16_bal_cfg_set(set_cfg); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 617 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | |
| 621 | /* |
| 622 | * This functions gets invoked whenever bal clear RPC gets called |
| 623 | */ |
| 624 | void bal__bal_cfg_clear_cb(grpc_c_context_t *context) |
| 625 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 626 | BalKey *clear_key = 0; |
Girish Gowdru | 50278de | 2017-11-23 12:35:41 +0530 | [diff] [blame] | 627 | BalErr bal_err; |
| 628 | int ret_val = 0; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 629 | |
| 630 | /* |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 631 | * Read incoming message into clear_key |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 632 | */ |
| 633 | if (context->gcc_payload) { |
| 634 | context->gcc_stream->read(context, (void **)&clear_key, 0); |
| 635 | } |
| 636 | |
Girish Gowdru | 50278de | 2017-11-23 12:35:41 +0530 | [diff] [blame] | 637 | /* |
| 638 | * send it to BAL |
| 639 | */ |
| 640 | |
| 641 | bal_err__init(&bal_err); |
| 642 | |
| 643 | bal_err.err= 0; |
| 644 | |
| 645 | /* |
| 646 | * Write reply back to the client |
| 647 | */ |
| 648 | |
| 649 | ret_val = context->gcc_stream->write(context, &bal_err, 0); |
| 650 | is_grpc_write_pending(ret_val); |
| 651 | |
| 652 | grpc_c_status_t status; |
| 653 | status.gcs_code = 0; |
| 654 | |
| 655 | /* |
| 656 | * Finish response for RPC |
| 657 | */ |
| 658 | if (context->gcc_stream->finish(context, &status)) |
| 659 | { |
| 660 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
| 661 | } |
| 662 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 663 | if (clear_key) { |
| 664 | asfvolt16_bal_cfg_clear(clear_key); |
| 665 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | |
| 669 | /* |
| 670 | * This functions gets invoked whenever bal Init RPC gets called |
| 671 | */ |
| 672 | void bal__bal_api_init_cb(grpc_c_context_t *context) |
| 673 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 674 | BalInit *bal_init = 0; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 675 | BalErr bal_err; |
| 676 | int ret_val; |
| 677 | |
| 678 | /* |
| 679 | * Read incoming message into set_cfg |
| 680 | */ |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 681 | if (context->gcc_payload) |
| 682 | { |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 683 | context->gcc_stream->read(context, (void **)&bal_init, 0); |
| 684 | } |
| 685 | |
| 686 | /* |
| 687 | * send it to BAL |
| 688 | */ |
| 689 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 690 | ASFVOLT_LOG(ASFVOLT_INFO, "Received API Init msg"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 691 | |
| 692 | bal_err__init(&bal_err); |
| 693 | |
| 694 | bal_err.err= 0; |
| 695 | |
| 696 | /* |
| 697 | * Write reply back to the client |
| 698 | */ |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 699 | ret_val = context->gcc_stream->write(context, &bal_err, -1); |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 700 | is_grpc_write_pending(ret_val); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 701 | |
| 702 | grpc_c_status_t status; |
| 703 | status.gcs_code = 0; |
| 704 | |
| 705 | /* |
| 706 | * Finish response for RPC |
| 707 | */ |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 708 | if (context->gcc_stream->finish(context, &status)) |
| 709 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 710 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 711 | } |
| 712 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 713 | if (bal_init) { |
| 714 | asfvolt16_bal_init(bal_init, &coreIpPortInfo); |
| 715 | } |
| 716 | is_init_done = true; |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 717 | } |
| 718 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 719 | |
| 720 | void bal_get_ind__free_mem_access_term_ind_op_state(BalIndications *balIndCfg) |
| 721 | { |
| 722 | free(balIndCfg->access_term_ind_op_state->data); |
| 723 | free(balIndCfg->access_term_ind_op_state->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 724 | free(balIndCfg->access_term_ind_op_state); |
| 725 | free(balIndCfg); |
| 726 | } |
| 727 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 728 | void bal_get_ind__free_mem_access_term_proc_err(BalIndications *balIndCfg) |
| 729 | { |
| 730 | free(balIndCfg->access_term_proc_err->key); |
| 731 | free(balIndCfg->access_term_proc_err); |
| 732 | free(balIndCfg); |
| 733 | } |
| 734 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 735 | void bal_get_ind__free_mem_flow_op_state(BalIndications *balIndCfg) |
| 736 | { |
| 737 | free(balIndCfg->flow_op_state->data); |
| 738 | free(balIndCfg->flow_op_state->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 739 | free(balIndCfg->flow_op_state); |
| 740 | free(balIndCfg); |
| 741 | } |
| 742 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 743 | void bal_get_ind__free_mem_flow_proc_err(BalIndications *balIndCfg) |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 744 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 745 | free(balIndCfg->flow_proc_err->key); |
| 746 | free(balIndCfg->flow_proc_err); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 747 | free(balIndCfg); |
| 748 | } |
| 749 | |
| 750 | void bal_get_ind__free_mem_interface_op_state(BalIndications *balIndCfg) |
| 751 | { |
| 752 | free(balIndCfg->interface_op_state->data); |
| 753 | free(balIndCfg->interface_op_state->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 754 | free(balIndCfg->interface_op_state); |
| 755 | free(balIndCfg); |
| 756 | } |
| 757 | |
| 758 | void bal_get_ind__free_mem_interface_los(BalIndications *balIndCfg) |
| 759 | { |
| 760 | free(balIndCfg->interface_los->data); |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 761 | free(balIndCfg->interface_los); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 762 | free(balIndCfg); |
| 763 | } |
| 764 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 765 | void bal_get_ind__free_mem_terminal_op_state(BalIndications *balIndCfg) |
| 766 | { |
| 767 | free(balIndCfg->terminal_op_state->data); |
| 768 | free(balIndCfg->terminal_op_state->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 769 | free(balIndCfg->terminal_op_state); |
| 770 | free(balIndCfg); |
| 771 | } |
| 772 | |
| 773 | void bal_get_ind__free_mem_terminal_disc(BalIndications *balIndCfg) |
| 774 | { |
| 775 | free(balIndCfg->terminal_disc->data->serial_number->vendor_specific); |
| 776 | free(balIndCfg->terminal_disc->data->serial_number->vendor_id); |
| 777 | free(balIndCfg->terminal_disc->data->serial_number); |
| 778 | free(balIndCfg->terminal_disc->data); |
| 779 | free(balIndCfg->terminal_disc->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 780 | free(balIndCfg->terminal_disc); |
| 781 | free(balIndCfg); |
| 782 | } |
| 783 | |
| 784 | void bal_get_ind__free_mem_terminal_alarm(BalIndications *balIndCfg) |
| 785 | { |
| 786 | free(balIndCfg->terminal_alarm->data->alarm); |
| 787 | free(balIndCfg->terminal_alarm->data); |
| 788 | free(balIndCfg->terminal_alarm->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 789 | free(balIndCfg->terminal_alarm); |
| 790 | free(balIndCfg); |
| 791 | } |
| 792 | |
| 793 | void bal_get_ind__free_mem_terminal_dgi(BalIndications *balIndCfg) |
| 794 | { |
| 795 | free(balIndCfg->terminal_dgi->data); |
| 796 | free(balIndCfg->terminal_dgi->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 797 | free(balIndCfg->terminal_dgi); |
| 798 | free(balIndCfg); |
| 799 | } |
| 800 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 801 | void bal_get_ind__free_mem_terminal_dowi(BalIndications *balIndCfg) |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 802 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 803 | free(balIndCfg->terminal_dowi->data); |
| 804 | free(balIndCfg->terminal_dowi->key); |
| 805 | free(balIndCfg->terminal_dowi); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 806 | free(balIndCfg); |
| 807 | } |
| 808 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 809 | void bal_get_ind__free_mem_terminal_looci(BalIndications *balIndCfg) |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 810 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 811 | free(balIndCfg->terminal_looci->data); |
| 812 | free(balIndCfg->terminal_looci->key); |
| 813 | free(balIndCfg->terminal_looci); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 814 | free(balIndCfg); |
| 815 | } |
| 816 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 817 | void bal_get_ind__free_mem_terminal_proc_err(BalIndications *balIndCfg) |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 818 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 819 | free(balIndCfg->terminal_proc_err->key); |
| 820 | free(balIndCfg->terminal_proc_err); |
| 821 | free(balIndCfg); |
| 822 | } |
| 823 | |
| 824 | void bal_get_ind__free_mem_terminal_sdi(BalIndications *balIndCfg) |
| 825 | { |
| 826 | free(balIndCfg->terminal_sdi->data); |
| 827 | free(balIndCfg->terminal_sdi->key); |
| 828 | free(balIndCfg->terminal_sdi); |
| 829 | free(balIndCfg); |
| 830 | } |
| 831 | |
| 832 | void bal_get_ind__free_mem_terminal_sfi(BalIndications *balIndCfg) |
| 833 | { |
| 834 | free(balIndCfg->terminal_sfi->data); |
| 835 | free(balIndCfg->terminal_sfi->key); |
| 836 | free(balIndCfg->terminal_sfi); |
| 837 | free(balIndCfg); |
| 838 | } |
| 839 | |
| 840 | void bal_get_ind__free_mem_terminal_sufi(BalIndications *balIndCfg) |
| 841 | { |
| 842 | free(balIndCfg->terminal_sufi->data); |
| 843 | free(balIndCfg->terminal_sufi->key); |
| 844 | free(balIndCfg->terminal_sufi); |
| 845 | free(balIndCfg); |
| 846 | } |
| 847 | |
| 848 | void bal_get_ind__free_mem_terminal_sub_term_act_fail(BalIndications *balIndCfg) |
| 849 | { |
| 850 | free(balIndCfg->terminal_sub_term_act_fail->data); |
| 851 | free(balIndCfg->terminal_sub_term_act_fail->key); |
| 852 | free(balIndCfg->terminal_sub_term_act_fail); |
| 853 | free(balIndCfg); |
| 854 | } |
| 855 | |
| 856 | void bal_get_ind__free_mem_terminal_tiwi(BalIndications *balIndCfg) |
| 857 | { |
| 858 | free(balIndCfg->terminal_tiwi->data); |
| 859 | free(balIndCfg->terminal_tiwi->key); |
| 860 | free(balIndCfg->terminal_tiwi); |
| 861 | free(balIndCfg); |
| 862 | } |
| 863 | |
| 864 | void bal_get_ind__free_mem_tm_sched_osc(BalIndications *balIndCfg) |
| 865 | { |
| 866 | free(balIndCfg->tm_sched_oper_stats_change->data); |
| 867 | free(balIndCfg->tm_sched_oper_stats_change->key); |
| 868 | free(balIndCfg->tm_sched_oper_stats_change); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 869 | free(balIndCfg); |
| 870 | } |
| 871 | |
| 872 | void bal_get_ind__free_mem_u_pkt_data(BalIndications *balIndCfg) |
| 873 | { |
| 874 | free(balIndCfg->pktdata->data->pkt.data); |
| 875 | free(balIndCfg->pktdata->data); |
| 876 | switch(balIndCfg->pktdata->key->packet_send_dest->type) |
| 877 | { |
| 878 | case BAL_DEST_TYPE__BAL_DEST_TYPE_NNI: |
| 879 | free(balIndCfg->pktdata->key->packet_send_dest->nni); |
| 880 | break; |
| 881 | case BAL_DEST_TYPE__BAL_DEST_TYPE_SUB_TERM: |
| 882 | free(balIndCfg->pktdata->key->packet_send_dest->sub_term); |
| 883 | break; |
| 884 | case BAL_DEST_TYPE__BAL_DEST_TYPE_SVC_PORT: |
| 885 | free(balIndCfg->pktdata->key->packet_send_dest->svc_port); |
| 886 | break; |
| 887 | default: |
| 888 | /*Nothing to do*/ |
| 889 | break; |
| 890 | } |
| 891 | free(balIndCfg->pktdata->key->packet_send_dest); |
| 892 | free(balIndCfg->pktdata->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 893 | free(balIndCfg->pktdata); |
| 894 | free(balIndCfg); |
| 895 | } |
| 896 | |
| 897 | void bal_get_ind__free_mem_u_bal_omci_resp(BalIndications *balIndCfg) |
| 898 | { |
| 899 | switch(balIndCfg->balomciresp->key->packet_send_dest->type) |
| 900 | { |
| 901 | case BAL_DEST_TYPE__BAL_DEST_TYPE_ITU_OMCI_CHANNEL: |
| 902 | free(balIndCfg->balomciresp->key->packet_send_dest->itu_omci_channel); |
| 903 | break; |
| 904 | default: |
| 905 | /*Nothing to do*/ |
| 906 | break; |
| 907 | } |
| 908 | free(balIndCfg->balomciresp->key->packet_send_dest); |
| 909 | free(balIndCfg->balomciresp->data->pkt.data); |
| 910 | free(balIndCfg->balomciresp->data); |
| 911 | free(balIndCfg->balomciresp->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 912 | free(balIndCfg->balomciresp); |
| 913 | free(balIndCfg); |
| 914 | } |
| 915 | |
| 916 | void bal_get_ind__free_mem_u_bal_oam_resp(BalIndications *balIndCfg) |
| 917 | { |
| 918 | free(balIndCfg->baloamresp->data->pkt.data); |
| 919 | free(balIndCfg->baloamresp->data); |
| 920 | switch(balIndCfg->baloamresp->key->packet_send_dest->type) |
| 921 | { |
| 922 | case BAL_DEST_TYPE__BAL_DEST_TYPE_IEEE_OAM_CHANNEL: |
| 923 | free(balIndCfg->baloamresp->key->packet_send_dest->ieee_oam_channel); |
| 924 | break; |
| 925 | default: |
| 926 | /*Nothing to do*/ |
| 927 | break; |
| 928 | } |
| 929 | free(balIndCfg->baloamresp->key->packet_send_dest); |
| 930 | free(balIndCfg->baloamresp->key); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 931 | free(balIndCfg->baloamresp); |
| 932 | free(balIndCfg); |
| 933 | } |
| 934 | |
| 935 | void bal_get_ind__free_mem(BalIndications *balIndCfg) |
| 936 | { |
| 937 | switch (balIndCfg->u_case) |
| 938 | { |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 939 | case BAL_INDICATIONS__U_ACCESS_TERM_IND_OP_STATE: |
| 940 | bal_get_ind__free_mem_access_term_ind_op_state(balIndCfg); |
| 941 | break; |
| 942 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 943 | case BAL_INDICATIONS__U_ACCESS_TERM_PROC_ERR: |
| 944 | bal_get_ind__free_mem_access_term_proc_err(balIndCfg); |
| 945 | break; |
| 946 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 947 | case BAL_INDICATIONS__U_FLOW_OP_STATE: |
| 948 | bal_get_ind__free_mem_flow_op_state(balIndCfg); |
| 949 | break; |
| 950 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 951 | case BAL_INDICATIONS__U_FLOW_PROC_ERR: |
| 952 | bal_get_ind__free_mem_flow_proc_err(balIndCfg); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 953 | break; |
| 954 | |
| 955 | case BAL_INDICATIONS__U_INTERFACE_OP_STATE: |
| 956 | bal_get_ind__free_mem_interface_op_state(balIndCfg); |
| 957 | break; |
| 958 | |
| 959 | case BAL_INDICATIONS__U_INTERFACE_LOS: |
| 960 | bal_get_ind__free_mem_interface_los(balIndCfg); |
| 961 | break; |
| 962 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 963 | case BAL_INDICATIONS__U_TERMINAL_OP_STATE: |
| 964 | bal_get_ind__free_mem_terminal_op_state(balIndCfg); |
| 965 | break; |
| 966 | |
| 967 | case BAL_INDICATIONS__U_TERMINAL_DISC: |
| 968 | bal_get_ind__free_mem_terminal_disc(balIndCfg); |
| 969 | break; |
| 970 | |
| 971 | case BAL_INDICATIONS__U_TERMINAL_ALARM: |
| 972 | bal_get_ind__free_mem_terminal_alarm(balIndCfg); |
| 973 | break; |
| 974 | |
| 975 | case BAL_INDICATIONS__U_TERMINAL_DGI: |
| 976 | bal_get_ind__free_mem_terminal_dgi(balIndCfg); |
| 977 | break; |
| 978 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 979 | case BAL_INDICATIONS__U_TERMINAL_DOWI: |
| 980 | bal_get_ind__free_mem_terminal_dowi(balIndCfg); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 981 | break; |
| 982 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 983 | case BAL_INDICATIONS__U_TERMINAL_LOOCI: |
| 984 | bal_get_ind__free_mem_terminal_looci(balIndCfg); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 985 | break; |
| 986 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 987 | case BAL_INDICATIONS__U_TERMINAL_PROC_ERR: |
| 988 | bal_get_ind__free_mem_terminal_proc_err(balIndCfg); |
| 989 | break; |
| 990 | |
| 991 | case BAL_INDICATIONS__U_TERMINAL_SDI: |
| 992 | bal_get_ind__free_mem_terminal_sdi(balIndCfg); |
| 993 | break; |
| 994 | |
| 995 | case BAL_INDICATIONS__U_TERMINAL_SFI: |
| 996 | bal_get_ind__free_mem_terminal_sfi(balIndCfg); |
| 997 | break; |
| 998 | |
| 999 | case BAL_INDICATIONS__U_TERMINAL_SUFI: |
| 1000 | bal_get_ind__free_mem_terminal_sufi(balIndCfg); |
| 1001 | break; |
| 1002 | |
| 1003 | case BAL_INDICATIONS__U_TERMINAL_SUB_TERM_ACT_FAIL: |
| 1004 | bal_get_ind__free_mem_terminal_sub_term_act_fail(balIndCfg); |
| 1005 | break; |
| 1006 | |
| 1007 | case BAL_INDICATIONS__U_TERMINAL_TIWI: |
| 1008 | bal_get_ind__free_mem_terminal_tiwi(balIndCfg); |
| 1009 | break; |
| 1010 | |
| 1011 | case BAL_INDICATIONS__U_TM_SCHED_OPER_STATS_CHANGE: |
| 1012 | bal_get_ind__free_mem_tm_sched_osc(balIndCfg); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 1013 | break; |
| 1014 | |
| 1015 | case BAL_INDICATIONS__U_PKT_DATA: |
| 1016 | bal_get_ind__free_mem_u_pkt_data(balIndCfg); |
| 1017 | break; |
| 1018 | |
| 1019 | case BAL_INDICATIONS__U_BAL_OMCI_RESP: |
| 1020 | bal_get_ind__free_mem_u_bal_omci_resp(balIndCfg); |
| 1021 | break; |
| 1022 | |
| 1023 | case BAL_INDICATIONS__U_BAL_OAM_RESP: |
| 1024 | bal_get_ind__free_mem_u_bal_oam_resp(balIndCfg); |
| 1025 | break; |
| 1026 | |
| 1027 | default: |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 1028 | ASFVOLT_LOG(ASFVOLT_ERROR, "Unknown BAL indication %u", balIndCfg->u_case); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 1029 | break; |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | void bal_get_ind__bal_get_ind_from_device_cb(grpc_c_context_t *context) |
| 1034 | { |
| 1035 | BalDefault *dummy; |
| 1036 | BalIndications *bal_indication; |
| 1037 | list_node *node = NULL; |
| 1038 | int ret_val = 0; |
| 1039 | |
| 1040 | /* |
| 1041 | * Read incoming message into set_cfg |
| 1042 | */ |
| 1043 | if (context->gcc_payload) { |
| 1044 | context->gcc_stream->read(context, (void **)&dummy, 0); |
| 1045 | } |
| 1046 | |
| 1047 | /* |
| 1048 | * send it to BAL |
| 1049 | */ |
| 1050 | |
| 1051 | pthread_mutex_lock(&bal_ind_queue_lock); |
| 1052 | node = get_bal_indication_node(); |
| 1053 | pthread_mutex_unlock(&bal_ind_queue_lock); |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 1054 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 1055 | if(node != NULL) |
| 1056 | { |
| 1057 | bal_indication = node->bal_indication; |
| 1058 | bal_indication->ind_present = true; |
| 1059 | bal_indication->has_ind_present = true; |
| 1060 | } |
| 1061 | else |
| 1062 | { |
| 1063 | bal_indication = malloc(sizeof(BalIndications)); |
| 1064 | memset(bal_indication, 0, sizeof(BalIndications)); |
| 1065 | bal_indications__init(bal_indication); |
| 1066 | bal_indication->ind_present = false; |
| 1067 | bal_indication->has_ind_present = true; |
| 1068 | } |
| 1069 | |
| 1070 | /* |
| 1071 | * Write reply back to the client |
| 1072 | */ |
| 1073 | |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 1074 | ret_val = context->gcc_stream->write(context, bal_indication, -1); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 1075 | is_grpc_write_pending(ret_val); |
| 1076 | |
| 1077 | grpc_c_status_t status; |
| 1078 | status.gcs_code = 0; |
| 1079 | |
| 1080 | /* |
| 1081 | * Finish response for RPC |
| 1082 | */ |
| 1083 | if (context->gcc_stream->finish(context, &status)) |
| 1084 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 1085 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to write status"); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 1086 | } |
root | 2ca2cc0 | 2017-11-03 19:51:57 +0530 | [diff] [blame] | 1087 | |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 1088 | /*Free memory for 'bal_indication' and 'node'*/ |
| 1089 | if (bal_indication->ind_present) |
| 1090 | { |
| 1091 | bal_get_ind__free_mem(bal_indication); |
| 1092 | free(node); |
| 1093 | } |
| 1094 | else |
| 1095 | { |
| 1096 | free(bal_indication); |
| 1097 | } |
| 1098 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1099 | |
| 1100 | /* |
| 1101 | * This functions gets invoked whenever bal finish RPC gets called |
| 1102 | */ |
| 1103 | void bal__bal_api_finish_cb(grpc_c_context_t *context) |
| 1104 | { |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1105 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1106 | } |
| 1107 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1108 | void bal_ind__bal_acc_term_oper_sts_cng_ind_cb(grpc_c_context_t *context) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1109 | { |
| 1110 | } |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1111 | void bal_ind__bal_acc_term_cfg_cb(grpc_c_context_t *context) |
| 1112 | { |
| 1113 | } |
| 1114 | void bal_ind__bal_acc_term_proc_err_cb(grpc_c_context_t *context) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1115 | { |
| 1116 | } |
| 1117 | void bal_ind__bal_flow_oper_sts_cng_cb(grpc_c_context_t *context) |
| 1118 | { |
| 1119 | } |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1120 | void bal_ind__bal_flow_proc_err_cb(grpc_c_context_t *context) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1121 | { |
| 1122 | } |
| 1123 | void bal_ind__bal_iface_oper_sts_cng_cb(grpc_c_context_t *context) |
| 1124 | { |
| 1125 | } |
| 1126 | void bal_ind__bal_iface_los_cb(grpc_c_context_t *context) |
| 1127 | { |
| 1128 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1129 | void bal_ind__bal_iface_stat_cb(grpc_c_context_t *context) |
| 1130 | { |
| 1131 | } |
| 1132 | void bal_ind__bal_subs_term_oper_sts_cng_cb(grpc_c_context_t *context) |
| 1133 | { |
| 1134 | } |
| 1135 | void bal_ind__bal_subs_term_discovery_ind_cb(grpc_c_context_t *context) |
| 1136 | { |
| 1137 | } |
| 1138 | void bal_ind__bal_subs_term_alarm_ind_cb(grpc_c_context_t *context) |
| 1139 | { |
| 1140 | } |
| 1141 | void bal_ind__bal_subs_term_dgi_ind_cb(grpc_c_context_t *context) |
| 1142 | { |
| 1143 | } |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1144 | void bal_ind__bal_subs_term_proc_err_cb(grpc_c_context_t *context) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1145 | { |
| 1146 | } |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1147 | void bal_ind__bal_subs_term_dowi_ind_cb(grpc_c_context_t *context) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1148 | { |
| 1149 | } |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1150 | void bal_ind__bal_subs_term_looci_ind_cb(grpc_c_context_t *context) |
| 1151 | { |
| 1152 | } |
| 1153 | void bal_ind__bal_subs_term_sdi_ind_cb(grpc_c_context_t *context) |
| 1154 | { |
| 1155 | } |
| 1156 | void bal_ind__bal_subs_term_sfi_ind_cb(grpc_c_context_t *context) |
| 1157 | { |
| 1158 | } |
| 1159 | void bal_ind__bal_subs_term_sufi_ind_cb(grpc_c_context_t *context) |
| 1160 | { |
| 1161 | } |
| 1162 | void bal_ind__bal_subs_term_tiwi_ind_cb(grpc_c_context_t *context) |
| 1163 | { |
| 1164 | } |
| 1165 | void bal_ind__bal_sub_term_act_fail_ind_cb(grpc_c_context_t *context) |
| 1166 | { |
| 1167 | } |
| 1168 | void bal_ind__bal_tm_sched_oper_stats_change_cb(grpc_c_context_t *context) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1169 | { |
| 1170 | } |
| 1171 | void bal_ind__bal_pkt_bearer_channel_rx_ind_cb(grpc_c_context_t *context) |
| 1172 | { |
| 1173 | } |
| 1174 | void bal_ind__bal_pkt_omci_channel_rx_ind_cb(grpc_c_context_t *context) |
| 1175 | { |
| 1176 | } |
| 1177 | void bal_ind__bal_pkt_ieee_oam_channel_rx_ind_cb(grpc_c_context_t *context) |
| 1178 | { |
| 1179 | } |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1180 | void bal_ind__bal_sys_profile_ind_cb(grpc_c_context_t *context) |
| 1181 | { |
| 1182 | } |
A R Karthick | 1d25103 | 2017-09-06 09:38:34 -0700 | [diff] [blame] | 1183 | |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 1184 | /* |
| 1185 | ** ASFVOLT_HEX2LOG(ASFVOLT_DEBUG, "OMCI Response with %zd bytes is", |
| 1186 | ** balIndCfg.balomciresp->data->pkt.data, balIndCfg.balomciresp->data->pkt.len); |
| 1187 | */ |
| 1188 | #define SYSLOG_MAX_SIZE 1024 |
| 1189 | void asfvolt_hexlog2(int prio, const char *_file_loc, int _file_line, const char *pFormat, void* pData, size_t len) |
| 1190 | { |
| 1191 | unsigned char *inpPtr = pData; |
| 1192 | char tempBuf[SYSLOG_MAX_SIZE]; |
| 1193 | size_t idx = 0; |
| 1194 | |
| 1195 | idx += snprintf(tempBuf+idx, SYSLOG_MAX_SIZE-1, pFormat, len); |
| 1196 | while (len-- > 0 && idx < SYSLOG_MAX_SIZE) |
| 1197 | { |
| 1198 | idx += snprintf(tempBuf+idx, SYSLOG_MAX_SIZE-idx, "%02x", *inpPtr++); |
| 1199 | } |
| 1200 | ASFVOLT_LOG_LOC(prio, _file_loc, _file_line, "%s", tempBuf); |
| 1201 | } |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1202 | |
| 1203 | /* |
| 1204 | * Takes socket path as argument |
| 1205 | */ |
Rajeswara Rao | a3efbca | 2017-09-08 18:01:16 +0530 | [diff] [blame] | 1206 | int main (int argc, char **argv) |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1207 | { |
| 1208 | int i = 0; |
| 1209 | grpc_c_server_t *server = NULL; |
| 1210 | |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1211 | if (argc < 4) |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 1212 | { |
Girish Gowdru | 9ebd8b2 | 2018-09-26 03:21:03 -0700 | [diff] [blame] | 1213 | fprintf(stderr, "Missing arguments\n"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1214 | exit(1); |
| 1215 | } |
| 1216 | |
| 1217 | strcpy(coreIpPortInfo.bal_core_arg1, argv[2] /*, strlen(argv[2])*/); |
| 1218 | strcpy(coreIpPortInfo.bal_core_ip_port, argv[3]/*, strlen(argv[3])*/); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1219 | |
| 1220 | signal(SIGINT, sigint_handler); |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 1221 | |
| 1222 | /* |
| 1223 | ** syslog initialization |
| 1224 | */ |
| 1225 | //setlogmask (LOG_UPTO (LOG_NOTICE)); |
| 1226 | |
| 1227 | openlog (ASFVOLT_SYSLOG_NAME, ASFVOLT_SYSLOG_MODE, LOG_LOCAL1); |
| 1228 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1229 | /* |
| 1230 | * Initialize grpc-c library to be used with vanilla gRPC |
| 1231 | */ |
| 1232 | grpc_c_init(GRPC_THREADS, NULL); |
| 1233 | |
| 1234 | /* |
| 1235 | * Create server object |
| 1236 | */ |
| 1237 | test_server = grpc_c_server_create(argv[1]); |
| 1238 | |
Rajeswara Rao | 9f1cea1 | 2017-10-10 18:25:29 +0530 | [diff] [blame] | 1239 | if (test_server == NULL) |
| 1240 | { |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 1241 | ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to create server"); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1242 | exit(1); |
| 1243 | } |
| 1244 | |
| 1245 | /* |
| 1246 | * Initialize greeter service |
| 1247 | */ |
Kim Kempf | afa1ab4 | 2017-11-13 09:31:47 -0800 | [diff] [blame] | 1248 | ASFVOLT_LOG(ASFVOLT_INFO, "voltha_bal_driver running....."); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1249 | bal__service_init(test_server); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 1250 | bal_get_ind__service_init(test_server); |
root | 5be94e5 | 2018-02-15 22:30:14 +0530 | [diff] [blame] | 1251 | asfvolt__service_init(test_server); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1252 | |
| 1253 | /* |
| 1254 | * Start server |
| 1255 | */ |
| 1256 | grpc_c_server_start(test_server); |
| 1257 | |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1258 | /* |
| 1259 | * Blocks server to wait to completion |
| 1260 | */ |
| 1261 | grpc_c_server_wait(test_server); |
| 1262 | |
| 1263 | /* code added for example Makefile to compile grpc-c along with edgecore driver */ |
| 1264 | bal__service_init(server); |
VoLTHA | 753536e | 2017-11-02 20:15:09 +0530 | [diff] [blame] | 1265 | bal_get_ind__service_init(server); |
root | 5be94e5 | 2018-02-15 22:30:14 +0530 | [diff] [blame] | 1266 | asfvolt__service_init(server); |
Rajeswara Rao | f6b4e6c | 2017-08-31 17:26:27 +0530 | [diff] [blame] | 1267 | } |