akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 1 | #ifndef _NLSR_LSDB_H_ |
| 2 | #define _NLSR_LSDB_H_ |
| 3 | |
| 4 | #define LS_TYPE_ADJ 1 |
| 5 | #define LS_TYPE_NAME 2 |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 6 | #define LS_TYPE_COR 3 |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 7 | |
| 8 | struct link |
| 9 | { |
| 10 | struct name_prefix *nbr; |
| 11 | int face; |
| 12 | int metric; |
| 13 | }; |
| 14 | |
| 15 | |
| 16 | struct alsa_header |
| 17 | { |
| 18 | unsigned int ls_type; |
| 19 | char *orig_time; |
| 20 | struct name_prefix *orig_router; |
| 21 | |
| 22 | }; |
| 23 | |
| 24 | struct alsa |
| 25 | { |
| 26 | struct alsa_header *header; |
| 27 | int no_link; |
| 28 | struct link *links; |
| 29 | char * body; |
| 30 | }; |
| 31 | |
| 32 | struct 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 | |
| 42 | struct nlsa |
| 43 | { |
| 44 | struct nlsa_header *header; |
| 45 | struct name_prefix *name_prefix; |
| 46 | }; |
| 47 | |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 48 | struct clsa |
| 49 | { |
| 50 | struct alsa_header *header; |
| 51 | double cor_r; |
| 52 | double cor_theta; |
| 53 | }; |
| 54 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 55 | |
| 56 | void set_new_lsdb_version(void); |
| 57 | void build_and_install_name_lsas(void); |
| 58 | void build_and_install_single_name_lsa(struct name_prefix *np); |
| 59 | void build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np); |
| 60 | void install_name_lsa(struct nlsa *name_lsa); |
| 61 | void print_name_lsa(struct nlsa *name_lsa); |
| 62 | void write_log_for_name_lsa(struct nlsa *name_lsa); |
| 63 | void print_name_lsdb(void); |
| 64 | void build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np); |
| 65 | void 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); |
| 66 | void make_name_lsa_key(char *key, char *orig_router, int ls_type, long int ls_id); |
| 67 | int refresh_lsdb(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags); |
| 68 | |
| 69 | int build_and_install_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags); |
| 70 | void build_adj_lsa(struct alsa * adj_lsa); |
| 71 | void install_adj_lsa(struct alsa * adj_lsa); |
| 72 | void print_adj_lsa_body(const char *body, int no_link); |
| 73 | void print_adj_lsa(struct alsa * adj_lsa); |
| 74 | void write_log_for_adj_lsa(struct alsa * adj_lsa); |
| 75 | void print_adj_lsdb(void); |
| 76 | void make_adj_lsa_key(char *key,struct alsa *adj_lsa); |
| 77 | void build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data); |
| 78 | void build_others_adj_lsa(struct alsa *adj_lsa,char *orig_router,int ls_type,char *orig_time,int no_link,char *data); |
| 79 | |
| 80 | long int get_name_lsdb_num_element(void); |
| 81 | long int get_adj_lsdb_num_element(void); |
| 82 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 83 | int check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time); |
| 84 | int check_is_new_adj_lsa(char *orig_router,char *lst,char *orig_time); |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 85 | int check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 86 | |
| 87 | void get_name_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId); |
| 88 | void get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId); |
| 89 | |
| 90 | void make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id); |
| 91 | |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 92 | void build_and_install_cor_lsa(); |
| 93 | void print_cor_lsdb(); |
| 94 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 95 | void write_name_lsdb_to_repo(char *slice_prefix); |
| 96 | void write_name_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id); |
| 97 | void make_name_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, long int ls_id,char *orig_time,char *slice_prefix); |
akmhoque | 4ae1694 | 2012-12-10 11:50:43 -0600 | [diff] [blame] | 98 | void write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id); |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 99 | |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 100 | void write_cor_lsa_to_repo(struct clsa *cor_lsa); |
| 101 | void build_and_install_others_cor_lsa(char *orig_router,int ls_type,char *orig_time, double cor_r, double cor_theta); |
akmhoque | f06586e | 2013-02-05 12:09:38 -0600 | [diff] [blame] | 102 | double get_hyperbolic_r(char *router); |
| 103 | double get_hyperbolic_theta(char *router); |
akmhoque | ed418f3 | 2013-01-30 12:25:04 -0600 | [diff] [blame] | 104 | |
akmhoque | 8fdd641 | 2012-12-04 15:05:33 -0600 | [diff] [blame] | 105 | #endif |