diff options
Diffstat (limited to 'tools/config')
-rw-r--r-- | tools/config/example_toml.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/config/example_toml.go b/tools/config/example_toml.go index 003e9897..607e6a63 100644 --- a/tools/config/example_toml.go +++ b/tools/config/example_toml.go @@ -20,6 +20,10 @@ func main() { NeighborAddress: net.ParseIP("192.168.177.32"), AuthPassword: "apple", AfiSafiList: []config.AfiSafi{config.AfiSafi{AfiSafiName: "ipv4-unicast"}, config.AfiSafi{AfiSafiName: "ipv6-unicast"}}, + ApplyPolicy: config.ApplyPolicy{ + ImportPolicies: []string{"pd1"}, + DefaultImportPolicy: config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE, + }, }, config.Neighbor{ PeerAs: 12334, @@ -41,5 +45,60 @@ func main() { panic(err) } + err = encoder.Encode(policy()) + if err != nil { + panic(err) + } fmt.Printf("%v\n", buffer.String()) } + +func policy() config.RoutingPolicy { + + ps := config.PrefixSet{ + PrefixSetName: "ps1", + PrefixList: []config.Prefix{ + config.Prefix{ + Address: net.ParseIP("10.3.192.0"), + Masklength: 21, + MasklengthRange: "21..24", + }}, + } + + ns := config.NeighborSet{ + NeighborSetName: "ns1", + NeighborInfoList: []config.NeighborInfo{ + config.NeighborInfo{ + Address: net.ParseIP("10.0.0.2"), + }}, + } + + ds := config.DefinedSets{ + PrefixSetList: []config.PrefixSet{ps}, + NeighborSetList: []config.NeighborSet{ns}, + } + + s := config.Statement{ + Name: "statement1", + Conditions: config.Conditions{ + MatchPrefixSet: "ps1", + MatchNeighborSet: "ns1", + MatchSetOptions: config.MATCH_SET_OPTIONS_TYPE_ALL, + }, + Actions: config.Actions{ + AcceptRoute: false, + RejectRoute: true, + }, + } + + pd := config.PolicyDefinition{ + Name: "pd1", + StatementList: []config.Statement{s}, + } + + p := config.RoutingPolicy{ + DefinedSets: ds, + PolicyDefinitionList: []config.PolicyDefinition{pd}, + } + + return p +} |