diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-03-12 20:53:59 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-24 22:18:39 +0900 |
commit | dd1600a08288e3276526c0c266df41c57d19bc8a (patch) | |
tree | 09f146ecc566d7990c2d6cd246deb42eb36c343b /tools/config | |
parent | 38bb94707f35e103db3b313978bcac4046f99a20 (diff) |
policy: add example configs for import policy
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
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 +} |