/* DELETE statements */
#define DELETE_RESTRICTIONS "DELETE FROM restrictions " \
- " WHERE binpath = ? AND iftype = ? AND subscriber_id = ?"
+ " WHERE binpath = ? AND iftype = ? AND ifname = ? " \
+ " AND subscriber_id = ? AND roaming = ?"
/* SELECT statements */
#define SELECT_RESTRICTIONS "SELECT binpath, data_limit, " \
} while (rc == SQLITE_ROW);
handle_error:
- sqlite3_reset(stmt);
+ rc = sqlite3_reset(stmt);
+ if (rc != SQLITE_OK)
+ error_code = STC_ERROR_DB_FAILED;
+
__STC_LOG_FUNC_EXIT__;
return error_code;
}
-stc_error_e table_restrictions_foreach(const table_restrictions_info_cb restriction_cb,
+API stc_error_e table_restrictions_foreach(const table_restrictions_info_cb restriction_cb,
void *user_data)
{
__STC_LOG_FUNC_ENTER__;
}
} while (rc == SQLITE_ROW);
- sqlite3_reset(stmt);
+ rc = sqlite3_reset(stmt);
+ if (rc != SQLITE_OK)
+ error_code = STC_ERROR_DB_FAILED;
+
__STC_LOG_FUNC_EXIT__;
return error_code;
}
}
*type = STC_RSTN_TYPE_UNKNOWN;
- sqlite3_reset(select_restriction_type_subscriber_id);
- sqlite3_reset(select_restriction_type);
+ ret = sqlite3_reset(select_restriction_type_subscriber_id);
+ if (ret != SQLITE_OK) {
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+ }
+
+ ret = sqlite3_reset(select_restriction_type);
+ if (ret != SQLITE_OK) {
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+ }
if (subscriber_id == NULL) {
state_subscriber_id = 0;
}
handle_error:
- sqlite3_reset(select_restriction_type);
- sqlite3_reset(select_restriction_type_subscriber_id);
+ ret = sqlite3_reset(select_restriction_type);
+ if (ret != SQLITE_OK)
+ error_code = STC_ERROR_DB_FAILED;
+
+ ret = sqlite3_reset(select_restriction_type_subscriber_id);
+ if (ret != SQLITE_OK)
+ error_code = STC_ERROR_DB_FAILED;
+
return error_code;
}
stc_error_e table_restrictions_delete(const char *app_id,
const stc_iface_type_e iftype,
- const char *subscriber_id)
+ const char *ifname,
+ const char *subscriber_id,
+ const stc_roaming_type_e roaming)
{
stc_error_e error_code = STC_ERROR_NONE;
sqlite3_stmt *stmt = delete_restrictions;
- STC_LOGD("app_id [%s], iftype [%d], subscriber_id [%s]",
- app_id, iftype, subscriber_id);
+ STC_LOGD("app_id[%s] iftype[%d] ifname[%s] subscriber_id[%s] roaming[%d]",
+ app_id, iftype, ifname, subscriber_id, roaming);
DB_ACTION(sqlite3_bind_text(stmt, 1, app_id ? app_id : "",
-1, SQLITE_TRANSIENT));
DB_ACTION(sqlite3_bind_int(stmt, 2, iftype));
- DB_ACTION(sqlite3_bind_text(stmt, 3, subscriber_id ? subscriber_id : "", -1,
- SQLITE_TRANSIENT));
+ DB_ACTION(sqlite3_bind_text(stmt, 3, ifname ? ifname : "",
+ -1, SQLITE_TRANSIENT));
+ DB_ACTION(sqlite3_bind_text(stmt, 4, subscriber_id ? subscriber_id : "",
+ -1, SQLITE_TRANSIENT));
+ DB_ACTION(sqlite3_bind_int(stmt, 5, roaming));
if (sqlite3_step(stmt) != SQLITE_DONE) {
STC_LOGE("Failed to remove restrictions by network interface %s\n", //LCOV_EXCL_LINE
handle_error:
- sqlite3_reset(stmt);
+ if (sqlite3_reset(stmt) != SQLITE_OK)
+ error_code = STC_ERROR_DB_FAILED;
+
return error_code;
}
default:
STC_LOGE("Failed to get restriction id: %s\n", //LCOV_EXCL_LINE
sqlite3_errmsg(stc_db_get_database()));
+ error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
}
handle_error:
- sqlite3_reset(stmt);
+ rc = sqlite3_reset(stmt);
+ if (rc != SQLITE_OK)
+ error_code = STC_ERROR_DB_FAILED;
+
__STC_LOG_FUNC_EXIT__;
return error_code;
}
goto handle_error; //LCOV_EXCL_LINE
}
- __get_restriction_id(info);
+ if (__get_restriction_id(info) != STC_ERROR_NONE) {
+ error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+ goto handle_error; //LCOV_EXCL_LINE
+ }
+
if (info->restriction_id)
stmt = update_net_restrictions;
STC_LOGD("Restriction updated app_id [%s]", info->app_id);
} else {
STC_LOGD("Restriction inserted app_id [%s]", info->app_id);
- __get_restriction_id(info);
+ if (__get_restriction_id(info) != STC_ERROR_NONE)
+ error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
}
handle_error:
- sqlite3_reset(stmt);
+ if (sqlite3_reset(stmt) != SQLITE_OK)
+ error_code = STC_ERROR_DB_FAILED;
+
return error_code;
}