1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1987                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1986 *
  6         *                                                         *
  7         *********************************************************** */
  8 
  9 /****^  HISTORY COMMENTS:
 10   1) change(86-08-27,Smith), approve(87-07-15,MCR7580),
 11      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 12      Created.
 13   2) change(86-10-22,Smith), approve(87-07-15,MCR7580),
 14      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 15      Added checks for messages with invalid destinations.
 16   3) change(86-11-27,Flegel), approve(86-11-27,MCR7580),
 17      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 18      Approved.
 19   4) change(86-12-10,Flegel), approve(86-12-10,MCR7580),
 20      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 21      Replaced signalling of mowse_fatal_error with a call to fatal_mowse_trap_.
 22   5) change(86-12-11,Flegel), approve(86-12-11,MCR7580),
 23      audit(87-07-30,RBarstad), install(87-08-07,MR12.1-1075):
 24      Guaruntee that a RESPONSE_DISCONNECT message is sent back in the event of
 25      an error to the destination of a REQUEST_DISCONNECT message.
 26                                                    END HISTORY COMMENTS */
 27 
 28 /* format: style4,indattr,ifthen,^indcomtxt,thendo,^indproc,^indblkcom,initcol1,declareind8,dclind4,struclvlind3,comcol55 */
 29 rcvdat_:
 30      proc (p_mowse_mcb_ptr, p_msg_ptr, p_msg_len, p_status);
 31 
 32 /* : PROGRAM FUNCTION
 33 Get a message from the Protocol Handler (0.1) and pass it on to the parser.
 34 */
 35 
 36 /* : NOTES
 37 
 38 All error handling should be done from here on down.
 39 */
 40 
 41 /* INPUT PARAMETERS */
 42 dcl p_mowse_mcb_ptr        ptr parameter;             /* mcb of mowse_io_ */
 43 dcl p_msg_ptr              ptr parameter;             /* Pointer to a message record */
 44 dcl p_msg_len              fixed bin (21) parameter;  /* Length of message */
 45 dcl p_status               fixed bin (35) parameter;  /* Error code */
 46 
 47 
 48 /* EXTERNAL CALLS */
 49 dcl send_msg_              entry (ptr, fixed bin, fixed bin, ptr, fixed bin,
 50                            fixed bin, fixed bin (35));
 51 dcl capability_$pack       entry (fixed bin, fixed bin, fixed bin,
 52                            fixed bin (35));
 53 dcl ws_$put_background_message
 54                            entry () options (variable);
 55 dcl message_parser_        entry (ptr, fixed bin, ptr, fixed bin (35));
 56 
 57 /* SYSTEM CALLS */
 58 
 59 /* SYSTEM CALL SUPPORT */
 60 dcl ws_error_$no_capability
 61                            fixed bin (35) ext static;
 62 dcl ws_error_$invalid_capability_number
 63                            fixed bin (35) ext static;
 64 dcl ws_error_$invalid_system_id
 65                            fixed bin (35) ext static;
 66 
 67 /* STRUCTURES */
 68 
 69 /* MISC VARIABLES */
 70 dcl mowse_info_ptr         ptr;
 71 dcl system                 fixed bin;
 72 dcl major                  fixed bin;
 73 dcl minor                  fixed bin;
 74 dcl source_system          fixed bin;
 75 dcl source_major           fixed bin;
 76 dcl ecode                  fixed bin (35);
 77 
 78 /* BUILTINS */
 79 dcl convert                builtin;
 80 dcl null                   builtin;
 81 dcl rank                   builtin;
 82 dcl addr                   builtin;
 83 dcl byte                   builtin;
 84 
 85 /* CONDITIONS */
 86 
 87 /*^L*/
 88 
 89 /* INITIALIZATION */
 90 
 91           p_status = 0;
 92           message_ptr = p_msg_ptr;
 93           message_len = convert (message_len, p_msg_len);
 94 
 95 /* MAIN */
 96 
 97 /* : Get mowse_info_ptr */
 98 
 99           mowse_info_ptr = p_mowse_mcb_ptr -> mcb.mowse_info_ptr;
