Knox Tizen Wearable SDK
Firewall policy group

Firewall policy group provides a front-end to configure Firewall Rules on device using iptables. More...

Functions

mdm_data_tmdm_get_iptables_allow_rules (void)
 API to get "allow rules". More...
 
mdm_data_tmdm_get_iptables_deny_rules (void)
 API to get "deny rules". More...
 
mdm_data_tmdm_get_iptables_proxy_rules (void)
 API to get "proxy rules". More...
 
mdm_data_tmdm_get_iptables_reroute_rules (void)
 API to get "reroute rules". More...
 
mdm_data_tmdm_get_iptables_rules (void)
 API to get all "allow", "deny", "reroute", and "redirect exceptions" rules. More...
 
mdm_result_t mdm_add_iptables_allow_rules (void *p_ruleslist)
 API to add "allow rules" in iptables. More...
 
mdm_result_t mdm_add_iptables_deny_rules (void *p_ruleslist)
 API to add "deny rules" in iptables. More...
 
mdm_result_t mdm_add_iptables_reroute_rules (void *p_ruleslist)
 API to add "reroute rules" in iptables. More...
 
mdm_result_t mdm_clean_iptables_allow_rules (void)
 API to clean "allow rules" in iptables. More...
 
mdm_result_t mdm_clean_iptables_deny_rules (void)
 API to clean "deny rules" in iptables. More...
 
mdm_result_t mdm_clean_iptables_proxy_rules (void)
 API to clean "proxy rules" in iptables. More...
 
mdm_result_t mdm_clean_iptables_reroute_rules (void)
 API to clean "reroute rules" in iptables. More...
 
mdm_result_t mdm_get_allow_iptables_option (int *p_value)
 API to query whether "allow", "deny", and "reroute" rules are enabled or not. More...
 
mdm_result_t mdm_get_allow_iptables_proxy_option (int *p_value)
 API to query whether "proxy" rules are enabled or not. More...
 
mdm_result_t mdm_remove_iptables_allow_rules (void *p_ruleslist)
 API to remove "allow rules" from iptables. More...
 
mdm_result_t mdm_remove_iptables_deny_rules (void *p_ruleslist)
 API to remove "deny rules" from iptables. More...
 
mdm_result_t mdm_remove_iptables_reroute_rules (void *p_ruleslist)
 API to remove "reroute rules" from iptables. More...
 
mdm_result_t mdm_remove_iptables_rules (void)
 API to remove "allow", "deny", and "reroute" from iptables. More...
 
mdm_result_t mdm_set_iptables_allow_rules (void *p_ruleslist)
 API to set "allow rules" to iptables. More...
 
mdm_result_t mdm_set_iptables_deny_rules (void *p_ruleslist)
 API to set "deny rules" to iptables. More...
 
mdm_result_t mdm_set_allow_iptables_option (mdm_status_t status)
 API to enable or disable all "allow", "deny", "reroute", and "redirect exceptions" rules on iptables. More...
 
mdm_result_t mdm_set_allow_iptables_proxy_option (mdm_status_t status)
 API to enable or disable "proxy rule" on iptables. More...
 
mdm_result_t mdm_set_iptables_proxy_rules (char *ip, char *port)
 API to set a "proxy rule" on iptables. This API is used to setup a transparent HTTP proxy by defining an IP and port of the target proxy server. More...
 
mdm_result_t mdm_set_iptables_reroute_rules (void *p_ruleslist)
 API to set "reroute rules" on iptables. More...
 

Detailed Description

Firewall policy group provides a front-end to configure Firewall Rules on device using iptables.

Firewall policy group.

Required Header

#include <mdm.h>

Overview

This API provides a front-end to configure Firewall Rules on device using iptables. Be careful when using rules with hostnames as iptables uses a DNS to translate hostnames to IP addresses. When using this type of rules make sure that you did not block the DNS Server port or DNS Server IP and that you have an internet connection available. If DNS is blocked (internet connection is not available) Firewall will enqueue rules with hostname and apply them when a valid DNS connection is verified. Firewall resolves hostnames when the device is powered up and when rules are applied. Be aware that during this interval hostname's IP address are subject to change. Firewall Policy can conflict with others features that uses iptables breaking firewall functionality. Tethering, Cisco AnyConnect App, Data Usage (feature available on settings menu of device), and B2C Firewall (feature available on settings menu of some Samsung devices) are known to conflict with Firewall Policy. Do not use Firewall Policy together with this features. Firewall must be used with Tethering disabled.

