ptpd: Code quality improvements
This commit is contained in:
parent
083eb5e993
commit
6dd9adbb5b
@ -140,6 +140,11 @@ int ptpd_start(FAR const char *interface);
|
|||||||
* On success, returns OK.
|
* On success, returns OK.
|
||||||
* On failure, a negated errno value is returned.
|
* On failure, a negated errno value is returned.
|
||||||
*
|
*
|
||||||
|
* Assumptions/Limitations:
|
||||||
|
* Multiple threads with priority less than CONFIG_NETUTILS_PTPD_SERVERPRIO
|
||||||
|
* can request status simultaneously. If higher priority threads request
|
||||||
|
* status simultaneously, some of the requests may timeout.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int ptpd_status(int pid, FAR struct ptpd_status_s *status);
|
int ptpd_status(int pid, FAR struct ptpd_status_s *status);
|
||||||
|
@ -381,7 +381,7 @@ static int ptp_getrxtime(FAR struct ptp_state_s *state,
|
|||||||
cmsg->cmsg_type == SO_TIMESTAMP &&
|
cmsg->cmsg_type == SO_TIMESTAMP &&
|
||||||
cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval)))
|
cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval)))
|
||||||
{
|
{
|
||||||
TIMEVAL_TO_TIMESPEC((struct timeval *)CMSG_DATA(cmsg), ts);
|
TIMEVAL_TO_TIMESPEC((FAR struct timeval *)CMSG_DATA(cmsg), ts);
|
||||||
|
|
||||||
/* Sanity-check the value */
|
/* Sanity-check the value */
|
||||||
|
|
||||||
@ -762,7 +762,7 @@ static int ptp_send_delay_req(FAR struct ptp_state_s *state)
|
|||||||
timespec_to_ptp_format(&state->delayreq_time, req.origintimestamp);
|
timespec_to_ptp_format(&state->delayreq_time, req.origintimestamp);
|
||||||
|
|
||||||
ret = sendto(state->tx_socket, &req, sizeof(req), 0,
|
ret = sendto(state->tx_socket, &req, sizeof(req), 0,
|
||||||
(struct sockaddr *)&addr, sizeof(addr));
|
(FAR struct sockaddr *)&addr, sizeof(addr));
|
||||||
|
|
||||||
/* Get timestamp after send completes.
|
/* Get timestamp after send completes.
|
||||||
* TODO: Implement SO_TIMESTAMPING and use the actual tx timestamp here.
|
* TODO: Implement SO_TIMESTAMPING and use the actual tx timestamp here.
|
||||||
@ -1132,7 +1132,7 @@ static int ptp_process_delay_req(FAR struct ptp_state_s *state,
|
|||||||
resp.header.logmessageinterval = CONFIG_NETUTILS_PTPD_DELAYRESP_INTERVAL;
|
resp.header.logmessageinterval = CONFIG_NETUTILS_PTPD_DELAYRESP_INTERVAL;
|
||||||
|
|
||||||
ret = sendto(state->tx_socket, &resp, sizeof(resp), 0,
|
ret = sendto(state->tx_socket, &resp, sizeof(resp), 0,
|
||||||
(struct sockaddr *)&addr, sizeof(addr));
|
(FAR struct sockaddr *)&addr, sizeof(addr));
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -1333,7 +1333,7 @@ static void ptp_process_statusreq(FAR struct ptp_state_s *state)
|
|||||||
{
|
{
|
||||||
/* Copy relevant parts of announce info to status struct */
|
/* Copy relevant parts of announce info to status struct */
|
||||||
|
|
||||||
struct ptp_announce_s *s = &state->selected_source;
|
FAR struct ptp_announce_s *s = &state->selected_source;
|
||||||
|
|
||||||
memcpy(status->clock_source_info.id,
|
memcpy(status->clock_source_info.id,
|
||||||
s->header.sourceidentity,
|
s->header.sourceidentity,
|
||||||
@ -1390,7 +1390,7 @@ static void ptp_process_statusreq(FAR struct ptp_state_s *state)
|
|||||||
|
|
||||||
static int ptp_daemon(int argc, FAR char** argv)
|
static int ptp_daemon(int argc, FAR char** argv)
|
||||||
{
|
{
|
||||||
const char *interface = "eth0";
|
FAR const char *interface = "eth0";
|
||||||
FAR struct ptp_state_s *state;
|
FAR struct ptp_state_s *state;
|
||||||
struct pollfd pollfds[2];
|
struct pollfd pollfds[2];
|
||||||
struct msghdr rxhdr;
|
struct msghdr rxhdr;
|
||||||
@ -1546,6 +1546,11 @@ int ptpd_start(FAR const char *interface)
|
|||||||
* On success, returns OK.
|
* On success, returns OK.
|
||||||
* On failure, a negated errno value is returned.
|
* On failure, a negated errno value is returned.
|
||||||
*
|
*
|
||||||
|
* Assumptions/Limitations:
|
||||||
|
* Multiple threads with priority less than CONFIG_NETUTILS_PTPD_SERVERPRIO
|
||||||
|
* can request status simultaneously. If higher priority threads request
|
||||||
|
* status simultaneously, some of the requests may timeout.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int ptpd_status(int pid, FAR struct ptpd_status_s *status)
|
int ptpd_status(int pid, FAR struct ptpd_status_s *status)
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int do_ptpd_start(const char *interface)
|
static int do_ptpd_start(FAR const char *interface)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user