From: magardner2010 <magardner2010@gmail.com>
Subject: gnat -xdr flag confusion.
Date: Tue, 4 Jul 2023 13:56:26 +0300 [thread overview]
Message-ID: <u80tsr$33eu$1@dont-email.me> (raw)
I'm still working on the p2p one-to-many data streaming protocol thing
(at https://github.com/smeagolthellama/szakdolgozat-notes/tree/main/ada)
and I'm trying to get it to communicate with a C thing via the xdr
protocol. I'm trying to transfer a Child_Set, where
```
type Child_Number is range 0 .. 2;
subtype Child_Index is Child_Number range 1 .. Child_Number'Last;
type Child_Set is array (Child_Index) of GNAT.Sockets.Sock_Addr_Type;
```
With the help of chatGPT, I wrote the following xdr spec file:
```
const CHILD_NUMBER = 2;
typedef unsigned int uint32;
typedef unsigned char uint8;
enum family_type {
FAMILY_INET = 0,
FAMILY_INET6 = 1,
FAMILY_UNIX = 2,
FAMILY_UNSPEC = 3
};
union inet_addr_type switch (family_type family) {
case FAMILY_INET:
opaque sin_v4[4];
case FAMILY_INET6:
opaque sin_v6[16];
default:
void;
};
struct address_and_port{
inet_addr_type addr;
unsigned int port;
};
union sock_addr_type switch (family_type family) {
case FAMILY_UNIX:
string name<>;
case FAMILY_INET:
address_and_port anp4;
case FAMILY_INET6:
address_and_port anp6;
case FAMILY_UNSPEC:
void;
};
struct child_set {
sock_addr_type child_set_array[CHILD_NUMBER];
};
```
and using rpcgen, generated a C thing to encode/decode the messages the
ada program is sending.
However, if the ada code encodes the object with 'write, then it creates
something about 4 bytes too short, and if I use 'output, it is parsed as
starting with family_type 256, which is not a member of the enum. Given
that the gnat documentation for the -xdr flag is literally two lines, I
don't really know where to look for more information on what I'm doing
wrong. My current hypotheses include the C code having the family type
recorded too many times (but I don't know how to check or fix that in
the .x file) or the ada code not encoding the data according to the xdr
standard correctly (but I am using the flag, and neither 'write or
'output fixes it).
next reply other threads:[~2023-07-04 10:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-04 10:56 magardner2010 [this message]
2023-07-04 11:39 ` gnat -xdr flag confusion Dmitry A. Kazakov
2023-07-06 17:32 ` magardner2010
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox