User Tools

Site Tools


cdc:nos2.source:nam5871:ipprecv

IPPRECV

Table Of Contents

  • [00004] PROC IPPRECV (SOCKID, BUFFER, BUFLEN, ADDRESS, SOCKSTATUS)
  • [00006] IPPRECV - RECEIVE DATA FOR SOCKET
  • [00042] PROC IMNS
  • [00043] PROC IPIAIPA
  • [00044] PROC IPIDOSM
  • [00045] PROC IPINITH
  • [00046] PROC MESSAGE
  • [00047] PROC RTIME
  • [00048] PROC XDRBYTE
  • [00049] PROC XDRINT
  • [00050] PROC XWHD

Source Code

IPPRECV.txt
  1. *DECK IPPRECV
  2. USETEXT TEXTIPL
  3. USETEXT TEXTXDR
  4. PROC IPPRECV (SOCKID, BUFFER, BUFLEN, ADDRESS, SOCKSTATUS);
  5. *CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
  6. # TITLE IPPRECV - RECEIVE DATA FOR SOCKET #
  7.  
  8. BEGIN # IPPRECV #
  9. #
  10. **** IPPRECV RECEIVE DATA FOR SOCKET
  11. *
  12. * THIS PROCEDURE OBTAINS A BLOCK OF DATA FOR THE SOCKET.
  13. *
  14. * PROC IPPRECV
  15. *
  16. * ENTRY SOCKID = INTEGER VALUE OF SOCKET
  17. * BUFFER = BUFFER TO PLACE THE DATA
  18. *
  19. * EXIT BUFFER = BUFFER WITH RECEIVED DATA
  20. * BUFLEN = INTEGER VALUE OF NUMBER BYTES IN BUFFER
  21. * ADDRESS = 4 WORD SOURCE IP ADDRESS ARRAY
  22. * SOCKSTATUS = COMPLETION STATUS
  23. *
  24. * METHOD IF THE SOCKET HAS BEEN ABORTED BY NAM, RETURN AN ABORT
  25. * STATUS TO INFORM THE CALLER. IF THE SOCKET
  26. * IS NOT CONNECTED, RETURN AN ERROR STATUS. IF DATA
  27. * IS NOT QUEUED TO THE CONNECTION AND THE SOCKET BLOCKS,
  28. * LOOP CALLING THE NAM INPUT HANDLER UNTIL DATA IS
  29. * RECEIVED OR THE SPECIFIED BLOCKING TIMER HAS EXPIRED.
  30. * IF DATA IS RECEIVED, EXTRACT THE HEADER AND VERIFY THE
  31. * REQUEST AND UDP VERSION. PLACE THE SOURCE ADDRESS FROM
  32. * THE HEADER INTO *ADDRESS*, AND THE REMAINDER DATA INTO
  33. * *BUFFER*. ISSUE A LST/ON SM TO NAM SO MORE DATA CAN
  34. * BE SENT TO THE APPLICATION.
  35. #
  36.  
  37. #
  38. **** PROC IPPRECV - XREF LIST
  39. #
  40. XREF
  41. BEGIN
  42. PROC IMNS; # MOVE NON-OVERLAPPING STRING #
  43. PROC IPIAIPA; # ABORT IP APPLICATION #
  44. PROC IPIDOSM; # DISPATCH OUTPUT SUPERVISORY MESSAGE #
  45. PROC IPINITH; # NAM INPUT TRAFFIC HANDLER #
  46. PROC MESSAGE; # ISSUE DAYFILE MESSAGE #
  47. PROC RTIME; # REAL TIME CLOCK #
  48. PROC XDRBYTE; # CONVERT BYTES TO XDR FORMAT #
  49. PROC XDRINT; # CONVERT INTEGERS TO XDR FORMAT #
  50. PROC XWHD; # CONVERT HEXIDECIMAL TO DISPLAY #
  51. END
  52. #
  53. **
  54. #
  55. ITEM SOCKID I; # SOCKET IDENTIFIER #
  56. ARRAY BUFFER [00:00] S(1);; # BUFFER TO RECEIVE DATA #
  57. ARRAY ADDRESS [00:00] S(1);; # SOURCE ADDRESS FOR DATA #
  58. ITEM BUFLEN U; # LENGTH OF DATA IN BUFFER #
  59. ITEM SOCKSTATUS S:SOCKSTAT; # RETURNED SOCKET STATUS #
  60.  
  61.  
  62. #
  63. **** THIS ARRAY DEFINES THE DAYFILE MESSAGE FOR DISPLAYING AN INVALID
  64. * MESSAGE RECEIVED.
  65. #
  66. ARRAY DATAMSG [00:00] S(3);
  67. BEGIN
  68. ITEM DATA$TEXT C(00,00,20);
  69. ITEM DATA$ZBYTE U(02,00,60) = [0];
  70. END
  71.  
  72. #
  73. **** BASED ARRAY WHICH POINTS TO THE BLOCK OF DATA THAT WAS RECEIVED BY
  74. * NAM.
  75. #
  76.  
  77. BASED ARRAY INP$BUF [00:INPSIZE$] S(1);
  78. BEGIN
  79. ITEM INP$WRD U(00,00,60); # FULL WORD REFERENCE #
  80. END
  81.  
  82. ITEM DESTBUF I; # CURRENT WRD LOCATION IN BUFFER#
  83. ITEM DESTPOS U; # BIT OFFSET IN BUFFER WORD #
  84. ITEM INDEX I; # LOOP COUNTER #
  85. ITEM INPPOS U; # OFFSET IN INP$BUF BYTE #
  86. ITEM LOOP I; # LOOP COUNTER #
  87. ITEM MOVEBITS U; # BITS TO MOVE TO *BUFFER* #
  88. ITEM SCRBUF U; # CURRENT LOCATION INP$BUF #
  89. ITEM SCRPOS U; # BIT OFFSET IN INP$BUF WORD #
  90. ITEM WAITLOOP I; # NUMBER OF WAIT CYCLES #
  91. BASED ARRAY IPADDR [00:00] S(1);;# SOURCE ADDRESS FOR XDR CALL #
  92. CONTROL EJECT;
  93. #
  94. **** START MAIN PROCEDURE
  95. #
  96.  
  97. IF (ACN$ABORT [SOCKID])
  98. THEN
  99. BEGIN # CONNECTION ABORTED #
  100. SOCKSTATUS = S"ABORT";
  101. RETURN;
  102. END
  103.  
  104. IF NOT ACN$CONNECT [SOCKID]
  105. THEN
  106. BEGIN
  107. SOCKSTATUS = SOCKSTAT"INVALIDST";
  108. RETURN;
  109. END
  110.  
  111. BLOCK = ACN$BLOCK [SOCKID]; # SET GLOBAL BLOCKING FLAG #
  112.  
  113. IF NOT ACN$DATAV [SOCKID]
  114. THEN
  115. BEGIN # DATA NOT AVAILABLE #
  116. IF BLOCK
  117. THEN
  118. BEGIN # IF BLOCKING #
  119. WAITLOOP = ACN$WAITIME [SOCKID] / 2 + 1;
  120. RTIME (BWT$TIME); # CURRENT TIME #
  121. BWT$EXPIRE [0] = BWT$SECONDS [0] + ACN$WAITIME [SOCKID];
  122.  
  123. #
  124. **** CONTINUE POLLING THE NETWORK FOR DATA UNTIL EITHER DATA IS
  125. * IS RECEIVED ON THE CONNECTION OR UNTIL THE WAIT TIMER HAS EXPIRED.
  126. * THE LOOP COUNTER IS SET TO THE TIME/2 DUE TO THE NETWAIT TIME OF
  127. * 2 SECONDS WHILE BLOCKING.
  128. #
  129.  
  130. FOR LOOP = 0
  131. WHILE (NOT ACN$DATAV [SOCKID])
  132. DO
  133. BEGIN # WAIT FOR DATA OR EXPIRED TIME #
  134. FOR INDEX = 1 STEP 1
  135. WHILE (NOT ACN$DATAV [SOCKID]) AND
  136. (NOT ACN$ABORT [SOCKID]) AND
  137. (INDEX LQ WAITLOOP)
  138. DO
  139. BEGIN
  140. IPINITH; # NAM INPUT TRAFFIC HANDLER #
  141. END
  142.  
  143. IF (ACN$ABORT [SOCKID])
  144. THEN
  145. BEGIN # CONNECTION ABORTED #
  146. SOCKSTATUS = S"ABORT";
  147. RETURN;
  148. END
  149.  
  150. IF NOT ACN$DATAV [SOCKID]
  151. THEN
  152. BEGIN # CHECK IF TIMED OUT #
  153. RTIME (BWT$TIME);
  154. IF (BWT$SECONDS [0] GQ BWT$EXPIRE [0])
  155. THEN
  156. BEGIN # TIMER EXPIRED #
  157. SOCKSTATUS = S"NODATA";
  158. RETURN;
  159. END
  160. ELSE
  161. BEGIN # TIME STILL TO WAIT #
  162. WAITLOOP = (BWT$EXPIRE [0] -
  163. BWT$SECONDS [0]) / 2 + 1;
  164. END
  165. END # CHECK IF TIMED OUT #
  166. END # WAIT FOR DATA OR EXPIRED TIME #
  167. END # IF BLOCKING #
  168. ELSE
  169. BEGIN # NO DATA/NOT BLOCKING RETURN #
  170. IPINITH; # NAM INPUT TRAFFIC HANDLER #
  171.  
  172. IF (ACN$ABORT [SOCKID])
  173. THEN
  174. BEGIN # CONNECTION ABORTED #
  175. SOCKSTATUS = S"ABORT";
  176. RETURN;
  177. END
  178.  
  179. IF (NOT ACN$DATAV [SOCKID])
  180. THEN
  181. BEGIN
  182. SOCKSTATUS = S"NODATA";
  183. RETURN;
  184. END
  185. END
  186. END # DATA NOT AVAILABLE #
  187.  
  188. P<INP$BUF> = ACN$BUFFER [SOCKID];# INITIALIZE SOURCE POINTER #
  189. MOVEBITS = (ACN$DATALNTH [SOCKID] - UDPHEADSZ$) * 8;
  190.  
  191. #
  192. **** DATA IS AVAILABLE. VERIFY THE FIRST TWO BYTES OF DATA INDICATE
  193. * A VALID UDP REQUEST AND VERSION. IF IT DOES, THEN EXTRACT THE
  194. * SOURCE ADDRESS FROM BUFFER AND PLACE IN *ADDRESS*. MOVE THE
  195. * REMAINDER OF THE SOURCE BUFFER TO *BUFFER* WITH *IMNS*.
  196. #
  197.  
  198. INPPOS = 0; # STARTING OFFSET IN INP$BUF #
  199. XDRBYTE (INP$BUF, INPPOS, REC$UDP, 2, XDROPER"READ");
  200.  
  201. IF ((REC$REQ [0] NQ CALLRES$) AND
  202. (REC$REQ [0] NQ DATAIND$)) OR
  203. (REC$VER [0] NQ UDPVERS$) OR
  204. (MOVEBITS LS 0)
  205. THEN
  206. BEGIN # INVALID DATA, ABORT APPLICATIO#
  207. XWHD (INP$WRD [0], DATAMSG);
  208. MESSAGE (DATAMSG, 0);
  209. XWHD (REC$REQ, DATAMSG);
  210. MESSAGE (DATAMSG, 0);
  211. XWHD (REC$VER, DATAMSG);
  212. MESSAGE (DATAMSG, 0);
  213. IPIAIPA (NINVALID$);
  214. RETURN;
  215. END
  216.  
  217. P<IPADDR> = LOC (ADDRESS) + 1;
  218. INPPOS = 3; # BEGIN EXTRACT SOURCE ADDRESS #
  219. XDRBYTE (INP$BUF, INPPOS, ADDRESS, 1, XDROPER"READ");
  220. XDRINT (INP$BUF, INPPOS, IPADDR, 3, XDROPER"READ");
  221.  
  222. BUFLEN = MOVEBITS / 8; # NUMBER OF BYTES IN BUFFER #
  223. IF MOVEBITS NQ 0
  224. THEN
  225. BEGIN
  226. SCRBUF = LOC (INP$BUF) + (INPPOS * 2) / 15;
  227. DESTBUF = LOC (BUFFER);
  228. SCRPOS = XDRMODU ((INPPOS * 8), 60);# WORD BIT OFFSET #
  229. DESTPOS = 0;
  230. IMNS (MOVEBITS, SCRBUF, SCRPOS, DESTBUF, DESTPOS);
  231. END
  232.  
  233. #
  234. **** CLEAR FLOW CONTROL ON THIS CONNECTION NOW THAT THE DATA HAS
  235. * BEEN PROCESSED.
  236. *
  237. #
  238. IF ACN$DATAV [SOCKID]
  239. THEN
  240. BEGIN
  241. ACN$DATAV [SOCKID] = FALSE;
  242. P<APSM> = LOC(OUTBUF);
  243. SPMSG0 [0] = 0;
  244. LSTACN [0] = SOCKID;
  245. IPIDOSM (LSTON, LLST); # ISSUE LST/ON/R SM #
  246. END
  247.  
  248. SOCKSTATUS = S"OK";
  249.  
  250. RETURN; # RETURN TO CALLER #
  251.  
  252. END # IPPRECV #
  253.  
  254. TERM
cdc/nos2.source/nam5871/ipprecv.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator