state-uncalibrated.c 809 Bytes
Newer Older
1
/*
2 3
 * Aurelio Colosimo for CERN, 2011 -- GNU LGPL v2.1 or later
 * Based on PTPd project v. 2.1.0 (see AUTHORS for details)
4
 */
5

6
#include <pptp/pptp.h>
7
#include "common-fun.h"
8 9 10

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

	switch (ppi->msg_tmp_header.messageType) {

	case PPM_ANNOUNCE:
16
		e = st_com_slave_handle_announce(ppi, pkt, plen);
17 18 19
		break;

	case PPM_SYNC:
20
		e = st_com_slave_handle_sync(ppi, pkt, plen);
21 22 23
		break;

	case PPM_FOLLOW_UP:
24
		e = st_com_slave_handle_followup(ppi, pkt, plen);
25 26 27 28 29 30 31 32
		break;

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

	if (e == 0)
33 34 35
		e = st_com_execute_slave(ppi);

	if (e != 0)
36 37 38 39
		ppi->next_state = PPS_FAULTY;

	ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;

40 41
	return 0;
}