blob: 94e84afbcbe8529fcfbbffec15cb628e56881770 [file] [log] [blame]
akmhoque902d57e2012-08-17 09:24:38 -05001#ifndef _NLSR_LSDB_H_
2#define _NLSR_LSDB_H_
3
akmhoquef71d9082012-08-22 12:51:53 -04004#define LS_TYPE_ADJ 1
5#define LS_TYPE_NAME 2
akmhoqueb77b95f2013-02-08 12:28:47 -06006#define LS_TYPE_COR 3
akmhoquef71d9082012-08-22 12:51:53 -04007
akmhoque902d57e2012-08-17 09:24:38 -05008struct link
9{
akmhoque53f64222012-09-05 13:57:51 -050010 struct name_prefix *nbr;
akmhoque902d57e2012-08-17 09:24:38 -050011 int face;
12 int metric;
13};
14
akmhoquef71d9082012-08-22 12:51:53 -040015
16struct alsa_header
akmhoque902d57e2012-08-17 09:24:38 -050017{
akmhoquef71d9082012-08-22 12:51:53 -040018 unsigned int ls_type;
akmhoque53f64222012-09-05 13:57:51 -050019 char *orig_time;
20 struct name_prefix *orig_router;
21
akmhoquef71d9082012-08-22 12:51:53 -040022};
akmhoque902d57e2012-08-17 09:24:38 -050023
akmhoquef71d9082012-08-22 12:51:53 -040024struct alsa
25{
26 struct alsa_header *header;
akmhoque902d57e2012-08-17 09:24:38 -050027 int no_link;
akmhoque03004e62012-09-06 01:12:28 -050028 struct link *links;
29 char * body;
akmhoque902d57e2012-08-17 09:24:38 -050030};
31
akmhoquef71d9082012-08-22 12:51:53 -040032struct nlsa_header
akmhoque902d57e2012-08-17 09:24:38 -050033{
akmhoquef71d9082012-08-22 12:51:53 -040034 unsigned int ls_type;
akmhoque53f64222012-09-05 13:57:51 -050035 char *orig_time;
akmhoquef71d9082012-08-22 12:51:53 -040036 long int ls_id;
akmhoque53f64222012-09-05 13:57:51 -050037 struct name_prefix *orig_router;
akmhoque8c1cdbf2012-08-26 21:09:11 -050038 unsigned int isValid;
akmhoque902d57e2012-08-17 09:24:38 -050039
akmhoque902d57e2012-08-17 09:24:38 -050040};
41
akmhoquef71d9082012-08-22 12:51:53 -040042struct nlsa
43{
44 struct nlsa_header *header;
akmhoque53f64222012-09-05 13:57:51 -050045 struct name_prefix *name_prefix;
akmhoquef71d9082012-08-22 12:51:53 -040046};
47
akmhoqueb77b95f2013-02-08 12:28:47 -060048struct clsa
49{
50 struct alsa_header *header;
51 double cor_r;
52 double cor_theta;
53};
54
akmhoquef71d9082012-08-22 12:51:53 -040055
akmhoque03004e62012-09-06 01:12:28 -050056void set_new_lsdb_version(void);
akmhoque53f64222012-09-05 13:57:51 -050057void build_and_install_name_lsas(void);
akmhoque3171d652012-11-13 11:44:33 -060058void build_and_install_single_name_lsa(struct name_prefix *np);
akmhoque53f64222012-09-05 13:57:51 -050059void build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np);
akmhoque53f64222012-09-05 13:57:51 -050060void install_name_lsa(struct nlsa *name_lsa);
akmhoque03004e62012-09-06 01:12:28 -050061void print_name_lsa(struct nlsa *name_lsa);
akmhoque9e9fc722012-09-26 14:03:25 -050062void write_log_for_name_lsa(struct nlsa *name_lsa);
akmhoque53f64222012-09-05 13:57:51 -050063void print_name_lsdb(void);
akmhoque03004e62012-09-06 01:12:28 -050064void 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);
akmhoqueffacaa82012-09-13 17:48:30 -050067int refresh_lsdb(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
akmhoquef71d9082012-08-22 12:51:53 -040068
akmhoque53f64222012-09-05 13:57:51 -050069int build_and_install_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
akmhoque53f64222012-09-05 13:57:51 -050070void build_adj_lsa(struct alsa * adj_lsa);
akmhoque53f64222012-09-05 13:57:51 -050071void install_adj_lsa(struct alsa * adj_lsa);
akmhoque53f64222012-09-05 13:57:51 -050072void print_adj_lsa_body(const char *body, int no_link);
73void print_adj_lsa(struct alsa * adj_lsa);
akmhoque9e9fc722012-09-26 14:03:25 -050074void write_log_for_adj_lsa(struct alsa * adj_lsa);
akmhoque53f64222012-09-05 13:57:51 -050075void print_adj_lsdb(void);
akmhoque03004e62012-09-06 01:12:28 -050076void 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);
akmhoque53f64222012-09-05 13:57:51 -050079
80long int get_name_lsdb_num_element(void);
81long int get_adj_lsdb_num_element(void);
akmhoqued79438d2012-08-27 13:31:42 -050082
akmhoque03004e62012-09-06 01:12:28 -050083int 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);
akmhoqueb77b95f2013-02-08 12:28:47 -060085int check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time);
akmhoque03004e62012-09-06 01:12:28 -050086
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
akmhoque3171d652012-11-13 11:44:33 -060090void make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id);
91
akmhoqueb77b95f2013-02-08 12:28:47 -060092void build_and_install_cor_lsa();
93void print_cor_lsdb();
94
95void 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);
98void write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id);
99
100void 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);
102double get_hyperbolic_r(char *router);
103double get_hyperbolic_theta(char *router);
104
akmhoquead584782013-02-22 10:56:03 -0600105void destroy_lsdb(void);
106
akmhoque9635b852013-04-04 23:29:48 -0500107void
108get_lsdb_summary(struct ccn_charbuf *lsdb_data);
109
akmhoque902d57e2012-08-17 09:24:38 -0500110#endif