summaryrefslogtreecommitdiff
path: root/daemons/gptp/common/avbts_message.hpp
blob: f5ccd9a183219d050082e002a4fa143cfd0ebd98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
/******************************************************************************

  Copyright (c) 2009-2012, Intel Corporation
  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are met:

   1. Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.

   2. Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.

   3. Neither the name of the Intel Corporation nor the names of its
      contributors may be used to endorse or promote products derived from
      this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE.

******************************************************************************/

#ifndef AVBTS_MESSAGE_HPP
#define AVBTS_MESSAGE_HPP

#include <stdint.h>
#include <avbts_osnet.hpp>
#include <ieee1588.hpp>

#include <list>
#include <algorithm>

/** @file **/

#define PTP_CODE_STRING_LENGTH 4		/*!< PTP code string length in bytes */
#define PTP_SUBDOMAIN_NAME_LENGTH 16	/*!< PTP subdomain name lenght in bytes */
#define PTP_FLAGS_LENGTH 2				/*!< PTP flags length in bytes */

#define GPTP_VERSION 2			/*!< GPTP version */
#define PTP_NETWORK_VERSION 1	/*!< PTP Network version */

#define PTP_ETHER 1		/*!< @todo Not used */
#define PTP_DEFAULT 255	/*!< @todo Not used */

#define PTP_COMMON_HDR_OFFSET 0		/*!< PTP common header offset */
#define PTP_COMMON_HDR_LENGTH 34	/*!< PTP common header length in bytes */
#define PTP_COMMON_HDR_TRANSSPEC_MSGTYPE(x) x	/*!< Gets the message type offset on PTP header */
#define PTP_COMMON_HDR_PTP_VERSION(x) x+1		/*!< Gets the ptp version offset on PTP header */
#define PTP_COMMON_HDR_MSG_LENGTH(x) x+2		/*!< Gets the message length offset on PTP header */
#define PTP_COMMON_HDR_DOMAIN_NUMBER(x) x+4		/*!< Gets the domain number offset on PTP header */
#define PTP_COMMON_HDR_FLAGS(x) x+6				/*!< Gets the flags offset on PTP header */
#define PTP_COMMON_HDR_CORRECTION(x) x+8		/*!< Gets the correction field offset on PTP header */
#define PTP_COMMON_HDR_SOURCE_CLOCK_ID(x) x+20	/*!< Gets the source clock id offset on PTP header */
#define PTP_COMMON_HDR_SOURCE_PORT_ID(x) x+28	/*!< Gets the source port id offset on PTP header */
#define PTP_COMMON_HDR_SEQUENCE_ID(x) x+30		/*!< Gets the sequence id offset on PTP header */
#define PTP_COMMON_HDR_CONTROL(x) x+32			/*!< Gets the control offset on PTP header */
#define PTP_COMMON_HDR_LOG_MSG_INTRVL(x) x+33	/*!< Gets the log message interval offset on PTP header */

#define PTP_ANNOUNCE_OFFSET 34							/*!< PTP announce offset */
#define PTP_ANNOUNCE_LENGTH 30							/*!< PTP announce length in bytes */
#define PTP_ANNOUNCE_CURRENT_UTC_OFFSET(x) x+10			/*!< Gets PTP announce current UTC offset */
#define PTP_ANNOUNCE_GRANDMASTER_PRIORITY1(x) x+13		/*!< Gets Grandmaster priority1 offset on announce fields */
#define PTP_ANNOUNCE_GRANDMASTER_CLOCK_QUALITY(x) x+14	/*!< Gets Grandmaster clock quality offset on announce fields */
#define PTP_ANNOUNCE_GRANDMASTER_PRIORITY2(x) x+18		/*!< Gets Grandmasdter priority2 offset on announce fields*/
#define PTP_ANNOUNCE_GRANDMASTER_IDENTITY(x) x+19		/*!< Gets Grandmaster identity offset on announce fields*/
#define PTP_ANNOUNCE_STEPS_REMOVED(x) x+27				/*!< Gets steps removed offset on announce fields*/
#define PTP_ANNOUNCE_TIME_SOURCE(x) x+29				/*!< Gets time source offset on announce fields*/

#define PTP_SYNC_OFFSET 34		/*!< PTP SYNC base offset */
#define PTP_SYNC_LENGTH 10		/*!< PTP SYNC length in bytes */
#define PTP_SYNC_SEC_MS(x) x	/*!< PTP SYNC seconds MSB offset */
#define PTP_SYNC_SEC_LS(x) x+2	/*!< PTP SYNC seconds LSB offset */
#define PTP_SYNC_NSEC(x) x+6	/*!< PTP SYNC nanoseconds offset */

#define PTP_FOLLOWUP_OFFSET 34		/*!< PTP FOLLOWUP base offset */
#define PTP_FOLLOWUP_LENGTH 10		/*!< PTP FOLLOWUP length in bytes */
#define PTP_FOLLOWUP_SEC_MS(x) x	/*!< Gets the followup seconds MSB offset */
#define PTP_FOLLOWUP_SEC_LS(x) x+2	/*!< Gets the followup seconds LSB offset */
#define PTP_FOLLOWUP_NSEC(x) x+6	/*!< Gets tne followup nanoseconds offset */

#define PTP_PDELAY_REQ_OFFSET 34		/*!< PTP PDELAY REQUEST base offset */
#define PTP_PDELAY_REQ_LENGTH 20		/*!< PTP PDELAY REQUEST length in bytes */
#define PTP_PDELAY_REQ_SEC_MS(x) x		/*!< Gets the pdelay request seconds MSB offset */
#define PTP_PDELAY_REQ_SEC_LS(x) x+2	/*!< Gets the pdelay request seconds LSB offset */
#define PTP_PDELAY_REQ_NSEC(x) x+6		/*!< Gets the pdelay request nanoseconds offset */

#define PTP_PDELAY_RESP_OFFSET 34				/*!< PDELAY RESPONSE base offset */
#define PTP_PDELAY_RESP_LENGTH 20				/*!< PDELAY RESPONSE length in bytes */
#define PTP_PDELAY_RESP_SEC_MS(x) x				/*!< Gets the pdelay response seconds MSB offset */
#define PTP_PDELAY_RESP_SEC_LS(x) x+2			/*!< Gets the pdelay response seconds LSB offset */
#define PTP_PDELAY_RESP_NSEC(x) x+6				/*!< Gets the pdelay nanoseconds offset */
#define PTP_PDELAY_RESP_REQ_CLOCK_ID(x) x+10	/*!< Gets the pdelay response request clock id offset */
#define PTP_PDELAY_RESP_REQ_PORT_ID(x) x+18		/*!< Gets the pdelay response request port id offset */

#define PTP_PDELAY_FOLLOWUP_OFFSET 34				/*!< PTP PDELAY FOLLOWUP base offset*/
#define PTP_PDELAY_FOLLOWUP_LENGTH 20				/*!< PTP PDELAY FOLLOWUP length in bytes */
#define PTP_PDELAY_FOLLOWUP_SEC_MS(x) x				/*!< Gets the pdelay followup seconds MSB offset*/
#define PTP_PDELAY_FOLLOWUP_SEC_LS(x) x+2			/*!< Gets the pdelay followup seconds LSB offset*/
#define PTP_PDELAY_FOLLOWUP_NSEC(x) x+6				/*!< Gets the pdelay followup nanoseconds offset*/
#define PTP_PDELAY_FOLLOWUP_REQ_CLOCK_ID(x) x+10	/*!< Gets the pdelay followup request clock id offset*/
#define PTP_PDELAY_FOLLOWUP_REQ_PORT_ID(x) x+18		/*!< Gets the pdelay followup request port id offset*/

#define PTP_SIGNALLING_OFFSET 34                        /*!< PTP signalling offset */
#define PTP_SIGNALLING_LENGTH 10                        /*!< PTP signalling length in bytes */
#define PTP_SIGNALLING_TARGET_PORT_IDENTITY(x) x        /*!< PTP signalling Tareget Port Identity */

#define PTP_LI_61_BYTE 1		/*!< PTP_LI_61(leap61) byte offset on flags field */
#define PTP_LI_61_BIT 0			/*!< PTP_LI_61(leap61) bit offset on PTP_LI_61 byte*/
#define PTP_LI_59_BYTE 1		/*!< PTP_LI_59(leap59) byte offset on flags field*/
#define PTP_LI_59_BIT 1			/*!< PTP_LI_59(leap59) bit offset on PTP_LI_59 byte*/
#define PTP_ASSIST_BYTE 0		/*!< PTP_ASSIST(two step flag) byte offset on flags field*/
#define PTP_ASSIST_BIT 1		/*!< PTP_ASSIST(two step flag) bit on PTP_ASSIST byte*/
#define PTP_PTPTIMESCALE_BYTE 1	/*!< PTPTIMESCALE byte offset on flags field*/
#define PTP_PTPTIMESCALE_BIT 3	/*!< PTPTIMESCAPE bit offset on PTPTIMESCALE byte*/

#define TX_TIMEOUT_BASE 1000 	/*!< Timeout base in microseconds */
#define TX_TIMEOUT_ITER 6		/*!< Number of timeout iteractions for sending/receiving messages*/

/**
 * @brief Enumeration message type. IEEE 1588-2008 Clause 13.3.2.2
 */
enum MessageType {
	SYNC_MESSAGE = 0,
	DELAY_REQ_MESSAGE = 1,
	PATH_DELAY_REQ_MESSAGE = 2,
	PATH_DELAY_RESP_MESSAGE = 3,
	FOLLOWUP_MESSAGE = 8,
	DELAY_RESP_MESSAGE = 9,
	PATH_DELAY_FOLLOWUP_MESSAGE = 0xA,
	ANNOUNCE_MESSAGE = 0xB,
	SIGNALLING_MESSAGE = 0xC,
	MANAGEMENT_MESSAGE = 0xD,
};

/**
 * @brief Enumeration legacy message type
 */
enum LegacyMessageType {
	SYNC,
	DELAY_REQ,
	FOLLOWUP,
	DELAY_RESP,
	MANAGEMENT,
	MESSAGE_OTHER
};

/**
 * @brief Enumeration multicast type.
 */
enum MulticastType {
	MCAST_NONE,
	MCAST_PDELAY,
	MCAST_TEST_STATUS,
	MCAST_OTHER
};

