2 * $Id: RTPSHeader.c,v 0.0.0.1 2003/08/21
4 * DEBUG: section 40 Operations with header of RTPS
6 * -------------------------------------------------------------------
8 * Open Real-Time Ethernet
10 * Copyright (C) 2001-2006
11 * Department of Control Engineering FEE CTU Prague, Czech Republic
12 * http://dce.felk.cvut.cz
13 * http://www.ocera.org
15 * Author: Petr Smolik petr.smolik@wo.cz
17 * Project Responsible: Zdenek Hanzalek
18 * --------------------------------------------------------------------
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
34 /**********************************************************************************/
36 RTPSHeaderCreate(CDR_Codec *cdrCodec,HostId hid,AppId aid) {
37 CDR_Endianness data_endian;
41 CDR_put_octet(cdrCodec,'R');
42 CDR_put_octet(cdrCodec,'T');
43 CDR_put_octet(cdrCodec,'P');
44 CDR_put_octet(cdrCodec,'S');
46 /* Protocol version */
47 PROTOCOL_VERSION_1_0(pv);
48 CDR_put_octet(cdrCodec,pv.major);
49 CDR_put_octet(cdrCodec,pv.minor);
52 VENDOR_ID_UNKNOWN(vid);
53 CDR_put_octet(cdrCodec,vid.major);
54 CDR_put_octet(cdrCodec,vid.minor);
56 /* next data are sent in big endianing */
57 data_endian=cdrCodec->data_endian;
58 cdrCodec->data_endian=FLAG_BIG_ENDIAN;
61 CDR_put_ulong(cdrCodec,hid);
64 CDR_put_ulong(cdrCodec,aid);
66 cdrCodec->data_endian=data_endian;
70 /**********************************************************************************/
72 RTPSHeaderCheck(CDR_Codec *cdrCodec,int32_t len,MessageInterpret *mi) {
73 CDR_Endianness data_endian;
76 if (len<16) return -1; /* message is too small */
77 CDR_get_octet(cdrCodec, (CORBA_octet *)&c);
78 if (c!='R') return -2; /* header is invalid */
79 CDR_get_octet(cdrCodec, (CORBA_octet *)&c);
80 if (c!='T') return -2;
81 CDR_get_octet(cdrCodec, (CORBA_octet *)&c);
82 if (c!='P') return -2;
83 CDR_get_octet(cdrCodec, (CORBA_octet *)&c);
84 if (c!='S') return -2;
86 /* Protocol Version */
87 CDR_get_octet(cdrCodec, (CORBA_octet *)&mi->sourceVersion.major);
88 CDR_get_octet(cdrCodec, (CORBA_octet *)&mi->sourceVersion.minor);
91 CDR_get_octet(cdrCodec, (CORBA_octet *)&mi->sourceVendorId.major);
92 CDR_get_octet(cdrCodec, (CORBA_octet *)&mi->sourceVendorId.minor);
94 /* next data are sent in big endianing */
95 data_endian=cdrCodec->data_endian;
96 cdrCodec->data_endian=FLAG_BIG_ENDIAN;
99 CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&mi->sourceHostId);
102 CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&mi->sourceAppId);
104 cdrCodec->data_endian=data_endian;
106 mi->haveTimestamp=ORTE_FALSE; /* false */