× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Scott,

I would be interested in the API and sample code, especially since Rob has found that DIG does not work 100%.

Paul

-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Monday, May 18, 2015 5:35 PM
To: Midrange Systems Technical Discussion
Subject: Re: Input IPv4 address - return DNS name

IBM i has "resolver" routines built-in that do this sort of thing.  If all you need is IPv4, you could call the gethostbyaddr() API.  There are newer/better routines available that support IPv6 (though, I must admit, it'd take a bit of research for me to find this.)

I wonder if it'd make sense for you to use these routines instead of calling the DIG program?  Nothing wrong with using DIG, I guess...  but calling the APIs directly would be faster, no need to output to a file 
and read a file, it'd return the result directly.   But, it does involve 
some pointer work...

Want a code sample?  (If so, is RPG alright, or does it need to be CL?)

-SK

On 5/18/2015 3:36 PM, Steinmetz, Paul wrote:
> I've created a utility that inputs an IPv4 address and returns the DNS name.
> It uses the DIG command with the out file option.
> Does anything exist that does something similar?
>
> I'm planning on using this as part of a larger project to create and 
> populate a log file of all external communications, (FTP, SSL, SSH, 
> etc)
>
> 0008.00              PGM        PARM(&IPV4 &DNSNAM)
> 0009.00
> 0010.00              /* VARIABLE DECLARATIONS                */
> 0011.00
> 0012.00              DCL        VAR(&IPV4) TYPE(*CHAR) LEN(30)
> 0013.00              DCL        VAR(&DNSNAM) TYPE(*CHAR) LEN(256 )
> 0014.00
> 0015.00              RMVLNK     OBJLNK('/DIGOUT')
> 0016.00
> 0017.00              DIG        HOSTNAME(&IPV4) REVERSE(*YES) +
> 0018.00                           IPVSN(*IPV4ONLY) SHORT(*YES) +
> 0019.00                           IDENTIFY(*YES) TOSTMF(DIGOUT)
> 0020.00
> 0021.00              CPYFRMIMPF FROMSTMF('/DIGOUT') TOFILE(QGPL/DIGOUT) +
> 0022.00                           MBROPT(*REPLACE) RCDDLM(*LF) +
> 0023.00                           RPLNULLVAL(*FLDDFT)
> 0024.00
> 0025.00              CALL       PGM(DIGCONV) PARM(&DNSNAM) /* Search DIG +
> 0026.00                           outfile, find and return DNS name */
> 0027.00
> 0028.00              DMPCLPGM
> 0029.00
> 0030.00  END:        ENDPGM
>
>
> 0001.00 H DEBUG
> 0009.00  **************************************************************************
> 0010.00 Fdigout    ipe  f 3965        disk
> 0011.00  **************************************************************************
> 0012.00 dsearchfor        s             12
> 0013.00  
> **********************************************************************
> ****
> 0014.00  * Input Parameters
> 0015.00 idigout    AA  01
> 0016.00
> 0017.00  * Record type
> 0018.00
> 0019.00 i                                  1 3965  irec
> 0020.00  **************************************************************************
> 0021.00 C     *entry        plist
> 0022.00 C                   parm                    dnsfnd          256
> 0023.00
> 0024.00 c                   eval      searchfor = 'from server '
> 0025.00 c                   exsr      search
> 0026.00  **************************************************************************
> 0027.00 C     search        begsr
> 0028.00  
> **********************************************************************
> ****
> 0029.00  /free
> 0030.00                     pos = %scan(searchfor: irec :1);
> 0031.00                     if        pos <> 0;
> 0032.00                     dnsfnd = %Subst(irec:1 :pos-3);
> 0033.00                     endif;
> 0034.00  /end-free
> 0035.00 c                   endsr
>
> Thank You
> _____
> Paul Steinmetz
> IBM i Systems Administrator
>
> Pencor Services, Inc.
> 462 Delaware Ave
> Palmerton Pa 18071
>
> 610-826-9117 work
> 610-826-9188 fax
> 610-349-0913 cell
> 610-377-6012 home
>
> psteinmetz@xxxxxxxxxx
> http://www.pencor.com/
>
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.