/* $XORP: xorp/etc/templates/ripng.tp,v 1.48 2008/10/30 00:17:23 pavlin Exp $ */

/*
 * RIPng attribute descriptions
 */

protocols {
    ripng {
	targetname: txt = "ripng";
	traceoptions {
	    flag {
		all {
		    disable:		toggle = false;
		}
	    }
	}
	interface @: txt {
	    vif @: txt {
		address @: ipv6 {
		    metric:			u32	=   1;
		    horizon:			txt	= "split-horizon-poison-reverse";
		    disable:			toggle	= false;
		    enabled:			bool;	/* %deprecated */
		    passive:			bool	= false;
		    accept-non-rip-requests:	bool	= true;
		    accept-default-route:	bool	= true;
		    advertise-default-route:	bool	= true;
		    route-timeout:		u32	= 180;
		    route-expiry-secs:		u32;	/* %deprecated */
		    deletion-delay:		u32	= 120;
		    route-deletion-secs:	u32;	/* %deprecated */
		    triggered-delay:		u32	=   3;
		    triggered-jitter:		u32	=  66;
		    update-interval:		u32	=  30;
		    update-jitter:		u32	=  16;
		    request-interval:		u32	=  30;
		    table-request-secs:		u32;	/* %deprecated */
		    interpacket-delay:		u32	=  50;
		    interpacket-delay-msecs:	u32;	/* %deprecated */
		}
	    }
	}

	import: txt;
	export: txt;
    }
}

policy {
    policy-statement @: txt {
	term @: txt {
	    from {
		metric: u32range;
	    }
	    to {
		metric: u32range;
	    }
	    then {
		metric: u32;
	    }
	}
    }
}

/*
 * RIPNG attribute manipulation.
 */
