#define DELETE_COUNTER "DELETE FROM counters WHERE restriction_id=?"
-#define SELECT_COUNTER "SELECT sent_bytes, rcv_bytes FROM counters WHERE restriction_id=?"
+#define SELECT_COUNTER "SELECT data_counter FROM counters WHERE restriction_id=?"
-#define INSERT_COUNTER "INSERT INTO counters (restriction_id, sent_bytes, rcv_bytes) " \
- " VALUES (?, ?, ?)"
+#define INSERT_COUNTER "INSERT INTO counters (restriction_id, data_counter) " \
+ " VALUES (?, ?)"
-#define UPDATE_COUNTER "REPLACE INTO counters (restriction_id, sent_bytes, rcv_bytes) " \
- " VALUES (?, ?, ?)"
+#define UPDATE_COUNTER "REPLACE INTO counters (restriction_id, data_counter) " \
+ " VALUES (?, ?)"
static void __finalize_delete(void);
if (info == NULL)
goto handle_error;
+ info->restriction_id = restriction_id;
+
DB_ACTION(sqlite3_bind_int64(stmt, 1, restriction_id));
do {
case SQLITE_DONE:
break;
case SQLITE_ROW:
- info->sent_bytes = sqlite3_column_int64(stmt, 0);
- info->rcv_bytes = sqlite3_column_int64(stmt, 1);
+ info->data_counter = sqlite3_column_int64(stmt, 0);
- STC_LOGD("rstn_id [%llu] counters [sent = %lld rcv = %lld]",
- restriction_id, info->sent_bytes,
- info->rcv_bytes);
+ STC_LOGD("rstn_id [%llu] data_counters [%lld] bytes",
+ restriction_id, info->data_counter);
break;
case SQLITE_ERROR:
default:
stc_error_e error_code = STC_ERROR_NONE;
sqlite3_stmt *stmt = update_counter;
- if (!info->rcv_bytes && !info->sent_bytes) {
+ if (!info->data_counter) {
error_code = STC_ERROR_INVALID_PARAMETER;
goto handle_error;
}
DB_ACTION(sqlite3_bind_int64(stmt, 1, info->restriction_id));
- DB_ACTION(sqlite3_bind_int64(stmt, 2, info->sent_bytes));
- DB_ACTION(sqlite3_bind_int64(stmt, 3, info->rcv_bytes));
+ DB_ACTION(sqlite3_bind_int64(stmt, 2, info->data_counter));
if (sqlite3_step(stmt) != SQLITE_DONE) {
STC_LOGE("Failed to update counter: %s\n",