Commit 722e8147 authored by Aurelio Colosimo's avatar Aurelio Colosimo

fix: rt_opts variable usage fix

used OPTS(ppi) everywhere instead of ppi->rt_opts
removed rt_opts as function parameter
parent c14f12fd
......@@ -275,8 +275,7 @@ extern void pp_update_clock(struct pp_instance *ppi);
extern void m1(struct pp_instance *ppi);
extern void s1(struct pp_instance *ppi, MsgHeader *header, MsgAnnounce *ann);
extern UInteger8 bmc(struct pp_instance *ppi,
struct pp_frgn_master *frgn_master,
struct pp_runtime_opts *rt_opts);
struct pp_frgn_master *frgn_master);
/* msg.c */
extern void msg_pack_header(struct pp_instance *ppi, void *buf);
......
......@@ -238,12 +238,11 @@ Integer8 bmc_dataset_cmp(struct pp_instance *ppi,
/* State decision algorithm 9.3.3 Fig 26 */
UInteger8 bmc_state_decision( struct pp_instance *ppi,
MsgHeader *hdr, MsgAnnounce *ann,
struct pp_runtime_opts *rt_opts)
MsgHeader *hdr, MsgAnnounce *ann)
{
int cmpres;
if (rt_opts->slave_only) {
if (OPTS(ppi)->slave_only) {
s1(ppi, hdr, ann);
return PPS_SLAVE;
}
......@@ -289,8 +288,7 @@ UInteger8 bmc_state_decision( struct pp_instance *ppi,
UInteger8 bmc(struct pp_instance *ppi, struct pp_frgn_master *frgn_master,
struct pp_runtime_opts *rt_opts)
UInteger8 bmc(struct pp_instance *ppi, struct pp_frgn_master *frgn_master)
{
Integer16 i, best;
......@@ -312,6 +310,5 @@ UInteger8 bmc(struct pp_instance *ppi, struct pp_frgn_master *frgn_master,
ppi->foreign_record_best = best;
return bmc_state_decision(ppi, &frgn_master[best].hdr,
&frgn_master[best].ann,
rt_opts);
&frgn_master[best].ann);
}
......@@ -23,7 +23,7 @@ int st_com_execute_slave(struct pp_instance *ppi)
}
}
if (ppi->rt_opts->e2e_mode) {
if (OPTS(ppi)->e2e_mode) {
if (pp_timer_expired(ppi->timers[PP_TIMER_DELAYREQ])) {
PP_VPRINTF("event DELAYREQ_INTERVAL_TIMEOUT_EXPIRES\n");
return msg_issue_delay_req(ppi);
......@@ -55,7 +55,7 @@ int st_com_check_record_update(struct pp_instance *ppi)
if (ppi->record_update) {
PP_VPRINTF("event STATE_DECISION_EVENT\n");
ppi->record_update = FALSE;
ppi->next_state = bmc(ppi, ppi->frgn_master, ppi->rt_opts);
ppi->next_state = bmc(ppi, ppi->frgn_master);
if (ppi->next_state != ppi->state)
return 1;
......@@ -182,7 +182,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
ppi->sync_receive_time.nanoseconds = time->nanoseconds;
/* FIXME diag to file? will we ever handle it?
if (ppi->rt_opts->recordFP)
if (OPTS(ppi)->recordFP)
fprintf(rtOpts->recordFP, "%d %llu\n",
header->sequenceId,
((time->seconds * 1000000000ULL) +
......@@ -276,7 +276,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf,
if (len < PP_PDELAY_REQ_LENGTH)
return -1;
if (ppi->rt_opts->e2e_mode)
if (OPTS(ppi)->e2e_mode)
return 0;
time = &ppi->last_rcv_time;
......@@ -292,7 +292,7 @@ int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf,
/*Add latency*/
add_TimeInternal(&ppi->pdelay_req_send_time,
&ppi->pdelay_req_send_time,
&ppi->rt_opts->outbound_latency);
&OPTS(ppi)->outbound_latency);
} else {
msg_copy_header(&ppi->pdelay_req_hdr, hdr);
......@@ -334,7 +334,7 @@ int st_com_master_handle_sync(struct pp_instance *ppi, unsigned char *buf,
time = &ppi->last_rcv_time;
/* Add latency */
add_TimeInternal(time, time, &ppi->rt_opts->outbound_latency);
add_TimeInternal(time, time, &OPTS(ppi)->outbound_latency);
msg_issue_followup(ppi, time);
return 0;
}
......@@ -238,9 +238,9 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv)
int pp_open_instance(struct pp_instance *ppi, struct pp_runtime_opts *rt_opts)
{
if (rt_opts)
ppi->rt_opts = rt_opts;
OPTS(ppi) = rt_opts;
else
ppi->rt_opts = &default_rt_opts;
OPTS(ppi) = &default_rt_opts;
ppi->state = PPS_INITIALIZING;
......
......@@ -12,8 +12,6 @@
int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
struct pp_runtime_opts *rt_opts = ppi->rt_opts;
pp_net_shutdown(ppi);
if (pp_net_init(ppi) < 0)
......@@ -26,13 +24,13 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
DSDEF(ppi)->clockIdentity[3] = 0xff;
DSDEF(ppi)->clockIdentity[4] = 0xfe;
DSDEF(ppi)->numberPorts = 1;
pp_memcpy(&DSDEF(ppi)->clockQuality, &rt_opts->clock_quality,
pp_memcpy(&DSDEF(ppi)->clockQuality, &OPTS(ppi)->clock_quality,
sizeof(ClockQuality));
DSDEF(ppi)->priority1 = rt_opts->prio1;
DSDEF(ppi)->priority2 = rt_opts->prio2;
DSDEF(ppi)->domainNumber = rt_opts->domain_number;
DSDEF(ppi)->slaveOnly = rt_opts->slave_only;
if (rt_opts->slave_only)
DSDEF(ppi)->priority1 = OPTS(ppi)->prio1;
DSDEF(ppi)->priority2 = OPTS(ppi)->prio2;
DSDEF(ppi)->domainNumber = OPTS(ppi)->domain_number;
DSDEF(ppi)->slaveOnly = OPTS(ppi)->slave_only;
if (OPTS(ppi)->slave_only)
ppi->defaultDS->clockQuality.clockClass = 255;
/* Initialize port data set */
......@@ -42,10 +40,10 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
DSPOR(ppi)->logMinDelayReqInterval = PP_DEFAULT_DELAYREQ_INTERVAL;
DSPOR(ppi)->peerMeanPathDelay.seconds = 0;
DSPOR(ppi)->peerMeanPathDelay.nanoseconds = 0;
DSPOR(ppi)->logAnnounceInterval = rt_opts->announce_intvl;
DSPOR(ppi)->logAnnounceInterval = OPTS(ppi)->announce_intvl;
DSPOR(ppi)->announceReceiptTimeout =
PP_DEFAULT_ANNOUNCE_RECEIPT_TIMEOUT;
DSPOR(ppi)->logSyncInterval = rt_opts->sync_intvl;
DSPOR(ppi)->logSyncInterval = OPTS(ppi)->sync_intvl;
DSPOR(ppi)->delayMechanism = PP_DEFAULT_DELAY_MECHANISM;
DSPOR(ppi)->logMinPdelayReqInterval = PP_DEFAULT_PDELAYREQ_INTERVAL;
DSPOR(ppi)->versionNumber = PP_VERSION_PTP;
......
......@@ -45,7 +45,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
goto failure;
}
if (!ppi->rt_opts->e2e_mode) {
if (!OPTS(ppi)->e2e_mode) {
if (pp_timer_expired(ppi->timers[PP_TIMER_PDELAYREQ])) {
PP_VPRINTF("event PDELAYREQ_INTERVAL_TOUT_EXPIRES\n");
if (msg_issue_pdelay_req(ppi) < 0)
......@@ -77,13 +77,13 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
case PPM_PDELAY_RESP:
/* Loopback Timestamp */
if (ppi->rt_opts->e2e_mode)
if (OPTS(ppi)->e2e_mode)
break;
if (ppi->is_from_self) {
/*Add latency*/
add_TimeInternal(time, time,
&ppi->rt_opts->outbound_latency);
&OPTS(ppi)->outbound_latency);
e = msg_issue_pdelay_resp_follow_up(ppi, time);
break;
......
......@@ -34,7 +34,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
st_com_restart_annrec_timer(ppi);
if (ppi->rt_opts->e2e_mode)
if (OPTS(ppi)->e2e_mode)
pp_timer_start(1 << DSPOR(ppi)->logMinDelayReqInterval,
ppi->timers[PP_TIMER_DELAYREQ]);
else
......@@ -78,7 +78,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
/* Add latency */
add_TimeInternal(&ppi->delay_req_send_time,
&ppi->delay_req_send_time,
&ppi->rt_opts->outbound_latency);
&OPTS(ppi)->outbound_latency);
}
break;
......@@ -89,7 +89,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (e)
break;
if (!ppi->rt_opts->e2e_mode)
if (!OPTS(ppi)->e2e_mode)
break;
msg_unpack_delay_resp(pkt, &ppi->msg_tmp.resp);
......@@ -131,7 +131,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
case PPM_PDELAY_RESP:
if (ppi->rt_opts->e2e_mode)
if (OPTS(ppi)->e2e_mode)
break;
e = (plen < PP_PDELAY_RESP_LENGTH);
......@@ -141,7 +141,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->is_from_self) {
add_TimeInternal(time, time,
&ppi->rt_opts->outbound_latency);
&OPTS(ppi)->outbound_latency);
msg_issue_pdelay_resp_follow_up(ppi, time);
break;
}
......@@ -200,7 +200,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
case PPM_PDELAY_RESP_FOLLOW_UP:
if (ppi->rt_opts->e2e_mode)
if (OPTS(ppi)->e2e_mode)
break;
e = (plen < PP_PDELAY_RESP_FOLLOW_UP_LENGTH);
......@@ -254,7 +254,7 @@ state_updated:
if (ppi->next_state != ppi->state) {
pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]);
if (ppi->rt_opts->e2e_mode)
if (OPTS(ppi)->e2e_mode)
pp_timer_stop(ppi->timers[PP_TIMER_DELAYREQ]);
else
pp_timer_stop(ppi->timers[PP_TIMER_PDELAYREQ]);
......
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