Added log and nflog rule for firewall
[platform/core/connectivity/stc-manager.git] / include / stc-manager.h
old mode 100755 (executable)
new mode 100644 (file)
index ac8ecb4..898e7ae
 #define NET_CLS_SUBSYS "net_cls"
 
 #define STC_BACKGROUND_APP_SUFFIX "_BACKGROUND"
+#define STC_BACKGROUND_APP_ID "BACKGROUND"
 #define STC_TOTAL_DATACALL "TOTAL_DATACALL"
 #define STC_TOTAL_WIFI "TOTAL_WIFI"
 #define STC_TOTAL_BLUETOOTH "TOTAL_BLUETOOTH"
+#define STC_TOTAL_IPV4 "TOTAL_IPV4"
+#define STC_TOTAL_IPV6 "TOTAL_IPV6"
+#define STC_TOTAL_TETHERING "TOTAL_TETHERING"
+
+#define STC_IPTABLES "/usr/sbin/iptables"
+#define STC_IP6TABLES "/usr/sbin/ip6tables"
+
+#define STC_CMD_SIZE 256
+
+#define STC_DEBUG_LOG (stc_util_get_debuglog())
 
 typedef enum {
        STC_CANCEL = 0,    /**< cancel */
        STC_CONTINUE = 1,  /**< continue */
 } stc_cb_ret_e;
 
+typedef enum {
+       STC_CMD_NONE,
+       STC_CMD_SET_FOREGRD,
+       STC_CMD_SET_BACKGRD,
+       STC_CMD_SET_APP_LAUNCHED,
+       STC_CMD_SET_SERVICE_LAUNCHED,
+       STC_CMD_SET_TERMINATED,
+       STC_CMD_MAX_ELEM
+} stc_cmd_type_e;
+
+typedef enum {
+       STC_FW_DIRECTION_NONE,
+       STC_FW_DIRECTION_IN,
+       STC_FW_DIRECTION_OUT
+} stc_fw_direction_e;
+
+typedef enum {
+       STC_FW_FAMILY_NONE,
+       STC_FW_FAMILY_V4,
+       STC_FW_FAMILY_V6
+} stc_fw_family_type_e;
+
+typedef enum {
+       STC_FW_IP_NONE,
+       STC_FW_IP_SINGLE,
+       STC_FW_IP_MASK,
+       STC_FW_IP_RANGE
+} stc_fw_ip_type_e;
+
+typedef enum {
+       STC_FW_PORT_NONE,
+       STC_FW_PORT_SINGLE,
+       STC_FW_PORT_RANGE
+} stc_fw_port_type_e;
+
+typedef enum {
+       STC_FW_PROTOCOL_NONE,
+       STC_FW_PROTOCOL_TCP,
+       STC_FW_PROTOCOL_UDP,
+       STC_FW_PROTOCOL_ICMP,
+       STC_FW_PROTOCOL_ESP,
+       STC_FW_PROTOCOL_AH,
+       STC_FW_PROTOCOL_SCTP,
+       STC_FW_PROTOCOL_MH,
+       STC_FW_PROTOCOL_ALL,
+} stc_fw_protocol_type_e;
+
+typedef enum {
+       STC_FW_CHAIN_TARGET_NONE,
+       STC_FW_CHAIN_TARGET_INPUT,
+       STC_FW_CHAIN_TARGET_OUTPUT,
+       STC_FW_CHAIN_TARGET_MAX
+} stc_fw_chain_target_e;
+
+typedef enum {
+       STC_FW_RULE_TARGET_NONE,
+       STC_FW_RULE_TARGET_ACCEPT,
+       STC_FW_RULE_TARGET_DROP,
+       STC_FW_RULE_TARGET_LOG,
+       STC_FW_RULE_TARGET_NFLOG,
+       STC_FW_RULE_TARGET_MAX
+} stc_fw_rule_target_e;
+
 /**
  * @brief Monitored application types
  */
