Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

rpcmem.cc

Go to the documentation of this file.
00001 /*************************************************************************
00002 * File:rpcmem.cc                                                         *
00003 * Authors: Fred Proctor, Will Shackleford                                *
00004 * Purpose: C++ file for RPC client that reads and writes                 *
00005 *          to a local NML buffer for remote processes.                   *
00006 * Includes:                                                              *
00007 *          1. class RPCMEM member functions.                             *
00008 *************************************************************************/
00009 
00010 #include "rcs_defs.hh"          /* __MSDOS__, EXTERN_C_STD_HEADERS */
00011 
00012 #ifdef EXTERN_C_STD_HEADERS
00013 extern "C"
00014 {
00015 #endif
00016 
00017 #include <stdlib.h>             /* exit() */
00018 #include <string.h>             /* strncpy(), strchr() */
00019 #include <stddef.h>             /* size_t */
00020 
00021 #if defined(WIN32) && !defined(USE_OLD_WINSOCK)
00022 /* Lame problem if windows.h is included before winsock2.h many redefined
00023  compiler errors result. */
00024 #include <winsock2.h>
00025 #endif
00026 
00027 #ifndef __MSDOS__
00028 #include <rpc/rpc.h>            /* bool_t, xdr_ & clnt_ functions  */
00029 #endif
00030 #ifndef irix6
00031 #include <math.h>               /* fmod() */
00032 #else
00033 // Work around for the conflict between the gcc includes and /usr/includes
00034 // on some of our SGI's regarding the definition of initstate()
00035   extern double fmod (double, double);
00036 #endif
00037 
00038 #ifdef VXWORKS
00039 #include <sys/types.h>          /* u_short (needed by socket.h) */
00040 #include <sys/socket.h>         /* sockaddr_in */
00041 #include <hostLib.h>            /* hostGetByName() */
00042 #include <rpcLib.h>             /* rpcTaskInit() */
00043 #include <rpc/rpcGbl.h>         /* rpc_createerr */
00044 #endif
00045 
00046 #ifdef EXTERN_C_STD_HEADERS
00047 }
00048 #endif
00049 
00050 #ifdef __MSDOS__
00051 extern "C"
00052 {
00053 #ifndef WIN32
00054 #include <sys/nfs_time.h>       /* struct timeval */
00055 #endif
00056 #include <rpc/rpc.h>            /* struct CLIENT, enum clnt_stat */
00057 #ifdef _MSDOS
00058 /* PC-NFS 5.0 Programmer`s Toolkit Header files */
00059 #include <tklib.h>              /* tkdll_cleanup() */
00060 #endif
00061 }
00062 #endif
00063 
00064 #include "cms.hh"               /* class CMS, enum CMS_STATUS */
00065 #include "rpcmem.hh"            /* class RPCMEM */
00066 #include "timer.hh"             /* class RCS_TIMER */
00067 #include "xdr_msg.hh"           /* struct XBUFFER, xdr_XBUFFER() */
00068 #include "rcs_prnt.hh"          /* rcs_print_error() */
00069 #include "rpcintrf.h"           /* Dynamic Interface to RPC (dl_clnt_ )functions */
00070 #include "crypt2.hh"            // crypt()
00071 
00072 
00073 RPCMEM::RPCMEM (char *bufline, char *procline):
00074 CMS (bufline, procline)
00075 {
00076   /* Set pointers to dynamically allocated objects to NULL so that the */
00077   /* destructor won't delete them unless they are actually created. */
00078   clnt = NULL;
00079   timeval_time_out = NULL;
00080   //rpc_host = NULL;
00081 
00082   /* Load the interface for RPC functions and pointers.
00083      * This is required so that  Windows apps that don't need RPC
00084      * can run on systems without PCNFS. */
00085   if (load_rpc_interface () < 0)
00086     {
00087       /* PCNFS appears to not be available. */
00088       status = CMS_LIBRARY_UNAVAILABLE_ERROR;
00089       return;
00090     }
00091   timeval_time_out = malloc (sizeof (struct timeval));
00092 
00093 #ifdef VXWORKS
00094   rpcTaskInit ();
00095 #endif
00096   open ();
00097 }
00098 
00099 RPCMEM::~RPCMEM ()
00100 {
00101 #ifdef DEBUG
00102   rcs_print_error ("deleting RPCMEM\n");
00103   fflush (stderr);
00104 #endif
00105   if (NULL != timeval_time_out)
00106     {
00107 #ifdef sparcworks_sun4          /* free is defined as int free(char *)
00108                                    for this platform
00109                                    it should be void free(void *); */
00110       free ((char *) timeval_time_out);
00111 #else
00112       free (timeval_time_out);
00113 #endif
00114       timeval_time_out = NULL;
00115     }
00116   close ();
00117 
00118   /* Calling this decrements a counter,
00119      when the counter reaches zero under Windows
00120      the PCNFS DLL should be unloaded. */
00121   unload_rpc_interface ();
00122 }
00123 
00124 /*
00125   Open the RPCMEM cms
00126   */
00127 int
00128 RPCMEM::open ()
00129 {
00130 #if 0
00131   /* Check to see if the remote server has registered with the portmapper. */
00132   if (NULL != rpc_host)
00133     {
00134       if (-1 ==
00135           (registered =
00136            rpc_host->check_if_prog_registered (rpc_program_number)))
00137         {
00138           rcs_print_error
00139             ("RPCMEM: Can`t find out if server is registered.\n");
00140           status = CMS_MISC_ERROR;
00141           return -1;
00142         }
00143       if (!registered)
00144         {
00145           rcs_print_error ("RPCMEM: Please start server for %s on %s.\n",
00146                            BufferName, BufferHost);
00147           rcs_print_error
00148             ("RPCMEM: It should register as program 0x%X(%ld).\n",
00149              rpc_program_number, rpc_program_number);
00150           status = CMS_NO_SERVER_ERROR;
00151           return -1;
00152         }
00153     }
00154 #endif
00155 
00156   clnt = dl_clnt_create (BufferHost, rpc_program_number, 1, "tcp");
00157   if (clnt == NULL)
00158     {
00159       //      rcs_print_error("RPCMEM::open: cf_stat = %d\n", rpc_createerr.cf_stat);
00160 #ifndef _Windows
00161       if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
00162         {
00163           status = CMS_NO_SERVER_ERROR;
00164         }
00165       else
00166         {
00167           status = CMS_MISC_ERROR;
00168         }
00169 #else
00170       status = CMS_NO_SERVER_ERROR;
00171 #endif
00172       char *error_msg;
00173       error_msg = dl_clnt_spcreateerror ("RPCMEM::open");
00174       rcs_puts (error_msg);
00175 #if 0
00176       // It is not neccessary to get the TLI errno because the message
00177       //  from dl_clnt_spcreateerror will include it if there's a TLI error any way.
00178       if (rpc_createerr.cf_stat == RPC_TLIERROR && t_errno != 0)
00179         {
00180           error_msg = t_strerror (t_errno);
00181           rcs_puts (error_msg);
00182         }
00183 #endif
00184       rcs_print_error ("RPCMEM::open (Name = %s, ", BufferName);
00185       rcs_print_error ("BufferHost = %s, ", BufferHost);
00186       rcs_print_error ("prog = 0x%lX(%ld))\n",
00187                        rpc_program_number, rpc_program_number);
00188       return (-1);
00189     }
00190   if (timeout >= 0.0)
00191     {
00192       /* Fill the timeval structure from the timout in sec
00193        * tv_sec = interger part of timeout
00194        * tv_usec = fractional part of timeout * 1000;
00195        */
00196       ((struct timeval *) timeval_time_out)->tv_sec = (long) timeout;
00197       ((struct timeval *) timeval_time_out)->tv_usec = (long) (timeout * 1000000.0);
00198       if (((struct timeval *) timeval_time_out)->tv_usec >= 1000000)
00199         {
00200 
00201           ((struct timeval *) timeval_time_out)->tv_usec =
00202             ((struct timeval *) timeval_time_out)->tv_usec % 1000000;
00203         }
00204     }
00205   else
00206     {
00207       /* Time out should be infinite,but I can only set it high. */
00208       /* I can't even set it as high as I would like because it causes */
00209       /* a wierd problem where the dl_clnt_create function stops working */
00210       /* after 7 more calls. */
00211       ((struct timeval *) timeval_time_out)->tv_sec = 60;       /* 1 minute. */
00212       ((struct timeval *) timeval_time_out)->tv_usec = 500;
00213     }
00214   if (!dl_clnt_control
00215       ((CLIENT *) clnt, CLSET_TIMEOUT, (char *) timeval_time_out))
00216     {
00217       rcs_print_error ("RPCMEM:Could not set timeout.\n");
00218     }
00219   return 0;
00220 }
00221 
00222 
00223 /* Closes the socket file descriptors. */
00224 int
00225 RPCMEM::close ()
00226 {
00227   if (delete_totally && NULL != clnt)
00228     {
00229       /* Send the server the command to kill itself. */
00230       dl_clnt_call ((CLIENT *) clnt, 4,
00231                     (xdrproc_t)
00232                     ((rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00233                      (void *) ptr_to_xdr_void :
00234                      (void *) ptr_to_pascal_xdr_void),
00235                     (char *) NULL,
00236                     (xdrproc_t)
00237                     ((rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00238                      (void *) ptr_to_xdr_void :
00239                      (void *) ptr_to_pascal_xdr_void),
00240                     (char *) NULL, *((struct timeval *) timeval_time_out));
00241     }
00242   if (NULL == clnt)
00243     {
00244       return (-1);
00245     }
00246   else
00247     {
00248       dl_clnt_destroy ((CLIENT *) clnt);
00249     }
00250   return 0;
00251 }
00252 
00253 int
00254 RPCMEM::check_if_read ()
00255 {
00256   static int retval;
00257   clnt_stat val;
00258 
00259 
00260   /* get the latest buffer data from the server */
00261   if ((val = dl_clnt_call ((CLIENT *) clnt, 3,
00262                            (xdrproc_t)
00263                            ((rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00264                             (void *) ptr_to_xdr_long :
00265                             (void *) ptr_to_pascal_xdr_long),
00266                            (char *) &buffer_number,
00267                            (xdrproc_t)
00268                            ((rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00269                             (void *) ptr_to_xdr_int :
00270                             (void *) ptr_to_pascal_xdr_int),
00271                            (char *) &retval,
00272                            *((struct timeval *) timeval_time_out))) != 0)
00273     {
00274       char *error_msg;
00275       error_msg = dl_clnt_sperrno (val);
00276       rcs_puts (error_msg);
00277       rcs_print_error ("\n");
00278       if (val == RPC_TIMEDOUT)
00279         {
00280           status = CMS_TIMED_OUT;
00281         }
00282       else
00283         {
00284           status = CMS_MISC_ERROR;
00285         }
00286       return (-1);
00287     }
00288 
00289   /* increment debug heartbeat */
00290   return (retval);
00291 }
00292 
00293 CMS_STATUS
00294 RPCMEM::clear ()
00295 {
00296   static int retval;
00297   clnt_stat val;
00298 
00299 
00300   /* get the latest buffer data from the server */
00301   if ((val = dl_clnt_call ((CLIENT *) clnt, 5,
00302                            (xdrproc_t)
00303                            ((rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00304                             (void *) ptr_to_xdr_long :
00305                             (void *) ptr_to_pascal_xdr_long),
00306                            (char *) &buffer_number,
00307                            (xdrproc_t) (void *) ptr_to_xdr_int,
00308                            (char *) &retval,
00309                            *((struct timeval *) timeval_time_out))) != 0)
00310     {
00311       char *error_msg;
00312       error_msg = dl_clnt_sperrno (val);
00313       rcs_puts (error_msg);
00314       rcs_print_error ("\n");
00315       if (val == RPC_TIMEDOUT)
00316         {
00317           status = CMS_TIMED_OUT;
00318         }
00319       else
00320         {
00321           status = CMS_MISC_ERROR;
00322         }
00323       return (status);
00324     }
00325 
00326   return ((CMS_STATUS) retval);
00327 }
00328 
00329 /* Copy data from network to local buffer */
00330 CMS_STATUS
00331 RPCMEM::read ()
00332 {
00333   clnt_stat val;
00334   REMOTE_READ_REQUEST read_req;
00335   REMOTE_READ_REPLY read_reply;
00336 
00337   /* Check pointers. */
00338   if ((NULL == clnt))
00339     {
00340       rcs_print_error ("RPCMEM: clnt is NULL.\n");
00341       return (status = CMS_MISC_ERROR);
00342     }
00343 
00344   /* Set up read request message. */
00345   read_req.buffer_number = buffer_number;
00346   read_req.access_type = CMS_READ_ACCESS;
00347   read_req.last_id_read = in_buffer_id;
00348 
00349   /* Setup storage for reply */
00350   read_reply.data = encoded_data;
00351 
00352   /* get the latest buffer data from the server */
00353   if ((val = dl_clnt_call ((CLIENT *) clnt, 1,
00354                            (xdrproc_t)
00355                            (
00356                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00357                             (void *) xdr_REMOTE_READ_REQUEST :
00358                             (void *) xdr_REMOTE_READ_REQUEST_PASCAL),
00359                            (char *) &read_req,
00360                            (xdrproc_t)
00361                            (
00362                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00363                             (void *) xdr_REMOTE_READ_REPLY :
00364                             (void *) xdr_REMOTE_READ_REPLY_PASCAL),
00365                            (char *) &read_reply,
00366                            *((struct timeval *) timeval_time_out))) != 0)
00367     {
00368       char *error_msg;
00369       error_msg = dl_clnt_sperrno (val);
00370       rcs_puts (error_msg);
00371       rcs_print_error ("\n");
00372       if (val == RPC_TIMEDOUT)
00373         {
00374           rcs_print_error ("CMS:(%s) Network timed-out on read.\n",
00375                            BufferName);
00376           status = CMS_TIMED_OUT;
00377         }
00378       else
00379         {
00380           rcs_print_error ("CMS:(%s) Network communication error on read.\n",
00381                            BufferName);
00382           status = CMS_MISC_ERROR;
00383         }
00384       return (status);
00385     }
00386 
00387   if (read_reply.status != CMS_READ_OK && read_reply.status != CMS_READ_OLD)
00388     {
00389       rcs_print_error ("CMS:(%s) Failure with remote server on read.\n",
00390                        BufferName);
00391     }
00392   status = (CMS_STATUS) read_reply.status;
00393   header.was_read = read_reply.was_read;
00394   check_id (read_reply.write_id);
00395 
00396   return (status);
00397 }
00398 
00399 /* Copy data from network to local buffer */
00400 /* Do not change was_read flag. */
00401 CMS_STATUS
00402 RPCMEM::peek ()
00403 {
00404   clnt_stat val;
00405   REMOTE_READ_REQUEST read_req;
00406   REMOTE_READ_REPLY read_reply;
00407 
00408   /* Check pointers. */
00409   if (NULL == clnt)
00410     {
00411       return (status = CMS_MISC_ERROR);
00412     }
00413 
00414   /* Set up read request message. */
00415   read_req.buffer_number = buffer_number;
00416   read_req.access_type = CMS_PEEK_ACCESS;
00417   read_req.last_id_read = in_buffer_id;
00418 
00419   /* Setup storage for reply */
00420   read_reply.data = encoded_data;
00421 
00422   /* get the latest buffer data from the server */
00423   if ((val = dl_clnt_call ((CLIENT *) clnt, 1,
00424                            (xdrproc_t)
00425                            (
00426                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00427                             (void *) xdr_REMOTE_READ_REQUEST :
00428                             (void *) xdr_REMOTE_READ_REQUEST_PASCAL),
00429                            (char *) &read_req,
00430                            (xdrproc_t)
00431                            (
00432                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00433                             (void *) xdr_REMOTE_READ_REPLY :
00434                             (void *) xdr_REMOTE_READ_REPLY_PASCAL),
00435                            (char *) &read_reply,
00436                            *((struct timeval *) timeval_time_out))) != 0)
00437     {
00438       char *error_msg;
00439       error_msg = dl_clnt_sperrno (val);
00440       rcs_print_error ("%s\n", error_msg);
00441       if (val == RPC_TIMEDOUT)
00442         {
00443           rcs_print_error ("CMS:(%s) Network timed-out on read.\n",
00444                            BufferName);
00445           status = CMS_TIMED_OUT;
00446         }
00447       else
00448         {
00449           rcs_print_error ("CMS:(%s) Network communication error on read.\n",
00450                            BufferName);
00451           status = CMS_MISC_ERROR;
00452         }
00453       return (status);
00454     }
00455   if (read_reply.status != CMS_READ_OK && read_reply.status != CMS_READ_OLD)
00456     {
00457       rcs_print_error ("CMS:(%s) Failure with remote server on read.\n",
00458                        BufferName);
00459     }
00460 
00461   status = (CMS_STATUS) read_reply.status;
00462   header.was_read = read_reply.was_read;
00463   check_id (read_reply.write_id);
00464 
00465   return (status);
00466 }
00467 
00468 /* Copy data from local buffer to server for deposit in shared memory */
00469 /* WARNING: user_data parameter is ignored. */
00470 CMS_STATUS
00471 RPCMEM::write (void *user_data)
00472 {
00473   REMOTE_WRITE_REQUEST write_req;
00474   REMOTE_WRITE_REPLY write_reply;
00475 
00476   clnt_stat val;
00477 
00478   /* Check pointers. */
00479   if (NULL == clnt)
00480     {
00481       return (status = CMS_MISC_ERROR);
00482     }
00483 
00484   /* Setup write request message. */
00485   write_req.data = (unsigned char *) encoded_data;
00486   write_req.size = (int) header.in_buffer_size;
00487   write_req.access_type = CMS_WRITE_ACCESS;
00488   write_req.buffer_number = buffer_number;
00489 
00490 
00491   /* write our data to the BufferHost's shared memory via the server */
00492   if ((val = dl_clnt_call ((CLIENT *) clnt, 2,
00493                            (xdrproc_t)
00494                            (
00495                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00496                             (void *) xdr_REMOTE_WRITE_REQUEST :
00497                             (void *) xdr_REMOTE_WRITE_REQUEST_PASCAL),
00498                            (char *) &write_req,
00499                            (xdrproc_t)
00500                            (
00501                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00502                             (void *) xdr_REMOTE_WRITE_REPLY :
00503                             (void *) xdr_REMOTE_WRITE_REPLY_PASCAL),
00504                            (char *) &write_reply,
00505                            *((struct timeval *) timeval_time_out))) != 0)
00506     {
00507       char *error_msg;
00508       error_msg = dl_clnt_sperrno (val);
00509       rcs_print_error ("%s\n", error_msg);
00510       if (val == RPC_TIMEDOUT)
00511         {
00512           rcs_print_error ("CMS:(%s) Network timed-out on write. \n",
00513                            BufferName);
00514           status = CMS_TIMED_OUT;
00515         }
00516       else
00517         {
00518           rcs_print_error
00519             ("CMS:(%s) Network communication error on write. \n", BufferName);
00520           status = CMS_MISC_ERROR;
00521         }
00522       return (status);
00523     }
00524 
00525   if (write_reply.status != CMS_WRITE_OK)
00526     {
00527       rcs_print_error ("CMS:(%s) Failure with remote server on write.\n",
00528                        BufferName);
00529     }
00530   status = (CMS_STATUS) write_reply.status;
00531   header.was_read = write_reply.was_read;
00532   return (status);
00533 }
00534 
00535 /* Copy data from local buffer to server for deposit in shared memory */
00536 /* Write will only succeed if the buffer has been read since the last write. */
00537 /* WARNING: user_data parameter is ignored. */
00538 CMS_STATUS
00539 RPCMEM::write_if_read (void *user_data)
00540 {
00541   REMOTE_WRITE_REQUEST write_req;
00542   REMOTE_WRITE_REPLY write_reply;
00543 
00544   clnt_stat val;
00545 
00546   /* Check pointers. */
00547   if (NULL == clnt)
00548     {
00549       return (status = CMS_MISC_ERROR);
00550     }
00551 
00552   /* Setup write request message. */
00553   write_req.data = (unsigned char *) encoded_data;
00554   write_req.access_type = CMS_WRITE_IF_READ_ACCESS;
00555   write_req.buffer_number = buffer_number;
00556 
00557   /* write our data to the BufferHost's shared memory via the server */
00558   if ((val = dl_clnt_call ((CLIENT *) clnt, 2,
00559                            (xdrproc_t)
00560                            (
00561                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00562                             (void *) xdr_REMOTE_WRITE_REQUEST :
00563                             (void *) xdr_REMOTE_WRITE_REQUEST_PASCAL),
00564                            (char *) &write_req,
00565                            (xdrproc_t)
00566                            (
00567                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00568                             (void *) xdr_REMOTE_WRITE_REPLY :
00569                             (void *) xdr_REMOTE_WRITE_REPLY_PASCAL),
00570                            (char *) &write_reply,
00571                            *((struct timeval *) timeval_time_out))) != 0)
00572     {
00573       char *error_msg;
00574       error_msg = dl_clnt_sperrno (val);
00575       rcs_print_error ("%s\n", error_msg);
00576       if (val == RPC_TIMEDOUT)
00577         {
00578           rcs_print_error ("CMS:(%s) Network timed-out on write. \n",
00579                            BufferName);
00580           status = CMS_TIMED_OUT;
00581         }
00582       else
00583         {
00584           rcs_print_error
00585             ("CMS:(%s) Network communication error on write. \n", BufferName);
00586           status = CMS_MISC_ERROR;
00587         }
00588       return (status);
00589     }
00590 
00591   if (write_reply.status != CMS_WRITE_OK &&
00592       write_reply.status != CMS_WRITE_WAS_BLOCKED)
00593     {
00594       rcs_print_error ("CMS:(%s) Failure with remote server on write.\n",
00595                        BufferName);
00596     }
00597   header.was_read = write_reply.was_read;
00598   status = (CMS_STATUS) write_reply.status;
00599   return (status);
00600 }
00601 
00602 int
00603 RPCMEM::login (const char *name, const char *passwd)
00604 {
00605   REMOTE_GET_KEYS_REQUEST get_keys_req;
00606   REMOTE_GET_KEYS_REPLY get_keys_reply;
00607   REMOTE_LOGIN_REQUEST login_req;
00608   REMOTE_LOGIN_REPLY login_reply;
00609   char *crypt1_ret = NULL;
00610   char *crypt2_ret = NULL;
00611   char passwd_pass1[16];
00612 
00613   clnt_stat val;
00614 
00615   /* Check pointers. */
00616   if (NULL == clnt)
00617     {
00618       return (status = CMS_MISC_ERROR);
00619     }
00620 
00621   /* Setup get_keys request message. */
00622   get_keys_req.buffer_number = buffer_number;
00623   strncpy (get_keys_req.name, name, 16);
00624 
00625   /* get_keys our data to the BufferHost's shared memory via the server */
00626   if ((val = dl_clnt_call ((CLIENT *) clnt, 6,
00627                            (xdrproc_t)
00628                            (
00629                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00630                             (void *) xdr_REMOTE_GET_KEYS_REQUEST :
00631                             (void *) xdr_REMOTE_GET_KEYS_REQUEST_PASCAL),
00632                            (char *) &get_keys_req,
00633                            (xdrproc_t)
00634                            (
00635                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00636                             (void *) xdr_REMOTE_GET_KEYS_REPLY :
00637                             (void *) xdr_REMOTE_GET_KEYS_REPLY_PASCAL),
00638                            (char *) &get_keys_reply,
00639                            *((struct timeval *) timeval_time_out))) != 0)
00640     {
00641       char *error_msg;
00642       error_msg = dl_clnt_sperrno (val);
00643       rcs_print_error ("%s\n", error_msg);
00644       if (val == RPC_TIMEDOUT)
00645         {
00646           rcs_print_error ("CMS:(%s) Network timed-out on get_keys. \n",
00647                            BufferName);
00648           status = CMS_TIMED_OUT;
00649         }
00650       else
00651         {
00652           rcs_print_error
00653             ("CMS:(%s) Network communication error on get_keys. \n",
00654              BufferName);
00655           status = CMS_MISC_ERROR;
00656         }
00657       return (status);
00658     }
00659 
00660 
00661   /* Setup login request message. */
00662   strncpy (login_req.name, name, 16);
00663   crypt1_ret = rcs_crypt (passwd, get_keys_reply.key1);
00664   if (NULL == crypt1_ret)
00665     {
00666       rcs_print_error ("RPCMEM::login() : crypt function failed.\n");
00667       return 0;
00668     }
00669   strncpy (passwd_pass1, crypt1_ret, 16);
00670   crypt2_ret = rcs_crypt (passwd_pass1, get_keys_reply.key2);
00671   if (NULL == crypt2_ret)
00672     {
00673       rcs_print_error ("RPCMEM::login() : crypt function failed.\n");
00674       return 0;
00675     }
00676   strncpy (login_req.passwd, crypt2_ret, 16);
00677   login_req.buffer_number = buffer_number;
00678 
00679 
00680 
00681   /* login our data to the BufferHost's shared memory via the server */
00682   if ((val = dl_clnt_call ((CLIENT *) clnt, 7,
00683                            (xdrproc_t)
00684                            (
00685                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00686                             (void *) xdr_REMOTE_LOGIN_REQUEST :
00687                             (void *) xdr_REMOTE_LOGIN_REQUEST_PASCAL),
00688                            (char *) &login_req,
00689                            (xdrproc_t)
00690                            (
00691                             (rpc_library_type != PCNFS_TKDLL_WINDOWS_31) ?
00692                             (void *) xdr_REMOTE_LOGIN_REPLY :
00693                             (void *) xdr_REMOTE_LOGIN_REPLY_PASCAL),
00694                            (char *) &login_reply,
00695                            *((struct timeval *) timeval_time_out))) != 0)
00696     {
00697       char *error_msg;
00698       error_msg = dl_clnt_sperrno (val);
00699       rcs_print_error ("%s\n", error_msg);
00700       if (val == RPC_TIMEDOUT)
00701         {
00702           rcs_print_error ("CMS:(%s) Network timed-out on login. \n",
00703                            BufferName);
00704           status = CMS_TIMED_OUT;
00705         }
00706       else
00707         {
00708           rcs_print_error
00709             ("CMS:(%s) Network communication error on login. \n", BufferName);
00710           status = CMS_MISC_ERROR;
00711         }
00712       return (0);
00713     }
00714   return (1);
00715 }

Generated on Sun Dec 2 15:56:52 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001