blob: c67348e18002e444818d892f0ef1b5a8427eae02 [file] [log] [blame]
akmhoque8fdd6412012-12-04 15:05:33 -06001#ifndef _NLSR_LSDB_H_
2#define _NLSR_LSDB_H_
3
4#define LS_TYPE_ADJ 1
5#define LS_TYPE_NAME 2
akmhoqueed418f32013-01-30 12:25:04 -06006#define LS_TYPE_COR 3
akmhoque8fdd6412012-12-04 15:05:33 -06007
8struct link
9{
10 struct name_prefix *nbr;
11 int face;
12 int metric;
13};
14
15
16struct alsa_header
17{
18 unsigned int ls_type;
19 char *orig_time;
20 struct name_prefix *orig_router;
21
22};
23
24struct alsa
25{
26 struct alsa_header *header;
27 int no_link;
28 struct link *links;
29 char * body;
30};
31
32struct nlsa_header
33{
34 unsigned int ls_type;
35 char *orig_time;
36 long int ls_id;
37 struct name_prefix *orig_router;
38 unsigned int isValid;
39
40};
41
42struct nlsa
43{
44 struct nlsa_header *header;
45 struct name_prefix *name_prefix;
46};
47
akmhoqueed418f32013-01-30 12:25:04 -060048struct clsa
49{
50 struct alsa_header *header;
51 double cor_r;
52 double cor_theta;
53};
54
akmhoque8fdd6412012-12-04 15:05:33 -060055
56void set_new_lsdb_version(void);
57void build_and_install_name_lsas(void);
58void build_and_install_single_name_lsa(struct name_prefix *np);
59void build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np);
60void install_name_lsa(struct nlsa *name_lsa);
61void print_name_lsa(struct nlsa *name_lsa);
62void write_log_for_name_lsa(struct nlsa *name_lsa);
63void print_name_lsdb(void);
64void build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np);
65void build_others_name_lsa(struct nlsa *name_lsa, char *orig_router,int ls_type,long int ls_id, char *orig_time, int isValid, char *np);
66void make_name_lsa_key(char *key, char *orig_router, int ls_type, long int ls_id);
67int refresh_lsdb(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
68
69int build_and_install_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
70void build_adj_lsa(struct alsa * adj_lsa);
71void install_adj_lsa(struct alsa * adj_lsa);
72void print_adj_lsa_body(const char *body, int no_link);
73void print_adj_lsa(struct alsa * adj_lsa);
74void write_log_for_adj_lsa(struct alsa * adj_lsa);
75void print_adj_lsdb(void);
76void make_adj_lsa_key(char *key,struct alsa *adj_lsa);
77void build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data);
78void build_others_adj_lsa(struct alsa *adj_lsa,char *orig_router,int ls_type,char *orig_time,int no_link,char *data);
79
80long int get_name_lsdb_num_element(void);
81long int get_adj_lsdb_num_element(void);
82
akmhoque8fdd6412012-12-04 15:05:33 -060083int check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time);
84int check_is_new_adj_lsa(char *orig_router,char *lst,char *orig_time);
akmhoqueed418f32013-01-30 12:25:04 -060085int check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time);
akmhoque8fdd6412012-12-04 15:05:33 -060086
87void get_name_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId);
88void get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId);
89
90void make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id);
91
akmhoqueed418f32013-01-30 12:25:04 -060092void build_and_install_cor_lsa();
93void print_cor_lsdb();
94
akmhoque8fdd6412012-12-04 15:05:33 -060095void write_name_lsdb_to_repo(char *slice_prefix);
96void write_name_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id);
97void make_name_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, long int ls_id,char *orig_time,char *slice_prefix);
akmhoque4ae16942012-12-10 11:50:43 -060098void write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id);
akmhoque8fdd6412012-12-04 15:05:33 -060099
akmhoqueed418f32013-01-30 12:25:04 -0600100void write_cor_lsa_to_repo(struct clsa *cor_lsa);
101void build_and_install_others_cor_lsa(char *orig_router,int ls_type,char *orig_time, double cor_r, double cor_theta);
akmhoquef06586e2013-02-05 12:09:38 -0600102double get_hyperbolic_r(char *router);
103double get_hyperbolic_theta(char *router);
akmhoqueed418f32013-01-30 12:25:04 -0600104
akmhoque8fdd6412012-12-04 15:05:33 -0600105#endif