Blame bmc.h

Packit 9c3e7e
/**
Packit 9c3e7e
 * @file bmc.h
Packit 9c3e7e
 * @brief Best master clock algorithm
Packit 9c3e7e
 * @note Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is free software; you can redistribute it and/or modify
Packit 9c3e7e
 * it under the terms of the GNU General Public License as published by
Packit 9c3e7e
 * the Free Software Foundation; either version 2 of the License, or
Packit 9c3e7e
 * (at your option) any later version.
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is distributed in the hope that it will be useful,
Packit 9c3e7e
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 9c3e7e
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 9c3e7e
 * GNU General Public License for more details.
Packit 9c3e7e
 *
Packit 9c3e7e
 * You should have received a copy of the GNU General Public License along
Packit 9c3e7e
 * with this program; if not, write to the Free Software Foundation, Inc.,
Packit 9c3e7e
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 9c3e7e
 */
Packit 9c3e7e
#ifndef HAVE_BMC_H
Packit 9c3e7e
#define HAVE_BMC_H
Packit 9c3e7e
Packit 9c3e7e
#include "clock.h"
Packit 9c3e7e
#include "port.h"
Packit 9c3e7e
#include "fsm.h"
Packit 9c3e7e
Packit 9c3e7e
#define A_BETTER_TOPO  2
Packit 9c3e7e
#define A_BETTER       1
Packit 9c3e7e
#define B_BETTER      -1
Packit 9c3e7e
#define B_BETTER_TOPO -2
Packit 9c3e7e
Packit 9c3e7e
enum {
Packit 9c3e7e
	DS_CMP_IEEE1588,
Packit 9c3e7e
	DS_CMP_G8275,
Packit 9c3e7e
};
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * BMC state decision algorithm.
Packit 9c3e7e
 * @param c  The local clock.
Packit 9c3e7e
 * @param r  The port in question.
Packit 9c3e7e
 * @param compare  The data set comparison algorithm.
Packit 9c3e7e
 * @return   A @ref port_state value as the recommended state.
Packit 9c3e7e
 */
Packit 9c3e7e
enum port_state bmc_state_decision(struct clock *c, struct port *r,
Packit 9c3e7e
				   int (*comapre)(struct dataset *a, struct dataset *b));
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * Compare two data sets using the algorithm defined in IEEE 1588.
Packit 9c3e7e
 * @param a A dataset to compare.
Packit 9c3e7e
 * @param b A dataset to compare.
Packit 9c3e7e
 * @return An integer less than, equal to, or greater than zero
Packit 9c3e7e
 *         if the dataset @a a is found, respectively, to be
Packit 9c3e7e
 *         less than, to match, or be greater than @a b.
Packit 9c3e7e
 */
Packit 9c3e7e
int dscmp(struct dataset *a, struct dataset *b);
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * Second part of the data set comparison algorithm, not for general
Packit 9c3e7e
 * public use.
Packit 9c3e7e
 */
Packit 9c3e7e
int dscmp2(struct dataset *a, struct dataset *b);
Packit 9c3e7e
Packit 9c3e7e
/**
Packit 9c3e7e
 * Compare two data sets using the algorithm defined in the Telecom
Packit 9c3e7e
 * Profiles according to ITU-T G.8275.1 and G.8275.2.
Packit 9c3e7e
 *
Packit 9c3e7e
 * @param a A dataset to compare.
Packit 9c3e7e
 * @param b A dataset to compare.
Packit 9c3e7e
 * @return An integer less than, equal to, or greater than zero
Packit 9c3e7e
 *         if the dataset @a a is found, respectively, to be
Packit 9c3e7e
 *         less than, to match, or be greater than @a b.
Packit 9c3e7e
 */
Packit 9c3e7e
int telecom_dscmp(struct dataset *a, struct dataset *b);
Packit 9c3e7e
Packit 9c3e7e
#endif