/* ospf_rte_table.h: Data type definitions and constants for OSPF */
/* routing table package.                                         */

/* Prevent multiple includes. */
#ifndef		HEADER_FILE_ospf_rte_table_h

#define		HEADER_FILE_ospf_rte_table_h

/* OspfT_Rte_Dest_Type: Type of destination for an OSPF route. */
typedef enum OspfT_Rte_Dest_Type
	{
	OspfC_Rte_Dest_Network,
	OspfC_Rte_Dest_ABR
	} OspfT_Rte_Dest_Type;

/* OspfT_Rte_Path_Type: Type of path used for an OSPF route. */
typedef enum OspfT_Rte_Path_Type
	{
	OspfC_Rte_Path_Intra_Area,
	OspfC_Rte_Path_Inter_Area
	} OspfT_Rte_Path_Type;

/* OspfT_Rte_Entry: OSPF routing table entry. */
typedef struct OspfT_Rte_Entry
	{
	OspfT_Rte_Dest_Type	route_dest_type;		/* Type of destination for route: network or ABR. */
	IpT_Address			dest_id;				/* IP address for networks, router ID for ABRs. */
	IpT_Address			subnet_mask;			/* Subnet mask (defined for network destinations only). */
 	IpT_Address			area_id;				/* Area that provided info for this entry. */
	OspfT_Rte_Path_Type	path_type;			      /* Path type used for route: Intra- or Inter-Area. */
	int		      cost;				      /* Cost to destination. */
	List *				path_list_ptr;			/* List (OspfT_Rte_Path *) of paths to the destination. */
	} OspfT_Rte_Entry;

/* OspfT_Rte_Path: Information about a path for an OSPF route. */
typedef struct OspfT_Rte_Path
	{
	IpT_Address			next_hop;				/* Outgoing router interface that goes to the destination. */
	IpT_Address			adv_router;				/* Router ID of router that advertised an inter-area path. */
	} OspfT_Rte_Path;

/***** Procedure Declarations. *****/
void						ospf_rte_table_calc (OspfT_Router *router_ptr);
List *						ospf_rte_table_djk_nodes_build (OspfT_Area *area_ptr);
void						ospf_rte_table_node_entries_add (DjkT_Node *root_node_ptr, OspfT_Rte_Table *rte_table_ptr, 	List *djk_node_list_ptr, OspfT_Area_Id area_id);
void						ospf_rte_table_entry_add (OspfT_Rte_Table *rte_table_ptr, OspfT_Rte_Dest_Type route_dest_type,
	IpT_Address dest_id, IpT_Address subnet_mask, OspfT_Area_Id area_id, IpT_Address next_hop, 
	OspfT_Rte_Path_Type path_type, int cost, OspfT_Router_Id adv_router_id);
IpT_Address					ospf_rte_table_node_next_hop_get (List *node_list_ptr);
void						ospf_rte_table_inter_area_rtes_add (OspfT_Router *router_ptr, IpT_Address dest_id, OspfT_Area *rcvd_area_ptr);
void						ospf_rte_table_areas_activate (OspfT_Router *router_ptr);
void						ospf_rte_table_areas_deactivate (OspfT_Router *router_ptr);
void						ospf_rte_table_abr_entries_remove (OspfT_Rte_Table *rte_table_ptr);
OspfT_Rte_Table *			ospf_rte_table_create (void);
OspfT_Rte_Entry *			ospf_rte_table_entry_create (void);
OspfT_Rte_Path *			ospf_rte_table_path_create (void);
void						ospf_rte_table_destroy (OspfT_Rte_Table *rte_table_ptr);
void						ospf_rte_table_entries_clear (OspfT_Rte_Table *rte_table_ptr);
void						ospf_rte_table_entry_destroy (OspfT_Rte_Entry *entry_ptr);
void						ospf_rte_table_path_destroy (OspfT_Rte_Path *path_ptr);
void						ospf_rte_table_print (OspfT_Rte_Table *rte_table_ptr);
Compcode					ospf_rte_table_lookup (int fast_address, IpT_Rte_Table_Handle rte_table_ptr, IpT_Address dest_addr, IpT_Address *next_addr_ptr);
int							ospf_rte_table_fast_addr_get (IpT_Rte_Table_Handle rte_table_ptr, IpT_Address dest_addr);
OspfT_Rte_Entry *			ospf_rte_table_entry_find (OspfT_Rte_Table *rte_table_ptr, IpT_Address entry_addr);
void						ospf_rte_table_summary_lsa_flush (OspfT_Router *router_ptr);
void						ospf_rte_table_summary_lsa_generate (OspfT_Router *router_ptr);
Compcode                                        ospf_rte_table_cost_lookup (int fast_address, IpT_Rte_Table_Handle rte_table_ptr, IpT_Address dest_addr, int *cost);

#endif