-Firewall Definitions: Local Port - It is the device's port. Example: To block the device's port 21 (FTP) to receive connections you must block "Local Port" 21. Remote Port - It is the server's port. Example: To block the device to connect to port 80 (HTTP) of a server you must block "Remote Port" 80. Wildcard - is a character that represents of all possible values for a parameter. Example: To block all ports for IP 1.2.3.4 you must specify * as the port parameter and 1.2.3.4 as the IP parameter.

-Firewall Rules Types: Allow Rules - Are firewall rules that allows the device to send traffic to or receive traffic from an specific network location, according to the rule created (that can be specified by IP, port, hostname, domain, port range, etc). Deny Rules - Are firewall rules that blocks the device to send traffic to or receive traffic from an specific network location, according to the rule created (that can be specified by IP, port, hostname, domain, port range, etc). Reroute Rules - Are firewall rules used to redirect traffic destined to a target to another destination, for instance, a proxy server.

-Multi Admin Scenario: When used with Multi Admin, Firewall will behave as follows:

-Example: Admin 1 enables his set of rules (Admin 1 rules set are active). Admin 2 enables his set of rules (Admin 2 rules set are active). Admin 3 enables his set of rules (Admin 3 rules set are active). Admin 2 disables his set of rules (Admin 3 rules set are active). Admin 3 disables his set of rules (Admin 1 rules set are active). Admin 1 disables his set of rules (No rules active).

-NOTE: "Basic rules" and "Proxy Rule" behave separately because they have different APIs for enable or disable. "Basic rules" use setIptablesOption(boolean) and "Proxy Rules" uses setIptablesProxyOption(boolean).

-Example: Admin 1 enables "Basic Rules" (Admin 1 "Basic rules" set are active, no "Proxy rule" active). Admin 2 enables "Proxy Rule" (Admin 1 "Basic rules" set are active, Admin 2 "Proxy rule" is active). Admin 3 enables "Basic Rules" (Admin 3 "Basic rules" set are active, Admin 2 "Proxy rule" is active). Admin 1 enables "Proxy Rules" (Admin 3 "Basic rules" set are active, Admin 1 "Proxy rule" is active). Admin 3 disables "Basic Rules" (Admin 1 "Basic rules" set are active, Admin 1 "Proxy rule" is active). Admin 1 disables "Proxy Rules" (Admin 1 "Basic rules" set are active, Admin 2 "Proxy rule" is active). Admin 2 disables "Proxy Rules" (Admin 1 "Basic rules" set are active, no "Proxy rule" active). Admin 1 disables "Basic Rules" (No "Basic rules" active, no "Proxy rule" active).

Function Documentation

mdm_result_t mdm_add_iptables_allow_rules ( void *  p_ruleslist)

