-
Notifications
You must be signed in to change notification settings - Fork 0
/
sr_rtable_hw.h
54 lines (39 loc) · 1.33 KB
/
sr_rtable_hw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
/*
* Filename: sr_rtable_hw.h
* Purpose: define the hw routing table and operations on it
*/
#include <pthread.h>
#include "sr_common.h"
#include "sr_interface.h"
#include "linked_list.h"
#include <pthread.h>
struct sr_router;
/** contains information about a route */
typedef struct hw_route_t {
addr_ip_t destination;
uint16_t primary;
uint16_t backup;
addr_ip_t subnet_mask;
} hw_route_t;
/** routing table data structure */
typedef struct {
node* hw_rtable_list;
pthread_mutex_t hw_lock_rtable;
} hw_rtable_t;
/** Initialize the routing table. */
void hw_rrtable_init(struct sr_router *router);
void hw_rrtable_destroy(hw_rtable_t *rtable);
/** Adds a route to the routing table. */
void hw_rrtable_route_add( hw_rtable_t *rtable,
addr_ip_t dest, addr_ip_t mask,
uint16_t primary, uint16_t backup);
/** Removes the specified route from the routing table, if present. */
bool hw_rrtable_route_remove( hw_rtable_t *rtable,
addr_ip_t dest, addr_ip_t mask );
/** Remove all routes from the router. */
void hw_rrtable_purge_all( hw_rtable_t* rtable );
hw_route_t* hw_make_route_t(addr_ip_t dst, uint16_t primary, uint16_t backup, addr_ip_t subnet_mask);
void hw_rrtable_to_string();
void hw_rrtable_write_hw();
void hw_rrtable_read_hw();