2 * $Id: RTPSHeader.c,v 0.0.0.1 2003/08/21
4 * DEBUG: section 40 Operations with header of RTPS
5 * AUTHOR: Petr Smolik petr.smolik@wo.cz
7 * ORTE - OCERA Real-Time Ethernet http://www.ocera.org/
8 * --------------------------------------------------------------------
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.
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.
24 /**********************************************************************************/
26 RTPSHeaderCreate(u_int8_t *msg,HostId hid,AppId aid) {
27 msg[0]='R';msg[1]='T'; msg[2]='P'; msg[3]='S';
29 PROTOCOL_VERSION_1_0((*((ProtocolVersion*)(msg+4))));
31 VENDOR_ID_UNKNOWN((*((VendorId*)(msg+6))));
34 *((HostId*)(msg+8))=hid;
37 *((AppId*)(msg+12))=aid;
40 /**********************************************************************************/
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 */