]> rtime.felk.cvut.cz Git - orte.git/blob - orte/liborte/RTPSInfoTS.c
e55bfc83fde4832b43ea275ae88b12f75c8c8d61
[orte.git] / orte / liborte / RTPSInfoTS.c
1 /*
2  *  $Id: RTPSInfoTS.c,v 0.0.0.1         2003/09/10
3  *
4  *  DEBUG:  section 45                  message INFO TS
5  *  AUTHOR: Petr Smolik                 petr.smolik@wo.cz
6  *
7  *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
8  *  --------------------------------------------------------------------
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *  
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *  
20  */ 
21
22 #include "orte.h"
23
24 /**********************************************************************************/
25 int32_t 
26 RTPSInfoTSCreate(u_int8_t *rtps_msg,u_int32_t max_msg_len,NtpTime time) {
27   if (max_msg_len<12) return -1;
28   rtps_msg[0]=(u_int8_t)INFO_TS;
29   rtps_msg[1]=ORTE_MY_MBO; //I-bit = 0
30   *((ParameterLength*)(rtps_msg+2))=8;
31   *((NtpTime*)(rtps_msg+4))=time;
32   return 0;
33 }
34
35 /**********************************************************************************/
36 void 
37 RTPSInfoTS(u_int8_t *rtps_msg,MessageInterpret *mi) {
38   int8_t   e_bit=rtps_msg[1] & 0x01;
39   int32_t  sec,msec;
40
41   if ((rtps_msg[1] & 0x02)==0) {               /* I = bit */
42     mi->haveTimestamp=ORTE_TRUE;
43     mi->timestamp=*((NtpTime*)(rtps_msg+4));
44     conv_sn((SequenceNumber*)&mi->timestamp,e_bit);
45   } else {
46     mi->haveTimestamp=ORTE_FALSE;
47     NTPTIME_ZERO(mi->timestamp);
48   }
49   NtpTimeDisAssembToMs(sec,msec,mi->timestamp);
50   if (mi->haveTimestamp)
51     debug(45,3) ("recv: RTPSInfoTS, timestamp %lis %lims\n",sec,msec);
52   else
53     debug(45,3) ("recv: RTPSInfoTS\n");
54 }