Fix the svace issue - DEREF_AFTER_NULL
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-network.c
old mode 100755 (executable)
new mode 100644 (file)
index 94dd467..43453cd
 #include "bt-request-sender.h"
 #include "bt-event-handler.h"
 
+#ifdef TIZEN_FEATURE_BT_DPM
+#include "bt-dpm.h"
+#endif
+
 BT_EXPORT_API int bluetooth_network_activate_server()
 {
        int result;
@@ -72,6 +76,49 @@ BT_EXPORT_API int bluetooth_network_connect(const bluetooth_device_address_t *de
                return BLUETOOTH_ERROR_PERMISSION_DEINED;
        }
 
+#ifdef TIZEN_FEATURE_BT_DPM
+       char *uuid = NULL;
+       if (_bt_check_dpm(BT_DPM_ADDRESS, (void *)device_address) == BT_DPM_RESTRICTED) {
+               BT_ERR("Blacklist device");
+               return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+       }
+
+       switch (role) {
+       case BLUETOOTH_NETWORK_PANU_ROLE:
+               uuid = g_strdup(BT_PAN_PANU_UUID);
+               break;
+       case BLUETOOTH_NETWORK_NAP_ROLE:
+               uuid = g_strdup(BT_PAN_NAP_UUID);
+               break;
+       case BLUETOOTH_NETWORK_GN_ROLE:
+               uuid = g_strdup(BT_PAN_GN_UUID);
+               break;
+       default:
+               break;
+       }
+
+       if (_bt_check_dpm(BT_DPM_UUID, uuid) == BT_DPM_RESTRICTED) {
+               BT_ERR("Blacklist uuid");
+               g_free(uuid);
+               return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+       }
+
+       if (_bt_check_dpm(BT_DPM_DESKTOP, NULL) == BT_DPM_RESTRICTED) {
+               char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+               bluetooth_device_class_t dev_class;
+
+               _bt_convert_addr_type_to_string(address, (unsigned char *)device_address->addr);
+               _bt_get_cod_by_address(address, &dev_class);
+
+               if (dev_class.major_class == BLUETOOTH_DEVICE_MAJOR_CLASS_COMPUTER) {
+                       BT_ERR("Reject a authorization due to MDM Policy");
+                       g_free(uuid);
+                       return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+               }
+       }
+       g_free(uuid);
+#endif
+
        user_info = _bt_get_user_data(BT_COMMON);
        retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);