1 /* Copyright (c) 2011-2015, 2018 The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation, nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef LOC_CFG_H 31 #define LOC_CFG_H 32 33 #include <stdio.h> 34 #include <stdint.h> 35 #include <sys/types.h> 36 #include <unistd.h> 37 #include <grp.h> 38 39 #define LOC_MAX_PARAM_NAME 80 40 #define LOC_MAX_PARAM_STRING 172 41 #define LOC_MAX_PARAM_LINE (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING) 42 43 #define LOC_FEATURE_MODE_DISABLED "DISABLED" 44 #define LOC_FEATURE_MODE_BASIC "BASIC" 45 #define LOC_FEATURE_MODE_PREMIUM "PREMIUM" 46 47 #define LOC_FEATURE_GTP_AP_CELL "gtp-ap-cell" 48 #define LOC_FEATURE_GTP_MODEM_CELL "gtp-modem-cell" 49 #define LOC_FEATURE_GTP_CELL_ENH "gtp-cell-enh" 50 #define LOC_FEATURE_GTP_WIFI "gtp-wifi" 51 #define LOC_FEATURE_GTP_WAA "gtp-waa" 52 #define LOC_FEATURE_SAP "sap" 53 54 #define LOC_PROCESS_MAX_NUM_GROUPS 20 55 #define LOC_PROCESS_MAX_NUM_ARGS 25 56 #define LOC_PROCESS_MAX_ARG_STR_LENGTH 32 57 58 #define UTIL_UPDATE_CONF(conf_data, len, config_table) \ 59 loc_update_conf((conf_data), (len), (config_table), \ 60 sizeof(config_table) / sizeof(config_table[0])) 61 62 #define UTIL_READ_CONF_DEFAULT(filename) \ 63 loc_read_conf((filename), NULL, 0); 64 65 #define UTIL_READ_CONF(filename, config_table) \ 66 loc_read_conf((filename), (config_table), sizeof(config_table) / sizeof(config_table[0])) 67 68 /*============================================================================= 69 * 70 * MODULE TYPE DECLARATION 71 * 72 *============================================================================*/ 73 typedef struct 74 { 75 const char *param_name; 76 void *param_ptr; /* for string type, buf size need to be LOC_MAX_PARAM_STRING */ 77 uint8_t *param_set; /* indicate value set by config file */ 78 char param_type; /* 'n' for number, 79 's' for string, NOTE: buf size need to be LOC_MAX_PARAM_STRING 80 'f' for double */ 81 } loc_param_s_type; 82 83 typedef enum { 84 ENABLED, 85 RUNNING, 86 DISABLED, 87 DISABLED_FROM_CONF, 88 DISABLED_VIA_VENDOR_ENHANCED_CHECK 89 } loc_process_e_status; 90 91 typedef struct { 92 loc_process_e_status proc_status; 93 pid_t proc_id; 94 char name[2][LOC_MAX_PARAM_STRING]; 95 gid_t group_list[LOC_PROCESS_MAX_NUM_GROUPS]; 96 unsigned char num_groups; 97 char args[LOC_PROCESS_MAX_NUM_ARGS][LOC_PROCESS_MAX_ARG_STR_LENGTH]; 98 char argumentString[LOC_MAX_PARAM_STRING]; 99 } loc_process_info_s_type; 100 101 /*============================================================================= 102 * 103 * MODULE EXTERNAL DATA 104 * 105 *============================================================================*/ 106 107 #ifdef __cplusplus 108 extern "C" { 109 #endif 110 111 /*============================================================================= 112 * 113 * MODULE EXPORTED FUNCTIONS 114 * 115 *============================================================================*/ 116 bool isVendorEnhanced(); 117 void setVendorEnhanced(bool vendorEnhanced); 118 void loc_read_conf(const char* conf_file_name, 119 const loc_param_s_type* config_table, 120 uint32_t table_length); 121 int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table, 122 uint32_t table_length); 123 int loc_update_conf(const char* conf_data, int32_t length, 124 const loc_param_s_type* config_table, uint32_t table_length); 125 126 // Below are the location conf file paths 127 extern const char LOC_PATH_GPS_CONF[]; 128 extern const char LOC_PATH_IZAT_CONF[]; 129 extern const char LOC_PATH_FLP_CONF[]; 130 extern const char LOC_PATH_LOWI_CONF[]; 131 extern const char LOC_PATH_SAP_CONF[]; 132 extern const char LOC_PATH_APDR_CONF[]; 133 extern const char LOC_PATH_XTWIFI_CONF[]; 134 extern const char LOC_PATH_QUIPC_CONF[]; 135 136 int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_ptr, 137 loc_process_info_s_type** process_info_table_ptr); 138 int loc_get_datum_type(); 139 #ifdef __cplusplus 140 } 141 #endif 142 143 #endif /* LOC_CFG_H */ 144