
#include <xorp_config.h>

/*
 * Routing Information Base XRL interface.
 */

interface rib/0.1 {
	/**
	 * Enable/disable/start/stop RIB.
	 */
	enable_rib;
	disable_rib;
	start_rib;
	stop_rib;

	/**
	 * Make errors fatal; used to detect errors we'd normally mask
	 */
	make_errors_fatal;

	/**
	 * Get the list of registered protocols.
	 *
	 * @param ipv4 if true, then include the IPv4 protocols.
	 * @param ipv6 if true, then include the IPv6 protocols.
	 * @param unicast if true, then include the protocols registered
	 * with the unicast RIB.
	 * @param multicast if true, then include the protocols registered
	 * with the multicast RIB.
	 * @param ipv4_unicast_protocols the list of IPv4 protocols registered
	 * with the unicast RIB.
	 * @param ipv6_unicast_protocols the list of IPv6 protocols registered
	 * with the unicast RIB.
	 * @param ipv4_multicast_protocols the list of IPv4 protocols
	 * registered with the multicast RIB.
	 * @param ipv6_multicast_protocols the list of IPv6 protocols
	 * registered with the multicast RIB.
	 */
	get_registered_protocols	? ipv4:bool & ipv6:bool		\
					& unicast:bool & multicast:bool	\
					-> ipv4_unicast_protocols:list<txt> \
					& ipv6_unicast_protocols:list<txt> \
					& ipv4_multicast_protocols:list<txt> \
					& ipv6_multicast_protocols:list<txt>;

	/**
	 * Add/delete an IGP or EGP table.
	 *
	 * @param protocol the name of the protocol.
	 * @param target_class the target class of the protocol.
	 * @param target_instance the target instance of the protocol.
	 * @param unicast true if the table is for the unicast RIB.
	 * @param multicast true if the table is for the multicast RIB.
	 */
	add_igp_table4		? protocol:txt				\
				& target_class:txt & target_instance:txt\
				& unicast:bool & multicast:bool;

	delete_igp_table4	? protocol:txt				\
				& target_class:txt & target_instance:txt\
				& unicast:bool & multicast:bool;

	add_egp_table4		? protocol:txt				\
				& target_class:txt & target_instance:txt\
				& unicast:bool & multicast:bool;

	delete_egp_table4	? protocol:txt				\
				& target_class:txt & target_instance:txt\
				& unicast:bool & multicast:bool;
/*
	add_mcast_table4	? protocol:txt				\
				& target_class:txt & target_instance:txt;
	delete_mcast_table4	? protocol:txt				\
				& target_class:txt & target_instance:txt;

	add_mcast_route4	? protocol:txt & mcast_addr:ipv4 & input_if:txt \
				& input_ip:ipv4 & output_ifs:txt;
	replace_mcast_route4	? protocol:txt & mcast_addr:ipv4 & input_if:txt \
				& input_ip:ipv4 & output_ifs:txt;
	delete_mcast_route4	? protocol:txt & mcast_addr:ipv4 & input_if:txt \
				& input_ip:ipv4 & output_ifs:txt;
*/

	/**
	 * Add/replace/delete a route.
	 *
	 * @param protocol the name of the protocol this route comes from.
	 * @param unicast true if the route is for the unicast RIB.
	 * @param multicast true if the route is for the multicast RIB.
	 * @param network the network address prefix of the route.
	 * @param nexthop the address of the next-hop router toward the
	 * destination.
	 * @param metric the routing metric.
	 * @param policytags a set of policy tags used for redistribution.
	 */
	add_route4	? protocol:txt & unicast:bool & multicast:bool	\
			& network:ipv4net & nexthop:ipv4 & metric:u32   \
			& policytags:list<u32>;

	replace_route4	? protocol:txt & unicast:bool & multicast:bool	\
			& network:ipv4net & nexthop:ipv4 & metric:u32   \
			& policytags:list<u32>;

	delete_route4	? protocol:txt & unicast:bool & multicast:bool	\
			& network:ipv4net;