API to add "allow rules" in iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can add "allow rules" on iptables. "Allow rules" have precedence over deny rules.
GList *lp_List = NULL;
//allows IP 1.2.3.4 on all remote and local ports
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:*;*"));
//allows connection to servers on port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;remote"));
//allows the device's port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;local"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// add error
} else {
// add success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: (In this function, we only add one node each time) "hostname:port;portLocation" or "hostname:port;portLocation;networkInterface" hostname - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and domain name are valid entries for hostname parameter. port - Port number, port range (e.g. 8080-8085) are valid entries for port parameter. portLocation - Specify if this rule must be applied to remote and, or local port(s); "local" and "remote" strings are valid entries for portLocation parameter. networkInterface: must only be "wifi", "data", or "*", all other values are invalid "*" can be used as a wildcard for the parameters (see example above).
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_allow_rules
mdm_result_t mdm_add_iptables_deny_rules ( void *  p_ruleslist)

API to add "deny rules" in iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can add "deny rules" on iptables. "Allow rules" have precedence over deny rules
GList *lp_List = NULL;
//blocks IP 1.2.3.4 on all remote and local ports
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:*;*"));
//blocks IP range 10.0.0.0-10.0.0.10
lp_List = g_list_append(lp_List, g_strdup("10.0.0.0-10.0.0.10:*;*"))
//blocks connection to servers on port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;remote"));
//blocks the device's port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;local"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// add error
} else {
// add success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: (In this function now, we only add one node each time) "hostname:port;portLocation" "hostname:port;portLocation;nativebrowser;networkInterface" hostname - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and domain name are valid entries for hostname parameter. port - Port number, port range (e.g. 8080-8085) are valid entries for port parameter. portLocation - Specify if this rule must be applied to remote and, or local port(s) "local" and "remote" strings are valid for portLocation parameter "*" can be used as a wildcard for the parameters (see the example above).
Returns
MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_deny_rules
mdm_result_t mdm_add_iptables_reroute_rules ( void *  p_ruleslist)

API to add "reroute rules" in iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can add "reroute rules" on iptables. "Reroute rules" have precedence over "proxy rule".
GList *lp_List = NULL;
//reroute traffic going to IP 1.2.3.4 to IP 1.1.1.1 and port 80
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:*;1.1.1.1:80"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// add error
} else {
// add success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: "hostTarget:portTarget;ipProxy:portProxy" hostTarget - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and Domain Name are valid entries for hostTarget parameter. portTarget - Port number, port range (e.g. 8080-8085) are valid entries for portTarget parameter. ipProxy - IP Address is a valid entry for IP parameter. portProxy - Port Number is a valid entry for portProxy parameter. "*" can be used as a wildcard for hostTarget and portTarget . ipProxy and portProxy do not support "*" wildcard (see the example above).
Returns
MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_reroute_rules
mdm_result_t mdm_clean_iptables_allow_rules ( void  )

API to clean "allow rules" in iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can clean all "allow rules" from iptables.
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// clean error
} else {
// clean success
}
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_allow_rules, mdm_add_iptables_allow_rules
mdm_result_t mdm_clean_iptables_deny_rules ( void  )

API to clean "deny rules" in iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can clean all "deny rules" from iptables.
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// clean error
} else {
// clean success
}
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_deny_rules, mdm_add_iptables_deny_rules
mdm_result_t mdm_clean_iptables_proxy_rules ( void  )

API to clean "proxy rules" in iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can clean all "proxy rules" from iptables.
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// clean error
} else {
// clean success
}
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_proxy_rules
mdm_result_t mdm_clean_iptables_reroute_rules ( void  )

API to clean "reroute rules" in iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can clean all "reroute rules" from iptables.
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// clean error
} else {
// clean success
}
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_reroute_rules
mdm_result_t mdm_get_allow_iptables_option ( int *  p_value)

API to query whether "allow", "deny", and "reroute" rules are enabled or not.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can query whether "allow", "deny," and "reroute" rules are enabled or not
int value = 0;
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// get error
} else {
// get success
printf("%d", value);
}
Parameters
[out]p_valueiptables_option
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
See also
mdm_set_allow_iptables_option
mdm_result_t mdm_get_allow_iptables_proxy_option ( int *  p_value)

API to query whether "proxy" rules are enabled or not.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can query whether "proxy" rules are enabled or not
int value = 0;
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// get error
} else {
// get success
printf("%d", value);
}
Parameters
[out]p_valueiptables_option
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
See also
mdm_set_allow_iptables_proxy_option
mdm_data_t* mdm_get_iptables_allow_rules ( void  )

API to get "allow rules".

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can get the "allow rules".
mdm_result_t ret = 0;
if (lp_data) {
GList *lp_list = (GList *)lp_data->data;
if (lp_list) {
lp_list = g_list_first(lp_list);
while (lp_list && lp_list->data) {
printf ("%s", (char *) lp_list->data);
// Sample Output
// 1.2.3.4:*;*
// *:80;*
lp_list = g_list_next(lp_list);
}
}
mdm_free_data(lp_data);
}
Returns
mdm_data_t * on success, NULL on error
See also
mdm_set_iptables_allow_rules
mdm_data_t* mdm_get_iptables_deny_rules ( void  )

