Exemplo n.º 1
0
// 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
}