User Tools

Site Tools


cdc:nos2.source:nam5871:ipucian

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
  1. *DECK IPUCIAN
  2. USETEXT TEXTIPL
  3. PROC IPUCIAN ((CHARADDR), IPADDR);
  4. *CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
  5. # TITLE IPUCIAN - CONVERT IP ADDRESS FROM DISPLAY TO NUMERIC #
  6.  
  7. BEGIN # IPUCIAN #
  8. #
  9. **** IPUCIAN - CONVERT IP ADDRESS FROM DISPLAY TO NUMERIC.
  10. *
  11. * THIS PROCEDURE CONVERTS A DISPLAY CODED ADDRESS IN INTERNET FORM
  12. * TO THE THREE WORD ADDRESS FORMAT USED TO COMMUNICATE TO THE
  13. * TCP/IP CDCNET GATEWAY.
  14. *
  15. * PROC IPPCIAN
  16. *
  17. * ENTRY CHARADDR = ADDRESS IN DISPLAY CODE IP FORMAT.
  18. *
  19. * EXIT IPADDR = ADDRESS IN NUMERIC FORM AS DEFINED BY
  20. * BASED ARRAY IP$ADDR$REC.
  21. *
  22. * METHOD EXTRACT THE FOUR OCTETS FROM *IPADDR*, EACH OCTET IS
  23. * TERMINATED BY A NON-NUMERIC CHARACTER. EACH OCTET IS
  24. * CONVERTED FROM CHARACTER TO NUMBER BY THE *XDXB* ROUTINE
  25. * AND SAVED IN THE OCTET NUMBER ARRAY. THE IP$ADDR$REC
  26. * BASED ARRAY IS SET TO THE *IPADDR* LOCATION. THE FIELDS
  27. * IN USE FIELD IS SET TO BOTH. THE ADDRESS CLASS IS
  28. * DETERMINED BY EXAMINING THE FIRST 2 BITS OF THE FIRST
  29. * OCTET, BASED ON THE ADDRESS TYPE THE APPROPRIATE NUMBER
  30. * OF OCTETS ARE SAVED IN THE NETWORK AND HOST FIELDS OF THE
  31. * ADDRESS.
  32. *
  33. * CLASS A ADDRESS - FIRST BIT = 0.
  34. * NETWORK FIELD - FIRST OCTET.
  35. * HOST FIELD - SECOND, THIRD, AND FOURTH OCTET.
  36. *
  37. * CLASS B ADDRESS - FIRST 2 BITS OF FIRST OCTET = 2.
  38. * NETWORK FIELD - FIRST AND SECOND OCTET.
  39. * HOST FIELD - THIRD AND FOURTH OCTET.
  40. *
  41. * CLASS C ADDRESS - FIRST 2 BITS OF THE FIRST OCTET = 3.
  42. * NETWORK FIELD - FIRST, SECOND, AND THIRD OCTET.
  43. * HOST FIELD - FOURTH OCTET.
  44. *
  45. #
  46.  
  47. #
  48. **** PROC IPUCIAN - XREF LIST
  49. #
  50. XREF
  51. BEGIN
  52. PROC IPUMCLR; # CLEAR MEMORY #
  53. PROC XDXB; # SRVLIB CONVERT DISPLAY TO BIN #
  54. END
  55.  
  56. ITEM CHARADDR C(20); # ADDRESS IN DISPLAY TO CONVERT #
  57. ARRAY IPADDR [00:00] S(1);; # ADDRESS IN NUMERIC FORM #
  58.  
  59. #
  60. **
  61. #
  62.  
  63. ARRAY OCTET [1:4] S(1); # FOUR WORD ARRAY FOR ADDRESS #
  64. BEGIN
  65. ITEM OCTET$NUM U(00,00,60); # OCTET IN NUMERIC FORM #
  66. END
  67.  
  68.  
  69. ITEM DPOS I; # DESTINATION POSITION IN OCTET #
  70. ITEM INDEX I; # LOOP INDEX #
  71. ITEM LOOP I; # LOOP INDEX #
  72. ITEM OCTETCHAR C(10); # DISPLAY CODE OF OCTET TO CONV #
  73. ITEM OCTETNUM U; # VALUE OF CONVERTED OCTET #
  74. ITEM SPOS I; # SOURCE POSITION IN *CHARADDR* #
  75. CONTROL EJECT;
  76.  
  77. #
  78. **** THE FOUR OCTETS ARE EXTRACTED FROM THE DISPLAY CODE ADDRESS.
  79. * EACH OCTET TERMINATES WITH A PERIOD, THE FINAL WITH A SPACE.
  80. #
  81.  
  82. SPOS = 0;
  83.  
  84. FOR INDEX = 1 STEP 1 UNTIL 4
  85. DO
  86. BEGIN
  87. OCTETCHAR = CHARSP$;
  88. DPOS = 0;
  89.  
  90. FOR LOOP = 0
  91. WHILE (C<SPOS, 1>CHARADDR GQ CHAR0$) AND
  92. (C<SPOS, 1>CHARADDR LQ CHAR9$)
  93. DO
  94. BEGIN
  95. C<DPOS, 1>OCTETCHAR = C<SPOS, 1>CHARADDR;
  96. SPOS = SPOS + 1;
  97. DPOS = DPOS + 1;
  98. END
  99. XDXB (OCTETCHAR, 1, OCTETNUM); # CONVERT TO NUMERIC #
  100. OCTET$NUM [INDEX] = OCTETNUM;
  101. SPOS = SPOS + 1; # SKIP NON NUMERIC CHARACTER #
  102. END
  103.  
  104. #
  105. **** SET THE IP_ADDRESS_REC TO THE PASSED *IPADDR* LOCATION AND MOVE
  106. * THE OCTET ARRAY TO THE APPROPRIATE FIELDS.
  107. #
  108.  
  109. IPUMCLR (LOC (IPADDR), 3);
  110. P<IP$ADDR$REC> = LOC (IPADDR);
  111. IP$IPFIU [0] = IP$FIU"BOTH";
  112.  
  113. #
  114. **** IF THE FIRST BIT OF THE FIRST OCTET = 0, THEN CLASS A ADDRESS.
  115. * (NETWORK = 1 OCTET)
  116. #
  117.  
  118. IF B<52, 1> OCTET$NUM [1] EQ 0
  119. THEN
  120. BEGIN # CLASS A #
  121. IP$IPNET [0] = OCTET$NUM [1];
  122. IP$IPHOST [0] = (OCTET$NUM [2] * X"10000") +
  123. (OCTET$NUM [3] * X"100") + OCTET$NUM [4];
  124. END # CLASS A #
  125.  
  126. #
  127. **** IF THE FIRST 2 BITS OF THE FIRST OCTET = 2 THEN CLASS B ADDRESS.
  128. * (NETWORK = 2 OCTETS)
  129. #
  130.  
  131. ELSE IF B<52, 2> OCTET$NUM [1] EQ 2
  132. THEN
  133. BEGIN # CLASS B #
  134. IP$IPNET [0] = (OCTET$NUM [1] * X"100") + OCTET$NUM [2];
  135. IP$IPHOST [0] = (OCTET$NUM [3] * X"100") + OCTET$NUM [4];
  136. END # CLASS B #
  137.  
  138. #
  139. **** IF THE FIRST 3 BITS OF THE FIRST OCTET = 3 THEN CLASS C ADDRESS.
  140. * (NETWORK = 3 OCTETS)
  141. #
  142.  
  143. ELSE IF B<52, 2> OCTET$NUM [1] EQ 3
  144. THEN
  145. BEGIN # CLASS C #
  146. IP$IPNET [0] = (OCTET$NUM [1] * X"10000") +
  147. (OCTET$NUM [2] * X"100") + OCTET$NUM [3];
  148. IP$IPHOST [0] = OCTET$NUM [4];
  149. END # CLASS C #
  150.  
  151. RETURN;
  152.  
  153. END # IPUCIAN #
  154.  
  155. TERM
cdc/nos2.source/nam5871/ipucian.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator