akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 1 | #ifndef _NLSR_LSDB_H_ |
| 2 | #define _NLSR_LSDB_H_ |
| 3 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 4 | #define LS_TYPE_ADJ 1 |
| 5 | #define LS_TYPE_NAME 2 |
akmhoque | b77b95f | 2013-02-08 12:28:47 -0600 | [diff] [blame] | 6 | #define LS_TYPE_COR 3 |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 7 | |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 8 | struct link |
| 9 | { |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 10 | struct name_prefix *nbr; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 11 | int face; |
| 12 | int metric; |
| 13 | }; |
| 14 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 15 | |
| 16 | struct alsa_header |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 17 | { |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 18 | unsigned int ls_type; |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 19 | char *orig_time; |
| 20 | struct name_prefix *orig_router; |
| 21 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 22 | }; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 23 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 24 | struct alsa |
| 25 | { |
| 26 | struct alsa_header *header; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 27 | int no_link; |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 28 | struct link *links; |
| 29 | char * body; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 30 | }; |
| 31 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 32 | struct nlsa_header |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 33 | { |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 34 | unsigned int ls_type; |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 35 | char *orig_time; |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 36 | long int ls_id; |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 37 | struct name_prefix *orig_router; |
akmhoque | 8c1cdbf | 2012-08-26 21:09:11 -0500 | [diff] [blame] | 38 | unsigned int isValid; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 39 | |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 40 | }; |
| 41 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 42 | struct nlsa |
| 43 | { |
| 44 | struct nlsa_header *header; |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 45 | struct name_prefix *name_prefix; |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 46 | }; |
| 47 | |
akmhoque | b77b95f | 2013-02-08 12:28:47 -0600 | [diff] [blame] | 48 | struct clsa |
| 49 | { |
| 50 | struct alsa_header *header; |
| 51 | double cor_r; |
| 52 | double cor_theta; |
| 53 | }; |
| 54 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 55 | |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 56 | void set_new_lsdb_version(void); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 57 | void build_and_install_name_lsas(void); |
akmhoque | 3171d65 | 2012-11-13 11:44:33 -0600 | [diff] [blame] | 58 | void build_and_install_single_name_lsa(struct name_prefix *np); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 59 | void build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 60 | void install_name_lsa(struct nlsa *name_lsa); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 61 | void print_name_lsa(struct nlsa *name_lsa); |
akmhoque | 9e9fc72 | 2012-09-26 14:03:25 -0500 | [diff] [blame] | 62 | void write_log_for_name_lsa(struct nlsa *name_lsa); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 63 | void print_name_lsdb(void); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 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); |
akmhoque | ffacaa8 | 2012-09-13 17:48:30 -0500 | [diff] [blame] | 67 | int refresh_lsdb(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags); |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 68 | |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 69 | int build_and_install_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 70 | void build_adj_lsa(struct alsa * adj_lsa); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 71 | void install_adj_lsa(struct alsa * adj_lsa); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 72 | void print_adj_lsa_body(const char *body, int no_link); |
| 73 | void print_adj_lsa(struct alsa * adj_lsa); |
akmhoque | 9e9fc72 | 2012-09-26 14:03:25 -0500 | [diff] [blame] | 74 | void write_log_for_adj_lsa(struct alsa * adj_lsa); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 75 | void print_adj_lsdb(void); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 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); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 79 | |
| 80 | long int get_name_lsdb_num_element(void); |
| 81 | long int get_adj_lsdb_num_element(void); |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 82 | |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [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 | b77b95f | 2013-02-08 12:28:47 -0600 | [diff] [blame] | 85 | int check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [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 | |
akmhoque | 3171d65 | 2012-11-13 11:44:33 -0600 | [diff] [blame] | 90 | void make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id); |
| 91 | |
akmhoque | b77b95f | 2013-02-08 12:28:47 -0600 | [diff] [blame] | 92 | void build_and_install_cor_lsa(); |
| 93 | void print_cor_lsdb(); |
| 94 | |
| 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); |
| 98 | void write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id); |
| 99 | |
| 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); |
| 102 | double get_hyperbolic_r(char *router); |
| 103 | double get_hyperbolic_theta(char *router); |
| 104 | |
akmhoque | ad58478 | 2013-02-22 10:56:03 -0600 | [diff] [blame] | 105 | void destroy_lsdb(void); |
| 106 | |
akmhoque | 9635b85 | 2013-04-04 23:29:48 -0500 | [diff] [blame] | 107 | void |
| 108 | get_lsdb_summary(struct ccn_charbuf *lsdb_data); |
| 109 | |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 110 | #endif |