state-uncalibrated.c 892 Bytes
Newer Older
1
/*
2 3
 * Copyright (C) 2011 CERN (www.cern.ch)
 * Author: Aurelio Colosimo
4
 * Based on PTPd project v. 2.1.0 (see AUTHORS for details)
5 6
 *
 * Released according to the GNU LGPL, version 2.1 or any later version.
7
 */
8

Alessandro Rubini's avatar
Alessandro Rubini committed
9
#include <ppsi/ppsi.h>
10
#include "common-fun.h"
11 12 13

int pp_uncalibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
14
	int e = 0; /* error var, to check errors in msg handling */
15

16
	switch (ppi->received_ptp_header.messageType) {
17 18

	case PPM_ANNOUNCE:
19
		e = pp_lib_handle_announce(ppi, pkt, plen);
20 21 22
		break;

	case PPM_SYNC:
23
		e = st_com_slave_handle_sync(ppi, pkt, plen);
24 25 26
		break;

	case PPM_FOLLOW_UP:
27
		e = st_com_slave_handle_followup(ppi, pkt, plen);
28 29 30 31 32 33 34 35
		break;

	default:
		/* disreguard, nothing to do */
		break;
	}

	if (e == 0)
36
		e = st_com_execute_slave(ppi);
37 38

	if (e != 0)
39 40 41 42
		ppi->next_state = PPS_FAULTY;

	ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;

43 44
	return 0;
}