100 
101 /* : Ensure that the destination of the message is valid. Ignore messages
102      received for the wrong system */
103 
104           system = rank (message_ptr -> input_message.header.system);
105           major = rank (message_ptr -> input_message.header.major);
106           minor = rank (message_ptr -> input_message.header.minor);
107           if minor ^= CONTINUE then do;
108                source_system =
109                     rank (message_ptr -> input_message.header.source_system);
110                source_major =
111                     rank (message_ptr -> input_message.header.source_major);
112           end;
113           else do;
114                source_system =
115                     rank (message_ptr
116                     -> more_remaining_message.header.source_system);
117                source_major =
118                     rank (message_ptr
119                     -> more_remaining_message.header.source_major);
120           end;
121 
122 /* : If destination major or system is invalid, send an error */
123 
124           if major < INTERNAL | major > MAXIMUM_CAT_ENTRY then do;
125                call message_error (system, major, minor, source_system,
126                     source_major, p_mowse_mcb_ptr,
127                     ws_error_$invalid_capability_number);
128                return;
129           end;
130 
131 /* : If the system is invalid, send an error */
132 
133           if system ^= LOCAL_SYSTEM then do;
134                call message_error (system, major, minor, source_system,
135                     source_major, p_mowse_mcb_ptr,
136                     ws_error_$invalid_system_id);
137                return;
138           end;
139 
140 /* : If the major number of the destination is valid ensure that there
141      is a valid MCB for this capability (ie the application is registered
142      with MOWSE). */
143 
144           if major ^= INTERNAL then
145                if p_mowse_mcb_ptr -> mcb.mowse_info_ptr
146                     -> mowse_info.local_cat (major).mcb_ptr = null
147                then do;
148                     call message_error (system, major, minor, source_system,
149                          source_major, p_mowse_mcb_ptr,
150                          ws_error_$no_capability);
151                     return;
152                end;
153 
154 /* : call message parser with message length and pointer to mesaage */
155 
156           call message_parser_ (p_mowse_mcb_ptr, message_len, p_msg_ptr,
157                ecode);
158 
159 /* : if the message is invalid then display a message indicating this
160      fact and terminate the capability sending the message */
161 
162           p_status = 0;
163           if ecode ^= 0 then do;
164                call message_error (system, major, minor, source_system,
165                     source_major, p_mowse_mcb_ptr, ecode);
166                return;
167           end;
168 
169 /*^L*/
170 /* INTERNAL PROCEDURES */
171 
172 /* *** Procedure: message_error - Internal proc for rcvdat_  *** */
173 
174 
175 message_error:
176      proc (p_system, p_major, p_minor, p_source_system, p_source_major,
177           p_mowse_mcb_ptr, p_code);
178 
179 /* : PROCEDURE FUNCTION
180 
181 Generate the appropriate action when an invalid message has been received.
182 */
183 
184 /* INPUT PARAMETERS */
185 dcl p_minor                fixed bin parameter;       /* Destination minor capability */
186 dcl p_mowse_mcb_ptr        ptr parameter;
187 dcl p_code                 fixed bin (35);
188 dcl p_source_major         fixed bin parameter;       /* Source major of message */
189 dcl p_source_system        fixed bin parameter;       /* Source system of message */
190 dcl p_major                fixed bin parameter;       /* Destination major */
191 dcl p_system               fixed bin parameter;
192 
193 
194 /* MISC VARIABLES */
195 dcl data_message           char (32);                 /* Data message string */
196 dcl source_major_cap       fixed bin;                 /* Packed capability number */
197 dcl data                   char (1);                  /* Data to send_msg_ */
198 
199 /* INITIALIZATION */
200 
201 /* : Generate an error message only if it is not because the destination
202      capability does not exist */
203 
204           if p_code ^= ws_error_$no_capability then
205                call ws_$put_background_message (p_mowse_mcb_ptr,
206                     p_code, "MULTICS MOWSE", "From [^d:^d] to [^d:^d:^d]",
207                     p_source_system, p_source_major, p_system, p_major,
208                     p_minor);
209           p_code = 0;
210 
211 /* : If invalid message was from MOWSE then do not send a message to the
212      source of the message. */
213 
214           if p_source_major = INTERNAL then
215                return;
216 
217 /* : Otherwise send a message to the source of the invalid message. */
218 
219           call capability_$pack (p_source_system, p_source_major,
220                source_major_cap, ecode);
221           if p_code ^= 0 then
222                return;
223 
224           if p_minor = REQUEST_DISCONNECT then do;
225                data = byte (REJECT);
226                call send_msg_ (p_mowse_mcb_ptr, source_major_cap,
227                     RESPONSE_DISCONNECT, addr (data), 1, BG, p_code);
228           end;
229           else if p_minor = STATUS then do;
230                data_message = "Capability does not exist.";
231                call send_msg_ (p_mowse_mcb_ptr, source_major_cap,
232                     STATUS_REPLY, addr (data_message), 26, FG, p_code);
233           end;
234 
235           else if p_minor >= MINIMUM_USER_MINOR & p_minor <= MAXIMUM_USER_MINOR
236                then
237                call send_msg_ (p_mowse_mcb_ptr, source_major_cap,
238                     FAIL_CAPABILITY, null, 0, BG, p_code);
239           else
240                call send_msg_ (p_mowse_mcb_ptr, source_major_cap,
241                     SYSTEM_ERROR, null, 0, BG, ecode);
242 
243      end message_error;
244 
245 /*^L*/
246 
247 /*^L*/
248 %page;
249 
250 /* INCLUDE FILES */
251 %include mowse;
252 %include mowse_mcb;
253 %include mowse_messages;
254 %include mowse_info;
255 
256 /* : END */
257      end rcvdat_;