protocols {
    ripng {
	%modinfo:	provides		ripng;
	%modinfo:	depends			rib;
	%modinfo:	depends			policy;
	%modinfo:	path			"rip/xorp_ripng";
	%modinfo:	default_targetname	"ripng";
	%modinfo:	status_method xrl	"$(ripng.targetname)/common/0.1/get_status->status:u32&reason:txt";
	%modinfo:	shutdown_method xrl	"$(ripng.targetname)/common/0.1/shutdown";
	%help:		short "RIPng configuration";

	%mandatory:	$(@.targetname);

	targetname {
	    %user-hidden: "XRL target name";
	    %help:	short "XRL target name";
	    %set:;
	}

	traceoptions {
	    %help:	short "Configure the tracing options";
	    flag {
		%help:	short "Configure the tracing operation to perform";
		all {
		    %help:	short	"Configure all tracing operations";

		    disable {
			%help:	short	"Disable all tracing operations";
			%set:	xrl "$(ripng.targetname)/ripng/0.1/trace?tvar:txt=all&enable:bool=`~$(@)`";
			%delete: xrl "$(ripng.targetname)/ripng/0.1/trace?tvar:txt=all&enable:bool=$(DEFAULT)";
		    }
		}
	    }
	}
 
	interface @ {
	    %help:	short "Interface in RIPng domain";
	    vif @ {
		%help:	short "Vif in RIPng domain";
		address @ {
		    %help: short "Address on vif used for RIPng";
		    %create: xrl "$(ripng.targetname)/ripng/0.1/add_rip_address?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)";
		    %delete: xrl "$(ripng.targetname)/ripng/0.1/remove_rip_address?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)";
		    %activate: xrl "$(ripng.targetname)/ripng/0.1/set_rip_address_enabled?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&enabled:bool=`~$(@.disable)`";

		    disable {
			%help: short "Disable RIPng on address";
			%create:;
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_rip_address_enabled?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&enabled:bool=`~$(@)`";
		    }

		    enabled {
			%deprecated: "Statement 'enabled: true/false' is replaced with 'disable: false/true'";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_rip_address_enabled?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&enabled:bool=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/rip_address_enabled?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->enabled:bool";
			%help: short "Enable RIPng on address";
		    }

		    metric {
			%allow-range: $(@) "0" "16" %help: "Cost metric added to routes received on address";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_cost?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&cost:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/cost?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->cost:u32";
			%help: short "Cost metric added to routes received on address";
		    }

		    horizon {
			%allow: $(@) "none" %help: "No horizon type";
			%allow: $(@) "split-horizon" %help: "Split horizon";
			%allow: $(@) "split-horizon-poison-reverse" %help: "Split horizon with poisoned reverse";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_horizon?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&horizon:txt=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/horizon?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->horizon:txt";
			%help: short "Horizon type applied to announced routes";
		    }

		    passive {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_passive?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&passive:bool=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/passive?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->passive:bool";
			%help: short "Do not transmit RIPng packets";
		    }

		    accept-non-rip-requests {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_accept_non_rip_requests?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&accept:bool=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/accept_non_rip_requests?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->accept:bool";
			%help: short "Accept RIPng requests from non-RIPng port";
		    }

		    accept-default-route {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_accept_default_route?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&accept:bool=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/accept_default_route?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->accept:bool";
			%help: short "Accept default route from RIPng neighbor";
		    }

		    advertise-default-route {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_advertise_default_route?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&advertise:bool=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/advertise_default_route?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->advertise:bool";
			%help: short "Advertise default route to RIPng neighbors";
		    }

		    route-timeout {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_route_timeout?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_secs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/route_timeout?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_secs:u32";
			%help: short "Route expiration time (sec)";
		    }

		    route-expiry-secs {
			%deprecated: "Statement 'route-expiry-secs' is replaced with 'route-timeout'";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_route_timeout?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_secs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/route_timeout?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_secs:u32";
			%help: short "Route expiration interval in the absence of updates";
		    }

		    deletion-delay {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_deletion_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_secs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/deletion_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_secs:u32";
			%help: short "Delay before expired routes are deleted (sec)";
		    }

		    route-deletion-secs {
			%deprecated: "Statement 'route-deletion-secs' is replaced with 'deletion-delay'";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_deletion_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_secs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/deletion_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_secs:u32";
			%help: short "Route deletion interval after advertised as unreachable";
		    }

		    triggered-delay {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_triggered_update_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_secs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/triggered_update_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_secs:u32";
			%help: short "Delay before sending repeated triggered update (sec)";
		    }

		    triggered-jitter {
			%allow-range: $(@) "0" "100" %help: "Jitter as percents of 'triggered-delay'";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_triggered_update_jitter?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_jitter:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/triggered_update_jitter?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_jitter:u32";
			%help: short "Jitter of repeated triggered update delay (percents)";
		    }

		    update-interval {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_update_interval?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_secs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/update_interval?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_secs:u32";
			%help: short "Interval between regular route updates (sec)";
		    }

		    update-jitter {
			%allow-range: $(@) "0" "100" %help: "Jitter as percents of 'update-interval'";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_update_jitter?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_jitter:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/update_jitter?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_jitter:u32";
			%help: short "Jitter of regular route update interval (percents)";
		    }

		    request-interval {
			%allow-range: $(@) "1" "10000" %help: "RIPng request interval when no known neighbors (sec)";
			%allow-range: $(@) "0" "0" %help: "Disable periodic RIPng requests";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_request_interval?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_secs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/request_interval?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_secs:u32";
			%help: short "RIPng request interval when no known neighbors (sec)";
		    }

		    table-request-secs {
			%deprecated: "Statement 'table-request-secs' is replaced with 'request-interval'";
			%allow-range: $(@) "1" "10000" %help: "RIPng request interval when no known neighbors";
			%allow-range: $(@) "0" "0" %help: "Disable periodic RIPng request packets when no known neighbors";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_request_interval?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_secs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/request_interval?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_secs:u32";
			%help: short "RIPng request interval when no known neighbors";
		    }

		    interpacket-delay {
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_interpacket_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_msecs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/interpacket_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_msecs:u32";
			%help: short "Minimum delay between outbound RIPng packets (msec)";
		    }

		    interpacket-delay-msecs {
			%deprecated: "Statement 'interpacket-delay-msecs' is replaced with 'interpacket-delay'";
			%set: xrl "$(ripng.targetname)/ripng/0.1/set_interpacket_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)&t_msecs:u32=$(@)";
			%get: xrl "$(ripng.targetname)/ripng/0.1/interpacket_delay?ifname:txt=$(interface.@)&vifname:txt=$(vif.@)&addr:ipv6=$(address.@)->t_msecs:u32";
			%help: short "Minimum delay between outbound RIP packets";
		    }
		}
	    }
	}

	import {
	    %help: short "Import policy name(s)";
	    %delete: xrl "policy/policy/0.1/import?protocol:txt=$(ripng.targetname)&policies:txt=&modifier:txt=";
	    %set: xrl "policy/policy/0.1/import?protocol:txt=$(ripng.targetname)&policies:txt=$(@)&modifier:txt=";
	}
	export {
	    %help: short "Export policy name(s)";
	    %delete: xrl "policy/policy/0.1/export?protocol:txt=$(ripng.targetname)&policies:txt=&modifier:txt=";
	    %set: xrl "policy/policy/0.1/export?protocol:txt=$(ripng.targetname)&policies:txt=$(@)&modifier:txt=";
	}
    }
}