	/**
	 * Add/replace a route by explicitly specifying the network
	 * interface toward the destination.
	 *
	 * @param protocol the name of the protocol this route comes from.
	 * @param unicast true if the route is for the unicast RIB.
	 * @param multicast true if the route is for the multicast RIB.
	 * @param network the network address prefix of the route.
	 * @param nexthop the address of the next-hop router toward the
	 * destination.
	 * @param ifname of the name of the physical interface toward the
	 * destination.
	 * @param vifname of the name of the virtual interface toward the
	 * destination.
	 * @param metric the routing metric.
	 * @param policytags a set of policy tags used for redistribution.
	 */
	add_interface_route4	? protocol:txt				\
				& unicast:bool & multicast:bool		\
				& network:ipv4net & nexthop:ipv4	\
				& ifname:txt & vifname:txt & metric:u32 \
				& policytags:list<u32>;

	replace_interface_route4 ? protocol:txt				\
				& unicast:bool & multicast:bool		\
				& network:ipv4net & nexthop:ipv4	\
				& ifname:txt & vifname:txt & metric:u32 \
				& policytags:list<u32>;

	/**
	 * Lookup nexthop.
	 *
	 * @param addr address to lookup.
	 *
	 * @param unicast look in unicast RIB.
	 *
	 * @param multicast look in multicast RIB.
	 *
	 * @param nexthop contains the resolved nexthop if successful,
	 * IPv4::ZERO otherwise.  It is an error for the unicast and multicast
	 * fields to both be true or both false.
	 */
	lookup_route_by_dest4 ? addr:ipv4 & unicast:bool & multicast:bool \
		-> nexthop:ipv4;


	/**
	 * Add a vif or a vif address to the RIB.
	 * This interface should be used only for testing purpose.
	 *
	 * @param name the name of the vif.
	 */
	new_vif ? name:txt;

	/**
	 * Add a vif address to the RIB.
	 * This interface should be used only for testing purpose.
	 *
	 * @param name the name of the vif.
	 * @param addr the address to add.
	 * @param subnet the subnet address to add.
	 */
	add_vif_addr4 ? name:txt & addr:ipv4 & subnet:ipv4net;

	/**
	 * Enable route redistribution from one routing protocol to
	 * another.
	 *
	 * @param to_xrl_target the XRL Target instance name of the caller.
	 *	  The caller must implement redist4/0.1.
	 *
	 * @param from_protocol the name of the routing process routes are
	 * to be redistributed from.
	 *
	 * @param unicast enable for unicast RIBs matching from and to.
	 *
	 * @param multicast enable for multicast RIBs matching from and to.
	 *
	 * @param network_prefix redistribite only the routes that fall
	 *        into this prefix address.
	 *
	 * @param cookie a text value passed back to creator in each call
	 *        from the RIB.  This allows creators to identity the source
	 *	  of updates it receives through the redist4/0.1
	 *	  interface.
	 */
	redist_enable4 ? to_xrl_target:txt				\
		       & from_protocol:txt				\
		       & unicast:bool					\
		       & multicast:bool					\
		       & network_prefix:ipv4net				\
		       & cookie:txt;

	/**
	 * Disable route redistribution from one routing protocol to
	 * another.
	 *
	 * @param to_xrl_target the XRL Target instance name of the caller.
	 *	  The caller must implement redist4/0.1 and previously
	 *	  called redist_enable4.
	 *
	 * @param from the name of the routing process routes are to be
	 *	  redistributed from.
	 *
	 * @param to the name of the routing process routes are to be
	 *	  redistributed to.
	 *
	 * @param unicast disable for unicast RIBs matching from and to.
	 *
	 * @param multicast disable for multicast RIBs matching from and to.
	 *
	 * @param cookie a text value passed back to creator in each call
	 *        from the RIB.  This allows creators to identity the source
	 *	  of updates it receives through the redist4/0.1
	 *	  interface.
	 */
	redist_disable4	? to_xrl_target:txt				\
			& from_protocol:txt				\
			& unicast:bool					\
			& multicast:bool				\
			& cookie:txt;

	/**
	 * Enable transaction-based route redistribution from
	 * one routing protocol to another.
	 *
	 * @param to_xrl_target the XRL Target instance name of the caller.
	 *	  The caller must implement redist_transaction4/0.1.
	 *
	 * @param from_protocol the name of the routing process routes are
	 * to be redistributed from.
	 *
	 * @param unicast enable for unicast RIBs matching from and to.
	 *
	 * @param multicast enable for multicast RIBs matching from and to.
	 *
	 * @param network_prefix redistribite only the routes that fall
	 *        into this prefix address.
	 *
	 * @param cookie a text value passed back to creator in each call
	 *        from the RIB.  This allows creators to identity the source
	 *	  of updates it receives through the redist_transaction4/0.1
	 *	  interface.
	 */
	redist_transaction_enable4	? to_xrl_target:txt		\
					& from_protocol:txt		\
					& unicast:bool			\
					& multicast:bool		\
					& network_prefix:ipv4net	\
					& cookie:txt;

