Yanick

This is the *assembler* list. It is *not* a list where you can expect
everyone to be familiar with the peculiarities of the old C sockets API.
That list is the IBMTCP-L list:

For IBMTCP-L subscribe / signoff / archive access instructions, send email
to [email protected] with the message: INFO IBMTCP-L

Note that some of the denizens of the IBMTCP-L list do indulge in using the
assembler flavour of what is/was originally the old C sockets API so these
folk will be able to provide reliable answers.

Note that, if you insist on using the assembler list, you had better provide
some help to any who may be tempted to try to reply by providing manual
references.

For example Barry would have stood some chance of providing you with
reliable responses if he had know where the gethostbyaddr call is documented
and how it actually works.

It is evident that Barry is unfamiliar with the peculiarity of the calls
which return the address a hostent structure in that - sound the trumpets! -
they return the address of a hostent structure! This is *not* intuitive. It
goes somewhat against the grain of the sort of tidy mind which I'm sure
Barry has that a programming interface should do anything as rash as
committing its own precious storage - that is, precious storage for which
the logic supporting the interface has taken ownership - to the user without
having any idea when it might be able to retrieve the ownership so that it
can tidy up by returning it to the "free pool".

You can read about the original C version of gethostbyaddr here:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/f1a1d490/3.1.9.12

and the derived assembler version here:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/f1a1d490/3.3.12.11

I've worked with the C version - long, long ago - in preparation for
teaching the topic in fact - and until now I was only aware of the chapter
where the assembler version was covered. Now I take a peek at it, surely
that diagram Figure 64, "HOSTENT structure returned by the GETHOSTBYADDR
macro" answers your question - and a number of others!

If not, please post again and specify what you cannot understand.

The only point I needed to look at twice for reassurance is that "Name
X'00'" almost certainly, following the C convention, means a character
string corresponding to the name with a null byte, a byte with the value
X'00', as the last byte of storage in order to provide the programmer with
the information needed to know that the immediately preceding byte was the
last byte of the actual name.

Note that the following in the description of the assembler version of the
gethostbyaddr call helps understand how the API uses storage, the point I
made earlier:

<quote>

GETHOSTBYADDR returns the HOSTENT structure shown in Figure 64. The HOSTENT
structure is a tasks's serially reusable storage area. It should not be used
or referenced between MVS tasks. The storage is freed when the task
terminates.

</quote>

What this means is that you had better have extracted every last morsel of
information from the hostent structure - and all the referenced variable
length fields - following one call of the type of call which causes the
returned hostent structure to be populated before you try another such call.

Well, I'd got this far before I noticed that your assembler macro is *not*
the same - although having many similarities - as the EZASMI macro in the
z/OS Communications Server IP Sockets Application Programming Interface
Guide and Reference manual.

This means that you really need to explain what is the origin of what I
imagine is the #SOCKET macro should you need to post again - together with
an online reference if at all possible. That will apply equally here in the
assembler list and also if you decide to post in the IBMTCP-L list.

Meantime I strongly suspect that that Figure 64 will answer most if not all
of your questions.

-

Note that I used, the term "old C sockets API" because, if your platform is
z/OS - and I am not now quite so sure that it is!, you need to be aware that
you are now expected to use the z/OS UNIX System Services C API in
preference - or any assembler derivative. You need to know that the set of
"resolver" API calls has been redesigned for this more recent environment.
Perhaps you should regard what you are doing now as "learning the ropes" so
that you can advance to the more recent implementation of "resolver" calls
in the future - and be "IPv6-ready".

-

Chris Mason

----- Original Message -----
From: "Yanick Jacques" <[email protected]>
To: <[email protected]>
Sent: Thursday, January 05, 2012 7:30 PM
Subject: How to display content of an address that point to a struct


I'm avancing in my developpement,now i receive the pointers to the
HOSTENTD struct. Can someone can help me write the name of the hostname to
the log .How can I obtain the content of an address ex: H@NAME ?


HOSTENTD DSECT ,
*
H@NAME   DS    A              A(hostname)
H@ALIAS  DS    A              A(zero-terminated array of aliases)
H@ADDRTY DS    F              Family of returned addresses
H@LENGTH DS    F              Length of returned addresses
H@ADDRLS DS    A              A(zero-terminated array of addresses)
*
HOSTENTL EQU   *-HOSTENTD     Length of HOSTENT main table




Here's what I'm doing.

#SOCKET GETHOSTBYADDR,IPADDR=HOSTIPA,IPADDRL=4,               X
      DOMAIN=AF@INET,HOSTENTP=(R2),                           X
      RETCODE=RETCODE,ERRNO=ERRNO,RSNCODE=RSNCODE
LA R1,MSG15 DISPLAY GETHOSTBYADDR RESULTS
L R15,=A(DISRC)
BALR R14,R15 DISPLAY THE 3 RETURN CODES
CLC RETCODE,=F'0' GETHOSTBYADDR SUCCESSFUL?
BNE TCPCLOSE N. CLOSE SOCKET AND EXIT.
USING HOSTENTD,R2
LA    R6,H@NAME
ST    R6,MYHOST
LA    R1,MSG16 .
L     R15,=A(DISLINE)
BALR  R14,R15




DISLINE  DS 0H
        #SAVEREG SAVE THE CALLER'S REGISTERS
        LR R12,R15
        USING DISLINE,R12
        LR R3,R1 GET PARM IN R3
*
        #WTL MSGID=M#999043,MSGDICT=NO,OVRIDES=OVRLOG,                X
              PARMS=((R3)),RGSV=(R2-R8)
*
        #RESTREG RESTORE THE CALLER'S REGISTERS


Thanks

Reply via email to