Files
2014-04-10 12:20:24 +00:00

53 lines
1014 B
C

/*
* Copyright (C) 2011 CERN (www.cern.ch)
* Author: Aurelio Colosimo
* Based on PTPd project v. 2.1.0 (see AUTHORS for details)
*
* Released according to the GNU LGPL, version 2.1 or any later version.
*/
#include <ppsi/ppsi.h>
#include "common-fun.h"
int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
int e = 0; /* error var, to check errors in msg handling */
if (ppi->is_new_state)
pp_timeout_restart_annrec(ppi);
if (plen == 0)
goto no_incoming_msg;
switch (ppi->received_ptp_header.messageType) {
case PPM_ANNOUNCE:
e = st_com_master_handle_announce(ppi, pkt, plen);
break;
case PPM_SYNC:
e = st_com_master_handle_sync(ppi, pkt, plen);
break;
default:
/* disreguard, nothing to do */
break;
}
no_incoming_msg:
if (e == 0)
e = st_com_execute_slave(ppi);
if (e != 0)
ppi->next_state = PPS_FAULTY;
if (ppi->next_state != ppi->state) {
pp_timeout_clr(ppi, PP_TO_ANN_RECEIPT);
}
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
return 0;
}