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 {
};
static void pp_diag_fsm(struct pp_instance *ppi, char *name, int sequence,
int plen)
int len)
{
if (sequence == STATE_ENTER) {
/* enter with or without a packet len */
pp_fsm_printf(ppi, "ENTER %s, packet len %i\n",
name, plen);
name, len);
return;
}
if (sequence == STATE_LOOP) {
......@@ -172,17 +172,17 @@ static int type_length[__PP_NR_MESSAGES_TYPES] = {
};
static int fsm_unpack_verify_frame(struct pp_instance *ppi,
uint8_t *packet, int plen)
void *buf, int len)
{
int msgtype = 0;
if (plen)
msgtype = packet[0] & 0xf;
if (msgtype >= __PP_NR_MESSAGES_TYPES || plen < type_length[msgtype])
if (len)
msgtype = ((*(UInteger8 *) (buf + 0)) & 0x0F);
if (msgtype >= __PP_NR_MESSAGES_TYPES || len < type_length[msgtype])
return 1; /* too short */
if ((packet[1] & 0xf) != 2)
if (((*(UInteger8 *) (buf + 1)) & 0x0F) != 2)
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,
* 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_time *t = &ppi->last_rcv_time;
int state, err = 0;
int msgtype;
if (plen > 0) {
msgtype = packet[0] & 0xf;
if (len > 0) {
msgtype = ((*(UInteger8 *) (buf + 0)) & 0x0F);
pp_diag(ppi, frames, 1,
"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,
msgtype, pp_msgtype_info[msgtype].name);
}
......@@ -213,9 +213,9 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
/*
* Discard too short packets
*/
if (plen < PP_HEADER_LENGTH) {
plen = 0;
packet = NULL;
if (len < PP_HEADER_LENGTH) {
len = 0;
buf = NULL;
}
/*
......@@ -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
* 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) {
plen = 0;
packet = NULL;
len = 0;
buf = NULL;
}
state = ppi->state;
......@@ -242,26 +242,26 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
ppi->next_state = state;
ppi->next_delay = 0;
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);
if (err < 0) {
packet = NULL;
plen = 0;
buf = NULL;
len = 0;
}
}
if (ppi->state != ppi->next_state)
return leave_current_state(ppi);
if (!plen)
if (!len)
ppi->received_ptp_header.messageType = PPM_NO_MESSAGE;
err = ip->f1(ppi, packet, plen);
err = ip->f1(ppi, buf, len);
if (err)
pp_printf("fsm for %s: Error %i in %s\n",
ppi->port_name, err, ip->name);
......
......@@ -66,7 +66,7 @@ struct pp_channel {
struct pp_frgn_master {
/* how many announce messages from this port where received in the
* interval */
int ann_cnt[PP_FOREIGN_MASTER_TIME_WINDOW];
UInteger16 foreignMasterAnnounceMessages[PP_FOREIGN_MASTER_TIME_WINDOW];
/* on which port we received the frame */
PortIdentity receivePortIdentity;
/* BMC related information */
......
......@@ -148,13 +148,13 @@ extern void pp_prepare_pointers(struct pp_instance *ppi);
* allow NULL pointers.
*/
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 (*close)(struct pp_globals *ppg);
int (*listening)(struct pp_instance *ppi, unsigned char *pkt, int plen);
int (*master_msg)(struct pp_instance *ppi, unsigned char *pkt,
int plen, int msgtype);
int (*new_slave)(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, void *buf,
int len, int msgtype);
int (*new_slave)(struct pp_instance *ppi, void *buf, int len);
int (*handle_resp)(struct pp_instance *ppi);
void (*s1)(struct pp_instance *ppi, struct pp_frgn_master *frgn_master);
int (*execute_slave)(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 *b);
extern void bmc_store_frgn_master(struct pp_instance *ppi,
struct pp_frgn_master *frgn_master, unsigned char *buf, int len);
extern void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf,
struct pp_frgn_master *frgn_master, void *buf, int len);
extern void bmc_add_frgn_master(struct pp_instance *ppi, void *buf,
int len);
/* msg.c */
extern void msg_init_header(struct pp_instance *ppi, void *buf);
extern int msg_from_current_master(struct pp_instance *ppi);
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 int msg_pack_sync(struct pp_instance *ppi, struct pp_time *orig_tstamp);
extern void msg_unpack_announce(void *buf, MsgAnnounce *ann);
......@@ -429,7 +429,7 @@ extern void pp_time_div2(struct pp_time *t);
*/
/* 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 {
int state;
......@@ -445,7 +445,7 @@ extern pp_action pp_initializing, pp_faulty, pp_disabled, pp_listening,
pp_slave, pp_pclock;;
/* 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 */
extern void ppsi_drop_init(struct pp_globals *ppg, unsigned long seed);
......
......@@ -3,7 +3,7 @@
/* 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);
......@@ -61,7 +61,7 @@ static int wr_open(struct pp_globals *ppg, struct pp_runtime_opts *rt_opts)
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);
......@@ -70,7 +70,7 @@ static int wr_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
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)
{
MsgSignaling wrsig_msg;
......@@ -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 */
case PPM_SIGNALING:
msg_unpack_wrsig(ppi, pkt, &wrsig_msg,
msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(WR_DSPOR(ppi)->msgTmpWrMessageID));
if ((WR_DSPOR(ppi)->msgTmpWrMessageID == SLAVE_PRESENT) &&
(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,
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__);
wr_servo_init(ppi);
......
......@@ -13,7 +13,7 @@
* We enter here from WRS_CALIBRATION. If master we wait for
* 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);
MsgSignaling wrsig_msg;
......@@ -32,7 +32,7 @@ int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen)
}
if (ppi->received_ptp_header.messageType == PPM_SIGNALING) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg,
msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID));
if ((wrp->msgTmpWrMessageID == CALIBRATE) &&
......
......@@ -13,7 +13,7 @@
* 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.
*/
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);
int sendmsg = 0;
......
......@@ -13,7 +13,7 @@
* 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
*/
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);
int e = 0;
......
......@@ -13,7 +13,7 @@
* WR slave: got here from WRS_S_LOCK: send LOCKED, wait for CALIBRATE.
* 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;
MsgSignaling wrsig_msg;
......@@ -36,7 +36,7 @@ int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->received_ptp_header.messageType == PPM_SIGNALING) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg,
msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID));
if (wrp->msgTmpWrMessageID == CALIBRATE)
......
......@@ -13,7 +13,7 @@
* This the entry point for a WR master: send "LOCK" and wait
* 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;
MsgSignaling wrsig_msg;
......@@ -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) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg,
msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID));
if (wrp->msgTmpWrMessageID == LOCKED)
......
......@@ -15,7 +15,7 @@
* Here we send SLAVE_PRESENT and wait for LOCK. If timeout,
* 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;
struct wr_dsport *wrp = WR_DSPOR(ppi);
......@@ -38,7 +38,7 @@ int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen)
}
if (ppi->received_ptp_header.messageType == PPM_SIGNALING) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg,
msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID));
if (wrp->msgTmpWrMessageID == LOCK)
......
......@@ -9,7 +9,7 @@
#include <ppsi/ppsi.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);
MsgSignaling wrsig_msg;
......@@ -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) {
msg_unpack_wrsig(ppi, pkt, &wrsig_msg,
msg_unpack_wrsig(ppi, buf, &wrsig_msg,
&(wrp->msgTmpWrMessageID));
if (wrp->msgTmpWrMessageID == CALIBRATED) {
......
......@@ -9,7 +9,7 @@
#include <ppsi/ppsi.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);
int enable = 0;
......
......@@ -11,7 +11,7 @@
/* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data
* 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. */
#ifndef __ASSEMBLY__
......@@ -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);
/* White rabbit state functions */
int wr_present(struct pp_instance *ppi, unsigned char *pkt, int plen);
int wr_m_lock(struct pp_instance *ppi, unsigned char *pkt, int plen);
int wr_s_lock(struct pp_instance *ppi, unsigned char *pkt, int plen);
int wr_locked(struct pp_instance *ppi, unsigned char *pkt, int plen);
int wr_calibration(struct pp_instance *ppi, unsigned char *pkt, int plen);
int wr_calibrated(struct pp_instance *ppi, unsigned char *pkt, int plen);
int wr_resp_calib_req(struct pp_instance *ppi, unsigned char *pkt, int plen);
int wr_link_on(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, void *buf, int len);
int wr_s_lock(struct pp_instance *ppi, void *buf, int len);
int wr_locked(struct pp_instance *ppi, void *buf, int len);
int wr_calibration(struct pp_instance *ppi, void *buf, int len);
int wr_calibrated(struct pp_instance *ppi, void *buf, int len);
int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len);
int wr_link_on(struct pp_instance *ppi, void *buf, int len);
int wr_abscal(struct pp_instance *ppi, unsigned char *pkt, int plen);
/* Common functions, used by various states and hooks */
......
......@@ -136,7 +136,7 @@ void bmc_setup_local_frgn_master(struct pp_instance *ppi,
/* this shall be always qualified */
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,
&DSPOR(ppi)->portIdentity, sizeof(PortIdentity));
......@@ -177,8 +177,8 @@ int bmc_gm_cmp(struct pp_instance *ppi,
int i;
struct ClockQuality *qa = &a->grandmasterClockQuality;
struct ClockQuality *qb = &b->grandmasterClockQuality;
int *ca = a->ann_cnt;
int *cb = b->ann_cnt;
UInteger16 *ca = a->foreignMasterAnnounceMessages;
UInteger16 *cb = b->foreignMasterAnnounceMessages;
int qualifieda = 0;
int qualifiedb = 0;
......@@ -265,8 +265,8 @@ int bmc_topology_cmp(struct pp_instance *ppi,
struct PortIdentity *pidtxb = &b->sourcePortIdentity;
struct PortIdentity *pidrxa = &a->receivePortIdentity;
struct PortIdentity *pidrxb = &b->receivePortIdentity;
int *ca = a->ann_cnt;
int *cb = b->ann_cnt;
UInteger16 *ca = a->foreignMasterAnnounceMessages;
UInteger16 *cb = b->foreignMasterAnnounceMessages;
int qualifieda = 0;
int qualifiedb = 0;
int diff;
......@@ -623,7 +623,7 @@ slave_s1:
}
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;
MsgHeader *hdr = &ppi->received_ptp_header;
......@@ -631,7 +631,7 @@ void bmc_store_frgn_master(struct pp_instance *ppi,
/* clear qualification timeouts */
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
......@@ -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 i, j, worst, sel;
......@@ -725,13 +725,14 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf,
/* fill in number of announce received */
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
* sequence number 9.3.2.5 b) */
if (hdr->sequenceId
== (ppi->frgn_master[i].sequenceId + 1))
frgn_master.ann_cnt[0]++;
frgn_master.foreignMasterAnnounceMessages[0]++;
/* already in Foreign master data set, update info */
memcpy(&ppi->frgn_master[i], &frgn_master,
......@@ -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*/
for (i = 0; i < PP_FOREIGN_MASTER_TIME_WINDOW; i++)
frgn_master.ann_cnt[i] = 1;
frgn_master.foreignMasterAnnounceMessages[i] = 1;
/* New foreign master */
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,
/* clear qualification timeouts */
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)*/
frgn_master.ann_cnt[0] = 1;
frgn_master.foreignMasterAnnounceMessages[0] = 1;
/* Copy the temporary foreign master entry */
memcpy(&ppi->frgn_master[sel], &frgn_master,
......@@ -798,17 +799,17 @@ static void bmc_age_frgn_master(struct pp_instance *ppi)
/* get qualification */
qualified = 0;
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 */
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)] =
ppi->frgn_master[i].ann_cnt[
ppi->frgn_master[i].foreignMasterAnnounceMessages[
(PP_FOREIGN_MASTER_TIME_WINDOW - j - 1)];
/* clear lowest */
ppi->frgn_master[i].ann_cnt[0] = 0;
ppi->frgn_master[i].foreignMasterAnnounceMessages[0] = 0;
/* remove aged out and shift foreign masters*/
if (qualified == 0) {
......
......@@ -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)
{
MsgPDelayResp resp;
......@@ -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,
unsigned char *buf, int plen)
void *buf, int len)
{
MsgHeader *hdr = &ppi->received_ptp_header;
MsgPDelayRespFollowUp respFllw;
......@@ -200,7 +200,7 @@ int st_com_peer_handle_pres_followup(struct pp_instance *ppi,
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 e = 0;
......@@ -220,7 +220,7 @@ int st_com_peer_handle_preq(struct pp_instance *ppi, unsigned char *buf,
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);
......
......@@ -15,27 +15,27 @@
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 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 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 __send_and_log(struct pp_instance *ppi, int msglen, int chtype);
/* 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)
{
int ret;
ret = ppi->n_ops->recv(ppi, pkt, len, t);
ret = ppi->n_ops->recv(ppi, buf, len, t);
if (ret > 0)
ppi->ptp_rx_count++;
return ret;
......
......@@ -22,7 +22,7 @@ int msg_from_current_master(struct pp_instance *ppi)
}
/* 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;
uint32_t lsb, msb;
......
......@@ -8,7 +8,7 @@
#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 */
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
......
......@@ -13,7 +13,7 @@
* 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)) {
ppi->next_state = PPS_INITIALIZING;
......
......@@ -36,7 +36,7 @@ static void init_parent_ds(struct pp_instance *ppi)
* 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;
struct DSPort *port = DSPOR(ppi);
......@@ -93,7 +93,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
pp_timeout_init(ppi);
if (pp_hooks.init)
ret = pp_hooks.init(ppi, pkt, plen);
ret = pp_hooks.init(ppi, buf, len);
if (ret) {
pp_diag(ppi, ext, 1, "%s: can't init extension\n", __func__);
goto failure;
......
......@@ -23,14 +23,14 @@ static pp_action *actions[] = {
/* 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 */
MsgHeader *hdr = &ppi->received_ptp_header;
pp_timeout_set(ppi, PP_TO_FAULT); /* no fault as long as we listen */
if (pp_hooks.listening)
e = pp_hooks.listening(ppi, pkt, plen);
e = pp_hooks.listening(ppi, buf, len);
if (e)
goto out;
......@@ -42,9 +42,9 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
*/
if (hdr->messageType < ARRAY_SIZE(actions)
&& actions[hdr->messageType]) {
e = actions[hdr->messageType](ppi, pkt, plen);
e = actions[hdr->messageType](ppi, buf, len);
} else {
if (plen)
if (len)
pp_diag(ppi, frames, 1, "Ignored frame %i\n",
hdr->messageType);
}
......
......@@ -10,7 +10,7 @@
#include "common-fun.h"
static int master_handle_delay_request(struct pp_instance *ppi,
unsigned char *pkt, int plen);
void *buf, int len);
static pp_action *actions[] = {
[PPM_SYNC] = 0,
......@@ -27,7 +27,7 @@ static pp_action *actions[] = {
};
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 */
msg_issue_delay_resp(ppi, &ppi->last_rcv_time);
......@@ -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
* 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 pre = (ppi->state == PPS_PRE_MASTER);
......@@ -79,10 +79,10 @@ int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen)
*/
msgtype = ppi->received_ptp_header.messageType;
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) {
e = msgtype;
plen = 0;
len = 0;
e = PP_SEND_ERROR; /* well, "error" in general */
goto out;
}
......@@ -92,9 +92,9 @@ int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen)
*/
if (msgtype < ARRAY_SIZE(actions)
&& actions[msgtype]) {
e = actions[msgtype](ppi, pkt, plen);
e = actions[msgtype](ppi, buf, len);
} else {
if (plen && msgtype != PPM_NO_MESSAGE)
if (len && msgtyp