loc_cfg.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* Copyright (c) 2011-2015, 2018 - 2021 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. #ifndef LOC_CFG_H
  30. #define LOC_CFG_H
  31. #include <stdio.h>
  32. #include <stdint.h>
  33. #include <sys/types.h>
  34. #include <unistd.h>
  35. #include <grp.h>
  36. #define LOC_MAX_PARAM_NAME 80
  37. #define LOC_MAX_PARAM_STRING 172
  38. #define LOC_MAX_PARAM_LINE (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING)
  39. #define LOC_FEATURE_MODE_DISABLED "DISABLED"
  40. #define LOC_FEATURE_MODE_BASIC "BASIC"
  41. #define LOC_FEATURE_MODE_PREMIUM "PREMIUM"
  42. #define LOC_FEATURE_GTP_AP_CELL "gtp-ap-cell"
  43. #define LOC_FEATURE_GTP_MODEM_CELL "gtp-modem-cell"
  44. #define LOC_FEATURE_GTP_CELL_ENH "gtp-cell-enh"
  45. #define LOC_FEATURE_GTP_WIFI "gtp-wifi"
  46. #define LOC_FEATURE_GTP_WAA "gtp-waa"
  47. #define LOC_FEATURE_SAP "sap"
  48. #define LOC_PROCESS_MAX_NUM_GROUPS 20
  49. #define LOC_PROCESS_MAX_NUM_ARGS 25
  50. #define LOC_PROCESS_MAX_ARG_STR_LENGTH 32
  51. #define UTIL_UPDATE_CONF(conf_data, len, config_table) \
  52. loc_update_conf((conf_data), (len), (&config_table[0]), \
  53. sizeof(config_table) / sizeof(config_table[0]))
  54. #define UTIL_READ_CONF_DEFAULT(filename) \
  55. loc_read_conf((filename), NULL, 0);
  56. #define UTIL_READ_CONF(filename, config_table) \
  57. loc_read_conf((filename), (&config_table[0]), sizeof(config_table) / sizeof(config_table[0]))
  58. #define UTIL_READ_CONF_LONG(filename, config_table, rec_len) \
  59. loc_read_conf_long((filename), (&config_table[0]), \
  60. sizeof(config_table) / sizeof(config_table[0]), (rec_len))
  61. /*=============================================================================
  62. *
  63. * MODULE TYPE DECLARATION
  64. *
  65. *============================================================================*/
  66. typedef struct
  67. {
  68. const char *param_name;
  69. void *param_ptr; /* for string type, buf size need to be LOC_MAX_PARAM_STRING */
  70. uint8_t *param_set; /* indicate value set by config file */
  71. char param_type; /* 'n' for number,
  72. 's' for string, NOTE: buf size need to be LOC_MAX_PARAM_STRING
  73. 'f' for double */
  74. } loc_param_s_type;
  75. typedef enum {
  76. ENABLED,
  77. RUNNING,
  78. DISABLED,
  79. DISABLED_FROM_CONF,
  80. DISABLED_VIA_VENDOR_ENHANCED_CHECK
  81. } loc_process_e_status;
  82. typedef struct {
  83. loc_process_e_status proc_status;
  84. pid_t proc_id;
  85. char name[2][LOC_MAX_PARAM_STRING];
  86. gid_t group_list[LOC_PROCESS_MAX_NUM_GROUPS];
  87. unsigned char num_groups;
  88. char args[LOC_PROCESS_MAX_NUM_ARGS][LOC_PROCESS_MAX_ARG_STR_LENGTH];
  89. char argumentString[LOC_MAX_PARAM_STRING];
  90. bool launch_on_optin;
  91. } loc_process_info_s_type;
  92. /*=============================================================================
  93. *
  94. * MODULE EXTERNAL DATA
  95. *
  96. *============================================================================*/
  97. #ifdef __cplusplus
  98. extern "C" {
  99. #endif
  100. /*=============================================================================
  101. *
  102. * MODULE EXPORTED FUNCTIONS
  103. *
  104. *============================================================================*/
  105. bool isVendorEnhanced();
  106. void setVendorEnhanced(bool vendorEnhanced);
  107. void loc_read_conf_long(const char* conf_file_name,
  108. const loc_param_s_type* config_table,
  109. uint32_t table_length, uint16_t string_len);
  110. int loc_read_conf_r_long(FILE *conf_fp, const loc_param_s_type* config_table,
  111. uint32_t table_length, uint16_t string_len);
  112. int loc_update_conf_long(const char* conf_data, int32_t length,
  113. const loc_param_s_type* config_table, uint32_t table_length,
  114. uint16_t string_len);
  115. inline void loc_read_conf(const char* conf_file_name,
  116. const loc_param_s_type* config_table, uint32_t table_length) {
  117. loc_read_conf_long(conf_file_name, config_table, table_length, LOC_MAX_PARAM_STRING);
  118. }
  119. inline int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table,
  120. uint32_t table_length) {
  121. return (loc_read_conf_r_long(conf_fp, config_table, table_length, LOC_MAX_PARAM_STRING));
  122. }
  123. inline int loc_update_conf(const char* conf_data, int32_t length,
  124. const loc_param_s_type* config_table, uint32_t table_length) {
  125. return (loc_update_conf_long(
  126. conf_data, length, config_table, table_length, LOC_MAX_PARAM_STRING));
  127. }
  128. // Below are the location conf file paths
  129. extern const char LOC_PATH_GPS_CONF[];
  130. extern const char LOC_PATH_IZAT_CONF[];
  131. extern const char LOC_PATH_BATCHING_CONF[];
  132. extern const char LOC_PATH_LOWI_CONF[];
  133. extern const char LOC_PATH_SAP_CONF[];
  134. extern const char LOC_PATH_APDR_CONF[];
  135. extern const char LOC_PATH_XTWIFI_CONF[];
  136. extern const char LOC_PATH_QUIPC_CONF[];
  137. extern const char LOC_PATH_ANT_CORR[];
  138. extern const char LOC_PATH_SLIM_CONF[];
  139. extern const char LOC_PATH_VPE_CONF[];
  140. extern const char LOC_PATH_QPPE_CONF[];
  141. int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_ptr,
  142. loc_process_info_s_type** process_info_table_ptr);
  143. int loc_get_datum_type();
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147. #endif /* LOC_CFG_H */