The Convert IP Address command checks an Internet Address for a valid
format. TAA9892 is sent if the address is not in the correct format.
If a 'generic like' IP address is entered, a low and high range of
addresses are returned. If a 'generic like' IP address is not
entered, a full address is returned. The intent of the command is to
return values that can be easily processed by a program.
A typical set of commands would be:
DCL &FULLADR *CHAR LEN(15)
.
CVTIPADR INTNETADR(123.301.200.245) RTNADR(&FULLADR)
In this example, the input value does not contain any 'generic like'
addresses. See the later CL coding example that would include
'generic like' input values.
Since a full address was input (all 15 characters), the exact same
address is returned.
The following chart describes some input values and the corresponding
returned full address when a set contains less than 3 digits, but is
not 'generic like'.
Input Address Returned address
------------- ----------------
123.201.056.1 123.201.056.001
123.201.056.10 123.201.056.010
123.2.056.10 123.002.056.010
123.2.56.10 123.002.056.010
123.0.56.10 123.000.056.010
123.0.0.1 123.000.000.001
'Generic like' addresses are written with a single 0 in the last set
of 3 digits or 0.0 as the last two sets, etc. If a 'generic like'
address is entered, the low and high range return values will be
provided.
The following chart describes some input values containing 'generic
like' values and the corresponding low and high range addresses
returned.
Input Address Low Range address High Range Address
------------- ----------------- ------------------
123.101.212.0 123.101.212.000 123.101.212.255
123.101.0.0 123.101.000.000 123.101.255.255
123.0.0.0 123.000.000.000 123.255.255.255
0.0.0.0 000.000.000.000 255.255.255.255
123.0.212.0 123.000.212.000 123.000.212.255
123.0.12.0 123.000.012.000 123.000.012.255
Note that the 5th example has a 0 in the 2nd set, but since the 3rd
set is not 'generic like', 000 is used as the value for the 2nd set.
The 6th example also shows a similar value.
If an address like 123.0.0.1 is entered, the value is not considered
'generic like' (because the last set is not 0) and a full address of
123.000.000.001 will be returned.
Error conditions
----------------
** Number of periods is not 3
** Consecutive periods exist
** More than 3 consecutive digits
** A set of three digits exceeds a value of 255
** Non-digit values (except for periods) exist
** Embedded blanks exist
If an error occurs, the TAA9892 message is sent as an escape message
with the text describing the specific error.
Typical coding
--------------
The following would represent typical coding when the input value is
a variable that could contain any form of an IP address. This code
is in a format that may be copied into a CL program.
PGM PARM(&INPADR)
DCL &INPADR *CHAR LEN(15)
DCL &FULLADR *CHAR LEN(15)
DCL &LORNG *CHAR LEN(15)
DCL &HIRNG *CHAR LEN(15)
CVTIPADR INTNETADR(&INPADR) RTNADR(&FULLADR) +
LORNG(&LORNG) HIRNG(&HIRNG)
/********************************************/
/* */
/* If TAA9892 handle a bad address */
/* */
/********************************************/
MONMSG MSGID(TAA9892) EXEC(DO) /* Bad address */
/* */
/* Your processing of a bad address */
/* */
ENDDO /* Bad address */
/********************************************/
/* */
/* If a Full Address exists, no */
/* 'generic like' address was input */
/* */
/********************************************/
IF (&FULLADR *NE ' ') DO /* Full address */
/* */
/* Your processing of a full address */
/* */
ENDDO /* Full address */
/********************************************/
/* */
/* A 'generic like' address was input */
/* */
/********************************************/
/* */
/* Your processing of the &LORNG */
/* and &HIRNG variables */
/* */
CVTIPADR escape messages you can monitor for
--------------------------------------------
TAA9892 The address is not valid.
Escape messages from based on functions will be re-sent.
Command parameters *CMD
------------------
INTNETADR The internet address to be converted. The address
can be a maximum of 15 characters in the format of
an internet address such as '123.201.145.003' or
'123.1.145.3'. A 'generic like' type of entry is
also valid such as '123.201.145.0' or '123.201.0.0'
or '123.0.0.0'.
RTNADR A return value that will contain the full address of
the INTNETADR value if a 'generic like' address did
not exist. If a 'generic like' address was entered,
this field will be blank. If used, the return
variable must be specified as *CHAR LEN(15).
LORNG A return value that will contain the low range
address of the INTNETADR value if a 'generic like'
address exists. If a 'generic like' address did not
exist, this field will be blank. If used, the
return variable must be specified as *CHAR LEN(15).
For example, if '123.201.145.0' is entered the low
range returned would be '123.201.145.000'.
HIRNG A return value that will contain the high range
address of the INTNETADR value if a 'generic like'
address exists. If a 'generic like' address did not
exist, this field will be blank. If used, the
return variable must be specified as *CHAR LEN(15).
For example, if '123.201.145.0' is entered the high
range returned would be '123.201.145.255'.
Restrictions
------------
The format of the address must meet the requirements outlined
previously to be considered valid.
Prerequisites
-------------
The following TAA Tools must be on your system:
EDTVAR Edit variable
SNDESCMSG Send escape message
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
CVTIPADR *CMD TAATCPC QATTCMD
TAATCPCC *PGM CLP TAATCPCC QATTCL
|