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 |
| 6 | |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 7 | struct link |
| 8 | { |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 9 | struct name_prefix *nbr; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 10 | int face; |
| 11 | int metric; |
| 12 | }; |
| 13 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 14 | |
| 15 | struct alsa_header |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 16 | { |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 17 | unsigned int ls_type; |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 18 | char *orig_time; |
| 19 | struct name_prefix *orig_router; |
| 20 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 21 | }; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 22 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 23 | struct alsa |
| 24 | { |
| 25 | struct alsa_header *header; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 26 | int no_link; |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 27 | struct link *links; |
| 28 | char * body; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 29 | }; |
| 30 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 31 | struct nlsa_header |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 32 | { |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 33 | unsigned int ls_type; |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 34 | char *orig_time; |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 35 | long int ls_id; |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 36 | struct name_prefix *orig_router; |
akmhoque | 8c1cdbf | 2012-08-26 21:09:11 -0500 | [diff] [blame] | 37 | unsigned int isValid; |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 38 | |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 39 | }; |
| 40 | |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 41 | struct nlsa |
| 42 | { |
| 43 | struct nlsa_header *header; |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 44 | struct name_prefix *name_prefix; |
akmhoque | f71d908 | 2012-08-22 12:51:53 -0400 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 48 | void set_new_lsdb_version(void); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 49 | void build_and_install_name_lsas(void); |
akmhoque | 3171d65 | 2012-11-13 11:44:33 -0600 | [diff] [blame^] | 50 | void build_and_install_single_name_lsa(struct name_prefix *np); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 51 | void build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 52 | void install_name_lsa(struct nlsa *name_lsa); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 53 | void print_name_lsa(struct nlsa *name_lsa); |
akmhoque | 9e9fc72 | 2012-09-26 14:03:25 -0500 | [diff] [blame] | 54 | void write_log_for_name_lsa(struct nlsa *name_lsa); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 55 | void print_name_lsdb(void); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 56 | void build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np); |
| 57 | 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); |
| 58 | 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] | 59 | 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] | 60 | |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 61 | 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] | 62 | void build_adj_lsa(struct alsa * adj_lsa); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 63 | void install_adj_lsa(struct alsa * adj_lsa); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 64 | void print_adj_lsa_body(const char *body, int no_link); |
| 65 | void print_adj_lsa(struct alsa * adj_lsa); |
akmhoque | 9e9fc72 | 2012-09-26 14:03:25 -0500 | [diff] [blame] | 66 | void write_log_for_adj_lsa(struct alsa * adj_lsa); |
akmhoque | 53f6422 | 2012-09-05 13:57:51 -0500 | [diff] [blame] | 67 | void print_adj_lsdb(void); |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 68 | void make_adj_lsa_key(char *key,struct alsa *adj_lsa); |
| 69 | void build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data); |
| 70 | 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] | 71 | |
| 72 | long int get_name_lsdb_num_element(void); |
| 73 | long int get_adj_lsdb_num_element(void); |
akmhoque | d79438d | 2012-08-27 13:31:42 -0500 | [diff] [blame] | 74 | |
akmhoque | 03004e6 | 2012-09-06 01:12:28 -0500 | [diff] [blame] | 75 | void get_name_lsdb_summary(struct ccn_charbuf *name_lsdb_data); |
| 76 | void get_adj_lsdb_summary(struct ccn_charbuf *adj_lsdb_data); |
| 77 | void get_lsdb_summary(struct ccn_charbuf *lsdb_data); |
| 78 | |
| 79 | int check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time); |
| 80 | int check_is_new_adj_lsa(char *orig_router,char *lst,char *orig_time); |
| 81 | |
| 82 | void get_name_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId); |
| 83 | void get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId); |
| 84 | |
akmhoque | 3171d65 | 2012-11-13 11:44:33 -0600 | [diff] [blame^] | 85 | void make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id); |
| 86 | |
akmhoque | 902d57e | 2012-08-17 09:24:38 -0500 | [diff] [blame] | 87 | #endif |