API to get "deny rules".

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can get the "deny rules".
mdm_result_t ret = 0;
if (lp_data) {
GList *lp_list = (GList *)lp_data->data;
if (lp_list) {
lp_list = g_list_first(lp_list);
while (lp_list && lp_list->data) {
printf ("%s", (char *) lp_list->data);
// Sample Output
// 1.2.3.4:*;*
// *:80;*
lp_list = g_list_next(lp_list);
}
}
mdm_free_data(lp_data);
}
Returns
mdm_data_t * on success, NULL on error
See also
mdm_set_iptables_deny_rules
mdm_data_t* mdm_get_iptables_proxy_rules ( void  )

API to get "proxy rules".

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can get the "proxy rules".
mdm_result_t ret = 0;
if (lp_data) {
GList *lp_list = (GList *)lp_data->data;
if (lp_list) {
lp_list = g_list_first(lp_list);
while (lp_list && lp_list->data) {
printf ("%s", (char *) lp_list->data);
// Sample Output
// 1.2.3.4:8080
// where 1.2.3.4 is the IP address of the proxy and 8080 the proxy port
lp_list = g_list_next(lp_list);
}
}
mdm_free_data(lp_data);
}
Returns
mdm_data_t * on success, NULL on error
See also
mdm_set_iptables_proxy_rules
mdm_data_t* mdm_get_iptables_reroute_rules ( void  )

API to get "reroute rules".

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can get the "reroute rules".
mdm_result_t ret = 0;
if (lp_data) {
GList *lp_list = (GList *)lp_data->data;
if (lp_list) {
lp_list = g_list_first(lp_list);
while (lp_list && lp_list->data) {
printf ("%s", (char *) lp_list->data);
// Sample Output
// 1.2.3.4:*;1.1.1.1:80
// where 1.2.3.4 is the hostTarget parameter, * the wildcard for the portTarget parameter,
// 1.1.1.1 is the ipProxy parameter, and 80 the portProxy parameter.
lp_list = g_list_next(lp_list);
}
}
mdm_free_data(lp_data);
}
Returns
mdm_data_t * on success, NULL on error
See also
mdm_set_iptables_reroute_rules
mdm_data_t* mdm_get_iptables_rules ( void  )

API to get all "allow", "deny", "reroute", and "redirect exceptions" rules.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can get all "allow", "deny", "reroute", and "redirect exceptions" rules.
mdm_result_t ret = 0;
if (lp_data) {
GList *lp_list = (GList *)lp_data->data;
if (lp_list) {
lp_list = g_list_first(lp_list);
while (lp_list && lp_list->data) {
printf ("%s", (char *) lp_list->data);
// Sample Output
// 1.2.3.4:*;*;allow
// *:80;*;deny
// 1.2.3.4:*;1.1.1.1:80;reroute
// In the first line of the output 1.2.3.4 is the hostname parameter,
// * is a wildcard for the port parameter, * is a wildcard for
// portLocation parameter,
// and "allow" means that it represents an "allow rule".
// In the second line of the output * is a wildcard for hostname parameter,
// 80 port parameter, * is a wildcard for portLocation parameter,
// and "deny" means that it represents a "deny rule".
// In the third line of the output 1.2.3.4 is the hostTarget parameter,
// * the wildcard for the portTarget parameter,
// 1.1.1.1 is the ipProxy parameter, 80 the portProxy parameter, and
// reroute means that it is a reroute rule.
lp_list = g_list_next(lp_list);
}
}
mdm_free_data(lp_data);
}
Returns
mdm_data_t * on success, NULL on error
See also
mdm_get_iptables_allow_rules, mdm_get_iptables_deny_rules, mdm_get_iptables_proxy_rules, mdm_get_iptables_reroute_rules
mdm_result_t mdm_remove_iptables_allow_rules ( void *  p_ruleslist)