	/**
	 * Disable transaction-based route redistribution from
	 * one routing protocol to another.
	 *
	 * @param to_xrl_target the XRL Target instance name of the caller.
	 *	  The caller must implement redist_transaction4/0.1
	 *	  and previously called redist_transaction_enable4.
	 *
	 * @param from the name of the routing process routes are to be
	 *	  redistributed from.
	 *
	 * @param to the name of the routing process routes are to be
	 *	  redistributed to.
	 *
	 * @param unicast disable for unicast RIBs matching from and to.
	 *
	 * @param multicast disable for multicast RIBs matching from and to.
	 *
	 * @param cookie a text value passed back to creator in each call
	 *        from the RIB.  This allows creators to identity the source
	 *	  of updates it receives through the redist_transaction4/0.1
	 *	  interface.
	 */
	redist_transaction_disable4	? to_xrl_target:txt		\
					& from_protocol:txt		\
					& unicast:bool			\
					& multicast:bool		\
					& cookie:txt;

	/**
 	 * Register an interest in a route.
	 *
	 * @param target the name of the XRL module to notify when the
         * information returned by this call becomes invalid.
	 *
	 * @param addr address of interest.
         *
         * @param resolves returns whether or not the address resolves
         * to a route that can be used for forwarding.
	 *
	 * @param base_addr returns the address of interest (actually
         * the base address of the subnet covered by addr/prefix_len).
	 *
	 * @param prefix_len returns the prefix length that the
	 * registration covers.  This response applies to all addresses
	 * in addr/prefix_len.
	 *
	 * @param real_prefix_len returns the actual prefix length of the
         * route that will be used to route addr.  If real_prefix_len is
         * not the same as prefix_len, this is because there are some more
         * specific routes that overlap addr/real_prefix_len.  real_prefix_len
         * is primarily given for debugging reasons.
	 *
	 * @param nexthop returns the address of the next hop for packets sent
	 * to addr.
	 *
	 * @param metric returns the IGP metric for this route.
         */
	register_interest4 ? target:txt & addr:ipv4 \
		-> resolves:bool & base_addr:ipv4 & prefix_len:u32 & \
                   real_prefix_len:u32 & nexthop:ipv4 & metric:u32;

	/**
	 * De-register an interest in a route.
	 *
	 * @param target the name of the XRL module that registered
         * the interest.
	 *
	 * @param addr the address of the previous registered
         * interest.  addr should be the base address of the
         * add/prefix_len subnet.
	 *
	 * @param prefix_len the prefix length of the registered interest,
         * as given in the response from register_interest.
	 */
	deregister_interest4 ?  target:txt & addr:ipv4 & prefix_len:u32;

	/**
	 * Remove protocol's redistribution tags
	 */
	remove_policy_redist_tags ? protocol:txt;

	/**
	 * Add policy tags for a specific protcol in the redistribution map.
	 *
	 * @param protocol The destination protocol of the redistribution.
	 * @param policytags The set of policytags of interest for the protocol.
	 *
	 */
	insert_policy_redist_tags ? protocol:txt & policytags:list<u32>;

	/**
	 * Reset the policy redistribution map.
	 *
	 * No policy based route redistribution will be available at this point.
	 *
	 */
	reset_policy_redist_tags;

	/**
	 * Get administrative distance for all protocols registered as
	 * having an admin distance in a selected RIB.
	 *
	 * @param ipv4 true if getting admin distances from IPv4 RIB;
	 * false if getting admin distances from IPv6 RIB.
	 * @param unicast true if getting admin distances from unicast RIB;
	 * false if getting admin distances from multicast RIB.
	 * @param protocols the list of protocols registered as having an
	 * admin distance in the selected RIB.
	 * @param admin_distance the administrative distance (1-255) for
	 * each protocol in the @ref protocols list.
	 */
	get_protocol_admin_distances	? ipv4:bool			\
					& unicast:bool			\
					-> protocols:list<txt>		\
					& admin_distances:list<u32>;

