ciena.grammar: parse interface local/remote
author"Tomas Zeman <tzeman@volny.cz>"
Wed, 30 Dec 2009 15:57:22 +0100
changeset 27 99ddc553a868
parent 26 e2265c3545d7
child 28 3337257bf0e7
ciena.grammar: parse interface local/remote
ciena.grammar
--- a/ciena.grammar	Fri Dec 18 20:02:09 2009 +0100
+++ b/ciena.grammar	Wed Dec 30 15:57:22 2009 +0100
@@ -50,6 +50,7 @@
 $::res->{vs} = {};
 $::res->{"vs-vlans"} = {};
 $::res->{vlans} = {};
+$::res->{interface} = {};
 
 # local (current line) attribute-value-list, ie. property value
 my $avl = {};
@@ -104,6 +105,7 @@
 		| l_vc
 		| l_vs
 		| l_vlan
+		| l_iface
 		| word(s) #eol
 
 word:		/[0-9a-zA-Z:\/_\#\"\.\$,+<>=-]+/
@@ -112,6 +114,9 @@
 identifier:	/[0-9a-zA-Z:_-]+/
 		{ $item[1] }
 
+ip4:		/\d+\.\d+\.\d+\.\d+/
+		{ $item[1] }
+
 quoted_text:	<perl_quotelike>
 		{ $item[1][2] }
 		| /[0-9a-zA-Z:\/_\#\"\.,-]+/
@@ -313,3 +318,26 @@
 		$vlan_range = {};
 		}
 
+# Interface
+l_iface:	"interface" "remote" "set" "ip" ip4 "subnet" ip4
+		{
+		my ($ip, $mask) = ($item[5], $item[7]);
+		$::res->{interface}->{remote} = {
+			ip => $ip,
+			mask => $mask
+		}
+		}
+		| "interface" "local" "disable"
+		{ $::res->{interface}->{'local'}->{disabled} = 1; }
+		| "interface" "set" "gateway" ip4
+		{ $::res->{interface}->{gateway} = $item{ip4}; }
+		| "interface" "create" "remote-interface" identifier "ip" ip4 "subnet" ip4 "vs" identifier
+		{
+		my ($iface, $ip, $mask, $vs) = ($item[4], $item[6], $item[8], $item[10]);
+		$::res->{interface}->{remote} = {
+			ip => $ip,
+			mask => $mask,
+			id => $iface,
+			vs => $vs,
+		}
+		}