]> rtime.felk.cvut.cz Git - orte.git/blob - orte/liborte/RTPSHeader.c
no fill callBack rutine in subscriber cause SIGSEV
[orte.git] / orte / liborte / RTPSHeader.c
1 /*
2  *  $Id: RTPSHeader.c,v 0.0.0.1  2003/08/21 
3  *
4  *  DEBUG:  section 40          Operations with header of RTPS
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 int16_t
26 RTPSHeaderCreate(u_int8_t *msg,HostId hid,AppId aid) {
27   msg[0]='R';msg[1]='T'; msg[2]='P'; msg[3]='S';
28   //Protocol version
29   PROTOCOL_VERSION_1_0((*((ProtocolVersion*)(msg+4))));
30   //Vendor id
31   VENDOR_ID_UNKNOWN((*((VendorId*)(msg+6))));
32   //HID
33   conv_u32(&hid,0);
34   *((HostId*)(msg+8))=hid;
35   //AID
36   conv_u32(&aid,0);
37   *((AppId*)(msg+12))=aid;
38   return 16;
39
40 /**********************************************************************************/
41 int16_t
42 RTPSHeaderCheck(u_int8_t *msg,int32_t len,MessageInterpret *mi) {
43   if (len<16) return -1;                          /* message is too small */
44   if (msg[0]!='R') return -2;                     /* header is invalid */
45   if (msg[1]!='T') return -2;                     /* header is invalid */
46   if (msg[2]!='P') return -2;                     /* header is invalid */
47   if (msg[3]!='S') return -2;                     /* header is invalid */
48   mi->sourceVersion=*((ProtocolVersion*)(msg+4)); /* ProtocolVersion */
49   mi->sourceVendorId=*((VendorId*)(msg+6));       /* Vendor Id */
50   mi->sourceHostId=*((HostId*)(msg+8));           /* Host Id */
51   conv_u32(&mi->sourceHostId,0);
52   mi->sourceAppId=*((AppId*)(msg+12));            /* App Id */
53   conv_u32(&mi->sourceAppId,0);
54   mi->haveTimestamp=ORTE_FALSE;                   /* false */
55   return 0;
56 }
57
58