本文整理匯總了Golang中github.com/osrg/gobgp/table.Path.GetAsPathLen方法的典型用法代碼示例。如果您正苦於以下問題:Golang Path.GetAsPathLen方法的具體用法?Golang Path.GetAsPathLen怎麽用?Golang Path.GetAsPathLen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/osrg/gobgp/table.Path
的用法示例。
在下文中一共展示了Path.GetAsPathLen方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: evaluate
// compare AS_PATH length in the message's AS_PATH attribute with
// the one in condition.
func (c *AsPathLengthCondition) evaluate(path *table.Path) bool {
length := uint32(path.GetAsPathLen())
result := false
switch c.Operator {
case ATTRIBUTE_EQ:
result = c.Value == length
case ATTRIBUTE_GE:
result = c.Value <= length
case ATTRIBUTE_LE:
result = c.Value >= length
default:
return false
}
if result {
log.WithFields(log.Fields{
"Topic": "Policy",
"Condition": "aspath length",
"Reason": c.Operator,
}).Debug("condition matched")
}
return result
}