Blame ddt.h

Packit 9c3e7e
/**
Packit 9c3e7e
 * @file ddt.h
Packit 9c3e7e
 * @brief Derived data types
Packit 9c3e7e
 * @note Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is free software; you can redistribute it and/or modify
Packit 9c3e7e
 * it under the terms of the GNU General Public License as published by
Packit 9c3e7e
 * the Free Software Foundation; either version 2 of the License, or
Packit 9c3e7e
 * (at your option) any later version.
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is distributed in the hope that it will be useful,
Packit 9c3e7e
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 9c3e7e
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 9c3e7e
 * GNU General Public License for more details.
Packit 9c3e7e
 *
Packit 9c3e7e
 * You should have received a copy of the GNU General Public License along
Packit 9c3e7e
 * with this program; if not, write to the Free Software Foundation, Inc.,
Packit 9c3e7e
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 9c3e7e
 */
Packit 9c3e7e
#ifndef HAVE_DDT_H
Packit 9c3e7e
#define HAVE_DDT_H
Packit 9c3e7e
Packit 9c3e7e
#include "pdt.h"
Packit 9c3e7e
Packit 9c3e7e
#define PACKED __attribute__((packed))
Packit 9c3e7e
Packit 9c3e7e
typedef Integer64 TimeInterval; /* nanoseconds << 16 */
Packit 9c3e7e
Packit 9c3e7e
/** On the wire time stamp format. */
Packit 9c3e7e
struct Timestamp {
Packit 9c3e7e
	uint16_t   seconds_msb; /* 16 bits + */
Packit 9c3e7e
	uint32_t   seconds_lsb; /* 32 bits = 48 bits*/
Packit 9c3e7e
	UInteger32 nanoseconds;
Packit 9c3e7e
} PACKED;
Packit 9c3e7e
Packit 9c3e7e
/** Internal binary time stamp format. */
Packit 9c3e7e
struct timestamp {
Packit 9c3e7e
	uint64_t   sec;
Packit 9c3e7e
	UInteger32 nsec;
Packit 9c3e7e
};
Packit 9c3e7e
Packit 9c3e7e
struct ClockIdentity {
Packit 9c3e7e
	Octet id[8];
Packit 9c3e7e
};
Packit 9c3e7e
Packit 9c3e7e
struct PortIdentity {
Packit 9c3e7e
	struct ClockIdentity clockIdentity;
Packit 9c3e7e
	UInteger16           portNumber;
Packit 9c3e7e
} PACKED;
Packit 9c3e7e
Packit 9c3e7e
struct PortAddress {
Packit 9c3e7e
	Enumeration16 networkProtocol;
Packit 9c3e7e
	UInteger16    addressLength;
Packit 9c3e7e
	Octet         address[0];
Packit 9c3e7e
} PACKED;
Packit 9c3e7e
Packit 9c3e7e
struct PhysicalAddress {
Packit 9c3e7e
	UInteger16 length;
Packit 9c3e7e
	Octet      address[0];
Packit 9c3e7e
} PACKED;
Packit 9c3e7e
Packit 9c3e7e
struct ClockQuality {
Packit 9c3e7e
	UInteger8     clockClass;
Packit 9c3e7e
	Enumeration8  clockAccuracy;
Packit 9c3e7e
	UInteger16    offsetScaledLogVariance;
Packit 9c3e7e
} PACKED;
Packit 9c3e7e
Packit 9c3e7e
struct TLV {
Packit 9c3e7e
	Enumeration16 type;
Packit 9c3e7e
	UInteger16    length; /* must be even */
Packit 9c3e7e
	Octet         value[0];
Packit 9c3e7e
} PACKED;
Packit 9c3e7e
Packit 9c3e7e
struct PTPText {
Packit 9c3e7e
	UInteger8 length;
Packit 9c3e7e
	Octet     text[0];
Packit 9c3e7e
} PACKED;
Packit 9c3e7e
Packit 9c3e7e
/* A static_ptp_text is like a PTPText but includes space to store the
Packit 9c3e7e
 * text inside the struct. The text array must always be
Packit 9c3e7e
 * null-terminated. Also tracks a maximum number of symbols. Note in
Packit 9c3e7e
 * UTF-8, # symbols != # bytes.
Packit 9c3e7e
 */
Packit 9c3e7e
#define MAX_PTP_OCTETS 255
Packit 9c3e7e
struct static_ptp_text {
Packit 9c3e7e
	/* null-terminated array of UTF-8 symbols */
Packit 9c3e7e
	Octet text[MAX_PTP_OCTETS + 1];
Packit 9c3e7e
	/* number of used bytes in text, not including trailing null */
Packit 9c3e7e
	int length;
Packit 9c3e7e
	/* max number of UTF-8 symbols that can be in text */
Packit 9c3e7e
	int max_symbols;
Packit 9c3e7e
};
Packit 9c3e7e
Packit 9c3e7e
struct FaultRecord {
Packit 9c3e7e
	UInteger16       faultRecordLength;
Packit 9c3e7e
	struct Timestamp faultTime;
Packit 9c3e7e
	Enumeration8     severityCode;
Packit 9c3e7e
	struct PTPText   faultName;
Packit 9c3e7e
	struct PTPText   faultValue;
Packit 9c3e7e
	struct PTPText   faultDescription;
Packit 9c3e7e
};
Packit 9c3e7e
Packit 9c3e7e
#endif