blob: 03839547b1d4dce9fe667ef108174e46445ed77b [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
6
akmhoque902d57e2012-08-17 09:24:38 -05007struct link
8{
akmhoque53f64222012-09-05 13:57:51 -05009 struct name_prefix *nbr;
akmhoque902d57e2012-08-17 09:24:38 -050010 int face;
11 int metric;
12};
13
akmhoquef71d9082012-08-22 12:51:53 -040014
15struct alsa_header
akmhoque902d57e2012-08-17 09:24:38 -050016{
akmhoquef71d9082012-08-22 12:51:53 -040017 unsigned int ls_type;
akmhoque53f64222012-09-05 13:57:51 -050018 char *orig_time;
19 struct name_prefix *orig_router;
20
akmhoquef71d9082012-08-22 12:51:53 -040021};
akmhoque902d57e2012-08-17 09:24:38 -050022
akmhoquef71d9082012-08-22 12:51:53 -040023struct alsa
24{
25 struct alsa_header *header;
akmhoque902d57e2012-08-17 09:24:38 -050026 int no_link;
akmhoque03004e62012-09-06 01:12:28 -050027 struct link *links;
28 char * body;
akmhoque902d57e2012-08-17 09:24:38 -050029};
30
akmhoquef71d9082012-08-22 12:51:53 -040031struct nlsa_header
akmhoque902d57e2012-08-17 09:24:38 -050032{
akmhoquef71d9082012-08-22 12:51:53 -040033 unsigned int ls_type;
akmhoque53f64222012-09-05 13:57:51 -050034 char *orig_time;
akmhoquef71d9082012-08-22 12:51:53 -040035 long int ls_id;
akmhoque53f64222012-09-05 13:57:51 -050036 struct name_prefix *orig_router;
akmhoque8c1cdbf2012-08-26 21:09:11 -050037 unsigned int isValid;
akmhoque902d57e2012-08-17 09:24:38 -050038
akmhoque902d57e2012-08-17 09:24:38 -050039};
40
akmhoquef71d9082012-08-22 12:51:53 -040041struct nlsa
42{
43 struct nlsa_header *header;
akmhoque53f64222012-09-05 13:57:51 -050044 struct name_prefix *name_prefix;
akmhoquef71d9082012-08-22 12:51:53 -040045};
46
47
akmhoque03004e62012-09-06 01:12:28 -050048void set_new_lsdb_version(void);
akmhoque53f64222012-09-05 13:57:51 -050049void build_and_install_name_lsas(void);
akmhoque3171d652012-11-13 11:44:33 -060050void build_and_install_single_name_lsa(struct name_prefix *np);
akmhoque53f64222012-09-05 13:57:51 -050051void build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np);
akmhoque53f64222012-09-05 13:57:51 -050052void install_name_lsa(struct nlsa *name_lsa);
akmhoque03004e62012-09-06 01:12:28 -050053void print_name_lsa(struct nlsa *name_lsa);
akmhoque9e9fc722012-09-26 14:03:25 -050054void write_log_for_name_lsa(struct nlsa *name_lsa);
akmhoque53f64222012-09-05 13:57:51 -050055void print_name_lsdb(void);
akmhoque03004e62012-09-06 01:12:28 -050056void build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np);
57void 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);
58void make_name_lsa_key(char *key, char *orig_router, int ls_type, long int ls_id);
akmhoqueffacaa82012-09-13 17:48:30 -050059int refresh_lsdb(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
akmhoquef71d9082012-08-22 12:51:53 -040060
akmhoque53f64222012-09-05 13:57:51 -050061int build_and_install_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
akmhoque53f64222012-09-05 13:57:51 -050062void build_adj_lsa(struct alsa * adj_lsa);
akmhoque53f64222012-09-05 13:57:51 -050063void install_adj_lsa(struct alsa * adj_lsa);
akmhoque53f64222012-09-05 13:57:51 -050064void print_adj_lsa_body(const char *body, int no_link);
65void print_adj_lsa(struct alsa * adj_lsa);
akmhoque9e9fc722012-09-26 14:03:25 -050066void write_log_for_adj_lsa(struct alsa * adj_lsa);
akmhoque53f64222012-09-05 13:57:51 -050067void print_adj_lsdb(void);
akmhoque03004e62012-09-06 01:12:28 -050068void make_adj_lsa_key(char *key,struct alsa *adj_lsa);
69void build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data);
70void 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 -050071
72long int get_name_lsdb_num_element(void);
73long int get_adj_lsdb_num_element(void);
akmhoqued79438d2012-08-27 13:31:42 -050074
akmhoque03004e62012-09-06 01:12:28 -050075void get_name_lsdb_summary(struct ccn_charbuf *name_lsdb_data);
76void get_adj_lsdb_summary(struct ccn_charbuf *adj_lsdb_data);
77void get_lsdb_summary(struct ccn_charbuf *lsdb_data);
78
79int check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time);
80int check_is_new_adj_lsa(char *orig_router,char *lst,char *orig_time);
81
82void get_name_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId);
83void get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId);
84
akmhoque3171d652012-11-13 11:44:33 -060085void make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id);
86
akmhoque902d57e2012-08-17 09:24:38 -050087#endif