tag:
type: txt
help: Set tunnel interface

syntax:expression: pattern $VAR(@) "^tun[0-9]+$" \
		   ; "tunnel must be (tun0-tun999)"

commit:expression: $VAR(./local-ip/) != "" ;                    \
                   "Must configure the tunnel local-ip for $VAR(@)"
commit:expression: $VAR(./remote-ip/) != "" ;                   \
                   "Must configure the tunnel remote-ip for $VAR(@)"
commit:expression: $VAR(./encapsulation/) != "" ;               \
                   "Must configure the tunnel encapsulation for $VAR(@)"

create:expression: "\
       if [ -n \"$VAR(./key/@)\" ]; then                        \
          KEY=\"key $VAR(./key/@)\";                            \
       fi;                                                      \
       MC=\"multicast $VAR(./multicast/@) allmulticast $VAR(./multicast/@)\"; \
       sudo ip tunnel add $VAR(@)                               \
            local $VAR(./local-ip/@) remote $VAR(./remote-ip/@) \
            mode $VAR(./encapsulation/@) $KEY;                  \
       sudo ip link set $VAR(@) $MC up;" ; "Error creating $VAR(@)"

delete:expression: "sudo ip tunnel del $VAR(@)" ; "Error deleting $VAR(@)"

comp_help: Enter tunnel interface name (tun0 - tun999)
