cdc:nos2.source:nam5871:ipucian
Table of Contents
IPUCIAN
Table Of Contents
- [00003] PROC IPUCIAN ((CHARADDR), IPADDR)
- [00005] IPUCIAN - CONVERT IP ADDRESS FROM DISPLAY TO NUMERIC
- [00052] PROC IPUMCLR
- [00053] PROC XDXB
Source Code
- IPUCIAN.txt
- *DECK IPUCIAN
- USETEXT TEXTIPL
- PROC IPUCIAN ((CHARADDR), IPADDR);
- *CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
- # TITLE IPUCIAN - CONVERT IP ADDRESS FROM DISPLAY TO NUMERIC #
- BEGIN # IPUCIAN #
- #
- **** IPUCIAN - CONVERT IP ADDRESS FROM DISPLAY TO NUMERIC.
- *
- * THIS PROCEDURE CONVERTS A DISPLAY CODED ADDRESS IN INTERNET FORM
- * TO THE THREE WORD ADDRESS FORMAT USED TO COMMUNICATE TO THE
- * TCP/IP CDCNET GATEWAY.
- *
- * PROC IPPCIAN
- *
- * ENTRY CHARADDR = ADDRESS IN DISPLAY CODE IP FORMAT.
- *
- * EXIT IPADDR = ADDRESS IN NUMERIC FORM AS DEFINED BY
- * BASED ARRAY IP$ADDR$REC.
- *
- * METHOD EXTRACT THE FOUR OCTETS FROM *IPADDR*, EACH OCTET IS
- * TERMINATED BY A NON-NUMERIC CHARACTER. EACH OCTET IS
- * CONVERTED FROM CHARACTER TO NUMBER BY THE *XDXB* ROUTINE
- * AND SAVED IN THE OCTET NUMBER ARRAY. THE IP$ADDR$REC
- * BASED ARRAY IS SET TO THE *IPADDR* LOCATION. THE FIELDS
- * IN USE FIELD IS SET TO BOTH. THE ADDRESS CLASS IS
- * DETERMINED BY EXAMINING THE FIRST 2 BITS OF THE FIRST
- * OCTET, BASED ON THE ADDRESS TYPE THE APPROPRIATE NUMBER
- * OF OCTETS ARE SAVED IN THE NETWORK AND HOST FIELDS OF THE
- * ADDRESS.
- *
- * CLASS A ADDRESS - FIRST BIT = 0.
- * NETWORK FIELD - FIRST OCTET.
- * HOST FIELD - SECOND, THIRD, AND FOURTH OCTET.
- *
- * CLASS B ADDRESS - FIRST 2 BITS OF FIRST OCTET = 2.
- * NETWORK FIELD - FIRST AND SECOND OCTET.
- * HOST FIELD - THIRD AND FOURTH OCTET.
- *
- * CLASS C ADDRESS - FIRST 2 BITS OF THE FIRST OCTET = 3.
- * NETWORK FIELD - FIRST, SECOND, AND THIRD OCTET.
- * HOST FIELD - FOURTH OCTET.
- *
- #
- #
- **** PROC IPUCIAN - XREF LIST
- #
- XREF
- BEGIN
- PROC IPUMCLR; # CLEAR MEMORY #
- PROC XDXB; # SRVLIB CONVERT DISPLAY TO BIN #
- END
- ITEM CHARADDR C(20); # ADDRESS IN DISPLAY TO CONVERT #
- ARRAY IPADDR [00:00] S(1);; # ADDRESS IN NUMERIC FORM #
- #
- **
- #
- ARRAY OCTET [1:4] S(1); # FOUR WORD ARRAY FOR ADDRESS #
- BEGIN
- ITEM OCTET$NUM U(00,00,60); # OCTET IN NUMERIC FORM #
- END
- ITEM DPOS I; # DESTINATION POSITION IN OCTET #
- ITEM INDEX I; # LOOP INDEX #
- ITEM LOOP I; # LOOP INDEX #
- ITEM OCTETCHAR C(10); # DISPLAY CODE OF OCTET TO CONV #
- ITEM OCTETNUM U; # VALUE OF CONVERTED OCTET #
- ITEM SPOS I; # SOURCE POSITION IN *CHARADDR* #
- CONTROL EJECT;
- #
- **** THE FOUR OCTETS ARE EXTRACTED FROM THE DISPLAY CODE ADDRESS.
- * EACH OCTET TERMINATES WITH A PERIOD, THE FINAL WITH A SPACE.
- #
- SPOS = 0;
- FOR INDEX = 1 STEP 1 UNTIL 4
- DO
- BEGIN
- OCTETCHAR = CHARSP$;
- DPOS = 0;
- FOR LOOP = 0
- WHILE (C<SPOS, 1>CHARADDR GQ CHAR0$) AND
- (C<SPOS, 1>CHARADDR LQ CHAR9$)
- DO
- BEGIN
- C<DPOS, 1>OCTETCHAR = C<SPOS, 1>CHARADDR;
- SPOS = SPOS + 1;
- DPOS = DPOS + 1;
- END
- XDXB (OCTETCHAR, 1, OCTETNUM); # CONVERT TO NUMERIC #
- OCTET$NUM [INDEX] = OCTETNUM;
- SPOS = SPOS + 1; # SKIP NON NUMERIC CHARACTER #
- END
- #
- **** SET THE IP_ADDRESS_REC TO THE PASSED *IPADDR* LOCATION AND MOVE
- * THE OCTET ARRAY TO THE APPROPRIATE FIELDS.
- #
- IPUMCLR (LOC (IPADDR), 3);
- P<IP$ADDR$REC> = LOC (IPADDR);
- IP$IPFIU [0] = IP$FIU"BOTH";
- #
- **** IF THE FIRST BIT OF THE FIRST OCTET = 0, THEN CLASS A ADDRESS.
- * (NETWORK = 1 OCTET)
- #
- IF B<52, 1> OCTET$NUM [1] EQ 0
- THEN
- BEGIN # CLASS A #
- IP$IPNET [0] = OCTET$NUM [1];
- IP$IPHOST [0] = (OCTET$NUM [2] * X"10000") +
- (OCTET$NUM [3] * X"100") + OCTET$NUM [4];
- END # CLASS A #
- #
- **** IF THE FIRST 2 BITS OF THE FIRST OCTET = 2 THEN CLASS B ADDRESS.
- * (NETWORK = 2 OCTETS)
- #
- ELSE IF B<52, 2> OCTET$NUM [1] EQ 2
- THEN
- BEGIN # CLASS B #
- IP$IPNET [0] = (OCTET$NUM [1] * X"100") + OCTET$NUM [2];
- IP$IPHOST [0] = (OCTET$NUM [3] * X"100") + OCTET$NUM [4];
- END # CLASS B #
- #
- **** IF THE FIRST 3 BITS OF THE FIRST OCTET = 3 THEN CLASS C ADDRESS.
- * (NETWORK = 3 OCTETS)
- #
- ELSE IF B<52, 2> OCTET$NUM [1] EQ 3
- THEN
- BEGIN # CLASS C #
- IP$IPNET [0] = (OCTET$NUM [1] * X"10000") +
- (OCTET$NUM [2] * X"100") + OCTET$NUM [3];
- IP$IPHOST [0] = OCTET$NUM [4];
- END # CLASS C #
- RETURN;
- END # IPUCIAN #
- TERM
cdc/nos2.source/nam5871/ipucian.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator