mirror of
https://github.com/Hizenberg469/Event-Loop-in-C.git
synced 2026-04-20 01:02:23 +03:00
Updated code base
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "utils.h"
|
||||
#include "rt.h"
|
||||
#include "stp_el.h"
|
||||
#include "timerlib.h"
|
||||
#include "stp_el.h"
|
||||
|
||||
rt_table_t*
|
||||
rt_create_new_rt_table(char* name) {
|
||||
@@ -18,6 +19,7 @@ rt_create_new_rt_table(char* name) {
|
||||
|
||||
static void
|
||||
rt_entry_exp_timer_cbk(Timer_t* timer, void* arg) {
|
||||
|
||||
rt_table_t* rt_table;
|
||||
rt_table_entry_t* rt_table_entry = (rt_table_entry_t*)arg;
|
||||
|
||||
@@ -47,7 +49,6 @@ rt_insert_new_entry(rt_table_t* rt,
|
||||
|
||||
rt_table_entry->rt_table = rt;
|
||||
|
||||
|
||||
strncpy(rt_table_entry->dest, dest, 16);
|
||||
rt_table_entry->mask = mask;
|
||||
strncpy(rt_table_entry->gw, gw, 16);
|
||||
@@ -56,7 +57,6 @@ rt_insert_new_entry(rt_table_t* rt,
|
||||
rt_table_entry->prev = 0;
|
||||
time(&rt_table_entry->last_updated_time);
|
||||
|
||||
|
||||
if (exp_timer_in_millisec) {
|
||||
rt_table_entry->exp_timer = setup_timer(
|
||||
rt_entry_exp_timer_cbk,
|
||||
@@ -151,6 +151,12 @@ rt_update_rt_entry(rt_table_t* rt,
|
||||
rt_table_entry->mask == mask &&
|
||||
strncmp(rt_table_entry->gw, new_gw, 16) == 0 &&
|
||||
strncmp(rt_table_entry->oif, new_oif, 32) == 0) {
|
||||
|
||||
/* Refresh the timer */
|
||||
if (rt_table_entry->exp_timer) {
|
||||
restart_timer(rt_table_entry->exp_timer);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -159,6 +165,13 @@ rt_update_rt_entry(rt_table_t* rt,
|
||||
strncpy(rt_table_entry->gw, new_gw, 16);
|
||||
strncpy(rt_table_entry->oif, new_oif, 32);
|
||||
time(&rt_table_entry->last_updated_time);
|
||||
|
||||
/* Refresh the timer */
|
||||
if (rt_table_entry->exp_timer) {
|
||||
|
||||
restart_timer(rt_table_entry->exp_timer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -178,16 +191,16 @@ rt_display_rt_table(rt_table_t* rt) {
|
||||
uptime_in_seconds = (unsigned int)difftime(
|
||||
curr_time, rt_table_entry->last_updated_time);
|
||||
|
||||
printf("%d. %-18s %-4d %-18s %-18s ", i,
|
||||
printf("%d. %-18s %-4d %-18s %-18s", i,
|
||||
rt_table_entry->dest,
|
||||
rt_table_entry->mask,
|
||||
rt_table_entry->gw,
|
||||
rt_table_entry->oif);
|
||||
printf("Last updated : %s\n", hrs_min_sec_format(uptime_in_seconds));
|
||||
|
||||
printf("Exp time : %lu\n",
|
||||
rt_table_entry->exp_timer ? \
|
||||
timer_get_time_remaining_in_mill_sec(rt_table_entry->exp_timer) : 0);
|
||||
printf("Last updated : %s ", hrs_min_sec_format(uptime_in_seconds)),
|
||||
printf("Exp time : %lu\n",
|
||||
rt_table_entry->exp_timer ? \
|
||||
timer_get_time_remaining_in_mill_sec(rt_table_entry->exp_timer) : 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user