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@smoliku.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)
38 CDR_Endianness data_endian;
42 CDR_put_octet(cdrCodec, 'R');
43 CDR_put_octet(cdrCodec, 'T');
44 CDR_put_octet(cdrCodec, 'P');
45 CDR_put_octet(cdrCodec, 'S');
47 /* Protocol version */
48 PROTOCOL_VERSION_1_0(pv);
49 CDR_put_octet(cdrCodec, pv.major);
50 CDR_put_octet(cdrCodec, pv.minor);
53 VENDOR_ID_UNKNOWN(vid);
54 CDR_put_octet(cdrCodec, vid.major);
55 CDR_put_octet(cdrCodec, vid.minor);
57 /* next data are sent in big endianing */
58 data_endian = cdrCodec->data_endian;
59 cdrCodec->data_endian = FLAG_BIG_ENDIAN;
62 CDR_put_ulong(cdrCodec, hid);
65 CDR_put_ulong(cdrCodec, aid);
67 cdrCodec->data_endian = data_endian;
71 /**********************************************************************************/
73 RTPSHeaderCheck(CDR_Codec *cdrCodec, int32_t len, MessageInterpret *mi)
75 CDR_Endianness data_endian;
79 return -1; /* message is too small */
80 CDR_get_octet(cdrCodec, (CORBA_octet *)&c);
82 return -2; /* header is invalid */
83 CDR_get_octet(cdrCodec, (CORBA_octet *)&c);
86 CDR_get_octet(cdrCodec, (CORBA_octet *)&c);
89 CDR_get_octet(cdrCodec, (CORBA_octet *)&c);
93 /* Protocol Version */
94 CDR_get_octet(cdrCodec, (CORBA_octet *)&mi->sourceVersion.major);
95 CDR_get_octet(cdrCodec, (CORBA_octet *)&mi->sourceVersion.minor);
98 CDR_get_octet(cdrCodec, (CORBA_octet *)&mi->sourceVendorId.major);
99 CDR_get_octet(cdrCodec, (CORBA_octet *)&mi->sourceVendorId.minor);
101 /* next data are sent in big endianing */
102 data_endian = cdrCodec->data_endian;
103 cdrCodec->data_endian = FLAG_BIG_ENDIAN;
106 CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&mi->sourceHostId);
109 CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&mi->sourceAppId);
111 cdrCodec->data_endian = data_endian;
113 mi->haveTimestamp = ORTE_FALSE; /* false */