diff options
Diffstat (limited to 'src/sa_types.h')
-rwxr-xr-x | src/sa_types.h | 240 |
1 files changed, 240 insertions, 0 deletions
diff --git a/src/sa_types.h b/src/sa_types.h new file mode 100755 index 0000000..4c50b70 --- /dev/null +++ b/src/sa_types.h @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __SA_TYPES_H__ +#define __SA_TYPES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define JSON_STR_ID_VERSION "version" +#define JSON_STR_ID_ENABLED "enabled" + +#define JSON_STR_ID_WIFI "wifi" +#define JSON_STR_ID_WIFI_SSID "ssid" +#define JSON_STR_ID_WIFI_PASSWORD "password" + +#define JSON_STR_ID_ETHERNET "ethernet" +#define JSON_STR_ID_DHCP_ENABLED "dhcpEnabled" +#define JSON_STR_ID_IPADDRESS "ipAddress" +#define JSON_STR_ID_NETMASK "netmask" +#define JSON_STR_ID_GATEWAY "defaultGateway" +#define JSON_STR_ID_DNS_SERVER_PRIMARY "primaryDnsServer" +#define JSON_STR_ID_DNS_SERVER_SECONDARY "secondaryDnsServer" + +#define JSON_STR_ID_INSECURE_REGISTRIES "insecureRegistries" +#define JSON_STR_ID_HTTP_PROXY "httpProxy" +#define JSON_STR_ID_HTTPS_PROXY "httpsProxy" +#define JSON_STR_SERVICE_OPERATOR "=" + +/** + * @brief This enum contains beluga-adaptor error information + * + * The sa_error_e indicates what error is happened + * + */ + typedef enum { + SA_ERROR_NONE = 0, /**< Successful */ + SA_ERROR_NOT_AVAILABLE, /**< Not Available */ + SA_ERROR_PARSING, /**< Parsing error */ + SA_ERROR_INVALID_PARAMETER, + /**< Invalid parameter */ + SA_ERROR_INVALID_CONTENTS, + /**< Invalid contents */ + SA_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + SA_ERROR_PERMISSION_DENIED, + /**< Permission denied */ + SA_ERROR_NOT_SUPPORTED, /**< Not supported */ + SA_ERROR_UNKNOWN, /**< UNKNOWN */ + } sa_error_e; + +/** + * @brief This enum contains beluga-adaptor error information + * + * The sa_error_e indicates what error is happened + * + */ + typedef enum { + SA_NETWORK_TYPE_NONE = 0, /**< none */ + SA_NETWORK_TYPE_ETH, /**< eth */ + SA_NETWORK_TYPE_WIFI, /**< wifi */ + } sa_network_type_e; + +/** + * @brief This enum contains beluga-adaptor error information + * + * The sa_network_state_e indicates connection info in the system + * + */ + typedef enum { + SA_NETWORK_STATE_DISCONNECTED = 0, /**< Disconnected */ + SA_NETWORK_STATE_PROGRESSING, /**< Connecting/Association/Configuration */ + SA_NETWORK_STATE_CONNECTED, /**< connected */ + SA_NETWORK_STATE_UNKNOWN, /**< UNKNOWN */ + } sa_network_state_e; + +/** + * @brief This enum contains file status information + * + * The sa_file_state_e indicates when the status of file is changed + * + */ + typedef enum { + SA_FILE_STATE_NOT_EXISTED = 0, + /**< Not Existed */ + SA_FILE_STATE_EXIST, /**< Existed */ + SA_FILE_STATE_REGISTERED, /**< Registered */ + SA_FILE_STATE_REMOVED, /**< Removed */ + SA_FILE_STATE_CHANGED, /**< Changed */ + } sa_file_state_e; + + typedef enum { + SA_FILE_CONFIG_SYSTEM = 0, /**< system configuration type */ + SA_FILE_CONFIG_ETHERNET, /**< ethernet configuration type */ + SA_FILE_CONFIG_WIFI, /**< wifi configuration type */ + SA_FILE_CONFIG_ALL, + SA_FILE_CONFIG_UNKNOWN + } sa_file_config_e; + +/** + * @brief This type is definition of status file change callback + * + * The file_state_cb includes param in the one data + * + */ + typedef void (*file_state_cb) (void *param); + +/** + * @struct sa_network_static_s + * @brief This struct contains network static information in the config + * + * The sa_network_static_s struct encapsulate ip, netmast, gateway and dns information in the one data + * + */ + typedef struct { + char ipAddress[255 + 1]; + char netmask[255 + 1]; + char defaultGateway[255 + 1]; + char primaryDnsServer[255 + 1]; + char secondaryDnsServer[255 + 1]; + } sa_network_static_s; + +/** + * @struct sa_wifi_s + * @brief This struct contains wifi information in the config + * + * The sa_wifi_s struct encapsulate enabled, dhcpEnabled, ssid, password and static information in the one data + * + */ + typedef struct { + int enabled; + int dhcpEnabled; + char ssid[255 + 1]; + char password[255 + 1]; + sa_network_static_s *staticInfo; + } sa_wifi_s; + +/** + * @struct sa_eth_s + * @brief This struct contains ethernet information in the config + * + * The sa_eth_s struct encapsulate enabled, dhcpEnabled and static information in the one data + * + */ + typedef struct { + int enabled; + int dhcpEnabled; + sa_network_static_s *staticInfo; + } sa_eth_s; + +/** + * @struct sa_proxy_s + * @brief This struct contains proxy information + * + * The sa_proxy_s struct encapsulate http(s)proxyHost and http(s)ProxyPort information in the one data + * + */ + typedef struct { + char httpProxy[255 + 1]; + char httpsProxy[255 + 1]; + } sa_proxy_s; + +/** + * @struct sa_dockerd_opt_s + * @brief This struct contains insecure registry information in the config + * + * The sa_dockerd_opt_s struct encapsulate count and insecureRegistries information in the one data + * + */ + typedef struct { + int count; + char **insecureRegistries; + } sa_dockerd_opt_s; + +/** + * @struct sa_system_s + * @brief This struct contains system data information in the config + * + * The sa_system_s struct encapsulate device name, proxy and dockerd options information in the one data + * + */ + typedef struct { + char deviceName[255 + 1]; + sa_proxy_s *proxy; + sa_dockerd_opt_s *dockerdOpt; + } sa_system_s; + +/** + * @struct sa_config_s + * @brief This struct contains config information + * + * The sa_config_s struct encapsulate version, network and system data information in the one data + * + */ + typedef struct { + char version[127 + 1]; + sa_system_s *systemData; + } sa_config_s; + +/** + * @struct sa_main_thread_s + * @brief This struct contains parameters of main thread + * + * The sa_main_thread_s includes the number of thread and file path for setting value(system, wifi, ethernet, etc..), and main loop. + */ + typedef struct { + int config_file_num; + char **config_file_path; + void (*setup_cb) (void); + void (*completed_notify_cb) (void); + } sa_main_thread_s; + +/** + * @struct sa_file_check_thread_s + * @brief This struct contains parameters of file checking thread + * + * The sa_file_check_thread_s includes file path for setting value(system, wifi, ethernet, etc..), and callback function to send evnet. + */ + typedef struct { + int id; + char *config_file_path; + void *file_state_cb; + } sa_file_check_thread_s; + +#ifdef __cplusplus +} +#endif +#endif /* __SA_TYPES_H__ */ |