]> rtime.felk.cvut.cz Git - orte.git/blob - orte/liborte/RTPSInfoREPLY.c
ddb91725040f9bfbd0d91aca917625e7243fd494
[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.smolik@wo.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) return -1;
41
42   /* submessage id */
43   CDR_put_octet(cdrCodec,INFO_REPLY);
44
45   /* flags */
46   flags=cdrCodec->data_endian;
47   CDR_put_octet(cdrCodec,flags);
48
49   /* length */
50   CDR_put_ushort(cdrCodec,8);
51
52   /* ipaddress */
53   CDR_put_ulong(cdrCodec,ipaddress);
54
55   /* port */
56   CDR_put_ulong(cdrCodec,port);
57   return 12;
58
59
60 /**********************************************************************************/
61 void 
62 RTPSInfoREPLY(CDR_Codec *cdrCodec,MessageInterpret *mi) 
63 {
64   CORBA_octet        flags;  
65   IPAddress          ipa;
66   Port               port;
67
68   /* restore flag possition in submessage */
69   cdrCodec->rptr-=3;
70
71   /* flags */
72   CDR_get_octet(cdrCodec, (CORBA_octet *)&flags);
73
74   /* move reading possition to begin of submessage */
75   cdrCodec->rptr+=2;
76
77   /* unicastReplyIPAddress */
78   CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&ipa);
79   
80   /* unicastReplyPort */
81   CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&port);
82   
83   debug(43,3) ("recv: RTPS InfoREPLY from 0x%x-0x%x\n",
84                 mi->sourceHostId,mi->sourceAppId);
85
86   if (ipa!=IPADDRESS_INVALID) {
87     mi->unicastReplyIPAddress=ipa;
88   }
89   mi->unicastReplyPort=port;
90
91   if (flags & 0x02) {
92     /* multicastReplyIPAddress */
93     CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&ipa);
94
95     /* multicastReplyPort */
96     CDR_get_ulong(cdrCodec, (CORBA_unsigned_long *)&port);
97
98     mi->multicastReplyIPAddress=ipa;
99     mi->multicastReplyPort=port;
100   } else {
101     mi->multicastReplyIPAddress=IPADDRESS_INVALID;
102     mi->multicastReplyPort     =PORT_INVALID;
103   }
104 }
105