Commit 6abaeb90 authored by Aurelio Colosimo's avatar Aurelio Colosimo

state-uncalibrated first implementation

parent 11ee8a2d
......@@ -2,6 +2,7 @@
* FIXME: header
*/
#include <pproto/pproto.h>
#include <dep/dep.h>
#include "state-common-fun.h"
void st_com_execute_slave(struct pp_instance *ppi)
......@@ -65,7 +66,7 @@ int st_com_check_record_update(struct pp_instance *ppi)
return 0;
}
void st_com_add_foreign(unsigned char *buf, MsgHeader *header,
void st_com_add_foreign(unsigned char *buf, MsgHeader *hdr,
struct pp_instance *ppi)
{
/*TODO "translate" it into ptp-wr structs*/
......@@ -125,3 +126,36 @@ void st_com_add_foreign(unsigned char *buf, MsgHeader *header,
}
#endif /* _FROM_PTPD_2_1_0_ */
}
int st_com_slave_handle_announce(unsigned char *buf, int len,
struct pp_instance *ppi)
{
MsgHeader *hdr = &ppi->msg_tmp_header;
if (len < PP_ANNOUNCE_LENGTH)
return -1;
if (ppi->is_from_self)
return 0;
/*
* Valid announce message is received : BMC algorithm
* will be executed
*/
ppi->record_update = TRUE;
if (!ppi->is_from_cur_par) {
msg_unpack_announce(buf, &ppi->msg_tmp.announce);
s1(hdr, &ppi->msg_tmp.announce, ppi);
}
else {
/* st_com_add_foreign takes care of announce unpacking */
st_com_add_foreign(buf, hdr, ppi);
}
/*Reset Timer handling Announce receipt timeout*/
st_com_restart_annrec_timer(ppi);
return 0;
}
......@@ -14,3 +14,6 @@ int st_com_check_record_update(struct pp_instance *ppi);
void st_com_add_foreign(unsigned char *buf, MsgHeader *header,
struct pp_instance *ppi);
int st_com_slave_handle_announce(unsigned char *buf, int len,
struct pp_instance *ppi);
......@@ -2,9 +2,37 @@
* FIXME: header
*/
#include <pproto/pproto.h>
#include "state-common-fun.h"
int pp_uncalibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
/* TODO */
int e = 0;
switch (ppi->msg_tmp_header.messageType) {
case PPM_ANNOUNCE:
e = st_com_slave_handle_announce(pkt, plen, ppi);
break;
case PPM_SYNC:
/* TODO */
break;
case PPM_FOLLOW_UP:
/* TODO */
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;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment