Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
74da3f32
Commit
74da3f32
authored
Dec 12, 2011
by
Aurelio Colosimo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integration of msg.c src file, containing function for message handling
parent
86c25f77
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
301 additions
and
257 deletions
+301
-257
posix-io.c
arch-gnu-linux/posix-io.c
+5
-0
posix-startup.c
arch-gnu-linux/posix-startup.c
+3
-1
dep.h
include/dep/dep.h
+1
-0
constants.h
include/pproto/constants.h
+11
-0
pproto.h
include/pproto/pproto.h
+10
-2
Makefile
proto-standard/Makefile
+1
-0
msg.c
proto-standard/msg.c
+270
-254
No files found.
arch-gnu-linux/posix-io.c
View file @
74da3f32
...
...
@@ -27,6 +27,11 @@ int pp_memcmp(void *s1, const void *s2, int count)
return
memcmp
(
s1
,
s2
,
count
);
}
void
*
pp_memset
(
void
*
s
,
int
c
,
int
count
)
{
return
memset
(
s
,
c
,
count
);
}
void
pp_get_stamp
(
uint32_t
*
sptr
)
{
*
sptr
=
htonl
(
time
(
NULL
));
...
...
arch-gnu-linux/posix-startup.c
View file @
74da3f32
...
...
@@ -31,6 +31,7 @@ int main(int argc, char **argv)
if
(
!
ppi
)
exit
(
__LINE__
);
ppi
->
sent_seq_id
=
calloc
(
16
,
sizeof
(
*
ppi
->
sent_seq_id
));
ppi
->
defaultDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
defaultDS
));
ppi
->
currentDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
currentDS
));
ppi
->
parentDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
parentDS
));
...
...
@@ -38,7 +39,8 @@ int main(int argc, char **argv)
ppi
->
timePropertiesDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
timePropertiesDS
));
if
((
!
ppi
->
defaultDS
)
||
(
!
ppi
->
currentDS
)
||
(
!
ppi
->
parentDS
)
||
(
!
ppi
->
portDS
)
||
(
!
ppi
->
timePropertiesDS
))
||
(
!
ppi
->
portDS
)
||
(
!
ppi
->
timePropertiesDS
)
||
(
!
ppi
->
sent_seq_id
)
)
exit
(
__LINE__
);
if
(
posix_open_ch
(
ppi
,
ifname
))
{
...
...
include/dep/dep.h
View file @
74da3f32
...
...
@@ -15,5 +15,6 @@ extern void pp_puts(const char *s);
extern
int
pp_strnlen
(
const
char
*
s
,
int
maxlen
);
extern
void
*
pp_memcpy
(
void
*
d
,
const
void
*
s
,
int
count
);
extern
int
pp_memcmp
(
void
*
s1
,
const
void
*
s2
,
int
count
);
extern
void
*
pp_memset
(
void
*
s
,
int
c
,
int
count
);
#endif
/* __PTP_DEP_H__ */
include/pproto/constants.h
View file @
74da3f32
...
...
@@ -42,4 +42,15 @@
#define PP_TWO_STEP_FLAG 2
#define PP_VERSION_PTP 2
#define PP_HEADER_LENGTH 34
#define PP_ANNOUNCE_LENGTH 64
#define PP_SYNC_LENGTH 44
#define PP_FOLLOW_UP_LENGTH 44
#define PP_PDELAY_REQ_LENGTH 54
#define PP_DELAY_REQ_LENGTH 44
#define PP_DELAY_RESP_LENGTH 54
#define PP_PDELAY_RESP_LENGTH 54
#define PP_PDELAY_RESP_FOLLOW_UP_LENGTH 54
#define PP_MANAGEMENT_LENGTH 48
#endif
/* __PTP_CONSTANTS_H__ */
include/pproto/pproto.h
View file @
74da3f32
...
...
@@ -108,13 +108,13 @@ struct pp_instance {
DSTimeProperties
*
timePropertiesDS
;
struct
pp_timer
*
timers
[
PP_TIMER_ARRAY_SIZE
];
/* FIXME: check the variables
below
. Now inherited from ptpd src*/
/* FIXME: check the variables
from now on
. Now inherited from ptpd src*/
UInteger16
number_foreign_records
;
Integer16
max_foreign_records
;
Integer16
foreign_record_i
;
Integer16
foreign_record_best
;
Boolean
record_update
;
MsgHeader
msg_tmp_header
;
union
{
MsgSync
sync
;
MsgFollowUp
follow
;
...
...
@@ -127,6 +127,11 @@ struct pp_instance {
MsgAnnounce
announce
;
MsgSignaling
signaling
;
}
msg_tmp
;
UInteger16
*
sent_seq_id
;
/* sequence id of the last message sent of the
* same type
*/
MsgHeader
msg_tmp_header
;
MsgHeader
pdelay_req_hdr
;
};
...
...
@@ -150,8 +155,11 @@ extern int pp_net_init(struct pp_instance *ppi);
extern
int
pp_net_shutdown
(
struct
pp_instance
*
ppi
);
extern
int
pp_recv_packet
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
);
extern
int
pp_send_packet
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
);
extern
UInteger32
pp_htonl
(
UInteger32
hostlong
);
extern
UInteger16
pp_htons
(
UInteger16
hostlong
);
/* Timers */
extern
int
pp_timer_init
(
struct
pp_instance
*
ppi
);
/* initializes timer common
structure */
extern
int
pp_timer_start
(
struct
pp_timer
*
tm
);
...
...
proto-standard/Makefile
View file @
74da3f32
...
...
@@ -18,6 +18,7 @@ OBJ-libstd := $D/state-table-default.o \
$D
/state-uncalibrated.o
\
$D
/state-slave.o
\
$D
/bmc.o
\
$D
/msg.o
\
$D
/open-close.o
$(TARGET).o
:
$(LIBSTD)
...
...
proto-standard/msg.c
View file @
74da3f32
/**
* @file msg.c
* @author George Neville-Neil <gnn@neville-neil.com>
* @date Tue Jul 20 16:17:05 2010
*
* @brief Functions to pack and unpack messages.
*
* See spec annex d
/*
* FIXME header
*/
#include "../ptpd.h"
#include <pproto/pproto.h>
#include <dep/dep.h>
/*Unpack Header from IN buffer to msgTmpHeader field */
void
msgUnpackHeader
(
void
*
buf
,
MsgHeader
*
heade
r
)
/* Unpack header from in buffer to msg_tmp_header field */
void
msg_unpack_header
(
void
*
buf
,
MsgHeader
*
hd
r
)
{
header
->
transportSpecific
=
(
*
(
Nibble
*
)
(
buf
+
0
))
>>
4
;
header
->
messageType
=
(
*
(
Enumeration4
*
)
(
buf
+
0
))
&
0x0F
;
header
->
versionPTP
=
(
*
(
UInteger4
*
)
(
buf
+
1
))
&
0x0F
;
/* force reserved bit to zero if not */
header
->
messageLength
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
2
));
header
->
domainNumber
=
(
*
(
UInteger8
*
)
(
buf
+
4
));
memcpy
(
header
->
flagField
,
(
buf
+
6
),
FLAG_FIELD_LENGTH
);
memcpy
(
&
header
->
correctionfield
.
msb
,
(
buf
+
8
),
4
);
memcpy
(
&
header
->
correctionfield
.
lsb
,
(
buf
+
12
),
4
);
header
->
correctionfield
.
msb
=
flip32
(
header
->
correctionfield
.
msb
);
header
->
correctionfield
.
lsb
=
flip32
(
header
->
correctionfield
.
lsb
);
memcpy
(
header
->
sourcePortIdentity
.
clockIdentity
,
(
buf
+
20
),
CLOCK_IDENTITY_LENGTH
);
header
->
sourcePortIdentity
.
portNumber
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
28
));
header
->
sequenceId
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
30
));
header
->
controlField
=
(
*
(
UInteger8
*
)
(
buf
+
32
));
header
->
logMessageInterval
=
(
*
(
Integer8
*
)
(
buf
+
33
));
hdr
->
transportSpecific
=
(
*
(
Nibble
*
)
(
buf
+
0
))
>>
4
;
hdr
->
messageType
=
(
*
(
Enumeration4
*
)
(
buf
+
0
))
&
0x0F
;
hdr
->
versionPTP
=
(
*
(
UInteger4
*
)
(
buf
+
1
))
&
0x0F
;
/* force reserved bit to zero if not */
hdr
->
messageLength
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
2
));
hdr
->
domainNumber
=
(
*
(
UInteger8
*
)
(
buf
+
4
));
/* pp_memcpy(hdr->flagField, (buf + 6), FIXME:FLAG_FIELD_LENGTH); */
pp_memcpy
(
&
hdr
->
correctionfield
.
msb
,
(
buf
+
8
),
4
);
pp_memcpy
(
&
hdr
->
correctionfield
.
lsb
,
(
buf
+
12
),
4
);
hdr
->
correctionfield
.
msb
=
pp_htonl
(
hdr
->
correctionfield
.
msb
);
hdr
->
correctionfield
.
lsb
=
pp_htonl
(
hdr
->
correctionfield
.
lsb
);
pp_memcpy
(
hdr
->
sourcePortIdentity
.
clockIdentity
,
(
buf
+
20
),
PP_CLOCK_IDENTITY_LENGTH
);
hdr
->
sourcePortIdentity
.
portNumber
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
28
));
hdr
->
sequenceId
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
30
));
hdr
->
controlField
=
(
*
(
UInteger8
*
)
(
buf
+
32
));
hdr
->
logMessageInterval
=
(
*
(
Integer8
*
)
(
buf
+
33
));
/* FIXME: diag
#ifdef PTPD_DBG
msgHeader_display(header);
#endif
/* PTPD_DBG */
#endif
*/
}
/*Pack header message into OUT buffer of ptpClock*/
void
msgPackHeader
(
void
*
buf
,
PtpClock
*
ptpClock
)
/* Pack header message into out buffer of ppi */
void
msg_pack_header
(
void
*
buf
,
struct
pp_instance
*
ppi
)
{
Nibble
transport
=
0x80
;
/* (spec annex D) */
*
(
UInteger8
*
)
(
buf
+
0
)
=
transport
;
*
(
UInteger4
*
)
(
buf
+
1
)
=
ptpClock
->
versionNumber
;
*
(
UInteger8
*
)
(
buf
+
4
)
=
ptpClock
->
domainNumber
;
*
(
UInteger4
*
)
(
buf
+
1
)
=
DSPOR
(
ppi
)
->
versionNumber
;
*
(
UInteger8
*
)
(
buf
+
4
)
=
DSDEF
(
ppi
)
->
domainNumber
;
if
(
ptpClock
->
twoStepFlag
)
*
(
UInteger8
*
)
(
buf
+
6
)
=
TWO_STEP_FLAG
;
if
(
DSDEF
(
ppi
)
->
twoStepFlag
)
*
(
UInteger8
*
)
(
buf
+
6
)
=
PP_
TWO_STEP_FLAG
;
memset
((
buf
+
8
),
0
,
8
);
memcpy
((
buf
+
20
),
ptpClock
->
portIdentity
.
clockIdentity
,
CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
28
)
=
flip16
(
ptpClock
->
portIdentity
.
portNumber
);
pp_memset
((
buf
+
8
),
0
,
8
);
pp_memcpy
((
buf
+
20
),
DSPOR
(
ppi
)
->
portIdentity
.
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
28
)
=
pp_htons
(
DSPOR
(
ppi
)
->
portIdentity
.
portNumber
);
*
(
UInteger8
*
)
(
buf
+
33
)
=
0x7F
;
/* Default value(spec Table 24) */
}
/*Pack SYNC message into OUT buffer of ptpClock*/
void
msgPackSync
(
void
*
buf
,
Timestamp
*
originTimestamp
,
PtpClock
*
ptpClock
)
/* Pack Sync message into out buffer of ppi */
void
msg_pack_sync
(
void
*
buf
,
Timestamp
*
orig_tstamp
,
struct
pp_instance
*
ppi
)
{
/* changes in header */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
&
0xF0
;
/* RAZ messageType */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
|
0x00
;
/* Table 19 */
*
(
UInteger16
*
)
(
buf
+
2
)
=
flip16
(
SYNC_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
flip16
(
ptpClock
->
sentSyncSequenceId
);
*
(
UInteger16
*
)
(
buf
+
2
)
=
pp_htons
(
PP_
SYNC_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
pp_htons
(
ppi
->
sent_seq_id
[
PPM_SYNC
]
);
*
(
UInteger8
*
)
(
buf
+
32
)
=
0x00
;
/* Table 23 */
*
(
Integer8
*
)
(
buf
+
33
)
=
ptpClock
->
logSyncInterval
;
memset
((
buf
+
8
),
0
,
8
);
*
(
Integer8
*
)
(
buf
+
33
)
=
DSPOR
(
ppi
)
->
logSyncInterval
;
pp_
memset
((
buf
+
8
),
0
,
8
);
/* Sync message */
*
(
UInteger16
*
)
(
buf
+
34
)
=
flip16
(
originTime
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
flip32
(
originTime
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
flip32
(
originTime
stamp
->
nanosecondsField
);
*
(
UInteger16
*
)
(
buf
+
34
)
=
pp_htons
(
orig_t
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
pp_htonl
(
orig_t
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
pp_htonl
(
orig_t
stamp
->
nanosecondsField
);
}
/*Unpack Sync message from IN buffer */
void
msgUnpackSync
(
void
*
buf
,
MsgSync
*
sync
)
/* Unpack Sync message from in buffer */
void
msg_unpack_sync
(
void
*
buf
,
MsgSync
*
sync
)
{
sync
->
originTimestamp
.
secondsField
.
msb
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
34
));
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
34
));
sync
->
originTimestamp
.
secondsField
.
lsb
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
36
));
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
36
));
sync
->
originTimestamp
.
nanosecondsField
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
40
));
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
/* FIXME: diag
#ifdef PTPD_DBG
msgSync_display(sync);
#endif
/* PTPD_DBG */
#endif
*/
}
/*Pack Announce message into OUT buffer of ptpClock*/
void
msgPackAnnounce
(
void
*
buf
,
PtpClock
*
ptpClock
)
/* Pack Announce message into out buffer of ppi */
void
msg_pack_announce
(
void
*
buf
,
struct
pp_instance
*
ppi
)
{
/* changes in header */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
&
0xF0
;
/* RAZ messageType */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
|
0x0B
;
/* Table 19 */
*
(
UInteger16
*
)
(
buf
+
2
)
=
flip16
(
ANNOUNCE_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
flip16
(
ptpClock
->
sentAnnounceSequenceId
);
*
(
UInteger16
*
)
(
buf
+
2
)
=
pp_htons
(
PP_
ANNOUNCE_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
pp_htons
(
ppi
->
sent_seq_id
[
PPM_ANNOUNCE
]
);
*
(
UInteger8
*
)
(
buf
+
32
)
=
0x05
;
/* Table 23 */
*
(
Integer8
*
)
(
buf
+
33
)
=
ptpClock
->
logAnnounceInterval
;
*
(
Integer8
*
)
(
buf
+
33
)
=
DSPOR
(
ppi
)
->
logAnnounceInterval
;
/* Announce message */
memset
((
buf
+
34
),
0
,
10
);
*
(
Integer16
*
)
(
buf
+
44
)
=
flip16
(
ptpClock
->
currentUtcOffset
);
*
(
UInteger8
*
)
(
buf
+
47
)
=
ptpClock
->
grandmasterPriority1
;
*
(
UInteger8
*
)
(
buf
+
48
)
=
ptpClock
->
clockQuality
.
clockClass
;
*
(
Enumeration8
*
)
(
buf
+
49
)
=
ptpClock
->
clockQuality
.
clockAccuracy
;
pp_
memset
((
buf
+
34
),
0
,
10
);
*
(
Integer16
*
)
(
buf
+
44
)
=
pp_htons
(
DSPRO
(
ppi
)
->
currentUtcOffset
);
*
(
UInteger8
*
)
(
buf
+
47
)
=
DSPAR
(
ppi
)
->
grandmasterPriority1
;
*
(
UInteger8
*
)
(
buf
+
48
)
=
DSDEF
(
ppi
)
->
clockQuality
.
clockClass
;
*
(
Enumeration8
*
)
(
buf
+
49
)
=
DSDEF
(
ppi
)
->
clockQuality
.
clockAccuracy
;
*
(
UInteger16
*
)
(
buf
+
50
)
=
flip16
(
ptpClock
->
clockQuality
.
offsetScaledLogVariance
);
*
(
UInteger8
*
)
(
buf
+
52
)
=
ptpClock
->
grandmasterPriority2
;
memcpy
((
buf
+
53
),
ptpClock
->
grandmasterIdentity
,
CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
61
)
=
flip16
(
ptpClock
->
stepsRemoved
);
*
(
Enumeration8
*
)
(
buf
+
63
)
=
ptpClock
->
timeSource
;
pp_htons
(
DSDEF
(
ppi
)
->
clockQuality
.
offsetScaledLogVariance
);
*
(
UInteger8
*
)
(
buf
+
52
)
=
DSPAR
(
ppi
)
->
grandmasterPriority2
;
pp_memcpy
((
buf
+
53
),
DSPAR
(
ppi
)
->
grandmasterIdentity
,
PP_CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
61
)
=
pp_htons
(
DSCUR
(
ppi
)
->
stepsRemoved
);
*
(
Enumeration8
*
)
(
buf
+
63
)
=
DSPRO
(
ppi
)
->
timeSource
;
}
/*Unpack Announce message from IN buffer of ptpClock to msgtmp.Announce*/
void
msgUnpackAnnounce
(
void
*
buf
,
MsgAnnounce
*
announce
)
/* Unpack Announce message from in buffer of ppi to msgtmp. Announce */
void
msg_unpack_announce
(
void
*
buf
,
MsgAnnounce
*
ann
)
{
ann
ounce
->
originTimestamp
.
secondsField
.
msb
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
34
));
ann
ounce
->
originTimestamp
.
secondsField
.
lsb
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
36
));
ann
ounce
->
originTimestamp
.
nanosecondsField
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
40
));
ann
ounce
->
currentUtcOffset
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
44
));
ann
ounce
->
grandmasterPriority1
=
*
(
UInteger8
*
)
(
buf
+
47
);
ann
ounce
->
grandmasterClockQuality
.
clockClass
=
ann
->
originTimestamp
.
secondsField
.
msb
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
34
));
ann
->
originTimestamp
.
secondsField
.
lsb
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
36
));
ann
->
originTimestamp
.
nanosecondsField
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
ann
->
currentUtcOffset
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
44
));
ann
->
grandmasterPriority1
=
*
(
UInteger8
*
)
(
buf
+
47
);
ann
->
grandmasterClockQuality
.
clockClass
=
*
(
UInteger8
*
)
(
buf
+
48
);
ann
ounce
->
grandmasterClockQuality
.
clockAccuracy
=
ann
->
grandmasterClockQuality
.
clockAccuracy
=
*
(
Enumeration8
*
)
(
buf
+
49
);
announce
->
grandmasterClockQuality
.
offsetScaledLogVariance
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
50
));
announce
->
grandmasterPriority2
=
*
(
UInteger8
*
)
(
buf
+
52
);
memcpy
(
announce
->
grandmasterIdentity
,
(
buf
+
53
),
CLOCK_IDENTITY_LENGTH
);
announce
->
stepsRemoved
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
61
));
announce
->
timeSource
=
*
(
Enumeration8
*
)
(
buf
+
63
);
ann
->
grandmasterClockQuality
.
offsetScaledLogVariance
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
50
));
ann
->
grandmasterPriority2
=
*
(
UInteger8
*
)
(
buf
+
52
);
pp_memcpy
(
ann
->
grandmasterIdentity
,
(
buf
+
53
),
PP_CLOCK_IDENTITY_LENGTH
);
ann
->
stepsRemoved
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
61
));
ann
->
timeSource
=
*
(
Enumeration8
*
)
(
buf
+
63
);
/* FIXME: diag
#ifdef PTPD_DBG
msgAnnounce_display(announce);
#endif
/* PTPD_DBG */
#endif
*/
}
/*pack Follow_up message into OUT buffer of ptpClock*/
void
msgPackFollowUp
(
void
*
buf
,
Timestamp
*
preciseOriginTimestamp
,
PtpClock
*
ptpClock
)
/* Pack Follow Up message into out buffer of ppi*/
void
msg_pack_follow_up
(
void
*
buf
,
Timestamp
*
prec_orig_tstamp
,
struct
pp_instance
*
ppi
)
{
/* changes in header */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
&
0xF0
;
/* RAZ messageType */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
|
0x08
;
/* Table 19 */
*
(
UInteger16
*
)
(
buf
+
2
)
=
flip16
(
FOLLOW_UP_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
flip16
(
ptpClock
->
sentSyncSequenceId
-
1
);
*
(
UInteger16
*
)
(
buf
+
2
)
=
pp_htons
(
PP_FOLLOW_UP_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
pp_htons
(
ppi
->
sent_seq_id
[
PPM_SYNC
]
-
1
);
/* sentSyncSequenceId has already been incremented in "issueSync" */
*
(
UInteger8
*
)
(
buf
+
32
)
=
0x02
;
/* Table 23 */
*
(
Integer8
*
)
(
buf
+
33
)
=
ptpClock
->
logSyncInterval
;
*
(
Integer8
*
)
(
buf
+
33
)
=
DSPOR
(
ppi
)
->
logSyncInterval
;
/* Follow
_u
p message */
/* Follow
U
p message */
*
(
UInteger16
*
)
(
buf
+
34
)
=
flip16
(
preciseOriginTime
stamp
->
secondsField
.
msb
);
pp_htons
(
prec_orig_t
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
flip32
(
preciseOriginTime
stamp
->
secondsField
.
lsb
);
pp_htonl
(
prec_orig_t
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
flip32
(
preciseOriginTime
stamp
->
nanosecondsField
);
pp_htonl
(
prec_orig_t
stamp
->
nanosecondsField
);
}
/*Unpack Follow_up message from IN buffer of ptpClock to msgtmp.follow*/
void
msgUnpackFollowUp
(
void
*
buf
,
MsgFollowUp
*
follow
)
/* Unpack FollowUp message from in buffer of ppi to msgtmp.follow */
void
msg_unpack_follow_up
(
void
*
buf
,
MsgFollowUp
*
flwup
)
{
follow
->
preciseOriginTimestamp
.
secondsField
.
msb
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
34
));
follow
->
preciseOriginTimestamp
.
secondsField
.
lsb
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
36
));
follow
->
preciseOriginTimestamp
.
nanosecondsField
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
40
));
flwup
->
preciseOriginTimestamp
.
secondsField
.
msb
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
34
));
flwup
->
preciseOriginTimestamp
.
secondsField
.
lsb
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
36
));
flwup
->
preciseOriginTimestamp
.
nanosecondsField
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
/* FIXME: diag
#ifdef PTPD_DBG
msgFollowUp_display(follow);
#endif
/* PTPD_DBG */
#endif
*/
}
/*pack PdelayReq message into OUT buffer of ptpClock*/
void
msgPackPDelayReq
(
void
*
buf
,
Timestamp
*
originTimestamp
,
PtpClock
*
ptpClock
)
/* pack PdelayReq message into out buffer of ppi */
void
msg_pack_pdelay_req
(
void
*
buf
,
Timestamp
*
orig_tstamp
,
struct
pp_instance
*
ppi
)
{
/* changes in header */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
&
0xF0
;
/* RAZ messageType */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
|
0x02
;
/* Table 19 */
*
(
UInteger16
*
)
(
buf
+
2
)
=
flip16
(
PDELAY_REQ_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
flip16
(
ptpClock
->
sentPDelayReqSequenceId
);
*
(
UInteger16
*
)
(
buf
+
2
)
=
pp_htons
(
PP_
PDELAY_REQ_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
pp_htons
(
ppi
->
sent_seq_id
[
PPM_PDELAY_REQ
]
);
*
(
UInteger8
*
)
(
buf
+
32
)
=
0x05
;
/* Table 23 */
*
(
Integer8
*
)
(
buf
+
33
)
=
0x7F
;
/* Table 24 */
memset
((
buf
+
8
),
0
,
8
);
pp_
memset
((
buf
+
8
),
0
,
8
);
/* Pdelay_req message */
*
(
UInteger16
*
)
(
buf
+
34
)
=
flip16
(
originTime
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
flip32
(
originTime
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
flip32
(
originTime
stamp
->
nanosecondsField
);
*
(
UInteger16
*
)
(
buf
+
34
)
=
pp_htons
(
orig_t
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
pp_htonl
(
orig_t
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
pp_htonl
(
orig_t
stamp
->
nanosecondsField
);
memset
((
buf
+
44
),
0
,
10
);
pp_
memset
((
buf
+
44
),
0
,
10
);
/* RAZ reserved octets */
}
/*pack delayReq message into OUT buffer of ptpClock*/
void
msgPackDelayReq
(
void
*
buf
,
Timestamp
*
originTimestamp
,
PtpClock
*
ptpClock
)
/*pack DelayReq message into out buffer of ppi*/
void
msg_pack_delay_req
(
void
*
buf
,
Timestamp
*
orig_tstamp
,
struct
pp_instance
*
ppi
)
{
/* changes in header */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
&
0xF0
;
/* RAZ messageType */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
|
0x01
;
/* Table 19 */
*
(
UInteger16
*
)
(
buf
+
2
)
=
flip16
(
DELAY_REQ_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
flip16
(
ptpClock
->
sentDelayReqSequenceId
);
*
(
UInteger16
*
)
(
buf
+
2
)
=
pp_htons
(
PP_
DELAY_REQ_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
pp_htons
(
ppi
->
sent_seq_id
[
PPM_DELAY_REQ
]
);
*
(
UInteger8
*
)
(
buf
+
32
)
=
0x01
;
/* Table 23 */
*
(
Integer8
*
)
(
buf
+
33
)
=
0x7F
;
/* Table 24 */
memset
((
buf
+
8
),
0
,
8
);
pp_
memset
((
buf
+
8
),
0
,
8
);
/* Pdelay_req message */
*
(
UInteger16
*
)
(
buf
+
34
)
=
flip16
(
originTime
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
flip32
(
originTime
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
flip32
(
originTime
stamp
->
nanosecondsField
);
*
(
UInteger16
*
)
(
buf
+
34
)
=
pp_htons
(
orig_t
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
pp_htonl
(
orig_t
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
pp_htonl
(
orig_t
stamp
->
nanosecondsField
);
}
/*pack delayResp message into OUT buffer of ptpClock*/
void
msgPackDelayResp
(
void
*
buf
,
MsgHeader
*
header
,
Timestamp
*
receiveTimestamp
,
PtpClock
*
ptpClock
)
/*pack delayResp message into OUT buffer of ppi*/
void
msg_pack_delay_resp
(
void
*
buf
,
MsgHeader
*
hdr
,
Timestamp
*
rcv_tstamp
,
struct
pp_instance
*
ppi
)
{
/* changes in header */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
&
0xF0
;
/* RAZ messageType */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
|
0x09
;
/* Table 19 */
*
(
UInteger16
*
)
(
buf
+
2
)
=
flip16
(
DELAY_RESP_LENGTH
);
*
(
UInteger8
*
)
(
buf
+
4
)
=
h
eade
r
->
domainNumber
;
memset
((
buf
+
8
),
0
,
8
);
*
(
UInteger16
*
)
(
buf
+
2
)
=
pp_htons
(
PP_
DELAY_RESP_LENGTH
);
*
(
UInteger8
*
)
(
buf
+
4
)
=
h
d
r
->
domainNumber
;
pp_
memset
((
buf
+
8
),
0
,
8
);
/* Copy correctionField of PdelayReqMessage */
*
(
Integer32
*
)
(
buf
+
8
)
=
flip32
(
heade
r
->
correctionfield
.
msb
);
*
(
Integer32
*
)
(
buf
+
12
)
=
flip32
(
heade
r
->
correctionfield
.
lsb
);
*
(
Integer32
*
)
(
buf
+
8
)
=
pp_htonl
(
hd
r
->
correctionfield
.
msb
);
*
(
Integer32
*
)
(
buf
+
12
)
=
pp_htonl
(
hd
r
->
correctionfield
.
lsb
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
flip16
(
heade
r
->
sequenceId
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
pp_htons
(
hd
r
->
sequenceId
);
*
(
UInteger8
*
)
(
buf
+
32
)
=
0x03
;
/* Table 23 */
*
(
Integer8
*
)
(
buf
+
33
)
=
ptpClock
->
logMinDelayReqInterval
;
*
(
Integer8
*
)
(
buf
+
33
)
=
DSPOR
(
ppi
)
->
logMinDelayReqInterval
;
/* Table 24 */
/* Pdelay_resp message */
*
(
UInteger16
*
)
(
buf
+
34
)
=
flip16
(
receiveTime
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
flip32
(
receiveTime
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
flip32
(
receiveTime
stamp
->
nanosecondsField
);
memcpy
((
buf
+
44
),
header
->
sourcePortIdentity
.
clockIdentity
,
CLOCK_IDENTITY_LENGTH
);
pp_htons
(
rcv_t
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
pp_htonl
(
rcv_t
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
pp_htonl
(
rcv_t
stamp
->
nanosecondsField
);
pp_memcpy
((
buf
+
44
),
hdr
->
sourcePortIdentity
.
clockIdentity
,
PP_
CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
52
)
=
flip16
(
heade
r
->
sourcePortIdentity
.
portNumber
);
pp_htons
(
hd
r
->
sourcePortIdentity
.
portNumber
);
}
/*pack PdelayResp message into OUT buffer of ptpClock*/
void
msgPackPDelayResp
(
void
*
buf
,
MsgHeader
*
header
,
Timestamp
*
requestReceiptTimestamp
,
PtpClock
*
ptpClock
)
/* Pack PdelayResp message into out buffer of ppi */
void
msg_pack_pdelay_resp
(
void
*
buf
,
MsgHeader
*
hdr
,
Timestamp
*
req_rec_tstamp
,
struct
pp_instance
*
ppi
)
{
/* changes in header */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
&
0xF0
;
/* RAZ messageType */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
|
0x03
;
/* Table 19 */
*
(
UInteger16
*
)
(
buf
+
2
)
=
flip16
(
PDELAY_RESP_LENGTH
);
*
(
UInteger8
*
)
(
buf
+
4
)
=
header
->
domainNumber
;
memset
((
buf
+
8
),
0
,
8
);
*
(
UInteger16
*
)
(
buf
+
2
)
=
pp_htons
(
PP_PDELAY_RESP_LENGTH
);
*
(
UInteger8
*
)
(
buf
+
4
)
=
hdr
->
domainNumber
;
pp_memset
((
buf
+
8
),
0
,
8
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
flip16
(
heade
r
->
sequenceId
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
pp_htons
(
hd
r
->
sequenceId
);
*
(
UInteger8
*
)
(
buf
+
32
)
=
0x05
;
/* Table 23 */
...
...
@@ -313,137 +325,141 @@ msgPackPDelayResp(void *buf, MsgHeader * header, Timestamp * requestReceiptTimes
/* Table 24 */
/* Pdelay_resp message */
*
(
UInteger16
*
)
(
buf
+
34
)
=
flip16
(
requestReceiptTimestamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
flip32
(
requestReceiptTimestamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
flip32
(
requestReceiptTimestamp
->
nanosecondsField
);
memcpy
((
buf
+
44
),
header
->
sourcePortIdentity
.
clockIdentity
,
CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
52
)
=
flip16
(
header
->
sourcePortIdentity
.
portNumber
);
*
(
UInteger16
*
)
(
buf
+
34
)
=
pp_htons
(
req_rec_tstamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
pp_htonl
(
req_rec_tstamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
pp_htonl
(
req_rec_tstamp
->
nanosecondsField
);
pp_memcpy
((
buf
+
44
),
hdr
->
sourcePortIdentity
.
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
52
)
=
pp_htons
(
hdr
->
sourcePortIdentity
.
portNumber
);
}
/*Unpack delayReq message from IN buffer of ptpClock to msgtmp.req*/
void
msgUnpackDelayReq
(
void
*
buf
,
MsgDelayReq
*
delayreq
)
/* Unpack delayReq message from in buffer of ppi to msgtmp.req */
void
msg_unpack_delay_req
(
void
*
buf
,
MsgDelayReq
*
delay_req
)
{
delay
req
->
originTimestamp
.
secondsField
.
msb
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
34
));
delay
req
->
originTimestamp
.
secondsField
.
lsb
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
36
));
delay
req
->
originTimestamp
.
nanosecondsField
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
40
));
delay
_req
->
originTimestamp
.
secondsField
.
msb
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
34
));
delay
_req
->
originTimestamp
.
secondsField
.
lsb
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
36
));
delay
_req
->
originTimestamp
.
nanosecondsField
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
/* FIXME: diag
#ifdef PTPD_DBG
msgDelayReq_display(delayreq);
#endif
/* PTPD_DBG */
#endif
*/
}
/*Unpack PdelayReq message from IN buffer of ptpClock to msgtmp.req*/
void
msgUnpackPDelayReq
(
void
*
buf
,
MsgPDelayReq
*
pdelayreq
)
{
pdelayreq
->
originTimestamp
.
secondsField
.
msb
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
34
));
pdelayreq
->
originTimestamp
.
secondsField
.
lsb
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
36
));
pdelayreq
->
originTimestamp
.
nanosecondsField
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
40
));
/* Unpack PdelayReq message from IN buffer of ppi to msgtmp.req */
void
msg_unpack_pdelay_req
(
void
*
buf
,
MsgPDelayReq
*
pdelay_req
)
{
pdelay_req
->
originTimestamp
.
secondsField
.
msb
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
34
));
pdelay_req
->
originTimestamp
.
secondsField
.
lsb
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
36
));
pdelay_req
->
originTimestamp
.
nanosecondsField
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
/* FIXME: diag
#ifdef PTPD_DBG
msgPDelayReq_display(pdelayreq);
#endif
/* PTPD_DBG */
#endif
*/
}
/*Unpack delayResp message from IN buffer of ptpClock to msgtmp.presp*/
void
msgUnpackDelayResp
(
void
*
buf
,
MsgDelayResp
*
resp
)
/* Unpack delayResp message from IN buffer of ppi to msgtmp.presp */
void
msg_unpack_delay_resp
(
void
*
buf
,
MsgDelayResp
*
resp
)
{
resp
->
receiveTimestamp
.
secondsField
.
msb
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
34
));
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
34
));
resp
->
receiveTimestamp
.
secondsField
.
lsb
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
36
));
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
36
));
resp
->
receiveTimestamp
.
nanosecondsField
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
40
));
memcpy
(
resp
->
requestingPortIdentity
.
clockIdentity
,
(
buf
+
44
),
CLOCK_IDENTITY_LENGTH
);
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
pp_
memcpy
(
resp
->
requestingPortIdentity
.
clockIdentity
,
(
buf
+
44
),
PP_
CLOCK_IDENTITY_LENGTH
);
resp
->
requestingPortIdentity
.
portNumber
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
52
));
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
52
));
/* FIXME: diag
#ifdef PTPD_DBG
msgDelayResp_display(resp);
#endif
/* PTPD_DBG */
#endif
*/
}
/*Unpack PdelayResp message from IN buffer of ptpClock to msgtmp.presp*/
void
msgUnpackPDelayResp
(
void
*
buf
,
MsgPDelayResp
*
presp
)
/* Unpack PdelayResp message from IN buffer of ppi to msgtmp.presp */
void
msg_unpack_pdelay_resp
(
void
*
buf
,
MsgPDelayResp
*
presp
)
{
presp
->
requestReceiptTimestamp
.
secondsField
.
msb
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
34
));
presp
->
requestReceiptTimestamp
.
secondsField
.
lsb
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
36
));
presp
->
requestReceiptTimestamp
.
nanosecondsField
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
40
));
memcpy
(
presp
->
requestingPortIdentity
.
clockIdentity
,
(
buf
+
44
),
CLOCK_IDENTITY_LENGTH
);
presp
->
requestingPortIdentity
.
portNumber
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
52
));
presp
->
requestReceiptTimestamp
.
secondsField
.
msb
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
34
));
presp
->
requestReceiptTimestamp
.
secondsField
.
lsb
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
36
));
presp
->
requestReceiptTimestamp
.
nanosecondsField
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
pp_memcpy
(
presp
->
requestingPortIdentity
.
clockIdentity
,
(
buf
+
44
),
PP_CLOCK_IDENTITY_LENGTH
);
presp
->
requestingPortIdentity
.
portNumber
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
52
));
/* FIXME: diag
#ifdef PTPD_DBG
msgPDelayResp_display(presp);
#endif
/* PTPD_DBG */
#endif
*/
}
/*
pack PdelayRespfollowup message into OUT buffer of ptpClock
*/
void
msgPackPDelayRespFollowUp
(
void
*
buf
,
MsgHeader
*
header
,
Timestamp
*
responseOriginTimestamp
,
PtpClock
*
ptpClock
)
/*
Pack PdelayRespFollowUp message into out buffer of ppi
*/
void
msg_pack_pdelay_resp_followup
(
void
*
buf
,
MsgHeader
*
hdr
,
Timestamp
*
resp_orig_tstamp
,
struct
pp_instance
*
ppi
)
{
/* changes in header */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
&
0xF0
;
/* RAZ messageType */
*
(
char
*
)(
buf
+
0
)
=
*
(
char
*
)(
buf
+
0
)
|
0x0A
;
/* Table 19 */
*
(
UInteger16
*
)
(
buf
+
2
)
=
flip16
(
PDELAY_RESP_FOLLOW_UP_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
flip16
(
ptpClock
->
PdelayReqHeade
r
.
sequenceId
);
*
(
UInteger16
*
)
(
buf
+
2
)
=
pp_htons
(
PP_
PDELAY_RESP_FOLLOW_UP_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
30
)
=
pp_htons
(
ppi
->
pdelay_req_hd
r
.
sequenceId
);
*
(
UInteger8
*
)
(
buf
+
32
)
=
0x05
;
/* Table 23 */
*
(
Integer8
*
)
(
buf
+
33
)
=
0x7F
;
/* Table 24 */
/* Copy correctionField of PdelayReqMessage */
*
(
Integer32
*
)
(
buf
+
8
)
=
flip32
(
heade
r
->
correctionfield
.
msb
);
*
(
Integer32
*
)
(
buf
+
12
)
=
flip32
(
heade
r
->
correctionfield
.
lsb
);
*
(
Integer32
*
)
(
buf
+
8
)
=
pp_htonl
(
hd
r
->
correctionfield
.
msb
);
*
(
Integer32
*
)
(
buf
+
12
)
=
pp_htonl
(
hd
r
->
correctionfield
.
lsb
);
/* Pdelay_resp_follow_up message */
*
(
UInteger16
*
)
(
buf
+
34
)
=
flip16
(
responseOriginTime
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
flip32
(
responseOriginTime
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
flip32
(
responseOriginTime
stamp
->
nanosecondsField
);
memcpy
((
buf
+
44
),
header
->
sourcePortIdentity
.
clockIdentity
,
CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
52
)
=
flip16
(
heade
r
->
sourcePortIdentity
.
portNumber
);
*
(
UInteger16
*
)
(
buf
+
34
)
=
pp_htons
(
resp_orig_t
stamp
->
secondsField
.
msb
);
*
(
UInteger32
*
)
(
buf
+
36
)
=
pp_htonl
(
resp_orig_t
stamp
->
secondsField
.
lsb
);
*
(
UInteger32
*
)
(
buf
+
40
)
=
pp_htonl
(
resp_orig_t
stamp
->
nanosecondsField
);
pp_memcpy
((
buf
+
44
),
hdr
->
sourcePortIdentity
.
clockIdentity
,
PP_
CLOCK_IDENTITY_LENGTH
);
*
(
UInteger16
*
)
(
buf
+
52
)
=
pp_htons
(
hd
r
->
sourcePortIdentity
.
portNumber
);
}
/*
Unpack PdelayResp message from IN buffer of ptpClock to msgtmp.presp
*/
void
msgUnpackPDelayRespFollowUp
(
void
*
buf
,
MsgPDelayRespFollowUp
*
presp
follow
)
/*
Unpack PdelayResp message from in buffer of ppi to msgtmp.presp
*/
void
msg_unpack_pdelay_resp_followup
(
void
*
buf
,
MsgPDelayRespFollowUp
*
presp_
follow
)
{
presp
follow
->
responseOriginTimestamp
.
secondsField
.
msb
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
34
));
presp
follow
->
responseOriginTimestamp
.
secondsField
.
lsb
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
36
));
presp
follow
->
responseOriginTimestamp
.
nanosecondsField
=
flip32
(
*
(
UInteger32
*
)
(
buf
+
40
));
memcpy
(
prespfollow
->
requestingPortIdentity
.
clockIdentity
,
(
buf
+
44
),
CLOCK_IDENTITY_LENGTH
);
presp
follow
->
requestingPortIdentity
.
portNumber
=
flip16
(
*
(
UInteger16
*
)
(
buf
+
52
));
presp
_follow
->
responseOriginTimestamp
.
secondsField
.
msb
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
34
));
presp
_follow
->
responseOriginTimestamp
.
secondsField
.
lsb
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
36
));
presp
_follow
->
responseOriginTimestamp
.
nanosecondsField
=
pp_htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
pp_memcpy
(
presp_follow
->
requestingPortIdentity
.
clockIdentity
,
(
buf
+
44
),
PP_
CLOCK_IDENTITY_LENGTH
);
presp
_follow
->
requestingPortIdentity
.
portNumber
=
pp_htons
(
*
(
UInteger16
*
)
(
buf
+
52
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment