Commit a8683138 authored by Sven Meier's avatar Sven Meier Committed by Adam Wujek

audit porting: ported the patches of the audit chapter 2.4.5

Now everywhere the packet buffer is a void *buf and the lenght is int len
parent c105365a
...@@ -44,12 +44,12 @@ enum { ...@@ -44,12 +44,12 @@ enum {
}; };
static void pp_diag_fsm(struct pp_instance *ppi, char *name, int sequence, static void pp_diag_fsm(struct pp_instance *ppi, char *name, int sequence,
int plen) int len)
{ {
if (sequence == STATE_ENTER) { if (sequence == STATE_ENTER) {
/* enter with or without a packet len */ /* enter with or without a packet len */
pp_fsm_printf(ppi, "ENTER %s, packet len %i\n", pp_fsm_printf(ppi, "ENTER %s, packet len %i\n",
name, plen); name, len);
return; return;
} }
if (sequence == STATE_LOOP) { if (sequence == STATE_LOOP) {
...@@ -172,17 +172,17 @@ static int type_length[__PP_NR_MESSAGES_TYPES] = { ...@@ -172,17 +172,17 @@ static int type_length[__PP_NR_MESSAGES_TYPES] = {
}; };
static int fsm_unpack_verify_frame(struct pp_instance *ppi, static int fsm_unpack_verify_frame(struct pp_instance *ppi,
uint8_t *packet, int plen) void *buf, int len)
{ {
int msgtype = 0; int msgtype = 0;
if (plen) if (len)
msgtype = packet[0] & 0xf; msgtype = ((*(UInteger8 *) (buf + 0)) & 0x0F);
if (msgtype >= __PP_NR_MESSAGES_TYPES || plen < type_length[msgtype]) if (msgtype >= __PP_NR_MESSAGES_TYPES || len < type_length[msgtype])
return 1; /* too short */ return 1; /* too short */
if ((packet[1] & 0xf) != 2) if (((*(UInteger8 *) (buf + 1)) & 0x0F) != 2)
return 1; /* wrong ptp version */ return 1; /* wrong ptp version */
return msg_unpack_header(ppi, packet, plen); return msg_unpack_header(ppi, buf, len);
} }
/* /*
...@@ -194,18 +194,18 @@ static int fsm_unpack_verify_frame(struct pp_instance *ppi, ...@@ -194,18 +194,18 @@ static int fsm_unpack_verify_frame(struct pp_instance *ppi,
* is that of the extension, otherwise the one in state-table-default.c * is that of the extension, otherwise the one in state-table-default.c
*/ */
int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen) int pp_state_machine(struct pp_instance *ppi, void *buf, int len)
{ {
struct pp_state_table_item *ip; struct pp_state_table_item *ip;
struct pp_time *t = &ppi->last_rcv_time; struct pp_time *t = &ppi->last_rcv_time;
int state, err = 0; int state, err = 0;
int msgtype; int msgtype;
if (plen > 0) { if (len > 0) {
msgtype = packet[0] & 0xf; msgtype = ((*(UInteger8 *) (buf + 0)) & 0x0F);
pp_diag(ppi, frames, 1, pp_diag(ppi, frames, 1,
"RECV %02d bytes at %9d.%09d.%03d (type %x, %s)\n", "RECV %02d bytes at %9d.%09d.%03d (type %x, %s)\n",
plen, (int)t->secs, (int)(t->scaled_nsecs >> 16), len, (int)t->secs, (int)(t->scaled_nsecs >> 16),
((int)(t->scaled_nsecs & 0xffff) * 1000) >> 16, ((int)(t->scaled_nsecs & 0xffff) * 1000) >> 16,
msgtype, pp_msgtype_info[msgtype].name); msgtype, pp_msgtype_info[msgtype].name);
} }
...@@ -213,9 +213,9 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen) ...@@ -213,9 +213,9 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
/* /*
* Discard too short packets * Discard too short packets
*/ */
if (plen < PP_HEADER_LENGTH) { if (len < PP_HEADER_LENGTH) {
plen = 0; len = 0;
packet = NULL; buf = NULL;
} }
/* /*
...@@ -224,10 +224,10 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen) ...@@ -224,10 +224,10 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
* In case of error continue without a frame, so the current * In case of error continue without a frame, so the current
* ptp state can update ppi->next_delay and return a proper value * ptp state can update ppi->next_delay and return a proper value
*/ */
err = fsm_unpack_verify_frame(ppi, packet, plen); err = fsm_unpack_verify_frame(ppi, buf, len);
if (err) { if (err) {
plen = 0; len = 0;
packet = NULL; buf = NULL;
} }
state = ppi->state; state = ppi->state;
...@@ -242,26 +242,26 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen) ...@@ -242,26 +242,26 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
ppi->next_state = state; ppi->next_state = state;
ppi->next_delay = 0; ppi->next_delay = 0;
if (ppi->is_new_state) if (ppi->is_new_state)
pp_diag_fsm(ppi, ip->name, STATE_ENTER, plen); pp_diag_fsm(ppi, ip->name, STATE_ENTER, len);
/* /*
* Possibly filter out packet and maybe update port state * Possibly filter out buf and maybe update port state
*/ */
if (packet) { if (buf) {
err = pp_packet_prefilter(ppi); err = pp_packet_prefilter(ppi);
if (err < 0) { if (err < 0) {
packet = NULL; buf = NULL;
plen = 0; len = 0;
} }
} }
if (ppi->state != ppi->next_state) if (ppi->state != ppi->next_state)
return leave_current_state(ppi); return leave_current_state(ppi);
if (!plen) if (!len)
ppi->received_ptp_header.messageType = PPM_NO_MESSAGE; ppi->received_ptp_header.messageType = PPM_NO_MESSAGE;
err = ip->f1(ppi, packet, plen); err = ip->f1(ppi, buf, len);
if (err) if (err)
pp_printf("fsm for %s: Error %i in %s\n", pp_printf("fsm for %s: Error %i in %s\n",
ppi->port_name, err, ip->name); ppi->port_name, err, ip->name);
......
...@@ -66,7 +66,7 @@ struct pp_channel { ...@@ -66,7 +66,7 @@ struct pp_channel {
struct pp_frgn_master { struct pp_frgn_master {
/* how many announce messages from this port where received in the /* how many announce messages from this port where received in the
* interval */ * interval */
int ann_cnt[PP_FOREIGN_MASTER_TIME_WINDOW]; UInteger16 foreignMasterAnnounceMessages[PP_FOREIGN_MASTER_TIME_WINDOW];
/* on which port we received the frame */ /* on which port we received the frame */
PortIdentity receivePortIdentity; PortIdentity receivePortIdentity;
/* BMC related information */ /* BMC related information */
......
...@@ -148,13 +148,13 @@ extern void pp_prepare_pointers(struct pp_instance *ppi); ...@@ -148,13 +148,13 @@ extern void pp_prepare_pointers(struct pp_instance *ppi);
* allow NULL pointers. * allow NULL pointers.
*/ */
struct pp_ext_hooks { struct pp_ext_hooks {
int (*init)(struct pp_instance *ppg, unsigned char *pkt, int plen); int (*init)(struct pp_instance *ppg, void *buf, int len);
int (*open)(struct pp_globals *ppi, struct pp_runtime_opts *rt_opts); int (*open)(struct pp_globals *ppi, struct pp_runtime_opts *rt_opts);
int (*close)(struct pp_globals *ppg); int (*close)(struct pp_globals *ppg);
int (*listening)(struct pp_instance *ppi, unsigned char *pkt, int plen); int (*listening)(struct pp_instance *ppi, void *buf, int len);
int (*master_msg)(struct pp_instance *ppi, unsigned char *pkt, int (*master_msg)(struct pp_instance *ppi, void *buf,
int plen, int msgtype); int len, int msgtype);
int (*new_slave)(struct pp_instance *ppi, unsigned char *pkt, int plen); int (*new_slave)(struct pp_instance *ppi, void *buf, int len);
int (*handle_resp)(struct pp_instance *ppi); int (*handle_resp)(struct pp_instance *ppi);
void (*s1)(struct pp_instance *ppi, struct pp_frgn_master *frgn_master); void (*s1)(struct pp_instance *ppi, struct pp_frgn_master *frgn_master);
int (*execute_slave)(struct pp_instance *ppi); int (*execute_slave)(struct pp_instance *ppi);
...@@ -380,14 +380,14 @@ extern int bmc_dataset_cmp(struct pp_instance *ppi, ...@@ -380,14 +380,14 @@ extern int bmc_dataset_cmp(struct pp_instance *ppi,
struct pp_frgn_master *a, struct pp_frgn_master *a,
struct pp_frgn_master *b); struct pp_frgn_master *b);
extern void bmc_store_frgn_master(struct pp_instance *ppi, extern void bmc_store_frgn_master(struct pp_instance *ppi,
struct pp_frgn_master *frgn_master, unsigned char *buf, int len); struct pp_frgn_master *frgn_master, void *buf, int len);
extern void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf, extern void bmc_add_frgn_master(struct pp_instance *ppi, void *buf,
int len); int len);
/* msg.c */ /* msg.c */
extern void msg_init_header(struct pp_instance *ppi, void *buf); extern void msg_init_header(struct pp_instance *ppi, void *buf);
extern int msg_from_current_master(struct pp_instance *ppi); extern int msg_from_current_master(struct pp_instance *ppi);
extern int __attribute__((warn_unused_result)) extern int __attribute__((warn_unused_result))
msg_unpack_header(struct pp_instance *ppi, void *buf, int plen); msg_unpack_header(struct pp_instance *ppi, void *buf, int len);
extern void msg_unpack_sync(void *buf, MsgSync *sync); extern void msg_unpack_sync(void *buf, MsgSync *sync);
extern int msg_pack_sync(struct pp_instance *ppi, struct pp_time *orig_tstamp); extern int msg_pack_sync(struct pp_instance *ppi, struct pp_time *orig_tstamp);
extern void msg_unpack_announce(void *buf, MsgAnnounce *ann); extern void msg_unpack_announce(void *buf, MsgAnnounce *ann);
...@@ -429,7 +429,7 @@ extern void pp_time_div2(struct pp_time *t); ...@@ -429,7 +429,7 @@ extern void pp_time_div2(struct pp_time *t);
*/ */
/* Use a typedef, to avoid long prototypes */ /* Use a typedef, to avoid long prototypes */
typedef int pp_action(struct pp_instance *ppi, uint8_t *packet, int plen); typedef int pp_action(struct pp_instance *ppi, void *buf, int len);
struct pp_state_table_item { struct pp_state_table_item {
int state; int state;
...@@ -445,7 +445,7 @@ extern pp_action pp_initializing, pp_faulty, pp_disabled, pp_listening, ...@@ -445,7 +445,7 @@ extern pp_action pp_initializing, pp_faulty, pp_disabled, pp_listening,
pp_slave, pp_pclock;; pp_slave, pp_pclock;;
/* The engine */ /* The engine */
extern int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen); extern int pp_state_machine(struct pp_instance *ppi, void *buf, int len);
/* Frame-drop support -- rx before tx, alphabetically */ /* Frame-drop support -- rx before tx, alphabetically */
extern void ppsi_drop_init(struct pp_globals *ppg, unsigned long seed); extern void ppsi_drop_init(struct pp_globals *ppg, unsigned long seed);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/* ext-whiterabbit must offer its own hooks */ /* ext-whiterabbit must offer its own hooks */
static int wr_init(struct pp_instance *ppi, unsigned char *pkt, int plen) static int wr_init(struct pp_instance *ppi, void *buf, int len)
{ {
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
...@@ -61,7 +61,7 @@ static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts) ...@@ -61,7 +61,7 @@ static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts)
return 0; return 0;
} }
static int wr_listening(struct pp_instance *ppi, unsigned char *pkt, int plen) static int wr_listening(struct pp_instance *ppi, void *buf, int len)
{ {
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
...@@ -70,7 +70,7 @@ static int wr_listening(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -70,7 +70,7 @@ static int wr_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
return 0; return 0;
} }
static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen, static int wr_master_msg(struct pp_instance *ppi, void *buf, int len,
int msgtype) int msgtype)
{ {
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
...@@ -93,7 +93,7 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen, ...@@ -93,7 +93,7 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen,
/* This is missing in the standard protocol */ /* This is missing in the standard protocol */
case PPM_SIGNALING: case PPM_SIGNALING:
msg_unpack_wrsig(ppi, pkt, &wrsig_msg, msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(WR_DSPOR(ppi)->msgTmpWrMessageID)); &(WR_DSPOR(ppi)->msgTmpWrMessageID));
if ((WR_DSPOR(ppi)->msgTmpWrMessageID == SLAVE_PRESENT) && if ((WR_DSPOR(ppi)->msgTmpWrMessageID == SLAVE_PRESENT) &&
(WR_DSPOR(ppi)->wrConfig & WR_M_ONLY)) { (WR_DSPOR(ppi)->wrConfig & WR_M_ONLY)) {
...@@ -107,7 +107,7 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen, ...@@ -107,7 +107,7 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen,
return msgtype; return msgtype;
} }
static int wr_new_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) static int wr_new_slave(struct pp_instance *ppi, void *buf, int len)
{ {
pp_diag(ppi, ext, 2, "hook: %s\n", __func__); pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
wr_servo_init(ppi); wr_servo_init(ppi);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* We enter here from WRS_CALIBRATION. If master we wait for * We enter here from WRS_CALIBRATION. If master we wait for
* a CALIBRATE message, if slave we wait for LINK_ON. * a CALIBRATE message, if slave we wait for LINK_ON.
*/ */
int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen) int wr_calibrated(struct pp_instance *ppi, void *buf, int len)
{ {
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
...@@ -32,7 +32,7 @@ int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -32,7 +32,7 @@ int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
} }
if (ppi->received_ptp_header.messageType == PPM_SIGNALING) { if (ppi->received_ptp_header.messageType == PPM_SIGNALING) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg, msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID)); &(wrp->msgTmpWrMessageID));
if ((wrp->msgTmpWrMessageID == CALIBRATE) && if ((wrp->msgTmpWrMessageID == CALIBRATE) &&
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* We enter this state from WRS_M_LOCK or WRS_RESP_CALIB_REQ. * We enter this state from WRS_M_LOCK or WRS_RESP_CALIB_REQ.
* We send CALIBRATE and do the hardware steps; finally we send CALIBRATED. * We send CALIBRATE and do the hardware steps; finally we send CALIBRATED.
*/ */
int wr_calibration(struct pp_instance *ppi, unsigned char *pkt, int plen) int wr_calibration(struct pp_instance *ppi, void *buf, int len)
{ {
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
int sendmsg = 0; int sendmsg = 0;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* This is the last WR state: ack the other party and go master or slave. * This is the last WR state: ack the other party and go master or slave.
* There is no timeout nor a check for is_new_state: we just do things once * There is no timeout nor a check for is_new_state: we just do things once
*/ */
int wr_link_on(struct pp_instance *ppi, unsigned char *pkt, int plen) int wr_link_on(struct pp_instance *ppi, void *buf, int len)
{ {
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
int e = 0; int e = 0;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* WR slave: got here from WRS_S_LOCK: send LOCKED, wait for CALIBRATE. * WR slave: got here from WRS_S_LOCK: send LOCKED, wait for CALIBRATE.
* On timeout resend. * On timeout resend.
*/ */
int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen) int wr_locked(struct pp_instance *ppi, void *buf, int len)
{ {
int e = 0, sendmsg = 0; int e = 0, sendmsg = 0;
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
...@@ -36,7 +36,7 @@ int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -36,7 +36,7 @@ int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->received_ptp_header.messageType == PPM_SIGNALING) { if (ppi->received_ptp_header.messageType == PPM_SIGNALING) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg, msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID)); &(wrp->msgTmpWrMessageID));
if (wrp->msgTmpWrMessageID == CALIBRATE) if (wrp->msgTmpWrMessageID == CALIBRATE)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* This the entry point for a WR master: send "LOCK" and wait * This the entry point for a WR master: send "LOCK" and wait
* for "LOCKED". On timeout retry sending, for WR_STATE_RETRY times. * for "LOCKED". On timeout retry sending, for WR_STATE_RETRY times.
*/ */
int wr_m_lock(struct pp_instance *ppi, unsigned char *pkt, int plen) int wr_m_lock(struct pp_instance *ppi, void *buf, int len)
{ {
int e = 0, sendmsg = 0; int e = 0, sendmsg = 0;
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
...@@ -35,7 +35,7 @@ int wr_m_lock(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -35,7 +35,7 @@ int wr_m_lock(struct pp_instance *ppi, unsigned char *pkt, int plen)
} }
if (ppi->received_ptp_header.messageType == PPM_SIGNALING) { if (ppi->received_ptp_header.messageType == PPM_SIGNALING) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg, msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID)); &(wrp->msgTmpWrMessageID));
if (wrp->msgTmpWrMessageID == LOCKED) if (wrp->msgTmpWrMessageID == LOCKED)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Here we send SLAVE_PRESENT and wait for LOCK. If timeout, * Here we send SLAVE_PRESENT and wait for LOCK. If timeout,
* resent SLAVE_PRESENT from WR_STATE_RETRY times * resent SLAVE_PRESENT from WR_STATE_RETRY times
*/ */
int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen) int wr_present(struct pp_instance *ppi, void *buf, int len)
{ {
int e = 0, sendmsg = 0; int e = 0, sendmsg = 0;
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
...@@ -38,7 +38,7 @@ int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -38,7 +38,7 @@ int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen)
} }
if (ppi->received_ptp_header.messageType == PPM_SIGNALING) { if (ppi->received_ptp_header.messageType == PPM_SIGNALING) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg, msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID)); &(wrp->msgTmpWrMessageID));
if (wrp->msgTmpWrMessageID == LOCK) if (wrp->msgTmpWrMessageID == LOCK)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "wr-api.h" #include "wr-api.h"
int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen) int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len)
{ {
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
MsgSignaling wrsig_msg; MsgSignaling wrsig_msg;
...@@ -37,7 +37,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -37,7 +37,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->received_ptp_header.messageType == PPM_SIGNALING) { if (ppi->received_ptp_header.messageType == PPM_SIGNALING) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg, msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID)); &(wrp->msgTmpWrMessageID));
if (wrp->msgTmpWrMessageID == CALIBRATED) { if (wrp->msgTmpWrMessageID == CALIBRATED) {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "wr-api.h" #include "wr-api.h"
int wr_s_lock(struct pp_instance *ppi, unsigned char *pkt, int plen) int wr_s_lock(struct pp_instance *ppi, void *buf, int len)
{ {
struct wr_dsport *wrp = WR_DSPOR(ppi); struct wr_dsport *wrp = WR_DSPOR(ppi);
int enable = 0; int enable = 0;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
/* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data /* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data
* structure */ * structure */
#define WRS_PPSI_SHMEM_VERSION 22 /* Changed struct pp_frgn_master */ #define WRS_PPSI_SHMEM_VERSION 23 /* Changed struct pp_frgn_master */
/* Don't include the Following when this file is included in assembler. */ /* Don't include the Following when this file is included in assembler. */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
...@@ -85,14 +85,14 @@ void msg_unpack_wrsig(struct pp_instance *ppi, void *buf, ...@@ -85,14 +85,14 @@ void msg_unpack_wrsig(struct pp_instance *ppi, void *buf,
int msg_issue_wrsig(struct pp_instance *ppi, Enumeration16 wr_msg_id); int msg_issue_wrsig(struct pp_instance *ppi, Enumeration16 wr_msg_id);
/* White rabbit state functions */ /* White rabbit state functions */
int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_present(struct pp_instance *ppi, void *buf, int len);
int wr_m_lock(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_m_lock(struct pp_instance *ppi, void *buf, int len);
int wr_s_lock(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_s_lock(struct pp_instance *ppi, void *buf, int len);
int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_locked(struct pp_instance *ppi, void *buf, int len);
int wr_calibration(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_calibration(struct pp_instance *ppi, void *buf, int len);
int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_calibrated(struct pp_instance *ppi, void *buf, int len);
int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len);
int wr_link_on(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_link_on(struct pp_instance *ppi, void *buf, int len);
int wr_abscal(struct pp_instance *ppi, unsigned char *pkt, int plen); int wr_abscal(struct pp_instance *ppi, unsigned char *pkt, int plen);
/* Common functions, used by various states and hooks */ /* Common functions, used by various states and hooks */
......
...@@ -136,7 +136,7 @@ void bmc_setup_local_frgn_master(struct pp_instance *ppi, ...@@ -136,7 +136,7 @@ void bmc_setup_local_frgn_master(struct pp_instance *ppi,
/* this shall be always qualified */ /* this shall be always qualified */
for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++) for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++)
frgn_master->ann_cnt[i] = 1; frgn_master->foreignMasterAnnounceMessages[i] = 1;
memcpy(&frgn_master->receivePortIdentity, memcpy(&frgn_master->receivePortIdentity,
&DSPOR(ppi)->portIdentity, sizeof(PortIdentity)); &DSPOR(ppi)->portIdentity, sizeof(PortIdentity));
...@@ -177,8 +177,8 @@ int bmc_gm_cmp(struct pp_instance *ppi, ...@@ -177,8 +177,8 @@ int bmc_gm_cmp(struct pp_instance *ppi,
int i; int i;
struct ClockQuality *qa = &a->grandmasterClockQuality; struct ClockQuality *qa = &a->grandmasterClockQuality;
struct ClockQuality *qb = &b->grandmasterClockQuality; struct ClockQuality *qb = &b->grandmasterClockQuality;
int *ca = a->ann_cnt; UInteger16 *ca = a->foreignMasterAnnounceMessages;
int *cb = b->ann_cnt; UInteger16 *cb = b->foreignMasterAnnounceMessages;
int qualifieda = 0; int qualifieda = 0;
int qualifiedb = 0; int qualifiedb = 0;
...@@ -265,8 +265,8 @@ int bmc_topology_cmp(struct pp_instance *ppi, ...@@ -265,8 +265,8 @@ int bmc_topology_cmp(struct pp_instance *ppi,
struct PortIdentity *pidtxb = &b->sourcePortIdentity; struct PortIdentity *pidtxb = &b->sourcePortIdentity;
struct PortIdentity *pidrxa = &a->receivePortIdentity; struct PortIdentity *pidrxa = &a->receivePortIdentity;
struct PortIdentity *pidrxb = &b->receivePortIdentity; struct PortIdentity *pidrxb = &b->receivePortIdentity;
int *ca = a->ann_cnt; UInteger16 *ca = a->foreignMasterAnnounceMessages;
int *cb = b->ann_cnt; UInteger16 *cb = b->foreignMasterAnnounceMessages;
int qualifieda = 0; int qualifieda = 0;
int qualifiedb = 0; int qualifiedb = 0;
int diff; int diff;
...@@ -623,7 +623,7 @@ slave_s1: ...@@ -623,7 +623,7 @@ slave_s1:
} }
void bmc_store_frgn_master(struct pp_instance *ppi, void bmc_store_frgn_master(struct pp_instance *ppi,
struct pp_frgn_master *frgn_master, unsigned char *buf, int len) struct pp_frgn_master *frgn_master, void *buf, int len)
{ {
int i; int i;
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
...@@ -631,7 +631,7 @@ void bmc_store_frgn_master(struct pp_instance *ppi, ...@@ -631,7 +631,7 @@ void bmc_store_frgn_master(struct pp_instance *ppi,
/* clear qualification timeouts */ /* clear qualification timeouts */
for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++) for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++)
frgn_master->ann_cnt[i] = 0; frgn_master->foreignMasterAnnounceMessages[i] = 0;
/* /*
* header and announce field of each Foreign Master are * header and announce field of each Foreign Master are
...@@ -662,7 +662,7 @@ void bmc_store_frgn_master(struct pp_instance *ppi, ...@@ -662,7 +662,7 @@ void bmc_store_frgn_master(struct pp_instance *ppi,
} }
void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf, void bmc_add_frgn_master(struct pp_instance *ppi, void *buf,
int len) int len)
{ {
int i, j, worst, sel; int i, j, worst, sel;
...@@ -725,13 +725,14 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf, ...@@ -725,13 +725,14 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf,
/* fill in number of announce received */ /* fill in number of announce received */
for (j = 0; j < PP_FOREIGN_MASTER_TIME_WINDOW; j++) for (j = 0; j < PP_FOREIGN_MASTER_TIME_WINDOW; j++)
frgn_master.ann_cnt[j] = ppi->frgn_master[i].ann_cnt[j]; frgn_master.foreignMasterAnnounceMessages[j] =
ppi->frgn_master[i].foreignMasterAnnounceMessages[j];
/* update the number of announce received if correct /* update the number of announce received if correct
* sequence number 9.3.2.5 b) */ * sequence number 9.3.2.5 b) */
if (hdr->sequenceId if (hdr->sequenceId
== (ppi->frgn_master[i].sequenceId + 1)) == (ppi->frgn_master[i].sequenceId + 1))
frgn_master.ann_cnt[0]++; frgn_master.foreignMasterAnnounceMessages[0]++;
/* already in Foreign master data set, update info */ /* already in Foreign master data set, update info */
memcpy(&ppi->frgn_master[i], &frgn_master, memcpy(&ppi->frgn_master[i], &frgn_master,
...@@ -742,7 +743,7 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf, ...@@ -742,7 +743,7 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf,
/* set qualification timeouts as valid to compare against worst*/ /* set qualification timeouts as valid to compare against worst*/
for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++) for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++)
frgn_master.ann_cnt[i] = 1; frgn_master.foreignMasterAnnounceMessages[i] = 1;
/* New foreign master */ /* New foreign master */
if (ppi->frgn_rec_num < PP_NR_FOREIGN_RECORDS) { if (ppi->frgn_rec_num < PP_NR_FOREIGN_RECORDS) {
...@@ -773,10 +774,10 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf, ...@@ -773,10 +774,10 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf,
/* clear qualification timeouts */ /* clear qualification timeouts */
for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++) for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++)
frgn_master.ann_cnt[i] = 0; frgn_master.foreignMasterAnnounceMessages[i] = 0;
/* This is the first one qualified 9.3.2.5 e)*/ /* This is the first one qualified 9.3.2.5 e)*/
frgn_master.ann_cnt[0] = 1; frgn_master.foreignMasterAnnounceMessages[0] = 1;
/* Copy the temporary foreign master entry */ /* Copy the temporary foreign master entry */
memcpy(&ppi->frgn_master[sel], &frgn_master, memcpy(&ppi->frgn_master[sel], &frgn_master,
...@@ -798,17 +799,17 @@ static void bmc_age_frgn_master(struct pp_instance *ppi) ...@@ -798,17 +799,17 @@ static void bmc_age_frgn_master(struct pp_instance *ppi)
/* get qualification */ /* get qualification */
qualified = 0; qualified = 0;
for (j = 0; j < PP_FOREIGN_MASTER_TIME_WINDOW; j++) for (j = 0; j < PP_FOREIGN_MASTER_TIME_WINDOW; j++)
qualified += ppi->frgn_master[i].ann_cnt[j]; qualified += ppi->frgn_master[i].foreignMasterAnnounceMessages[j];
/* shift qualification */ /* shift qualification */
for (j = 1; j < PP_FOREIGN_MASTER_TIME_WINDOW; j++) for (j = 1; j < PP_FOREIGN_MASTER_TIME_WINDOW; j++)
ppi->frgn_master[i].ann_cnt[ ppi->frgn_master[i].foreignMasterAnnounceMessages[
(PP_FOREIGN_MASTER_TIME_WINDOW - j)] = (PP_FOREIGN_MASTER_TIME_WINDOW - j)] =
ppi->frgn_master[i].ann_cnt[ ppi->frgn_master[i].foreignMasterAnnounceMessages[
(PP_FOREIGN_MASTER_TIME_WINDOW - j - 1)]; (PP_FOREIGN_MASTER_TIME_WINDOW - j - 1)];
/* clear lowest */ /* clear lowest */
ppi->frgn_master[i].ann_cnt[0] = 0; ppi->frgn_master[i].foreignMasterAnnounceMessages[0] = 0;
/* remove aged out and shift foreign masters*/ /* remove aged out and shift foreign masters*/
if (qualified == 0) { if (qualified == 0) {
......
...@@ -120,7 +120,7 @@ int st_com_check_announce_receive_timeout(struct pp_instance *ppi) ...@@ -120,7 +120,7 @@ int st_com_check_announce_receive_timeout(struct pp_instance *ppi)
} }
int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf, int st_com_peer_handle_pres(struct pp_instance *ppi, void *buf,
int len) int len)
{ {
MsgPDelayResp resp; MsgPDelayResp resp;
...@@ -167,7 +167,7 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf, ...@@ -167,7 +167,7 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf,
} }
int st_com_peer_handle_pres_followup(struct pp_instance *ppi, int st_com_peer_handle_pres_followup(struct pp_instance *ppi,
unsigned char *buf, int plen) void *buf, int len)
{ {
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
MsgPDelayRespFollowUp respFllw; MsgPDelayRespFollowUp respFllw;
...@@ -200,7 +200,7 @@ int st_com_peer_handle_pres_followup(struct pp_instance *ppi, ...@@ -200,7 +200,7 @@ int st_com_peer_handle_pres_followup(struct pp_instance *ppi,
return e; return e;
} }
int st_com_peer_handle_preq(struct pp_instance *ppi, unsigned char *buf, int st_com_peer_handle_preq(struct pp_instance *ppi, void *buf,
int len) int len)
{ {
int e = 0; int e = 0;
...@@ -220,7 +220,7 @@ int st_com_peer_handle_preq(struct pp_instance *ppi, unsigned char *buf, ...@@ -220,7 +220,7 @@ int st_com_peer_handle_preq(struct pp_instance *ppi, unsigned char *buf,
return 0; return 0;
} }
int st_com_handle_announce(struct pp_instance *ppi, unsigned char *buf, int len) int st_com_handle_announce(struct pp_instance *ppi, void *buf, int len)
{ {
bmc_add_frgn_master(ppi, buf, len); bmc_add_frgn_master(ppi, buf, len);
......
...@@ -15,27 +15,27 @@ ...@@ -15,27 +15,27 @@
int st_com_check_announce_receive_timeout(struct pp_instance *ppi); int st_com_check_announce_receive_timeout(struct pp_instance *ppi);
int st_com_peer_handle_preq(struct pp_instance *ppi, unsigned char *buf, int st_com_peer_handle_preq(struct pp_instance *ppi, void *buf,
int len); int len);
int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf, int st_com_peer_handle_pres(struct pp_instance *ppi, void *buf,
int len); int len);
int st_com_peer_handle_pres_followup(struct pp_instance *ppi, int st_com_peer_handle_pres_followup(struct pp_instance *ppi,
unsigned char *buf, int len); void *buf, int len);
int st_com_handle_announce(struct pp_instance *ppi, unsigned char *buf, int st_com_handle_announce(struct pp_instance *ppi, void *buf,
int len); int len);
int __send_and_log(struct pp_instance *ppi, int msglen, int chtype); int __send_and_log(struct pp_instance *ppi, int msglen, int chtype);
/* Count successfully received PTP packets */ /* Count successfully received PTP packets */
static inline int __recv_and_count(struct pp_instance *ppi, void *pkt, int len, static inline int __recv_and_count(struct pp_instance *ppi, void *buf, int len,
struct pp_time *t) struct pp_time *t)
{ {
int ret; int ret;
ret = ppi->n_ops->recv(ppi, pkt, len, t); ret = ppi->n_ops->recv(ppi, buf, len, t);
if (ret > 0) if (ret > 0)
ppi->ptp_rx_count++; ppi->ptp_rx_count++;
return ret; return ret;
......
...@@ -22,7 +22,7 @@ int msg_from_current_master(struct pp_instance *ppi) ...@@ -22,7 +22,7 @@ int msg_from_current_master(struct pp_instance *ppi)
} }
/* Unpack header from in buffer to receieved_ptp_header field */ /* Unpack header from in buffer to receieved_ptp_header field */
int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen) int msg_unpack_header(struct pp_instance *ppi, void *buf, int len)
{ {
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
uint32_t lsb, msb; uint32_t lsb, msb;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
int pp_disabled(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_disabled(struct pp_instance *ppi, void *buf, int len)
{ {
/* nothing to do */ /* nothing to do */
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS; ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* PTP_INITIALIZING state after a grace period. * PTP_INITIALIZING state after a grace period.
*/ */
int pp_faulty(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_faulty(struct pp_instance *ppi, void *buf, int len)
{ {
if (pp_timeout(ppi, PP_TO_FAULT)) { if (pp_timeout(ppi, PP_TO_FAULT)) {
ppi->next_state = PPS_INITIALIZING; ppi->next_state = PPS_INITIALIZING;
......
...@@ -36,7 +36,7 @@ static void init_parent_ds(struct pp_instance *ppi) ...@@ -36,7 +36,7 @@ static void init_parent_ds(struct pp_instance *ppi)
* Initializes network and other stuff * Initializes network and other stuff
*/ */
int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_initializing(struct pp_instance *ppi, void *buf, int len)
{ {
unsigned char *id, *mac; unsigned char *id, *mac;
struct DSPort *port = DSPOR(ppi); struct DSPort *port = DSPOR(ppi);
...@@ -93,7 +93,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -93,7 +93,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
pp_timeout_init(ppi); pp_timeout_init(ppi);
if (pp_hooks.init) if (pp_hooks.init)
ret = pp_hooks.init(ppi, pkt, plen); ret = pp_hooks.init(ppi, buf, len);
if (ret) { if (ret) {
pp_diag(ppi, ext, 1, "%s: can't init extension\n", __func__); pp_diag(ppi, ext, 1, "%s: can't init extension\n", __func__);
goto failure; goto failure;
......
...@@ -23,14 +23,14 @@ static pp_action *actions[] = { ...@@ -23,14 +23,14 @@ static pp_action *actions[] = {
/* skip signaling and management, for binary size */ /* skip signaling and management, for binary size */
}; };
int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_listening(struct pp_instance *ppi, void *buf, int len)
{ {
int e = 0; /* error var, to check errors in msg handling */ int e = 0; /* error var, to check errors in msg handling */
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
pp_timeout_set(ppi, PP_TO_FAULT); /* no fault as long as we listen */ pp_timeout_set(ppi, PP_TO_FAULT); /* no fault as long as we listen */
if (pp_hooks.listening) if (pp_hooks.listening)
e = pp_hooks.listening(ppi, pkt, plen); e = pp_hooks.listening(ppi, buf, len);
if (e) if (e)
goto out; goto out;
...@@ -42,9 +42,9 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -42,9 +42,9 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
*/ */
if (hdr->messageType < ARRAY_SIZE(actions) if (hdr->messageType < ARRAY_SIZE(actions)
&& actions[hdr->messageType]) { && actions[hdr->messageType]) {
e = actions[hdr->messageType](ppi, pkt, plen); e = actions[hdr->messageType](ppi, buf, len);
} else { } else {
if (plen) if (len)
pp_diag(ppi, frames, 1, "Ignored frame %i\n", pp_diag(ppi, frames, 1, "Ignored frame %i\n",
hdr->messageType); hdr->messageType);
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "common-fun.h" #include "common-fun.h"
static int master_handle_delay_request(struct pp_instance *ppi, static int master_handle_delay_request(struct pp_instance *ppi,
unsigned char *pkt, int plen); void *buf, int len);
static pp_action *actions[] = { static pp_action *actions[] = {
[PPM_SYNC] = 0, [PPM_SYNC] = 0,
...@@ -27,7 +27,7 @@ static pp_action *actions[] = { ...@@ -27,7 +27,7 @@ static pp_action *actions[] = {
}; };
static int master_handle_delay_request(struct pp_instance *ppi, static int master_handle_delay_request(struct pp_instance *ppi,
unsigned char *pkt, int plen) void *buf, int len)
{ {
if (ppi->state == PPS_MASTER) /* not pre-master */ if (ppi->state == PPS_MASTER) /* not pre-master */
msg_issue_delay_resp(ppi, &ppi->last_rcv_time); msg_issue_delay_resp(ppi, &ppi->last_rcv_time);
...@@ -38,7 +38,7 @@ static int master_handle_delay_request(struct pp_instance *ppi, ...@@ -38,7 +38,7 @@ static int master_handle_delay_request(struct pp_instance *ppi,
* MASTER and PRE_MASTER have many things in common. This function implements * MASTER and PRE_MASTER have many things in common. This function implements
* both states. We set "pre" internally to 0 or 1. * both states. We set "pre" internally to 0 or 1.
*/ */
int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen) int pp_master(struct pp_instance *ppi, void *buf, int len)
{ {
int msgtype; int msgtype;
int pre = (ppi->state == PPS_PRE_MASTER); int pre = (ppi->state == PPS_PRE_MASTER);
...@@ -79,10 +79,10 @@ int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen) ...@@ -79,10 +79,10 @@ int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen)
*/ */
msgtype = ppi->received_ptp_header.messageType; msgtype = ppi->received_ptp_header.messageType;
if (pp_hooks.master_msg) if (pp_hooks.master_msg)
msgtype = pp_hooks.master_msg(ppi, pkt, plen, msgtype); msgtype = pp_hooks.master_msg(ppi, buf, len, msgtype);
if (msgtype < 0) { if (msgtype < 0) {
e = msgtype; e = msgtype;
plen = 0; len = 0;
e = PP_SEND_ERROR; /* well, "error" in general */ e = PP_SEND_ERROR; /* well, "error" in general */
goto out; goto out;
} }
...@@ -92,9 +92,9 @@ int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen) ...@@ -92,9 +92,9 @@ int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen)
*/ */
if (msgtype < ARRAY_SIZE(actions) if (msgtype < ARRAY_SIZE(actions)
&& actions[msgtype]) { && actions[msgtype]) {
e = actions[msgtype](ppi, pkt, plen); e = actions[msgtype](ppi, buf, len);
} else { } else {
if (plen && msgtype != PPM_NO_MESSAGE) if (len && msgtype != PPM_NO_MESSAGE)
pp_diag(ppi, frames, 1, "Ignored frame %i\n", pp_diag(ppi, frames, 1, "Ignored frame %i\n",
msgtype); msgtype);
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "common-fun.h" #include "common-fun.h"
static int passive_handle_announce(struct pp_instance *ppi, unsigned char *buf, int len); static int passive_handle_announce(struct pp_instance *ppi, void *buf, int len);
static pp_action *actions[] = { static pp_action *actions[] = {
[PPM_SYNC] = 0, [PPM_SYNC] = 0,
...@@ -25,7 +25,7 @@ static pp_action *actions[] = { ...@@ -25,7 +25,7 @@ static pp_action *actions[] = {
/* skip signaling and management, for binary size */ /* skip signaling and management, for binary size */
}; };
static int passive_handle_announce(struct pp_instance *ppi, unsigned char *buf, int len) static int passive_handle_announce(struct pp_instance *ppi, void *buf, int len)
{ {
int ret = 0; int ret = 0;
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
...@@ -48,7 +48,7 @@ static int passive_handle_announce(struct pp_instance *ppi, unsigned char *buf, ...@@ -48,7 +48,7 @@ static int passive_handle_announce(struct pp_instance *ppi, unsigned char *buf,
return 0; return 0;
} }
int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_passive(struct pp_instance *ppi, void *buf, int len)
{ {
int e = 0; /* error var, to check errors in msg handling */ int e = 0; /* error var, to check errors in msg handling */
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
...@@ -65,9 +65,9 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -65,9 +65,9 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
*/ */
if (hdr->messageType < ARRAY_SIZE(actions) if (hdr->messageType < ARRAY_SIZE(actions)
&& actions[hdr->messageType]) { && actions[hdr->messageType]) {
e = actions[hdr->messageType](ppi, pkt, plen); e = actions[hdr->messageType](ppi, buf, len);
} else { } else {
if (plen) if (len)
pp_diag(ppi, frames, 1, "Ignored frame %i\n", pp_diag(ppi, frames, 1, "Ignored frame %i\n",
hdr->messageType); hdr->messageType);
} }
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
#include "common-fun.h" #include "common-fun.h"
static int slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, int len); static int slave_handle_sync(struct pp_instance *ppi, void *buf, int len);
static int slave_handle_followup(struct pp_instance *ppi, unsigned char *buf, static int slave_handle_followup(struct pp_instance *ppi, void *buf,
int len); int len);
static int slave_handle_response(struct pp_instance *ppi, unsigned char *buf, static int slave_handle_response(struct pp_instance *ppi, void *buf,
int len); int len);
static int slave_handle_announce(struct pp_instance *ppi, unsigned char *buf, int len); static int slave_handle_announce(struct pp_instance *ppi, void *buf, int len);
static pp_action *actions[] = { static pp_action *actions[] = {
[PPM_SYNC] = slave_handle_sync, [PPM_SYNC] = slave_handle_sync,
...@@ -32,7 +32,7 @@ static pp_action *actions[] = { ...@@ -32,7 +32,7 @@ static pp_action *actions[] = {
/* skip signaling and management, for binary size */ /* skip signaling and management, for binary size */
}; };
static int slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, static int slave_handle_sync(struct pp_instance *ppi, void *buf,
int len) int len)
{ {
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
...@@ -64,7 +64,7 @@ static int slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -64,7 +64,7 @@ static int slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
return 0; return 0;
} }
static int slave_handle_followup(struct pp_instance *ppi, unsigned char *buf, static int slave_handle_followup(struct pp_instance *ppi, void *buf,
int len) int len)
{ {
MsgFollowUp follow; MsgFollowUp follow;
...@@ -114,7 +114,7 @@ static int slave_handle_followup(struct pp_instance *ppi, unsigned char *buf, ...@@ -114,7 +114,7 @@ static int slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
return 0; return 0;
} }
static int slave_handle_response(struct pp_instance *ppi, unsigned char *buf, static int slave_handle_response(struct pp_instance *ppi, void *buf,
int len) int len)
{ {
int e = 0; int e = 0;
...@@ -159,7 +159,7 @@ static int slave_handle_response(struct pp_instance *ppi, unsigned char *buf, ...@@ -159,7 +159,7 @@ static int slave_handle_response(struct pp_instance *ppi, unsigned char *buf,
return 0; return 0;
} }
static int slave_handle_announce(struct pp_instance *ppi, unsigned char *buf, int len) static int slave_handle_announce(struct pp_instance *ppi, void *buf, int len)
{ {
int ret = 0; int ret = 0;
struct pp_frgn_master frgn_master; struct pp_frgn_master frgn_master;
...@@ -198,7 +198,7 @@ static int slave_execute(struct pp_instance *ppi) ...@@ -198,7 +198,7 @@ static int slave_execute(struct pp_instance *ppi)
* SLAVE and UNCALIBRATED have many things in common. This function implements * SLAVE and UNCALIBRATED have many things in common. This function implements
* both states. We set "uncalibrated" internally to 0 or 1. * both states. We set "uncalibrated" internally to 0 or 1.
*/ */
int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) int pp_slave(struct pp_instance *ppi, void *buf, int len)
{ {
int e = 0; /* error var, to check errors in msg handling */ int e = 0; /* error var, to check errors in msg handling */
int uncalibrated = (ppi->state == PPS_UNCALIBRATED); int uncalibrated = (ppi->state == PPS_UNCALIBRATED);
...@@ -223,7 +223,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -223,7 +223,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
pp_servo_init(ppi); pp_servo_init(ppi);
if (pp_hooks.new_slave) if (pp_hooks.new_slave)
e = pp_hooks.new_slave(ppi, pkt, plen); e = pp_hooks.new_slave(ppi, buf, len);
if (e) if (e)
goto out; goto out;
} }
...@@ -236,9 +236,9 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -236,9 +236,9 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
*/ */
if (hdr->messageType < ARRAY_SIZE(actions) if (hdr->messageType < ARRAY_SIZE(actions)
&& actions[hdr->messageType]) { && actions[hdr->messageType]) {
e = actions[hdr->messageType](ppi, pkt, plen); e = actions[hdr->messageType](ppi, buf, len);
} else { } else {
if (plen) if (len)
pp_diag(ppi, frames, 1, "Ignored frame %i\n", pp_diag(ppi, frames, 1, "Ignored frame %i\n",
hdr->messageType); hdr->messageType);
} }
......
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