	/**
	 * Get administrative distance for an individual protocol in
	 * a selected RIB.
	 *
	 * @param protocol the name of the protocol.
	 * @param ipv4 true if getting admin distance from IPv4 RIB;
	 * false if getting admin distance from IPv6 RIB.
	 * @param unicast true if getting admin distance from unicast RIB;
	 * false if getting admin distance from multicast RIB.
	 * @param admin_distance the administrative distance (1-255)
	 */
	get_protocol_admin_distance	? protocol:txt			\
					& ipv4:bool			\
					& unicast:bool			\
					-> admin_distance:u32;

	/**
	 * Set administrative distance for an individual protocol.
	 *
	 * @param protocol the name of the protocol.
	 * @param ipv4 true if setting admin distance for IPv4 RIB.
	 * @param ipv6 true if setting admin distance for IPv6 RIB.
	 * @param unicast true if setting admin distance for unicast RIB.
	 * @param multicast true if setting admin distance for multicast RIB.
	 * @param admin_distance the administrative distance (1-255)
	 */
	set_protocol_admin_distance	? protocol:txt			\
					& ipv4:bool			\
					& ipv6:bool			\
					& unicast:bool			\
					& multicast:bool		\
					& admin_distance:u32;
#ifdef HAVE_IPV6

	add_igp_table6		? protocol:txt				\
				& target_class:txt & target_instance:txt\
				& unicast:bool & multicast:bool;

	delete_igp_table6	? protocol:txt				\
				& target_class:txt & target_instance:txt\
				& unicast:bool & multicast:bool;

	add_egp_table6		? protocol:txt				\
				& target_class:txt & target_instance:txt\
				& unicast:bool & multicast:bool;

	delete_egp_table6	? protocol:txt				\
				& target_class:txt & target_instance:txt\
				& unicast:bool & multicast:bool;

	add_route6	? protocol:txt & unicast:bool & multicast:bool	\
			& network:ipv6net & nexthop:ipv6 & metric:u32   \
			& policytags:list<u32>;

	replace_route6	? protocol:txt & unicast:bool & multicast:bool	\
			& network:ipv6net & nexthop:ipv6 & metric:u32   \
			& policytags:list<u32>;

	delete_route6	? protocol:txt & unicast:bool & multicast:bool	\
			& network:ipv6net;

	add_interface_route6	? protocol:txt				\
				& unicast:bool & multicast:bool		\
				& network:ipv6net & nexthop:ipv6	\
				& ifname:txt & vifname:txt & metric:u32 \
				& policytags:list<u32>;

	replace_interface_route6 ? protocol:txt				\
				& unicast:bool & multicast:bool		\
				& network:ipv6net & nexthop:ipv6	\
				& ifname:txt & vifname:txt & metric:u32 \
				& policytags:list<u32>;
	/**
	 * Lookup nexthop.
	 *
	 * @param addr address to lookup.
	 *
	 * @param unicast look in unicast RIB.
	 *
	 * @param multicast look in multicast RIB.
	 *
	 * @param nexthop contains the resolved nexthop if successful,
	 * IPv6::ZERO otherwise.  It is an error for the unicast and multicast
	 * fields to both be true or both false.
	 */
	lookup_route_by_dest6 ? addr:ipv6 & unicast:bool & multicast:bool \
		-> nexthop:ipv6;

	add_vif_addr6 ? name:txt & addr:ipv6 & subnet:ipv6net;


	/**
	 * Enable route redistribution from one routing protocol to
	 * another.
	 *
	 * @param to_xrl_target the XRL Target instance name of the caller.
	 *	  The caller must implement redist6/0.1.
	 *
	 * @param from_protocol the name of the routing process routes are
	 * to be redistributed from.
	 *
	 * @param unicast enable for unicast RIBs matching from and to.
	 *
	 * @param multicast enable for multicast RIBs matching from and to.
	 *
	 * @param network_prefix redistribite only the routes that fall
	 *        into this prefix address.
	 *
	 * @param cookie a text value passed back to creator in each call
	 *        from the RIB.  This allows creators to identity the source
	 *	  of updates it receives through the redist6/0.1
	 *	  interface.
	 */
	redist_enable6 ? to_xrl_target:txt				\
		       & from_protocol:txt				\
		       & unicast:bool					\
		       & multicast:bool					\
		       & network_prefix:ipv6net				\
		       & cookie:txt;

	/**
	 * Disable route redistribution from one routing protocol to
	 * another.
	 *
	 * @param to_xrl_target the XRL Target instance name of the caller.
	 *	  The caller must implement redist6/0.1 and previously
	 *	  called redist_enable6.
	 *
	 * @param from the name of the routing process routes are to be
	 *	  redistributed from.
	 *
	 * @param unicast disable for unicast RIBs matching from and to.
	 *
	 * @param multicast disable for multicast RIBs matching from and to.
	 *
	 * @param cookie a text value passed back to creator in each call
	 *        from the RIB.  This allows creators to identity the source
	 *	  of updates it receives through the redist6/0.1
	 *	  interface.
	 */
	redist_disable6	? to_xrl_target:txt				\
			& from_protocol:txt				\
			& unicast:bool					\
			& multicast:bool				\
			& cookie:txt;

	/**
	 * Enable transaction-based route redistribution from
	 * one routing protocol to another.
	 *
	 * @param to_xrl_target the XRL Target instance name of the caller.
	 *	  The caller must implement redist_transaction6/0.1.
	 *
	 * @param from_protocol the name of the routing process routes are
	 * to be redistributed from.
	 *
	 * @param unicast enable for unicast RIBs matching from and to.
	 *
	 * @param multicast enable for multicast RIBs matching from and to.
	 *
	 * @param network_prefix redistribite only the routes that fall
	 *        into this prefix address.
	 *
	 * @param cookie a text value passed back to creator in each call
	 *        from the RIB.  This allows creators to identity the source
	 *	  of updates it receives through the redist_transaction6/0.1
	 *	  interface.
	 */
	redist_transaction_enable6	? to_xrl_target:txt		\
					& from_protocol:txt		\
					& unicast:bool			\
					& multicast:bool		\
					& network_prefix:ipv6net	\
					& cookie:txt;

	/**
	 * Disable transaction-based route redistribution from
	 * one routing protocol to another.
	 *
	 * @param to_xrl_target the XRL Target instance name of the caller.
	 *	  The caller must implement redist_transaction6/0.1
	 *	  and previously called redist_transaction_enable6.
	 *
	 * @param from the name of the routing process routes are to be
	 *	  redistributed from.
	 *
	 * @param unicast disable for unicast RIBs matching from and to.
	 *
	 * @param multicast disable for multicast RIBs matching from and to.
	 *
	 * @param cookie a text value passed back to creator in each call
	 *        from the RIB.  This allows creators to identity the source
	 *	  of updates it receives through the redist_transaction6/0.1
	 *	  interface.
	 */
	redist_transaction_disable6	? to_xrl_target:txt		\
					& from_protocol:txt		\
					& unicast:bool			\
					& multicast:bool		\
					& cookie:txt;

	/**
 	 * Register an interest in a route.
	 *
	 * @param target the name of the XRL module to notify when the
         * information returned by this call becomes invalid.
	 *
	 * @param addr address of interest.
	 *
         * @param resolves returns whether or not the address resolves
         * to a route that can be used for forwarding.
	 *
	 * @param base_addr returns the address of interest (actually
         * the base address of the subnet covered by addr/prefix_len).
	 *
	 * @param prefix_len returns the prefix length that the registration
         * covers.  This response applies to all addresses in addr/prefix_len.
	 *
	 * @param real_prefix_len returns the actual prefix length of the
         * route that will be used to route addr.  If real_prefix_len is
         * not the same as prefix_len, this is because there are some more
         * specific routes that overlap addr/real_prefix_len.  real_prefix_len
         * is primarily given for debugging reasons.
	 *
	 * @param nexthop returns the address of the next hop for packets sent
	 * to addr.
	 *
	 * @param metric returns the IGP metric for this route.
         */
	register_interest6 ? target:txt & addr:ipv6 \
		-> resolves:bool & base_addr:ipv6 & prefix_len:u32 & \
                   real_prefix_len:u32 & nexthop:ipv6 & metric:u32;

	/**
	 * De-register an interest in a route.
	 *
	 * @param target the name of the XRL module that registered
         * the interest.
	 *
	 * @param addr the address of the previous registered
         * interest.  addr should be the base address of the
         * add/prefix_len subnet.
	 *
	 * @param prefix_len the prefix length of the registered interest,
         * as given in the response from register_interest.
	 */
	deregister_interest6 ?  target:txt & addr:ipv6 & prefix_len:u32;
#endif //ipv6
}
