/* $XORP: xorp/etc/templates/interfaces.tp,v 1.35 2007/12/30 09:15:01 pavlin Exp $ */

interfaces {
    targetname:		txt = "fea";
    restore-original-config-on-shutdown:	bool = false;

    interface @: txt {
	description:	txt = "";
	disable:	toggle = false;
	enabled:	bool;			/* %deprecated */
	discard:	toggle = false;
	unreachable:	toggle = false;
	management:	toggle = false;
	mac:		macaddr;
	mtu:		u32;

	vif @: txt {
	    disable:	toggle = false;
	    enabled:	bool;			/* %deprecated */

	    vlan {
		vlan-id:		u32;
	    }

	    address @: ipv4 {
		prefix-length:		u32;
		broadcast:		ipv4;
		destination:		ipv4;
		multicast-capable:	bool;
		point-to-point:		bool;
		loopback:		bool;
		disable:		toggle = false;
		enabled:		bool;	/* %deprecated */
	    }

	    address @: ipv6 {
		prefix-length:		u32;
		destination:		ipv6;
		multicast-capable:	bool;
		point-to-point:		bool;
		loopback:		bool;
		disable:		toggle = false;
		enabled:		bool;	/* %deprecated */
	    }
	}
    }
}

interfaces {
    %help:	short		"Configure network interfaces";
    %modinfo:	provides	interfaces;
    %modinfo:	path		"fea/xorp_fea";
    %modinfo:	default_targetname "fea";
    %modinfo:	status_method	xrl "$(interfaces.targetname)/common/0.1/get_status->status:u32&reason:txt";
    %modinfo:	shutdown_method xrl "$(interfaces.targetname)/common/0.1/shutdown";
    %modinfo:	start_commit	xrl "$(interfaces.targetname)/ifmgr/0.1/start_transaction->tid:u32=$(interfaces.TID)";
    %modinfo:	end_commit	xrl "$(interfaces.targetname)/ifmgr/0.1/commit_transaction?tid:u32=$(interfaces.TID)";

    %mandatory:	$(@.targetname);

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

    TID {
	%user-hidden: "Transaction ID generated by the FEA";
	%create:;
    }

    restore-original-config-on-shutdown {
	%help:		short "Restore original configuration on shutdown";
	%create:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_restore_original_config_on_shutdown?enable:bool=$(@)";
	%set:		xrl "$(interfaces.targetname)/ifmgr/0.1/set_restore_original_config_on_shutdown?enable:bool=$(@)";
	%delete:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_restore_original_config_on_shutdown?enable:bool=$(DEFAULT)";
    }

    interface @: txt {
	%help:		short "Configure a network interface";
	%create:	xrl "$(interfaces.targetname)/ifmgr/0.1/create_interface?tid:u32=$(interfaces.TID)&ifname:txt=$(@)";
	%delete:	xrl "$(interfaces.targetname)/ifmgr/0.1/delete_interface?tid:u32=$(interfaces.TID)&ifname:txt=$(@)";
	%list:		xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_interface_names->ifnames:list";

	description {
	    %help:	short "Add a human-readable description of an interface";
	    %set:;
	    %get:;
	    %delete:;
	}

	disable {
	    %help:	short "Disable a network interface";
	    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_interface_enabled?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&enabled:bool=`~$(@)`";
	}

	enabled {
	    %deprecated: "Statement 'enabled: true/false' is replaced with 'disable: false/true'";
	    %help:	short "Enable a network interface";
	    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_interface_enabled?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&enabled:bool=$(@)";
	}

	discard {
	    %help:	short "Configure a discard interface";
	    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_interface_discard?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&discard:bool=$(@)";
	}

	unreachable {
	    %help:	short "Configure an unreachable interface";
	    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_interface_unreachable?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&unreachable:bool=$(@)";
	}

	management {
	    %help:	short "Configure a management interface";
	    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_interface_management?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&management:bool=$(@)";
	}

	default-system-config {
	    %help:	short "Use default values from the system";
	    %create:	xrl "$(interfaces.targetname)/ifmgr/0.1/configure_interface_from_system?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&enable:bool=true";
	    %delete:	xrl "$(interfaces.targetname)/ifmgr/0.1/configure_interface_from_system?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&enable:bool=false";
	}

	mac {
	    %help:	short "Set the MAC address";
	    %set:	xrl  "$(interfaces.targetname)/ifmgr/0.1/set_mac?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&mac:mac=$(@)";
	    %delete:	xrl  "$(interfaces.targetname)/ifmgr/0.1/restore_original_mac?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)";
	    %get:	xrl  "$(interfaces.targetname)/ifmgr/0.1/get_configured_mac?ifname:txt=$(interface.@)->mac:mac=$(@)";
	}

	mtu {
	    %help:	short "Set the MTU";
	    /* Minimum and maximum MTU as defined in RFC 791 and RFC 1191 */
	    %allow-range: $(@) "68" "65535" %help: "The MTU (in octets)";
	    %set:	xrl  "$(interfaces.targetname)/ifmgr/0.1/set_mtu?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&mtu:u32=$(@)";
	    %delete:	xrl  "$(interfaces.targetname)/ifmgr/0.1/restore_original_mtu?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)";
	    %get:	xrl  "$(interfaces.targetname)/ifmgr/0.1/get_configured_mtu?ifname:txt=$(interface.@)->mtu:u32=$(@)";
	}

	vif @: txt {
	    %help:	short "Configure a virtual interface";
	    %create:	xrl "$(interfaces.targetname)/ifmgr/0.1/create_vif?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(@)";
	    %delete:	xrl "$(interfaces.targetname)/ifmgr/0.1/delete_vif?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(@)";
	    %list:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_vif_names?ifname:txt=$(interface.@)->vifs:list";

	    disable {
		%help:	short "Disable a network interface";
		%set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_vif_enabled?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&enabled:bool=`~$(@)`";
	    }

	    enabled {
		%deprecated: "Statement 'enabled: true/false' is replaced with 'disable: false/true'";
		%help:	short "Enable a network interface";
		%set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_vif_enabled?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&enabled:bool=$(@)";
	    }

	    vlan {
		%help:	short "Configure a VLAN virtual interface";
		%create:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_vif_vlan?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&vlan_id:u32=$(@.vlan-id)";

		%mandatory:	$(@.vlan-id);

		vlan-id {
		    %help:	short "Set the VLAN ID";
		    %allow-range: $(@) "0" "4095" %help: "The VLAN ID";
		    %create:;
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_vif_vlan?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&vlan_id:u32=$(@)";
		}
	    }

	    address @: ipv4 {
		%help:		short "Configure an IPv4 address";
		%mandatory:	$(@.prefix-length);

		%create:	xrl "$(interfaces.targetname)/ifmgr/0.1/create_address4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(@)";
		%delete:	xrl "$(interfaces.targetname)/ifmgr/0.1/delete_address4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(@)";
		%list:		xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_vif_addresses4?ifname:txt=$(interface.@)&vif:txt->addresses:list";

		disable {
		    %help:	short "Disable the address";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_address_enabled4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)&enabled:bool=`~$(@)`";
		}

		enabled {
		    %deprecated: "Statement 'enabled: true/false' is replaced with 'disable: false/true'";
		    %help:	short "Enable the address";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_address_enabled4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)&enabled:bool=$(@)";
		}

		prefix-length {
		    %help:	short "Assign the network prefix length";
		    %allow-range: $(@) "1" "32" %help: "The network prefix length";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_prefix4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)&prefix_len:u32=$(@)";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_prefix4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->prefix_len:u32";
		}

		broadcast {
		    %help:	short "Assign the network broadcast address";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_broadcast4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)&broadcast:ipv4=$(@)";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_broadcast4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->broadcast:ipv4=$(@)";
		}

		destination {
		    %help:	short "Assign the destination address on point-to-point links";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_endpoint4?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)&endpoint:ipv4=$(@)";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_endpoint4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->endpoint:ipv4=$(@)";
		}

		multicast-capable {
		    %help:	short "Show if the address is multicast capable";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->enabled:bool&broadcast:bool&loopback:bool&point_to_point:bool&multicast:bool=$(@)";
		}

		point-to-point {
		    %help:	short "Show if the address is point-to-point";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->enabled:bool&broadcast:bool&loopback:bool&point_to_point:bool=$(@)&multicast:bool";
		}

		loopback {
		    %help:	short "Show if this is a loopback address";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags4?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv4=$(address.@)->enabled:bool&broadcast:bool&loopback:bool=$(@)&point_to_point:bool&multicast:bool";
		}
	    }

	    address @: ipv6 {
		%help:		short "Configure an IPv6 address";
		%mandatory:	$(@.prefix-length);

		%create:	xrl "$(interfaces.targetname)/ifmgr/0.1/create_address6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(@)";
		%delete:	xrl "$(interfaces.targetname)/ifmgr/0.1/delete_address6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(@)";
		%list:		xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_vif_addresses6?ifname:txt=$(interface.@)&vif:txt->addresses:list";

		disable {
		    %help:	short "Disable the address";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_address_enabled6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)&enabled:bool=`~$(@)`";
		}

		enabled {
		    %deprecated: "Statement 'enabled: true/false' is replaced with 'disable: false/true'";
		    %help:	short "Enable the address";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_address_enabled6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)&enabled:bool=$(@)";
		}

		prefix-length {
		    %help:	short "Assign the network prefix length";
		    %allow-range: $(@) "1" "128" %help: "The network prefix length";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_prefix6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)&prefix_len:u32=$(@)";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_prefix6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->prefix_len:u32";
		}

		destination {
		    %help:	short "Assign the destination address on point-to-point links";
		    %set:	xrl "$(interfaces.targetname)/ifmgr/0.1/set_endpoint6?tid:u32=$(interfaces.TID)&ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)&endpoint:ipv6=$(@)";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_endpoint6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->endpoint:ipv6=$(@)";
		}

		multicast-capable {
		    %help:	short "Show if the address is multicast capable";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->enabled:bool&loopback:bool&point_to_point:bool&multicast:bool=$(@)";
		}

		point-to-point {
		    %help:	short "Show if the address is point-to-point";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->enabled:bool&loopback:bool&point_to_point:bool=$(@)&multicast:bool";
		}

		loopback {
		    %help:	short "Show if this is a loopback address";
		    %get:	xrl "$(interfaces.targetname)/ifmgr/0.1/get_configured_address_flags6?ifname:txt=$(interface.@)&vif:txt=$(vif.@)&address:ipv6=$(address.@)->enabled:bool&loopback:bool=$(@)&point_to_point:bool&multicast:bool";
		}
	    }
	}
    }
}
