/*
 * 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;
  ifindex_t ifindex;
};

/* 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, int);

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 route_table *, struct prefix_ipv4 *);
extern int ospf_route_match_same (struct route_table *, struct prefix_ipv4 *,
				  struct ospf_route *);

#endif /* _ZEBRA_OSPF_ROUTE_H */
