Commit Graph

31 Commits (05bba46198cfc4ccfe0aff2e67e76d78898bbd96)

Author SHA1 Message Date
Florian Fainelli 8b61aa2c3f udp: Avoid including netdb.h
netdb.h pulls in a large chain of include files:
rpc/netdb.h
rpc/types.h

rpc/types.h re-defines TRUE/FALSE and does it in this way:

 #ifndef FALSE
 #      define  FALSE   (0)
 #endif

 #ifndef TRUE
 #      define  TRUE    (1)
 #endif

And this later causes build problems that appear in this way:

mipsel-linux-gnu-gcc -Wall -DVER=1.8  -D_GNU_SOURCE -DHAVE_CLOCK_ADJTIME
-DHAVE_POSIX_SPAWN -DHAVE_ONESTEP_SYNC  -Os -pipe -mno-branch-likely
-mips32r2 -mtune=24kc -fno-caller-saves -Wno-unused-result
-D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro
-I/home/florian/dev/openwrt/trunk/staging_dir/target-mipsel-unknown-linux-gnu_glibc/usr/include
-I/home/florian/dev/openwrt/trunk/staging_dir/target-mipsel-unknown-linux-gnu_glibc/include
-I/home/florian/dev/toolchains/stbgcc-4.8-1.5/usr/include
-I/home/florian/dev/toolchains/stbgcc-4.8-1.5/include
-DHAVE_CLOCK_ADJTIME -DHAVE_POSIX_SPAWN -DHAVE_ONESTEP_SYNC   -c -o
udp.o udp.c
In file included from
/home/florian/dev/openwrt/trunk/staging_dir/target-mipsel-unknown-linux-gnu_glibc/usr/include/rpc/netdb.h:45:0,
                 from
/home/florian/dev/toolchains/stbgcc-4.8-1.5/mipsel-linux-gnu/sys-root/usr/include/netdb.h:32,
                 from udp.c:23:
pdt.h:25:7: error: expected identifier before '(' token
 enum {FALSE, TRUE};
       ^
<builtin>: recipe for target 'udp.o' failed

Upon inspection, it does not appear that netdb.h is providing any useful
definition or declaration, so let's just remove its inclusion.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2017-05-07 23:22:50 +02:00
Jesuiter, Henry (ALC NetworX GmbH) 1e667ff7fb Introduce options to set DSCP values in PTP messages.
In the last years there are several media streaming standards
evolving that are relying on PTP. These standards make requirements
about the DSCP priority of PTP messages. This patch introduces two
new configuration options 'dscp_event' and 'dscp_general' to address
that issue and to be able to set the DSCP priority separately for
PTP event messages and PTP general messages.

Signed-off-by: Henry Jesuiter <henry.jesuiter@alcnetworx.de>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2016-07-12 15:11:56 +02:00
Richard Cochran d0eb73c87b Use the standardized low level socket address format.
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>
2015-08-29 11:32:41 +02:00
Richard Cochran 8d1b30d91c udp: set the destination port unconditionally.
Even if the caller provides the destination address, still the port must
depend on the passed 'event' value for correct delivery.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-29 11:32:29 +02:00
Richard Cochran d4995c6d71 udp: configure the socket with the TTL option.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-23 21:09:45 +02:00
Jiri Benc e804e6f9a0 Common type holding an address
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>
2014-04-25 14:28:14 +02:00
Stephan Gatzka 110849d422 Make functions and structs dealing with string literals const correct.
This allows the compiler to check if someone writes into string
literals.

Signed-off-by: Stephan Gatzka <stephan.gatzka@gmail.com>
2014-02-07 19:41:47 +01:00
Stephan Gatzka 886112e202 Make udp_physical_addr() and udp_protocol_addr() static.
They aren't used outside udp.c

Signed-off-by: Stephan Gatzka <stephan.gatzka@gmail.com>
2014-02-07 19:40:29 +01:00
Richard Cochran 7b7e046e91 Add an optional extra check on sync and follow up message ordering.
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>
2013-08-29 11:22:25 +02:00
Geoff Salmon c54f8a523b udp: implement getting physical and protocol addrs 2013-01-14 19:12:18 +01:00
Richard Cochran ae41fa0f68 udp: work around phyter quirk.
The phyter offers one step sync transmission, but it alters the UDP
checksum by changing the last two bytes, after the PTP payload. While this
is only standardized for IPv6, we will go with it for IPv4 as well, since
the phyter is the only hardware out there.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-30 11:34:29 +01:00
Richard Cochran 24385005b8 Enumerate the event codes for the transport layer transmission methods.
We add a new event code that indicates a one step event message.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-30 11:34:29 +01:00
Richard Cochran 87313fd05d Initialize the socket address structure to zero.
It is safer and more correct to clear the addresses before use. The IPv6
fields flowinfo and scope_id in particular should not be set to random
values from the stack.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-11-25 17:45:37 +01:00
Richard Cochran 8dde0d31b6 Pass transport type to time stamping initialization function.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Jiri Benc <jbenc@redhat.com>
2012-10-29 20:06:00 +01:00
Richard Cochran a0efbfd138 udp: Implement the peer transmission option.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-05 17:48:59 +02:00
Richard Cochran beb3d5d821 Expand the transport layer interface with a peer transmission method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-05 17:48:59 +02:00
Richard Cochran 0ca8143da5 Remove a useless variable from the file descriptor array data type.
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>
2012-03-21 13:55:56 +01:00
Richard Cochran 9d4d68e667 Add missing release method to the UDPv4 transport.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-17 17:30:21 +01:00
Richard Cochran 319aae1403 Move some sharable socket code into its own source file.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-17 17:30:21 +01:00
Richard Cochran 29463cd306 Make the transport layer more opaque.
Although the UDP/IPv4 layer does not need any state per instance (other
than the two file descriptors), the raw Ethernet layer will need this.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-13 08:28:37 +01:00
Richard Cochran a9e88a0a49 Fix segfault after missing transmit time stamp.
If the networking stack fails to provide a transmit time stamp, then we
might feed uninitialized stack data to the CMSG(3) macros. This can result
in a segfault or other badness.

The fix is to simply clear the control buffer in advance.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-11 09:45:23 +01:00
Richard Cochran 150da0cba9 Remove silly and incorrect error message.
Commit 32133050 introduced a bug that gives a bogus error message on
every 'general' (non-event) PTP packet. If we want to catch missing
time stamps, then it has to occur at the port level.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-04 11:33:22 +01:00
Richard Cochran 321330501f Be more verbose about errors on the receive path.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-04 08:23:40 +01:00
Richard Cochran 347b42b7d5 udp: Use the bind to device socket option.
Without this Linux specific option, multicast packets arrive on one
interface are delivered by the kernel to all others.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:54 +01:00
Richard Cochran 95d5c36c0f udp: turn off multicast loop back.
This option is on by default, but we don't want or need it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:54 +01:00
Richard Cochran 5555a2f029 udp: Use the IP_ADD_MEMBERSHIP socket option.
For some reason, MCAST_JOIN_GROUP is not working under uClinux. We can
just stick with the more traditional method.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-01-07 08:07:53 +01:00
Richard Cochran 447d4d442c udp: bring a warning or error if the driver changes our hwtstamp options.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-12-18 09:35:41 +01:00
Richard Cochran b0d547cac4 udp: use the message logging facility instead of stdio.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-12-18 08:21:47 +01:00
Richard Cochran cecc20a307 udp: wait longer for transmit time stamps
Some hardware is a bit pokey. We now wait forever on EINTR and just a
little bit on EAGAIN.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-12-13 05:28:54 +01:00
Richard Cochran 5f7facdc63 Bind transmitted packets to the port's network interface.
Even though the MCAST_JOIN_GROUP socket option includes the interface
index, this applies to the received packets only. To bind the outgoing
packets to a particular interface, the IP_MULTICAST_IF option is needed.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-11-20 18:31:33 +01:00
Richard Cochran 60f3a85463 Add transport over UDP IPv4.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-11-06 08:16:19 +01:00