ptp.c
void ptp_write_binary_timestamps(void *pPayload, struct TimestampI *ts, uint8_t n)
{
    uint8_t *p = ((uint8_t*) pPayload) + PTP_HEADER_LENGTH;

    // write n times
    uint8_t i;
    for (i = 0; i < n; i++)
    {
        // get timestamp data
        uint64_t sec = htonll(ts->sec << 16);
        uint64_t nanosec = htonl(ts->nanosec);

        // fill in time data
        memcpy(p, &sec, 6); // 48-bit
        p += 6;

        memcpy(p, &nanosec, 4);
        p += 4;

        // step onto next element
        ts++;
    }
}
// wrtie n timestamps after header in to packet (TODO: subjet to further test!)
wrtie n timestamps after header in to packet (TODO: subjet to further test!)
wrtie n timestamps after header in to packet ( TODO : subjet to further test! )
void ptp_write_binary_timestamps(void *pPayload, struct TimestampI *ts, uint8_t n)
{
    uint8_t *p = ((uint8_t*) pPayload) + PTP_HEADER_LENGTH;
    uint8_t i;
    for (i = 0; i < n; i++)
    {
        uint64_t sec = htonll(ts->sec << 16);
        uint64_t nanosec = htonl(ts->nanosec);
        memcpy(p, &sec, 6); 
        p += 6;
        memcpy(p, &nanosec, 4);
        p += 4;
        ts++;
    }
}
void ptp_write_binary_timestamps ( void * pPayload , struct TimestampI * ts , uint8_t n ) { uint8_t * p = ( ( uint8_t * ) pPayload ) + PTP_HEADER_LENGTH ; uint8_t i ; for ( i = 0 ; i < n ; i ++ ) { uint64_t sec = htonll ( ts -> sec << 16 ) ; uint64_t nanosec = htonl ( ts -> nanosec ) ; memcpy ( p , & sec , 6 ) ; p += 6 ; memcpy ( p , & nanosec , 4 ) ; p += 4 ; ts ++ ; } }
wrtie n timestamps after header in to packet (TODO: subjet to further test!)
wrtie n timestamps after header in to packet ( TODO : subjet to further test! )
// write n times // get timestamp data // fill in time data // 48-bit // step onto next element