-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Local compiler now supports meta fields (or "logical fields"). They can be mutable or immutable, and they can be initialized with the value of another field (such as the ingress port) or with a constant. See #517 for details.
- Loading branch information
Showing
23 changed files
with
438 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Meta Fields | ||
|
||
## Documentation | ||
see https://github.com/frenetic-lang/frenetic/pull/517 | ||
|
||
## Runing the examples | ||
The examples in this directory can be run by executing `frenetic dump local <file>`. | ||
Some examples require adding the flag `--switch 1`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var suspect:=0 in | ||
filter switch=1 and ip4Src=8.0.0.0/8; suspect:=1; port:=5 | | ||
filter switch=2 and suspect=1; drop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(* create immutable meta field that carries original port value *) | ||
let ingress := port in | ||
|
||
(* by default, forward packets to controller *) | ||
port := pipe("controller"); | ||
|
||
(* overwrite default behavior ... *) | ||
begin | ||
if ingress=1 then port:=2 else | ||
if ethDst=1 then port:=1 else | ||
id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(* let declares immutable variables - hence this should not compile *) | ||
let meta:=0 in | ||
meta:=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(* let declares immutable variables - hence this should not compile *) | ||
let meta:=switch in | ||
meta:=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let x:=1 in | ||
filter x=0; port:=0 | | ||
filter x=1; port:=1 | | ||
filter x=2; port:=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(* this will fail since we currently only support up to 5 meta fields in scope at once *) | ||
let m1 := vlanId in | ||
let m2 := port in | ||
let m3 := 423 in | ||
let m4 := port in | ||
let m5 := 1 in | ||
let m6 := 2 in | ||
id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
let m1 := vlanId in | ||
let m2 := port in | ||
let m3 := 423 in | ||
let m4 := port in | ||
filter m1=1 and m2=1 and m3=423; port:=pipe("success!") | | ||
filter m1=2 and m2=2 and m3=1; port:=pipe("fail :(") | | ||
filter m1=2 and m2=2 and m4=3; port:=pipe("fail :(") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.