class PTPMessageId {
	MessageType _messageType;
	uint16_t _sequenceId;
public:
	PTPMessageId() { };
	PTPMessageId(MessageType messageType, uint16_t sequenceId) :
		_messageType(messageType),_sequenceId(sequenceId) { }
	PTPMessageId(const PTPMessageId& a) {
		_messageType = a._messageType;
		_sequenceId = a._sequenceId;
	}

	MessageType getMessageType(void) {
		return _messageType;
	}
	void setMessageType(MessageType messageType) {
		_messageType = messageType;
	}

	uint16_t getSequenceId(void) {
		return _sequenceId;
	}
	void setSequenceId(uint16_t sequenceId) {
		_sequenceId = sequenceId;
	}

	bool operator!=(const PTPMessageId & cmp) const {
		return
			this->_sequenceId != cmp._sequenceId ||
			this->_messageType != cmp._messageType ? true : false;
	}
	bool operator==(const PTPMessageId & cmp)const {
		return
			this->_sequenceId == cmp._sequenceId &&
			this->_messageType == cmp._messageType ? true : false;
	}
};

/**
 * @brief  Builds PTP message from buffer
 * @param  buf [in] byte buffer containing PTP message
 * @param  size [in] length of buffer in bytes
 * @param  remote [in] address from where message was received
 * @param  port [in] port object that message was recieved on
 * @return PTP message object
 */
PTPMessageCommon *buildPTPMessage
( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );

/**
 * @brief Provides the PTPMessage common interface used during building of
 * PTP messages.
 */
class PTPMessageCommon {
protected:
	unsigned char versionPTP;	/*!< PTP version */
	uint16_t versionNetwork;	/*!< Network version */
	MessageType messageType;	/*!< MessageType to be built */

	PortIdentity *sourcePortIdentity;	/*!< PortIdentity from source*/

	uint16_t sequenceId;		/*!< PTP message sequence ID*/
	LegacyMessageType control;	/*!< Control message type of LegacyMessageType */
	unsigned char flags[2];		/*!< PTP flags field */

	uint16_t messageLength;			/*!< PTP message length */
	char logMeanMessageInterval;	/*!< LogMessageInterval (IEEE 1588-2008 table 24)*/
	long long correctionField;		/*!< Correction Field (IEEE 1588-2008 table 21) */
	unsigned char domainNumber;		/*!< PTP domain number */

	Timestamp _timestamp;	/*!< PTP message timestamp */
	unsigned _timestamp_counter_value;	/*!< PTP timestamp counter value */
	bool _gc;	/*!< Garbage collection flag */

	/**
	 * @brief Default constructor
	 */
	PTPMessageCommon(void) { };
 public:
	/**
	 * @brief Creates the PTPMessageCommon interface
	 * @param port EtherPort where the message interface is
	 * connected to.
	 */
	PTPMessageCommon( CommonPort *port );
	/**
	 * @brief Destroys PTPMessageCommon interface
	 */
	virtual ~PTPMessageCommon(void);

	/**
	 * @brief  Gets a pointer to the flags field within the PTP message.
	 * @return Pointer to the flags field
	 */
	unsigned char *getFlags(void) {
		return flags;
	}

	/**
	 * @brief  Gets the sequenceId value within a ptp message
	 * @return Sequence ID value
	 */
	uint16_t getSequenceId(void) {
		return sequenceId;
	}
	/**
	 * @brief  Sets the sequence ID value to the PTP message.
	 * @param  seq Sequence id value to be set.
	 * @return void
	 */
	void setSequenceId(uint16_t seq) {
		sequenceId = seq;
	}

	/**
	 * @brief  Gets the MessageType field within the PTP message.
	 * @return MessageType
	 */
	MessageType getMessageType(void) {
		return messageType;
	}

	/**
	 * @brief Check if message type is event
	 * @return true if an event message
	 */
	bool isEvent( void )
	{
		return (( messageType >> 3) & 0x1 ) == 0;
	}

	/**
	 * @brief Get TX timestamp
	 * @param port used to send message
	 * @param link_speed link speed of message
	 */
	bool getTxTimestamp( EtherPort *port, uint32_t link_speed );

	/**
	 * @brief  Gets the MessageID of the PTP message.
	 * @return MessageId
	 */
	PTPMessageId getMessageId(void) {
		return PTPMessageId(messageType, sequenceId);
	}
	/**
	 * @brief  Gets the correctionField value in a Little-Endian format.
	 * @return correctionField
	 * @todo Little endian format could be removed by adding endianess discovery on
	 * compile/run time.
	 */
	long long getCorrectionField(void) {
		return correctionField;
	}
	/**
	 * @brief  Sets the correction field. It expects the host format.
	 * @param  correctionAmount
	 * @return void
	 * @todo Little endian format could be removed by adding endianess discovery on
	 * compile/run time.
	 */
	void setCorrectionField(long long correctionAmount) {
		correctionField = correctionAmount;
	}

	/**
	 * @brief  Gets PortIdentity field
	 * @param  identity [out] Source port identity
	 * @return void
	 */
	void getPortIdentity(PortIdentity * identity);
	/**
	 * @brief  Sets PortIdentity value
	 * @param  identity [in] Source port identity value to be set.
	 * @return void
	 */
	void setPortIdentity(PortIdentity * identity);

	/**
	 * @brief  Gets the current Timestamp value from the PTP message
	 * @return Current Timestamp value
	 */
	Timestamp getTimestamp(void) {
		return _timestamp;
	}
	/**
	 * @brief  Gets the timestamp counter value set during the RX timestamp method.
	 * @return timestamp counter value
	 */
	uint32_t getTimestampCounterValue(void) {
		return _timestamp_counter_value;;
	}
	/**
	 * @brief  Sets the timestamp value
	 * @param  timestamp [in] Reference to Timestamp value
	 * @return void
	 */
	void setTimestamp(Timestamp & timestamp) {
		_timestamp = timestamp;
	}

	/**
	 * @brief Gets the garbage collection status
	 * @return TRUE when it needs to be clean. FALSE otherwise.
	 */
	bool garbage() {
		return _gc;
	}

	/**
	 * @brief  Determine whether the message was sent by given communication technology, uuid, and
	 * port id fields
	 * @param  portIdentity PortIdentity value
	 * @return TRUE if sender equals to internal PTPCommon values, FALSE otherwise.
	 */
	bool isSenderEqual(PortIdentity portIdentity);

	/**
	 * @brief  Generic interface for processing PTP message
	 * @param  port CommonPort object
	 * @return void
	 */
	virtual void processMessage( CommonPort *port );

	/**
	 * @brief  Builds PTP common header
	 * @param  buf [out] PTP message
	 * @return void
	 */
	void buildCommonHeader(uint8_t * buf);

	friend PTPMessageCommon *buildPTPMessage
	( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );
};

/*Exact fit. No padding*/
#pragma pack(push,1)

#define PATH_TRACE_TLV_TYPE 0x8		/*!< This is the value that indicates the
									  TLV is a path trace TLV, as specified in
									  16.2.7.1 and Table 34 of IEEE Std
									  1588-2008. The value is specified there
									  as PATH_TRACE, whose value is 0x8. */

/**
 * @brief Provides the PathTraceTLV interface
 * The fields of the path TLV shall be as specified in Table 10-8 and in
 * 10.5.4.3.2 through 10.5.4.3.9 from IEEE 802.1AS. This TLV,
 * and its use, are defined in IEEE Std 1588-2008 (see 16.2 and Table 34 of IEEE Std 1588-2008).
 */
class PathTraceTLV {
 private:
	uint16_t tlvType;
	typedef std::list<ClockIdentity> IdentityList;
	IdentityList identityList;
 public:
	/**
	 * @brief Creates the PathTraceTLV interface.
	 * Sets tlvType to PATH_TRACE_TLV_TYPE using network byte order
	 */
	PathTraceTLV() {
		tlvType = PLAT_htons(PATH_TRACE_TLV_TYPE);
	}
	/**
	 * @brief  Parses ClockIdentity from message buffer
	 * @param  buffer [in] Message buffer. It should be at least ::PTP_CLOCK_IDENTITY_LENGTH bytes long.
	 * @param  size [in] Buffer size. Should be the length of the data pointed to by the buffer argument.
	 * @return void
	 */
	void parseClockIdentity(uint8_t *buffer, int size) {
		int length = PLAT_ntohs(*(uint16_t*)buffer);

		buffer += sizeof(uint16_t);
		size -= sizeof(uint16_t);

		if((unsigned)size < (unsigned)length) {
			length = size;
		}
		length /= PTP_CLOCK_IDENTITY_LENGTH;

		for(; length > 0; --length) {
			ClockIdentity add;
			add.set(buffer);
			identityList.push_back(add);
			buffer += PTP_CLOCK_IDENTITY_LENGTH;
		}
	}

	/**
	 * @brief  Appends new ClockIdentity to internal ClockIdentity list
	 * @param  id ClockIdentity to be appended
	 * @return void
	 */
	void appendClockIdentity(ClockIdentity * id) {
		identityList.push_back(*id);
	}

	/**
	 * @brief  Gets TLV value in a byte string format
	 * @param  byte_str [out] Output byte string
	 * @return void
	 */
	void toByteString(uint8_t * byte_str) {
		IdentityList::iterator iter;
		*((uint16_t *)byte_str) = tlvType;  // tlvType already in network byte order
		byte_str += sizeof(tlvType);
		*((uint16_t *)byte_str) = PLAT_htons
			((uint16_t)identityList.size()*PTP_CLOCK_IDENTITY_LENGTH);
		byte_str += sizeof(uint16_t);
		for
			(iter = identityList.begin();
			 iter != identityList.end(); ++iter) {
			iter->getIdentityString(byte_str);
			byte_str += PTP_CLOCK_IDENTITY_LENGTH;
		}
	}

	/**
	 * @brief  Looks for a specific ClockIdentity on the current TLV
	 * @param  id [in] Desired ClockIdentity
	 * @return TRUE if it has found it, FALSE otherwise.
	 */
	bool has(ClockIdentity *id) {
		return std::find
			(identityList.begin(), identityList.end(), *id) !=
			identityList.end();
	}

	/**
	 * @brief  Gets the total length of TLV.
	 * Total length of TLV is length of type field (UINT16) + length of 'length'
	 * field (UINT16) + length of
	 * identities (each PTP_CLOCK_IDENTITY_LENGTH) in the path
	 * @return Total length
	 */
	int length() {
		return (int)(2*sizeof(uint16_t) + PTP_CLOCK_IDENTITY_LENGTH*identityList.size());
	}
};

/* back to whatever the previous packing mode was */
#pragma pack(pop)

/**
 * @brief Provides the PTPMessageAnnounce interface
 * The PTPMessageAnnounce class is used to create
 * announce messages on the 802.1AS format when building
 * the ptp messages.
 */
class PTPMessageAnnounce:public PTPMessageCommon {
 private:
	uint8_t grandmasterIdentity[PTP_CLOCK_IDENTITY_LENGTH];
	ClockQuality *grandmasterClockQuality;

	PathTraceTLV tlv;

	uint16_t currentUtcOffset;
	unsigned char grandmasterPriority1;
	unsigned char grandmasterPriority2;
	ClockQuality *clockQuality;
	uint16_t stepsRemoved;
	unsigned char timeSource;

	 PTPMessageAnnounce(void);
 public:
	 /**
	  * @brief Creates the PTPMessageAnnounce interface
	  */
	 PTPMessageAnnounce( CommonPort * port );

	 /**
	  * @brief Destroys the PTPMessageAnnounce interface
	  */
	~PTPMessageAnnounce();

	/**
	 * @brief  Compare gramdmaster's capabilities comming on the
	 * announce messages against the current grandmaster capabilities.
	 * @param  msg [in] PTPMessageAnnounce to be compared
	 * @return TRUE if it is better. FALSE otherwise.
	 */
	bool isBetterThan(PTPMessageAnnounce * msg);

	/**
	 * @brief  Gets grandmaster's priority1 value
	 * @return Grandmaster priority1
	 */
	unsigned char getGrandmasterPriority1(void) {
		return grandmasterPriority1;
	}

	/**
	 * @brief  Gets grandmaster's priority2 value
	 * @return Grandmaster priority2
	 */
	unsigned char getGrandmasterPriority2(void) {
		return grandmasterPriority2;
	}

	/**
	 * @brief  Gets grandmaster clock quality
	 * @return Pointer to a ClockQuality object.
	 */
	ClockQuality *getGrandmasterClockQuality(void) {
		return grandmasterClockQuality;
	}

	/**
	 * @brief  Gets the steps removed value. See IEEE 802.1AS-2011 Clause 10.3.3
	 * @return steps removed value
	 */
	uint16_t getStepsRemoved(void) {
		return stepsRemoved;
	}

	/**
	 * @brief Gets grandmaster identity value
	 * @param  identity [out] Grandmaster identity
	 * @return void
	 */
	void getGrandmasterIdentity(char *identity) {
		memcpy(identity, grandmasterIdentity, PTP_CLOCK_IDENTITY_LENGTH);
	}

	/**
	 * @brief  Gets grandmaster's clockIdentity value
	 * @return Grandmaster ClockIdentity
	 */
	ClockIdentity getGrandmasterClockIdentity() {
		ClockIdentity ret;
		ret.set( grandmasterIdentity );
		return ret;
	}

	void processMessage( CommonPort *port );

	/**
	 * @brief  Assembles PTPMessageAnnounce message on the
	 * EtherPort payload
	 * @param  port EtherPort where the message will be
	 * assembled
	 * @param  destIdentity [in] Destination PortIdentity
	 * @return true on success
	 */
	bool sendPort
	( CommonPort *port, PortIdentity *destIdentity);

	friend PTPMessageCommon *buildPTPMessage
	( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );
};

/**
 * @brief Provides a class for building the PTP Sync message
 */
class PTPMessageSync : public PTPMessageCommon {
 private:
	Timestamp originTimestamp;

	PTPMessageSync();
 public:
	/**
	 * @brief Default constructor. Creates PTPMessageSync
	 * @param port EtherPort
	 */
	PTPMessageSync( EtherPort *port );

	/**
	 * @brief Destroys PTPMessageSync interface
	 */
	~PTPMessageSync();

	void processMessage( CommonPort *port );

	/**
	 * @brief  Gets origin timestamp value
	 * @return Origin Timestamp
	 */
	Timestamp getOriginTimestamp(void) {
		return originTimestamp;
	}

	/**
	 * @brief  Assembles PTPMessageSync message on the
	 * EtherPort payload
	 * @param  port EtherPort where the message will be
	 * assembled
	 * @param  destIdentity [in] Destination PortIdentity
	 * @return true on success
	 */
	bool sendPort
	(EtherPort *port, PortIdentity *destIdentity );

	friend PTPMessageCommon *buildPTPMessage
	( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );
};

/* Exact fit. No padding*/
#pragma pack(push,1)

/**
 * @brief Provides a scaledNs interface
 * The scaledNs type represents signed values of time and time interval in units of 2e-16 ns.
 */
class scaledNs {
 private:
	int32_t ms;
	uint64_t ls;
 public:
	/**
	 * @brief Builds scaledNs interface
	 */
	scaledNs() {
		ms = 0;
		ls = 0;
	}

	/**
	 * @brief  Gets scaledNs in a byte string format
	 * @param  byte_str [out] scaledNs value
	 * @return void
	 */
	void toByteString(uint8_t * byte_str) {
		memcpy(byte_str, this, sizeof(*this));
	}

	/**
	 * @brief  Overloads the operator = for this class
	 * @param  other Value to be attributed to this object's instance.
	 * @return Reference to scaledNs object
	 */
	scaledNs& operator=(const scaledNs& other)
	{
		this->ms = other.ms;
		this->ls = other.ls;

		return *this;
	}

	/**
	 * @brief  Set the lowest 64bits from the scaledNs object
	 * @param  lsb Value to be set
	 * @return void
	 */
	void setLSB(uint64_t lsb)
	{
		this->ls = lsb;
	}

	/**
	 * @brief  Set the highest 32bits of the scaledNs object
	 * @param  msb 32-bit signed integer to be set
	 * @return void
	 */
	void setMSB(int32_t msb)
	{
		this->ms = msb;
	}
};

/**
 * @brief Provides a follow-up TLV interface back to the previous packing mode
 */
class FollowUpTLV {
 private:
	uint16_t tlvType;
	uint16_t lengthField;
	uint8_t organizationId[3];
	uint8_t organizationSubType_ms;
	uint16_t organizationSubType_ls;
	int32_t cumulativeScaledRateOffset;
	uint16_t gmTimeBaseIndicator;
	scaledNs scaledLastGmPhaseChange;
	int32_t scaledLastGmFreqChange;
 public:
	/**
	 * @brief Builds the FollowUpTLV interface
	 */
	FollowUpTLV() {
		tlvType = PLAT_htons(0x3);
		lengthField = PLAT_htons(28);
		organizationId[0] = '\x00';
		organizationId[1] = '\x80';
		organizationId[2] = '\xC2';
		organizationSubType_ms = 0;
		organizationSubType_ls = PLAT_htons(1);
		cumulativeScaledRateOffset = PLAT_htonl(0);
		gmTimeBaseIndicator = 0;
		scaledLastGmFreqChange = PLAT_htonl(0);
	}

	/**
	 * @brief  Gets FollowUpTLV information in a byte string format
	 * @param  byte_str [out] FollowUpTLV values
	 */
	void toByteString(uint8_t * byte_str) {
		memcpy(byte_str, this, sizeof(*this));
	}

	/**
	 * @brief  Gets the cummulative scaledRateOffset
	 * @return 32 bit signed value with the rate offset information.
	 */
	int32_t getRateOffset() {
		return cumulativeScaledRateOffset;
	}

	/**
	 * @brief Gets the gmTimeBaseIndicator
	 * @return 16 bit unsigned value of the gmTimeBaseIndicator
	 *         information
	 */
	uint16_t getGmTimeBaseIndicator() {
		return gmTimeBaseIndicator;
	}

	/**
	 * @brief  Updates the scaledLastGmFreqChanged private member
	 * @param  val Value to be set
	 * @return void
	 */
	void setScaledLastGmFreqChange(int32_t val)
	{
		scaledLastGmFreqChange = PLAT_htonl(val);
	}

	/**
	 * @brief  Gets the current scaledLastGmFreqChanged value
	 * @return scaledLastGmFreqChange
	 */
	int32_t getScaledLastGmFreqChange(void)
	{
		return scaledLastGmFreqChange;
	}

	/**
	 * @brief  Sets the gmTimeBaseIndicator private member
	 * @param  tbi Value to be set
	 * @return void
	 */
	void setGMTimeBaseIndicator(uint16_t tbi)
	{
		gmTimeBaseIndicator = tbi;
	}

	/**
	 * @brief  Incremets the Time Base Indicator member
	 * @return void
	 */
	void incrementGMTimeBaseIndicator(void)
	{
		++gmTimeBaseIndicator;
	}

	/**
	 * @brief  Gets the current gmTimeBaseIndicator value
	 * @return gmTimeBaseIndicator
	 */
	uint16_t getGMTimeBaseIndicator(void)
	{
		return gmTimeBaseIndicator;
	}

	/**
	 * @brief  Sets the scaledLastGmPhaseChange private member
	 * @param  pc Value to be set
	 * @return void
	 */
	void setScaledLastGmPhaseChange(scaledNs pc)
	{
		scaledLastGmPhaseChange = pc;
	}

	/**
	 * @brief  Gets the scaledLastGmPhaseChange private member value
	 * @return scaledLastGmPhaseChange value
	 */
	scaledNs getScaledLastGmPhaseChange(void)
	{
		return scaledLastGmPhaseChange;
	}
};

/* back to whatever the previous packing mode was */
#pragma pack(pop)

/**
 * @brief Provides a class for a class for building a PTP follow up message
 */
class PTPMessageFollowUp:public PTPMessageCommon {
private:
	Timestamp preciseOriginTimestamp;

	FollowUpTLV tlv;

	PTPMessageFollowUp(void) { }
public:
	/**
	 * @brief Builds the PTPMessageFollowUP object
	 */
	PTPMessageFollowUp( CommonPort *port );

	/**
	 * @brief write followup message into buffer
	 * @param port [in] associated CommonPort object
	 * @param buf_ptr [out] buffer to write data to
	 * @return number of bytes written to buffer
	 */
	size_t buildMessage(CommonPort *port, uint8_t *buf_ptr);

	/**
	 * @brief  Assembles PTPMessageFollowUp message on the
	 * EtherPort payload
	 * @param  port EtherPort where the message will be
	 * assembled
	 * @param  destIdentity [in] Destination PortIdentity
	 * @return true on success
	 */
	bool sendPort
	( EtherPort *port, PortIdentity *destIdentity );

	void processMessage( CommonPort *port );

	/**
	* @brief Processes PTP messages
	* @param port [in] CommonPort
	* @param receipt [in] local time message was received
	* @param delay
	* @return void
	*/
	void processMessage( CommonPort *port, Timestamp receipt );

	/**
	 * @brief  Gets the precise origin timestamp value
	 * @return preciseOriginTimestamp value
	 */
	Timestamp getPreciseOriginTimestamp(void) {
		return preciseOriginTimestamp;
	}

	/**
	 * @brief  Sets the precis origin timestamp value
	 * @param  timestamp Timestamp to be set
	 * @return void
	 */
	void setPreciseOriginTimestamp(Timestamp & timestamp) {
		preciseOriginTimestamp = timestamp;
	}

	/**
	 * @brief  Sets the clock source time interface (802.1AS 9.2)
	 * @param  fup Follow up message
	 * @return void
	 */
	void setClockSourceTime(FollowUpTLV *fup)
	{
		tlv.setGMTimeBaseIndicator(fup->getGMTimeBaseIndicator());
		tlv.setScaledLastGmFreqChange(fup->getScaledLastGmFreqChange());
		tlv.setScaledLastGmPhaseChange(fup->getScaledLastGmPhaseChange());
	}

	friend PTPMessageCommon *buildPTPMessage
	( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );
};

/**
 * @brief Provides a class for building the PTP Path Delay Request message
 */
class PTPMessagePathDelayReq : public PTPMessageCommon {
 private:
	Timestamp originTimestamp;

	PTPMessagePathDelayReq() {
		return;
	}
 public:
	/**
	 * @brief Destroys the PTPMessagePathDelayReq object
	 */
	~PTPMessagePathDelayReq() {
	}

	/**
	 * @brief Builds the PTPMessagePathDelayReq message
	 */
	PTPMessagePathDelayReq( EtherPort *port );

	/**
	 * @brief  Assembles PTPMessagePathDelayReq message on the
	 * EtherPort payload
	 * @param  port EtherPort where the message will be
	 * assembled
	 * @param  destIdentity [in] Destination PortIdentity
	 * @return true on success
	 */
	bool sendPort
	( EtherPort *port, PortIdentity *destIdentity );

	void processMessage( CommonPort *port );

	/**
	 * @brief  Gets origin timestamp value
	 * @return Origin Timestamp
	 */
	Timestamp getOriginTimestamp(void) {
		return originTimestamp;
	}

	friend PTPMessageCommon *buildPTPMessage
	( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );
};

/**
 * @brief Provides a class for building the PTP Path Delay Response message.
 */
class PTPMessagePathDelayResp:public PTPMessageCommon {
private:
	PortIdentity * requestingPortIdentity;
	Timestamp requestReceiptTimestamp;

	PTPMessagePathDelayResp(void) {
	}
public:
	/**
	 * @brief Destroys the PTPMessagePathDelayResp object
	 */
	~PTPMessagePathDelayResp();
	/**
	 * @brief Builds the PTPMessagePathDelayResp object
	 */
	PTPMessagePathDelayResp( EtherPort *port );

	/**
	 * @brief  Assembles PTPMessagePathDelayResp message on the
	 * EtherPort payload
	 * @param  port EtherPort where the message will be
	 * assembled
	 * @param  destIdentity [in] Destination PortIdentity
	 * @return true on success
	 */
	bool sendPort
	( EtherPort *port, PortIdentity *destIdentity );

	void processMessage( CommonPort *port );

	/**
	 * @brief  Sets the request receipt timestamp
	 * @param  timestamp Timestamp to be set
	 * @return void
	 */
	void setRequestReceiptTimestamp(Timestamp timestamp) {
		requestReceiptTimestamp = timestamp;
	}

	/**
	 * @brief  Sets requesting port identity
	 * @param  identity [in] PortIdentity to be set
	 * @return void
	 */
	void setRequestingPortIdentity(PortIdentity * identity);
	/**
	 * @brief  Gets requesting port identity
	 * @param  identity [out] Requested PortIdentity
	 * @return void
	 */
	void getRequestingPortIdentity(PortIdentity * identity);

	/**
	 * @brief  Gets the request receipt timestamp
	 * @return requestReceiptTimestamp
	 */
	Timestamp getRequestReceiptTimestamp(void) {
		return requestReceiptTimestamp;
	}

	friend PTPMessageCommon *buildPTPMessage
	( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );
};

/**
 * @brief Provides a class for building the PTP Path Delay Response follow up message.
 */
class PTPMessagePathDelayRespFollowUp:public PTPMessageCommon {
 private:
	Timestamp responseOriginTimestamp;
	PortIdentity *requestingPortIdentity;

	PTPMessagePathDelayRespFollowUp(void) { }

public:
	/**
	 * @brief Builds the PTPMessagePathDelayRespFollowUp object
	 */
	PTPMessagePathDelayRespFollowUp( EtherPort *port );

	/**
	 * @brief Destroys the PTPMessagePathDelayRespFollowUp object
	 */
	~PTPMessagePathDelayRespFollowUp();

	/**
	 * @brief  Assembles PTPMessageRespFollowUp message on the
	 * EtherPort payload
	 * @param  port EtherPort where the message will be
	 * assembled
	 * @param  destIdentity [in] Destination PortIdentity
	 * @return true on success
	 */
	bool sendPort
	( EtherPort *port, PortIdentity *destIdentity );

	void processMessage( CommonPort *port );

	/**
	 * @brief  Sets the response origin timestamp
	 * @param  timestamp Timestamp to be set
	 * @return void
	 */
	void setResponseOriginTimestamp(Timestamp timestamp) {
		responseOriginTimestamp = timestamp;
	}
	/**
	 * @brief  Sets the requesting port identity
	 * @param  identity [in] PortIdentity to be set
	 * @return void
	 */
	void setRequestingPortIdentity(PortIdentity * identity);

	/**
	 * @brief  Gets the response origin timestamp
	 * @return responseOriginTimestamp
	 */
	Timestamp getResponseOriginTimestamp(void) {
		return responseOriginTimestamp;
	}
	/**
	 * @brief Gets the requesting port identity
	 * @return Pointer to requesting PortIdentity object
	 */
	PortIdentity *getRequestingPortIdentity(void) {
		return requestingPortIdentity;
	}

	friend PTPMessageCommon *buildPTPMessage
	( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );
};

/*Exact fit. No padding*/
#pragma pack(push,1)


/**
 * @brief Provides a Signalling Msg Interval Request TLV interface back to the previous
 * packing mode
 */
class SignallingTLV {
 private:
	uint16_t tlvType;
	uint16_t lengthField;
	uint8_t organizationId[3];
	uint8_t organizationSubType_ms;
	uint16_t organizationSubType_ls;
	uint8_t linkDelayInterval;
	uint8_t timeSyncInterval;
	uint8_t announceInterval;
	uint8_t flags;
	uint16_t reserved;
 public:
	/**
	 * @brief Builds the Signalling Msg Interval Request TLV interface
	 */
	SignallingTLV() {
		tlvType = PLAT_htons(0x3);
		lengthField = PLAT_htons(12);
		organizationId[0] = '\x00';
		organizationId[1] = '\x80';
		organizationId[2] = '\xC2';
		organizationSubType_ms = 0;
		organizationSubType_ls = PLAT_htons(2);
		linkDelayInterval = 0;
		timeSyncInterval = 0;
		announceInterval = 0;
		flags = 3;
		reserved = PLAT_htons(0);
	}

	/**
	 * @brief  Gets Msg Interval Request TLV information in a byte
	 *         string format
	 * @param  byte_str [out] Msg Interval Request TLV values
	 */
	void toByteString(uint8_t * byte_str) {
		memcpy(byte_str, this, sizeof(*this));
	}

	/**
	 * @brief  Gets the link delay interval.
	 * @return 8 bit signed value of the link delay interval.
	 */
	int8_t getLinkDelayInterval() {
		return linkDelayInterval;
	}

	/**
	 * @brief  Sets the link delay interval.
	 * @param 8 bit signed value of the link delay interval.
	 * @return void
	 */
	void setLinkDelayInterval(int8_t linkDelayInterval) {
		this->linkDelayInterval = linkDelayInterval;
	}

	/**
	 * @brief  Gets the time sync interval.
	 * @return 8 bit signed value of the time sync interval.
	 */
	int8_t getTimeSyncInterval() {
		return timeSyncInterval;
	}

	/**
	 * @brief  Sets the time sync interval.
	 * #param  8 bit signed value of the time sync interval.
	 * @return void
	 */
	void setTimeSyncInterval(int8_t timeSyncInterval) {
		this->timeSyncInterval = timeSyncInterval;
	}

	/**
	 * @brief  Gets the announce interval.
	 * @return 8 bit signed value of the announce interval.
	 */
	int8_t getAnnounceInterval() {
		return announceInterval;
	}

	/**
	 * @brief  Sets the announce interval.
	 * @param  8 bit signed value of the announce interval.
	 * @return void
	 */
	void setAnnounceInterval(int8_t announceInterval) {
		this->announceInterval = announceInterval;
	}
};

/* back to whatever the previous packing mode was */
#pragma pack(pop)

/**
 * @brief Provides a class for building a PTP signalling message
 */
class PTPMessageSignalling:public PTPMessageCommon {
private:
	int8_t targetPortIdentify;
	SignallingTLV tlv;

	PTPMessageSignalling(void);
public:
	static const int8_t sigMsgInterval_Initial =  126;
	static const int8_t sigMsgInterval_NoSend =  127;
	static const int8_t sigMsgInterval_NoChange =  -128;

	/**
	 * @brief Builds the PTPMessageSignalling object
	 */
	PTPMessageSignalling( EtherPort *port );

	/**
	 * @brief Destroys the PTPMessageSignalling object
	 */
	~PTPMessageSignalling();

	/**
	 * @brief Sets the signalling intervals
	 * @param  linkDelayInterval link delay interval
	 * @param  timeSyncInterval Sync interval
	 * @param  announceInterval Announce interval
	 * @return void
	 */
	void setintervals(int8_t linkDelayInterval, int8_t timeSyncInterval, int8_t announceInterval);

	/**
	 * @brief  Assembles PTPMessageSignalling message on the
	 *         EtherPort payload
	 * @param  port EtherPort where the message will be
	 * assembled
	 * @param  destIdentity [in] Destination PortIdentity
	 * @return true on success
	 */
	bool sendPort
	( EtherPort *port, PortIdentity *destIdentity );

	void processMessage( CommonPort *port );

	friend PTPMessageCommon *buildPTPMessage
	( char *buf, int size, LinkLayerAddress *remote, CommonPort *port );
};

#endif