help / color / mirror / Atom feed
From: magardner2010 <>
Subject: Re: gnat -xdr flag confusion.
Date: Thu, 6 Jul 2023 20:32:10 +0300	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <u810dh$12i2$>

On 04/07/2023 14:39, Dmitry A. Kazakov wrote:
> On 2023-07-04 12:56, magardner2010 wrote:
>> ...
> You never defined the protocol and implemented it in the first place. 
> You used some code generation tools which, if ever worked, will bite you 
> in the end.

With regards to the code generation tool (which I'm assuming refers to 
chtGPT, for which I don't have enough creatively insulting backronyms), 
I spent a good half a day getting the output to actually be accepted by 
rpcgen. I then rewrote most of it from scratch.

With regards to the protocol implementation, I would like to point at 
the function that begins at 
, which has successfully communicated with other instances of itself, 
albeit using 'write and 'read to handle anything more complicated than 
"is the first character of the message a '?', a 'j', or a '>'?". My 
question was about how to get C to understand the language Ada is 
talking to itself in, given that that language should be at least 
related to XDR.

> To summarize the problem. The stream attribute 'Write writes the 
> constrained object. 'Output adds the constraints. Ada is capable to have 
> variable length records. C cannot do this. In short, it means that XDR's 
> discriminated union can be mapped onto Ada's variant record with no 
> default discriminant, but it cannot be directly mapped onto C's union. I 
> presume that GNAT implements XDR correctly and the C side does not cope.

I'm not sure I understand what you're saying here. Given that rpcgen 
(which generates functions for xdr, as well as rpc, a superset thereof) 
was a part of GNU's libc for a while, and still is on some ubuntu boxes, 
along with the fact that a number of Linux's favourite protocols (such 
as NFS) are implemented using it, I don't think the issue is the C side 
implementing the encoder/decoder in a way that doesn't match my spec. I 
expect either an Ada issue, a spec issue, or both.

> Which is one of thousand reasons not to implement a communication 
> protocol by deriving representation from some language objects. Cutting 
> corners will not help you.

I suppose there is wisdom in that, especially when attempting to 
communicate across architectures, but I was working under the assumption 
that the -xdr flag would remove the issue, as XDR is an 
architecture-and-programming-language-agnostic data encoding/decoding 
standard (or whatever an RFC counts as).

> Define the (application level [*]) protocol. Implement it in Ada. 
> Implement it in C. Done.
> ---------------------
> *  XDR or ASN.1 or whatever are not application level!

I wouldn't have called XDR a protocol in the first place, except as a 
simplification. I would like to use it as a *part* of my protocol, not 
dissimilar to how NFS does, or programs that use G*ogle's protobuf thingie.

Specifically, when a peer receives a query (in the form of a message 
starting with '?'), it should respond with a lump of data (current idea 
is the Child_Set type from my previous post, encoded in the XDR format, 
hence the difficulties) saying how many peers it has (in range 0..2), 
and who they are (address-port combinations, where address can be IPv4 
or 6), so that the querying party can find out if there is space for it 
on this peer, or if it should look elsewhere. There are a couple of edge 
cases, but this if you are curious you can look at my code.

      reply	other threads:[~2023-07-06 17:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04 10:56 gnat -xdr flag confusion magardner2010
2023-07-04 11:39 ` Dmitry A. Kazakov
2023-07-06 17:32   ` magardner2010 [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox