/*
 * OSPF routing table.
 * Copyright (C) 1999, 2000 Toshiaki Takada
 *
 * This file is part of GNU Zebra.
 *
 * GNU Zebra is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * GNU Zebra is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU Zebra; see the file COPYING.  If not, write to the Free
 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#ifndef _ZEBRA_OSPF_ROUTE_H
#define _ZEBRA_OSPF_ROUTE_H

#define OSPF_DESTINATION_ROUTER		1
#define OSPF_DESTINATION_NETWORK	2
#define OSPF_DESTINATION_DISCARD	3

#define OSPF_PATH_MIN			0
#define OSPF_PATH_INTRA_AREA		1
#define OSPF_PATH_INTER_AREA		2
#define OSPF_PATH_TYPE1_EXTERNAL	3
#define OSPF_PATH_TYPE2_EXTERNAL	4
#define OSPF_PATH_MAX			5

/* OSPF Path. */
struct ospf_path
{
  struct in_addr nexthop;
  struct in_addr adv_router;
  struct ospf_interface *oi;
};

/* Below is the structure linked to every
   route node. Note that for Network routing
   entries a single ospf_route is kept, while
   for ABRs and ASBRs (Router routing entries),
   we link an instance of ospf_router_route
   where a list of paths is maintained, so

   nr->info is a (struct ospf_route *) for OSPF_DESTINATION_NETWORK
   but
   nr->info is a (struct ospf_router_route *) for OSPF_DESTINATION_ROUTER
*/

struct route_standard
{
  /* Link Sate Origin. */
  struct lsa_header *origin;

  /* Associated Area. */
  struct in_addr area_id;	/* The area the route belongs to */

  /*  Area Type */
  int external_routing;

  /* Optional Capability. */
  u_char options;		/* Get from LSA header. */

  /*  */
  u_char flags; 		/* From router-LSA */
};

struct route_external
{
  /* Link State Origin. */
  struct ospf_lsa *origin;

  /* Link State Cost Type2. */
  u_int32_t type2_cost;

  /* Tag value. */
  u_int32_t tag;

  /* ASBR route. */
  struct ospf_route *asbr;
};

struct ospf_route
{
  /* Create time. */
  time_t ctime;

  /* Modified time. */
  time_t mtime;

  /* Destination Type. */
  u_char type;

  /* Destination ID. */		/* i.e. Link State ID. */
  struct in_addr id;

  /* Address Mask. */
  struct in_addr mask;		/* Only valid for networks. */

  /* Path Type. */
  u_char path_type;

  /* List of Paths. */
  struct list *paths;

  /* Link State Cost. */
  u_int32_t cost;		/* i.e. metric. */

  /* Route specific info. */
  union
  {
    struct route_standard std;
    struct route_external ext;
  } u;
};

extern struct ospf_path *ospf_path_new (void);
extern void ospf_path_free (struct ospf_path *);
extern struct ospf_path *ospf_path_lookup (struct list *, struct ospf_path *);
extern struct ospf_route *ospf_route_new (void);
extern void ospf_route_free (struct ospf_route *);
extern void ospf_route_delete (struct route_table *);
extern void ospf_route_table_free (struct route_table *);

extern void ospf_route_install (struct ospf *, struct route_table *);
extern void ospf_route_table_dump (struct route_table *);

extern void ospf_intra_add_router (struct route_table *, struct vertex *,
				   struct ospf_area *);

extern void ospf_intra_add_transit (struct route_table *, struct vertex *,
				    struct ospf_area *);

extern void ospf_intra_add_stub (struct route_table *,
				 struct router_lsa_link *, struct vertex *,
				 struct ospf_area *,
				 int parent_is_root);

extern int ospf_route_cmp (struct ospf *, struct ospf_route *,
			   struct ospf_route *);
extern void ospf_route_copy_nexthops (struct ospf_route *, struct list *);
extern void ospf_route_copy_nexthops_from_vertex (struct ospf_route *,
						  struct vertex *);

extern void ospf_route_subst (struct route_node *, struct ospf_route *,
			      struct ospf_route *);
extern void ospf_route_add (struct route_table *, struct prefix_ipv4 *,
			    struct ospf_route *, struct ospf_route *);

extern void ospf_route_subst_nexthops (struct ospf_route *, struct list *);
extern void ospf_prune_unreachable_networks (struct route_table *);
extern void ospf_prune_unreachable_routers (struct route_table *);
extern int ospf_add_discard_route (struct route_table *, struct ospf_area *,
				   struct prefix_ipv4 *);
extern void ospf_delete_discard_route (struct prefix_ipv4 *);
extern int ospf_route_match_same (struct route_table *, struct prefix_ipv4 *,
				  struct ospf_route *);

#endif /* _ZEBRA_OSPF_ROUTE_H */
