Valgrind is nagging us, saying we pass uninitialized data through a
setsockopt() call. This patch fixes the issue by clearing the entire
passed structure.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
On some platforms like br-arm-cortex-a9-musl struct ethhdr was defined twice
due to including of both linux/if_ether.h and netinet/ether.h. Which lead
to a compilation error.
Remove netinet/ether.h as the official header for struct ethhdr is
linux/if_ether.h
Signed-off-by: Petr Kulhavy <brain@jikos.cz>
The raw Ethernet transport code invented its own way of storing the MAC
address into our "struct address" data structure. However, this private
format is incompatible with the sockaddr_ll returned from the networking
stack. This patch converts the code to use the proper format.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This modifies all transports to use a new common address type, struct
address. This address is stored in a ptp_message for all received messages.
For sending, the "default" address is used with the default sending
functions, transport_send and transport_peer. The default address depends on
the transport; it's supposed to be the multicast address assigned by the
transport specification.
Later, a new transport_sendto function will be implemented that sends to the
address contained in the passed ptp_message.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
In order to be able to convert to a generic address struct, separate source
and destination address into separate fields.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
When less bytes than the header size is read, do not indicate to the caller
that the read was successful, as the caller would read uninitialized memory.
To achieve that, subtract the header size unconditionally (unless an error
was returned by sk_receive).
In addition, do not check for Ethernet type when full Ethernet header was
not read. This again may lead to reading of uninitialized memory.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Because of packet reordering that can occur in the network, in the
hardware, or in the networking stack, a follow up message can appear
to arrive in the application before the matching sync message. As this
is a normal occurrence, and the sequenceID message field ensures
proper matching, the ptp4l program accepts out of order packets.
This patch adds an additional check using the software time stamps
from the networking stack to verify that the sync message did arrive
first. This check is only useful if the sequence IDs generated by
the master might possibly be incorrect.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The power profile requires using VLAN priority tagged packets. The tags
may or may not reach the application. This commit adds code to handle the
tags in the case that they do appear.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The upper layer code will be confused by the extra fourteen byte length
of the Ethernet header.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
It was a cute idea to have the raw Ethernet layer use just one socket,
but it ended up not working on some specific PTP time stamping hardware.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>