]> rtime.felk.cvut.cz Git - orte.git/blob - orte/liborte/RTPSInfoREPLY.c
Reformat the sources with orte/uncrustify script
[orte.git] / orte / liborte / RTPSInfoREPLY.c
1 /*
2  *  $Id: RTPSInfoREPLY.c,v 0.0.0.1      2003/09/1
3  *
4  *  DEBUG:  section 43                  message INFO REPLY
5  *
6  *  -------------------------------------------------------------------
7  *                                ORTE
8  *                      Open Real-Time Ethernet
9  *
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
14  *
15  *  Author:              Petr Smolik    petr@smoliku.cz
16  *  Advisor:             Pavel Pisa
17  *  Project Responsible: Zdenek Hanzalek
18  *  --------------------------------------------------------------------
19  *
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.
24  *
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.
29  *
30  */
31
32 #include "orte_all.h"
33
34 /**********************************************************************************/
35 int
36 RTPSInfoREPLYCreate(CDR_Codec *cdrCodec, IPAddress ipaddress, Port port)
37 {
38   CORBA_octet flags;
39
40   if (cdrCodec->buf_len < cdrCodec->wptr+12)
41     return -1;
42
43   /* submessage id */
44   CDR_put_octet(cdrCodec, INFO_REPLY);
45
46   /* flags */
47   flags = cdrCodec->data_endian;
48   CDR_put_octet(cdrCodec, flags);
49
50   /* length */
51   CDR_put_ushort(cdrCodec, 8);
52
53   /* ipaddress */
54   CDR_put_ulong(cdrCodec, ipaddress);
55
56   /* port */
57   CDR_put_ulong(cdrCodec, port);
58   return 12;
59 }
60
61 /**********************************************************************************/
62 void
63 RTPSInfoREPLY(CDR_Codec *cdrCodec, MessageInterpret *mi)
64 {
65   CORBA_octet        flags;
66   IPAddress          ipa;
67   Port               port;
68
69   /* restore flag possition in submessage */
70   cdrCodec->rptr -= 3;
71
72   /* flags */
73   CDR_get_octet(cdrCodec, (CORBA_octet *)&flags);
74
75   /* move reading possition to begin of submessage */
76   cdrCodec->rptr += 2;
77
78   /* unicastReplyIPAddress */
79   CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&ipa);
80
81   /* unicastReplyPort */
82   CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&port);
83
84   debug(43, 3) ("recv: RTPS InfoREPLY from 0x%x-0x%x\n",
85                 mi->sourceHostId, mi->sourceAppId);
86
87   if (ipa != IPADDRESS_INVALID) {
88     mi->unicastReplyIPAddress = ipa;
89   }
90   mi->unicastReplyPort = port;
91
92   if (flags & 0x02) {
93     /* multicastReplyIPAddress */
94     CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&ipa);
95
96     /* multicastReplyPort */
97     CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&port);
98
99     mi->multicastReplyIPAddress = ipa;
100     mi->multicastReplyPort = port;
101   } else {
102     mi->multicastReplyIPAddress = IPADDRESS_INVALID;
103     mi->multicastReplyPort     = PORT_INVALID;
104   }
105 }