API to remove "allow rules" from iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can remove "allow rules" from iptables. Be sure to use the same parameters when setting or adding the rule to be removed.
GList *lp_List = NULL;
//removes IP 1.2.3.4 on all remote and local ports
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:*;*"));
//allows connection to servers on port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;remote"));
//allows the device's port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;local"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// remove error
} else {
// remove success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: "hostname:port;portLocation" or "hostname:port;portLocation;networkInterface" hostname - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and domain name are valid entries for hostname parameter. port - Port number, port range (e.g. 8080-8085) are valid entries for port parameter. portLocation - Specify if this rule must be applied to remote and, or local port(s); "local" and "remote" strings are valid for portLocation parameter. networkInterface: must only be "wifi", "data", or "*", all other values are invalid "*" can be used as a wildcard for the parameters (see the example above).
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_add_iptables_allow_rules
mdm_result_t mdm_remove_iptables_deny_rules ( void *  p_ruleslist)

API to remove "deny rules" from iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can remove "deny rules" from iptables. Be sure to use the same parameters when setting or adding the rule to be removed.
GList *lp_List = NULL;
//removes IP 1.2.3.4 on all remote and local ports
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:*;*"));
//removes IP range 10.0.0.0-10.0.0.10
lp_List = g_list_append(lp_List, g_strdup("10.0.0.0-10.0.0.10:*;*"))
//removes connection to servers on port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;remote"));
//removes the device's port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;local"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// remove error
} else {
// remove success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: "hostname:port;portLocation" or "hostname:port;portLocation;networkInterface" hostname - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and domain name are valid entries for hostname parameter. port - Port number, port range (e.g. 8080-8085) are valid entries for port parameter. portLocation - Specify if this rule must be applied to remote and, or local port(s); "local" and "remote" strings are valid for portLocation parameter. networkInterface: must only be "wifi", "data", or "*", all other values are invalid "*" can be used as a wildcard for the parameters (see the example above).
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_add_iptables_deny_rules
mdm_result_t mdm_remove_iptables_reroute_rules ( void *  p_ruleslist)

API to remove "reroute rules" from iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can remove "reroute rules" from iptables. Be sure to use the same parameters when setting or adding the rule to be removed.
GList *lp_List = NULL;
//remotes reroute traffic going to IP 1.2.3.4 to IP 1.1.1.1 and port 80
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:*;1.1.1.1:80"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// remove error
} else {
// remove success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: "hostname:port;portLocation" or "hostname:port;portLocation;networkInterface" hostname - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and domain name are valid entries for hostname parameter. port - Port number, port range (e.g. 8080-8085) are valid entries for port parameter. portLocation - Specify if this rule must be applied to remote and, or local port(s); "local" and "remote" strings are valid for portLocation parameter. networkInterface: must only be "wifi", "data", or "*", all other values are invalid "*" can be used as a wildcard for the parameters (see the example above).
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_add_iptables_reroute_rules
mdm_result_t mdm_remove_iptables_rules ( void  )

API to remove "allow", "deny", and "reroute" from iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can remove "allow", "deny", and "reroute" from iptables. Be sure to use the same parameters when setting or adding the rule to be removed.
int value = 0;
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// remove error
} else {
// remove success
}
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_rules
mdm_result_t mdm_set_allow_iptables_option ( mdm_status_t  status)

API to enable or disable all "allow", "deny", "reroute", and "redirect exceptions" rules on iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can enable or disable all "allow", "deny", "reroute", and "redirect exceptions" rules on iptables
mdm_result_t ret = 0;
int n_status = MDM_RESTRICTED;
if (ret != MDM_RESULT_SUCCESS) {
// function error
} else {
// function success
}
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]statusmdm status
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_allow_iptables_option
mdm_result_t mdm_set_allow_iptables_proxy_option ( mdm_status_t  status)

API to enable or disable "proxy rule" on iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can enable or disable "proxy rule" on iptables
mdm_result_t ret = 0;
int n_status = MDM_RESTRICTED;
if (ret != MDM_RESULT_SUCCESS) {
// function error
} else {
// function success
}
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]statusmdm status
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_allow_iptables_proxy_option
mdm_result_t mdm_set_iptables_allow_rules ( void *  p_ruleslist)