@@ -51,22 +125,31 @@ typedef enum {
  * @brief State of the statisticsed process
  */
 typedef enum {
-       STC_APP_STATE_UNKNOWN = 0,
-       STC_APP_STATE_FOREGROUND = 1 << 1,  /** < foreground state */
-       STC_APP_STATE_BACKGROUND = 1 << 2,  /** < background state */
-       STC_APP_STATE_LAST_ELEM = 1 << 3
+       STC_APP_STATE_UNKNOWN,
+       STC_APP_STATE_FOREGROUND,  /** < foreground state */
+       STC_APP_STATE_BACKGROUND,  /** < background state */
+       STC_APP_STATE_LAST_ELEM
 } stc_app_state_e;
 
 /**
  * @brief Network restriction states
  */
 typedef enum {
-       STC_RESTRICTION_UNKNOWN,
-       STC_RESTRICTION_ACTIVATED,  /** < restriction has been activated */
-       STC_RESTRICTION_REMOVED,    /** < restriction has been removed */
-       STC_RESTRICTION_EXCLUDED,   /** < restriction has been excluded */
-       STC_RESTRICTION_LAST_ELEM
-} stc_restriction_state_e;
+       STC_RSTN_STATE_UNKNOWN,
+       STC_RSTN_STATE_ACTIVATED,
+       STC_RSTN_STATE_DEACTIVATED,
+       STC_RSTN_STATE_LAST_ELEM
+} stc_rstn_state_e;
+
+/**
+ * @brief Network restriction types
+ */
+typedef enum {
+       STC_RSTN_TYPE_UNKNOWN,
+       STC_RSTN_TYPE_ACCEPT,
+       STC_RSTN_TYPE_DROP,
+       STC_RSTN_TYPE_LAST_ELEM
+} stc_rstn_type_e;
 
 /**
  * @brief Network interface types
@@ -77,6 +160,10 @@ typedef enum {
        STC_IFACE_WIFI,       /**< wifi data */
        STC_IFACE_WIRED,      /**< wired interface */
        STC_IFACE_BLUETOOTH,  /**< bluetooth interface */
+       STC_IFACE_IPV4,       /**< ipv4 interface */
+       STC_IFACE_IPV6,       /**< ipv6 interface */
+       STC_IFACE_USB,        /**< usb interface */
+       STC_IFACE_P2P,        /**< p2p interface */
        STC_IFACE_ALL,        /**< enumerate all network interface types */
        STC_IFACE_LAST_ELEM
 } stc_iface_type_e;
@@ -95,7 +182,7 @@ typedef enum {
  * @brief Hardware network protocol types
  */
 typedef enum {
-       STC_PROTOCOL_NONE,                /**< Network unknown */
+       STC_PROTOCOL_UNKNOWN,             /**< Network unknown */
        STC_PROTOCOL_DATACALL_NOSVC,      /**< Network no service */
        STC_PROTOCOL_DATACALL_EMERGENCY,  /**< Network emergency */
        STC_PROTOCOL_DATACALL_SEARCH,     /**< Network search 1900 */
@@ -120,7 +207,6 @@ typedef enum {
 
 /**
  * @desc Set of the options.
- * version - contains structure version
  * wifi - enable/disable wifi, STC_DB_OPTION_UNDEF to leave option as is
  * datacall - enable/disable datacall, STC_DB_OPTION_UNDEF to leave option as is
  * datausage_timer - set period of the updating data from the kernel,
@@ -129,7 +215,6 @@ typedef enum {
  *     STC_DB_OPTION_UNDEF to leave option as is
  */
 typedef struct {
-       unsigned char version;
        stc_option_state_e wifi;
        stc_option_state_e datacall;
        time_t datausage_timer;
@@ -149,6 +234,8 @@ typedef struct {
 
        gpointer statistics_obj;
        gpointer restriction_obj;
+       gpointer firewall_obj;
+       gpointer manager_obj;
 
        GDBusObjectManagerServer *obj_mgr;
        GDBusConnection *connection;
@@ -159,5 +246,7 @@ typedef struct {
 } stc_s;
 
 stc_s *stc_get_manager(void);
+void stc_stop_manager(void);
+int stc_commit_iptables(char *cmd, int *err_num, char **err_str);
 
 #endif /* __STC_MANAGER__ */