state-uncalibrated.c 877 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
	TimeInternal time; /* TODO: handle it, see handle(...) in protocol.c */
13 14 15 16

	switch (ppi->msg_tmp_header.messageType) {

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

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

	case PPM_FOLLOW_UP:
25
		e = st_com_slave_handle_followup(ppi, pkt, plen);
26 27 28 29 30 31 32 33 34 35 36 37 38 39
		break;

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

	if (e == 0)
		st_com_execute_slave(ppi);
	else
		ppi->next_state = PPS_FAULTY;

	ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;

40 41
	return 0;
}