API to set "allow rules" to iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can set "allow rules" to iptables. This API overwrites the "allow rules" previously added or set. "Allow rules" have precedence over "deny rules".
GList *lp_List = NULL;
//allows IP 1.2.3.4 on all remote and local ports
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:*;*"));
//allows IP range 10.0.0.0-10.0.0.10
lp_List = g_list_append(lp_List, g_strdup("10.0.0.0-10.0.0.10:*;*"))
//allows connection to servers on port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;remote"));
//allows the device's port 80
lp_List = g_list_append(lp_List, g_strdup("*:80;local"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// set error
} else {
// set success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: (In this function now, we only add one node each time) "hostname:port;portLocation" or "hostname:port;portLocation;networkInterface" hostname - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and domain name are valid entries for hostname parameter. port - Port number, port range (e.g. 8080-8085) are valid entries for port parameter. portLocation - Specify if this rule must be applied to remote and, or local port(s); "local" and "remote" strings are valid for portLocation parameter. networkInterface: must only be "wifi", "data", or "*", all other values are invalid "*" can be used as a wildcard for the parameters (see the example above).
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_allow_rules
mdm_result_t mdm_set_iptables_deny_rules ( void *  p_ruleslist)

API to set "deny rules" to iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can set "deny rules" on iptables. This API overwrites the "deny rules" previously added or set. "Allow rules" have precedence over "deny rules".
GList *lp_List = NULL;
//blocks IP 1.2.3.4 on remote 80 port
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:80;remote"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// set error
} else {
// set success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: (In this function now, we only add one node each time) "hostname:port;portLocation" or "hostname:port;portLocation;nativebrowser;networkInterface" hostname - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and domain name are valid entries for hostname parameter. port - Port number, port range (e.g. 8080-8085) are valid entries for port parameter. portLocation - Specify if this rule must be applied to remote and, or local port(s); "local" and "remote" strings are valid for portLocation parameter. networkInterface: must only be "wifi", "data", or "*", all other values are invalid "*" can be used as a wildcard for the parameters (see the example above).
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_deny_rules
mdm_result_t mdm_set_iptables_proxy_rules ( char *  ip,
char *  port 
)

API to set a "proxy rule" on iptables. This API is used to setup a transparent HTTP proxy by defining an IP and port of the target proxy server.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can set a "proxy rule" on iptables. A "proxy rule" is a set of IP address:port to where all traffic originally targeted to TCP port 80 will be redirected to. This API overwrites the "proxy rule" previously set
mdm_result_t ret = 0;
//sets proxy on IP 1.2.3.4 and port 8080 (proxy is not enabled yet)
ret = mdm_set_iptables_proxy_rules("1.2.3.4", "8080");
if (ret != MDM_RESULT_SUCCESS) {
// function error
} else {
// function success
}
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]ipIp address
[in]portPort number
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_proxy_rules
mdm_result_t mdm_set_iptables_reroute_rules ( void *  p_ruleslist)

API to set "reroute rules" on iptables.

Since (Knox_wearable):
1.0.0
Since (Tizen):
2.3.2.3
Feature:
http://developer.samsung.com/tizen/feature/mdm
Usage:
Admin can set "reroute rules" on iptables. This API overwrites the "reroute rules" previously set. "Reroute rules" have precedence over "proxy rules".
GList *lp_List = NULL;
//sets reroute traffic going to IP 1.2.3.4 to IP 1.1.1.1 and port 80
lp_List = g_list_append(lp_List, g_strdup("1.2.3.4:*;1.1.1.1:80"));
mdm_result_t ret = 0;
if (ret != MDM_RESULT_SUCCESS) {
// add error
} else {
// add success
}
g_list_foreach((GList *)lp_List, (GFunc)g_free, NULL);
g_list_free((GList *)lp_List);
Privilege Level:
public
Privilege:
http://developer.samsung.com/tizen/privilege/mdm.firewall
Parameters
[in]p_ruleslistEach node in the list must be in one of the following formats: "hostTarget:portTarget;ipProxy:portProxy" hostTarget - IP address, IP range (e.g. 100.0.0.0-100.0.0.10) and Domain Name are valid entries for hostTarget parameter. portTarget - Port number, port range (e.g. 8080-8085) are valid entries for portTarget parameter. ipProxy - IP Address is a valid entry for IP parameter. portProxy - Port Number is a valid entry for portProxy parameter. "*" can be used as a wildcard for hostTarget, portTarget. ipProxy and portProxy do not support "*" wildcard (see the example above).
Returns
mdm_result_t : MDM_RESULT_SUCCESS on success, an error code on error
Return values
MDM_RESULT_SUCCESSSuccessful
MDM_RESULT_FAILGeneral failure
MDM_RESULT_NOT_SUPPORTEDNot supported
MDM_RESULT_INVALID_PARAMInvalid parameter
MDM_RESULT_ACCESS_DENIEDThe application does not have the privilege to call this function.
Permission:
Usage of this API is restricted to registered clients only.
See also
mdm_get_iptables_reroute_rules