User Tools

Site Tools


cdc:nos2.source:nam5871:ippbins

IPPBINS

Table Of Contents

  • [00004] PROC IPPBINS (SOCKID, PORT, SOCKSTATUS)
  • [00006] IPPBINS - BIND SOCKET
  • [00041] PROC IPPRECV
  • [00042] PROC IPUMCLR
  • [00043] PROC NETPUT
  • [00044] PROC XDRBYTE
  • [00045] PROC XDRINT

Source Code

IPPBINS.txt
  1. *DECK IPPBINS
  2. USETEXT TEXTIPL
  3. USETEXT TEXTXDR
  4. PROC IPPBINS (SOCKID, PORT, SOCKSTATUS);
  5. *CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
  6. # TITLE IPPBINS - BIND SOCKET #
  7.  
  8. BEGIN # IPPBINS #
  9. #
  10. **** IPPBINS BIND SOCKET
  11. *
  12. * THIS PROCEDURE BINDS AN IP ADDRESS AND A PORT TO A SOCKET.
  13. *
  14. * PROC IPPBINS
  15. *
  16. * ENTRY SOCKID = INTEGER VALUE OF SOCKET
  17. * PORT = INTEGER VALUE OF PORT. IF THE PORT NUMBER
  18. * IS 0 THEN THE PORT IS ASSIGNED BY THE CDCNET
  19. * TCP/IP GATEWAY.
  20. *
  21. * EXIT SOCKSTATUS = COMPLETION STATUS
  22. *
  23. * METHOD IF THE SOCKET STATE IS NOT OPEN THEN RETURN WITH AN
  24. * APPROPRIATE STATUS INDICATION BASED ON THE CURRENT
  25. * STATE. IF THE SOCKET IS USING THE *UDP* PROTOCOL, THEN
  26. * SEND AN OPEN SAP REQUEST TO THE CDCNET TCP/IP GATEWAY.
  27. * IF A *PORT* IS NON-ZERO, INCLUDE IN THE ADDRESS PORTION
  28. * OF THE CALL REQUEST. THE PROCEDURE IPPRECV IS CALLED
  29. * TO WAIT FOR A CALL INDICATION FROM THE TCP/IP GATEWAY.
  30. * IF A RESPONSE IS NOT RECEIVED IN 60 SECONDS OR IF DATA
  31. * OTHER THAN A CALL RESPONSE IS RECEIVED, RETURN AN ERROR.
  32. * IF A VALID RESPONSE IS RECEIVED, STORE THE SOURCE ADDRESS
  33. * IN THE ACN ENTRY AND RETURN.
  34. #
  35.  
  36. #
  37. **** PROC IPPBINS - XREF LIST
  38. #
  39. XREF
  40. BEGIN
  41. PROC IPPRECV; # RECEIVE BLOCK OF DATA #
  42. PROC IPUMCLR; # MEMORY CLEAR #
  43. PROC NETPUT; # OUTPUT A MESSAGE TO THE NETWORK #
  44. PROC XDRBYTE; # CONVERT BYTES TO XDR FORMAT #
  45. PROC XDRINT; # CONVERT INTEGERS TO XDR FORMAT #
  46. END
  47. #
  48. **
  49. #
  50. ITEM SOCKID I; # SOCKET IDENTIFIER #
  51. ITEM PORT I; # PORT NUMBER #
  52. ITEM SOCKSTATUS S:SOCKSTAT; # RETURNED SOCKET STATUS #
  53.  
  54. ITEM BUFLENGTH I; # LENGTH OF RECEIVE BUFFER #
  55. ITEM BUFPOS I; # CURRENT POSITION IN BUFFER #
  56. ARRAY ADDRESS [00:00] S(ADDSIZE$);;# SOURCE ADDRESS FROM CALL RES#
  57. BASED ARRAY IPADDR [00:00] S(1);;# SOURCE ADDRESS FOR XDR CALL #
  58. CONTROL EJECT;
  59.  
  60. #
  61. **** START MAIN PROCEDURE
  62. #
  63.  
  64. IF ACN$STATE [SOCKID] NQ S"OPEN"
  65. THEN
  66. BEGIN
  67. SOCKSTATUS = SOCKSTAT"INVALIDST";
  68. RETURN;
  69. END
  70.  
  71. IF (ACN$ABORT [SOCKID])
  72. THEN
  73. BEGIN # CONNECTION ABORTED #
  74. SOCKSTATUS = S"ABORT";
  75. RETURN;
  76. END
  77.  
  78. SWITCH SOCK$:PTYPE SOCK$UDP:SOCKETUDP,
  79. SOCK$TCP:SOCKETTCP;
  80.  
  81. GOTO SOCK$ [ACN$PTYPE [SOCKID]];
  82. BEGIN # SOCKET TYPE #
  83.  
  84. SOCK$UDP:
  85. BUFPOS = 0; # INITIALIZE BUFFER POSITION #
  86.  
  87. P<IP$ADDR$REC> = LOC (HST$ADDR);
  88. P<IPADDR> = LOC (HST$ADDR) + 1;# LOCATION FOR XDR ROUTINES #
  89. IP$UDPORT = 0; # CLEAR PORT OF LOCAL HOST ADDR #
  90.  
  91. IF PORT NQ 0
  92. THEN
  93. BEGIN # ADD PORT TO THE HOST ADDRESS #
  94. IP$PIU = TRUE; # SET PORT IN USE #
  95. IP$PORT = PORT;
  96. END
  97.  
  98. #
  99. **** PACK THE CALL REQUEST FOR THE UDP INTERFACE INTO *OUTBUF*.
  100. * THE REQUEST CONSISTS OF THE CALL TYPE, UDP VERSION, A BYTE
  101. * INDICATING WHAT IP ADDRESS FIELDS ARE INCULDED, AND THREE 32
  102. * BIT INTEGERS INCLUDING THE NETWORK, HOST, AND PORT. THE NETWORK
  103. * AND HOST PORTION COME FROM THE COMMON HST$ADDR ARRAY.
  104. #
  105.  
  106. IPUMCLR (LOC (OUTBUF), 4); # CLEAR 4 WORDS OF OUTPUT #
  107. UDP$HEADER [0] = CALLREQ$;
  108. UDP$FIU [0] = IP$IPFIU [0];
  109. XDRBYTE (OUTBUF, BUFPOS, UDP$HEAD$REC, 4, XDROPER"WRITE");
  110. XDRINT (OUTBUF, BUFPOS, IPADDR, 3, XDROPER"WRITE");
  111. BUFPOS = BUFPOS + 14; # DESTINATION ADDRESS ZERO #
  112.  
  113. P<ABH> = LOC (DABH); # BASE ABH POINTER #
  114. ABHADR [0] = SOCKID; # STORE CONNECTION NUMBER #
  115. ABHABN [0] = ACN$ABN [SOCKID]; # STORE APPLICATION BLOCK NUMBER#
  116. ABHTLC [0] = BUFPOS; # STORE TEXT LENGTH IN BYTES #
  117. ACN$ABN [SOCKID] = ACN$ABN [SOCKID] + 1;
  118. ACN$OBC [SOCKID] = ACN$OBC [SOCKID] + 1;
  119. NETPUT (DABH, OUTBUF); # SEND THE REQUEST #
  120.  
  121. #
  122. **** WAIT FOR A RESPONSE FROM THE BIND. ONCE RECEIVED VERIFY THAT THE
  123. * RESPONSE IS A CALL RESPONSE. SAVE THE RETURNED IP ADDRESS IN
  124. * THE ACN SOCKET ENTRY.
  125. *
  126. #
  127.  
  128. IPPRECV (SOCKID, WORKBUF, BUFLENGTH, ADDRESS, SOCKSTATUS);
  129.  
  130. IF (SOCKSTATUS NQ S"OK") OR
  131. (REC$REQ [0] NQ CALLRES$)
  132. THEN
  133. BEGIN # BIND FAILED #
  134. SOCKSTATUS = S"REQFAIL";
  135. END
  136. ELSE
  137. BEGIN # MOVE IP ADDRESS TO ACN ENTRY #
  138. P<IP$ADDR$REC> = LOC (ADDRESS);
  139. ACN$SIPFIU [SOCKID] = IP$IPFIU [0];
  140. ACN$SIPHOST [SOCKID] = IP$IPHOST [0];
  141. ACN$SIPNET [SOCKID] = IP$IPNET [0];
  142. ACN$SIUPORT [SOCKID] = IP$UDPORT [0];
  143. ACN$STATE [SOCKID] = S"BOUND";
  144. SOCKSTATUS = S"OK";
  145. END
  146.  
  147. GOTO BIND$END;
  148.  
  149. SOCK$TCP:
  150. GOTO BIND$END;
  151. END # SOCKET TYPE #
  152.  
  153. BIND$END:
  154.  
  155. RETURN; # RETURN TO CALLER #
  156.  
  157. END # IPPBINS #
  158.  
  159. TERM
cdc/nos2.source/nam5871/ippbins.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator