Tell how to get the sources in the readme file.

Also fix a poorly worded sentence in the system requirements.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Log the relative time rather than the process identification.

When diagnosing a log file, it can be useful to know the relative time
between the log entries. In contrast, the PID is mostly useless, since
the program does not ever fork.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Fix memory leak, reference counting, and list handling in message code.

The message code is horribly broken in three ways.

1. Clearing the message also sets the reference count to zero.
2. The recycling code in msg_put does not test the reference count.
3. The allocation code does not remove the message from the pool,
   although this code was never reached because of point 2.

This patch fixes the issues and also adds some debugging code to trace
the message pool statistics.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Recover from lost link when running in slave only mode.

Under Linux, when the link goes down our multicast socket becomes stale.
We always poll(2) for events, but the link down does not trigger any event
to let us know that something is wrong. Once the port enters master mode
and starts announcing itself, the socket throws an error. This in turn
causes a fault, and we reopen the socket when clearing the fault.

However, in the case of slave only mode, if the port is listening then
it will never send, discover the link error, or repair the socket. This
patch fixes the issue by simply reopening the socket after an announce
timeout.

[ Another way would be to use a netlink socket, but that would add too
  much complexity as it poorly matches our port/interface model. ]

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Remove unneeded newline from pr_info message.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Fix unsafe reference of foreign master announce message.

When computing a port's best foreign master, we make use of a message
reference that possibly might have been dropped by calling msg_put in
the fc_prune subroutine. This commit fixes the issue by copying the
needed data from the message before pruning.

[ Actually, since msg_put only places the message into a list without
  altering its contents, there was no ill effect. But using a message
  after having released it is just plain wrong. ]

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Update data sets after loss of foreign master.

If an announce timeout occurs on a port, and no other port is slaved, then
the clock must become a grand master by default.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Prevent message buffer corruption on receive.

An oversize incoming packet might overwrite the reference counter in a
message. Prevent this by providing a buffer large enough for the largest
possible packet.

This will also be needed to support TLV suffixes.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Correctly handle a negative log message interval.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Bring the driver support matrix up to date with Linux version 3.4.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Update the readme file for Linux kernel 3.5.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Define CC = $(CROSS_COMPILE)gcc in makefile and add EXTRA_CFLAGS, EXTRA_LDFLAGS

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
Fix typo in the readme's driver support matrix.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Add transmit support for the transportSpecific field

Add transportSpecific parameter to config file parser
Set transportSpecific field in message headers as using the configuration (default to 0)

[ RC - reduced this patch to just the addition of the field ]

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Drop incoming packets on transportSpecific mismatch.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Add the transport specific field into the config file.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Add a configuration option to specify the L2 MAC addresses.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Add a configuration option to support 802.1AS only hardware.

Some of the time stamping hardware out there only recognizes layer 2
packets, and these do not work without changing the receive filter in
the SIOCSHWTSTAMP request.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Replace hard coded logMinPdelayReqInterval with configuration option.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Add an option to assume two step messaging.

Some commercial 802.1AS switches do not feel obliged to set the two step
flag. When we try to synchronize to their apparent one step sync messages,
nothing good happens. This commit adds a global option to work around the
issue.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>