]> rtime.felk.cvut.cz Git - orte.git/blob - orte/liborte/RTPSInfoREPLY.c
6f34b28ad08e2cca60d0bad4480d530a604bfe21
[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  *  AUTHOR: Petr Smolik                 petr.smolik@wo.cz
6  *
7  *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
8  *  --------------------------------------------------------------------
9  *
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.
14  *  
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.
19  *  
20  */ 
21
22 #include "orte_all.h"
23
24 /**********************************************************************************/
25 int 
26 RTPSInfoREPLYCreate(CDR_Codec *cdrCodec,IPAddress ipaddress,Port port)
27 {
28   CORBA_octet flags;
29
30   if (cdrCodec->buf_len<cdrCodec->wptr+12) return -1;
31
32   /* submessage id */
33   CDR_put_octet(cdrCodec,INFO_REPLY);
34
35   /* flags */
36   flags=cdrCodec->data_endian;
37   CDR_put_octet(cdrCodec,flags);
38
39   /* length */
40   CDR_put_ushort(cdrCodec,8);
41
42   /* ipaddress */
43   CDR_put_ulong(cdrCodec,ipaddress);
44
45   /* port */
46   CDR_put_ulong(cdrCodec,port);
47   return 12;
48
49
50 /**********************************************************************************/
51 void 
52 RTPSInfoREPLY(CDR_Codec *cdrCodec,MessageInterpret *mi) 
53 {
54   CORBA_octet        flags;  
55   IPAddress          ipa;
56   Port               port;
57
58   /* restore flag possition in submessage */
59   cdrCodec->rptr-=3;
60
61   /* flags */
62   CDR_get_octet(cdrCodec,&flags);
63
64   /* move reading possition to begin of submessage */
65   cdrCodec->rptr+=2;
66
67   /* unicastReplyIPAddress */
68   CDR_get_ulong(cdrCodec,&ipa);
69   
70   /* unicastReplyPort */
71   CDR_get_ulong(cdrCodec,&port);
72   
73   debug(43,3) ("recv: RTPS InfoREPLY from 0x%x-0x%x\n",
74                 mi->sourceHostId,mi->sourceAppId);
75
76   if (ipa!=IPADDRESS_INVALID) {
77     mi->unicastReplyIPAddress=ipa;
78   }
79   mi->unicastReplyPort=port;
80
81   if (flags & 0x02) {
82     /* multicastReplyIPAddress */
83     CDR_get_ulong(cdrCodec,&ipa);
84
85     /* multicastReplyPort */
86     CDR_get_ulong(cdrCodec,&port);
87
88     mi->multicastReplyIPAddress=ipa;
89     mi->multicastReplyPort=port;
90   } else {
91     mi->multicastReplyIPAddress=IPADDRESS_INVALID;
92     mi->multicastReplyPort     =PORT_INVALID;
93   }
94 }
95