policy {
    %create: xrl "$(policy.targetname)/policy/0.1/add_varmap?protocol:txt=ripng&variable:txt=network6&type:txt=ipv6net&access:txt=r&id:u32=12";
    %create: xrl "$(policy.targetname)/policy/0.1/add_varmap?protocol:txt=ripng&variable:txt=nexthop6&type:txt=ipv6nexthop&access:txt=rw&id:u32=13";
    %create: xrl "$(policy.targetname)/policy/0.1/add_varmap?protocol:txt=ripng&variable:txt=metric&type:txt=u32&access:txt=rw&id:u32=14";

    policy-statement @: txt {
	term @: txt {
	    from {
		metric {
		    %help: short "Metric value";
		    %allow-operator: ":" "==" "!=" "<" ">" "<=" ">=";
		    %set: xrl "$(policy.targetname)/policy/0.1/update_term_block?policy:txt=$(policy-statement.@)&term:txt=$(term.@)&block:u32=0&order:txt=$(#)&statement:txt=metric $(<>) $(@);";
		    %delete: xrl "$(policy.targetname)/policy/0.1/update_term_block?policy:txt=$(policy-statement.@)&term:txt=$(term.@)&block:u32=0&order:txt=$(#)&statement:txt=";
		}
	    }
	    to {
		metric {
		    %help: short "Metric value";
		    %allow-operator: ":" "==" "!=" "<" ">" "<=" ">=";
		    %set: xrl "$(policy.targetname)/policy/0.1/update_term_block?policy:txt=$(policy-statement.@)&term:txt=$(term.@)&block:u32=1&order:txt=$(#)&statement:txt=metric $(<>) $(@);";
		    %delete: xrl "$(policy.targetname)/policy/0.1/update_term_block?policy:txt=$(policy-statement.@)&term:txt=$(term.@)&block:u32=1&order:txt=$(#)&statement:txt=";
		}
	    }
	    then {
		metric {
		    %help: short "Set the metric value";
		    %allow-operator: ":" "=" "sub" "add";
		    %set: xrl "$(policy.targetname)/policy/0.1/update_term_block?policy:txt=$(policy-statement.@)&term:txt=$(term.@)&block:u32=2&order:txt=$(#)&statement:txt=metric $(<>) $(@);";
		    %delete: xrl "$(policy.targetname)/policy/0.1/update_term_block?policy:txt=$(policy-statement.@)&term:txt=$(term.@)&block:u32=2&order:txt=$(#)&statement:txt=";
		}
	    }
	}
    }
}
