| I know this is a lot of code (the customer stated he cut it down as
much as possible) but I really could use some help here. I'll IPMT if
that is appropriate. The code has a hard coded the name of the
directory service entry. I suspect that will need to change, right?
Any ways, each time I try to run this application, I get:
STITR_elin>run MLEAK_SRVR
DCE Initialization failed.
So I cannot verify if there is a memory leak.
Thanks,
Elin
>ty bld.com
$ cc/prefix=all mleak_clnt.c
$ cc/prefix=all mleak_cstub.c
$ cc/prefix=all mleak_clnt_init_dce.c
$ cc/prefix=all hndl_list_items.c
$ cc/prefix=all mleak_srvr.c
$ cc/prefix=all mleak_sstub.c
$ cc/prefix=all mleak_init_dce.c
$ cc/prefix=all mleak_list_items.c
$ link mleak_clnt,mleak_cstub,mleak_clnt_init_dce,-
hndl_list_items+dce:dce.opt/opt
$ link mleak_srvr,mleak_sstub,mleak_init_dce, -
mleak_list_items+dce:dce.opt/opt
$exit
-------------------------- cut here ------------------------------
/* ETI_SCADA_TYPES.H */
/* Generated by IDL compiler version DEC DCE T1.2.0-06 */
#ifndef etis_t_v1_0_included
#define etis_t_v1_0_included
#ifndef IDL_DOUBLE_USED
#define IDL_DOUBLE_USED
#endif
#ifndef IDLBASE_H
#include <dce/idlbase.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef nbase_v0_0_included
#include <dce/nbase.h>
#endif
#define STR_LEN (100)
#define ITEM_OK (0)
#define ITEM_NOT_FOUND (-1)
#define ITEM_NO_PRIV (-2)
#define ITEM_EXISTS (-3)
#define ITEM_BAD_TYPE (-4)
#define ITEM_ALRDY_LOCKED (-5)
#define ITEM_NOT_LOCKED (-6)
#define RGSTR_OK (0)
#define RGSTR_OK_RE_RGSTRD (1)
#define RGSTR_NO_PRIV (-21)
#define RGSTR_NOT_RGSTRD (-22)
#define RGSTR_ALRDY_RGSTRD (-23)
#define RGSTR_CANT_BIND_RCVR (-24)
#define RGSTR_RCVR_NO_RESP (-25)
#define RGSTR_DEACTIVATED (-26)
#define SBSCR_OK (0)
#define SBSCR_PERIOD_ERR (-41)
#define SBSCR_LIMIT_ERR (-42)
typedef idl_char *STRING_T;
typedef idl_char FIX_STRNG_T[101];
typedef enum {ITEM_FLOAT=0,
ITEM_INTEGER=1,
ITEM_STRING=2} DATA_T;
typedef struct {
DATA_T type;
union {
/* case(s): 0 */
idl_long_float float_val;
/* case(s): 1 */
idl_long_int int_val;
/* case(s): 2 */
FIX_STRNG_T str_val;
} value;
} VALUE_T;
typedef struct rcv_item {
STRING_T name;
idl_long_int quality;
idl_long_int time_stamp;
uuid_t subscriber;
uuid_t cell;
VALUE_T data;
} RCV_ITEM;
typedef enum {SCHD_ON_CHANGE=0,
SCHD_PERIODIC=1,
SCHD_HOURLY=2,
SCHD_DAILY=3,
SCHD_WEEKLY=4,
SCHD_MONTHLY=5} SBSCR_T;
typedef struct sbscr_basis {
FIX_STRNG_T item_name;
FIX_STRNG_T alias;
SBSCR_T type;
idl_long_int basis_id;
} SBSCR_BASIS;
#ifdef __cplusplus
}
#endif
#endif
-------------------------- cut here ------------------------------
/* MLEAK.H;1 */
/* Generated by IDL compiler version DEC DCE T1.2.0-06 */
#ifndef mleak_v1_0_included
#define mleak_v1_0_included
#ifndef IDLBASE_H
#include <dce/idlbase.h>
#endif
#include <dce/rpc.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef nbase_v0_0_included
#include <dce/nbase.h>
#endif
#ifndef etis_t_v1_0_included
#include "eti_scada_types.h"
#endif
typedef struct STR_PIPE {
void (IDL_ENTRY * pull)(
#ifdef IDL_PROTOTYPES
rpc_ss_pipe_state_t state,
FIX_STRNG_T *buf,
idl_ulong_int esize,
idl_ulong_int *ecount
#endif
);
void (IDL_ENTRY * push)(
#ifdef IDL_PROTOTYPES
rpc_ss_pipe_state_t state,
FIX_STRNG_T *buf,
idl_ulong_int ecount
#endif
);
void (IDL_ENTRY * alloc)(
#ifdef IDL_PROTOTYPES
rpc_ss_pipe_state_t state,
idl_ulong_int bsize,
FIX_STRNG_T **buf,
idl_ulong_int *bcount
#endif
);
rpc_ss_pipe_state_t state;
} STR_PIPE;
extern void list_items(
#ifdef IDL_PROTOTYPES
/* [in] */ handle_t IDL_handle,
/* [out] */ STR_PIPE item_name
#endif
);
#if defined(__VMS) && (defined(__DECC) || defined(__cplusplus))
#pragma extern_model __save
#pragma extern_model __common_block __shr
#endif
typedef struct mleak_v1_0_epv_t {
void (*list_items)(
#ifdef IDL_PROTOTYPES
/* [in] */ handle_t IDL_handle,
/* [out] */ STR_PIPE item_name
#endif
);
} mleak_v1_0_epv_t;
extern rpc_if_handle_t mleak_v1_0_c_ifspec;
extern rpc_if_handle_t mleak_v1_0_s_ifspec;
#if defined(__VMS) && (defined(__DECC) || defined(__cplusplus))
#pragma extern_model __restore
#endif
#ifdef __cplusplus
}
#else
#endif
#endif
-------------------------- cut here ------------------------------
/* MLEAK_CLNT_PROTO.H;1 */
#ifndef __MLEAK_CLNT_PROTO /* Include only once */
#define __MLEAK_CLNT_PROTO 1 /* Flag telling that the */
/* Prototypes header file */
/* has been included. */
#include <stdio.h> /* Standard IO defs */
#include <stdlib.h> /* Standard Runtime lib */
#include <string.h> /* String/Memory defs */
#include <math.h> /* Math definitions */
#include <pthread.h> /* Threads definitions */
#include <dce/rpc.h>
#include "mleak.h" /* Interface header */
/************************************************************************
* MLeak Server Macros *
************************************************************************/
/************************************************************************
* MLeak Client function Prototypes *
************************************************************************/
int main ( ); /* Main function */
int mleak_clnt_init_dce ( /* Initialize DCE */
rpc_binding_handle_t * ); /* Binding handle to server */
int hndl_list_items ( /* Handle Listing Items */
rpc_binding_handle_t ); /* Binding Handle to server */
#endif
-------------------------- cut here ------------------------------
/* MLEAK_SRVR_PROTO.H;1 */
#ifndef __MLEAK_SRVR_PROTO /* Include only once */
#define __MLEAK_SRVR_PROTO 1 /* Flag telling that the */
/* Prototypes header file */
/* has been included. */
/************************************************************************
* Header Files *
************************************************************************/
#include <stdio.h> /* Standard IO functions */
#include <string.h> /* String Handling */
#include <stdlib.h> /* Memory functions */
#include <math.h> /* Math Functions */
#include "mleak.h" /* Mem Leak Srvr defs */
#include <dce/rpc.h> /* Base RPC defs */
#include <dce/sec_login.h> /* DCE Security Login defs */
#include <dce/keymgmt.h> /* DCE Key Management defs */
/************************************************************************
* MLEAK Definitions *
************************************************************************/
#define PRINCIPAL_NAME "mleak" /* Server Principal Name */
#define KT_FILE_NAME "MLEAK.KTB" /* MLeak Server Keytab file */
#define LIST_SIZE 6000 /* Elements in List */
/************************************************************************
* MLEAK Structures *
************************************************************************/
/************************************************************************
* MLEAK Server function Prototypes *
************************************************************************/
int main ( ); /* Main function */
int mleak_init_dce ( ); /* Initialize DCE */
#endif
-------------------------- cut here ------------------------------
/* mleak.idl */
* DESCRIPTION: This file contains the IDL and basic typedefs
*
* for the LEAK SERVER interface. */
[
uuid(0094ed00-14d6-1340-aa4f-0004acb476df),
version(1.0)
]
interface mleak
{
import "eti_scada_types.idl"; /* Common Typedefs */
typedef pipe FIX_STRNG_T STR_PIPE; /* Pipe sends strings */
void list_items ( /* List All Accessible Items */
[out] STR_PIPE item_name ); /* Item names */
}
-------------------------- cut here ------------------------------
/* ETI_SCADA_TYPES.IDL */
/* DESCRIPTION: is file contains the basic typedefs for the */
/* ETI_SCADA and ETI_SCADA_RCVR interfaces. */
[
uuid(6fdac016-f12b-11cf-b446-08002b3882d5),
version(1.0)
]
interface etis_t
{
import "dce/nbase.idl"; /* UUID definition */
const short STR_LEN = 100; /* Pipe strlen */
const long ITEM_OK = 0; /* Item Operation OK */
const long ITEM_NOT_FOUND = -1; /* No such Item */
const long ITEM_NO_PRIV = -2; /* No Priv for item */
const long ITEM_EXISTS = -3; /* Can't add item */
const long ITEM_BAD_TYPE = -4; /* Item type wrong */
const long ITEM_ALRDY_LOCKED = -5; /* Item already lock */
const long ITEM_NOT_LOCKED = -6; /* Item not locked */
const long RGSTR_OK = 0; /* Registration OK */
const long RGSTR_OK_RE_RGSTRD = 1; /* Reactivated reg. */
const long RGSTR_NO_PRIV = -21; /* No Priv for item */
const long RGSTR_NOT_RGSTRD = -22; /* Subscr w/o reg. */
const long RGSTR_ALRDY_RGSTRD = -23; /* Resubscr attempt */
const long RGSTR_CANT_BIND_RCVR = -24; /* Unknown Receiver */
const long RGSTR_RCVR_NO_RESP = -25; /* Recvr not alive */
const long RGSTR_DEACTIVATED = -26; /* Deactivated rgstr */
const long SBSCR_OK = 0; /* Subscription OK */
const long SBSCR_PERIOD_ERR = -41; /* Out of range */
const long SBSCR_LIMIT_ERR = -42; /* Max subscriptions */
/****************************************************************
* Declare Structures Needed in interfaces *
****************************************************************/
typedef [string, ptr] char *STRING_T; /* String type data */
typedef [string] char FIX_STRNG_T[STR_LEN+1]; /* Fixed String type */
typedef enum
{ ITEM_FLOAT, /* Float Pt Data */
ITEM_INTEGER, /* Integer Data */
ITEM_STRING /* String Type Data */
} DATA_T; /* Enumerated Type */
typedef union switch(DATA_T type) value /* Union Name */
{ case ITEM_FLOAT: double float_val; /* Float Pt Value */
case ITEM_INTEGER:long int_val; /* Integer Value */
case ITEM_STRING: FIX_STRNG_T str_val; /* String Value */
} VALUE_T; /* Structure Type */
typedef struct rcv_item
{ STRING_T name; /* Item Name/Alias */
long quality; /* Data Quality */
long time_stamp; /* POSIX Time stamp */
uuid_t subscriber; /* Requestor UUID */
uuid_t cell; /* Cell UUID */
VALUE_T data; /* Data Values */
} RCV_ITEM; /* Structure Type */
typedef enum
{ SCHD_ON_CHANGE, /* Send as data chgs */
SCHD_PERIODIC, /* Send every X secs */
SCHD_HOURLY, /* After each hour */
SCHD_DAILY, /* After 12 am */
SCHD_WEEKLY, /* After 12 am Sunday */
SCHD_MONTHLY /* After 12 am on 1st */
} SBSCR_T; /* Enumerated Type */
typedef struct sbscr_basis
{ FIX_STRNG_T item_name; /* Item Name */
FIX_STRNG_T alias; /* Item return name */
SBSCR_T type; /* Subscription Type */
long basis_id; /* Unique Basis ID */
} SBSCR_BASIS; /* Structure Type */
}
-------------------------- cut here ------------------------------
/* mleak.acf */
[explicit_handle] interface mleak
{
}
-------------------------- cut here ------------------------------
/* HNDL_LIST_ITEMS.C */
/* DESCRIPTION: This function prints the item names returned *
* by the server. */
#include "mleak_clnt_proto.h" /* function prototypes */
FIX_STRNG_T item_name; /* Item Name Storage */
int hndl_list_items ( rpc_binding_handle_t s_handle )
{
int ret_status = TRUE; /* Return Status */
STR_PIPE data_out; /* Data Pipe */
void iname_alloc(), /* Pipe Allocation Routine */
iname_push(); /* Pipe Push Routine */
long data_state; /* Pipe State */
struct timespec delay_tm = { 30, 0 }; /* Loop Delay */
data_out.alloc = iname_alloc; /* Initialize Pipe */
data_out.push = iname_push;
data_out.state = (rpc_ss_pipe_state_t)&data_state;
while ( 1 )
{
list_items ( s_handle, data_out ); /* List Item Names */
pthread_delay_np ( &delay_tm );
}
return ( ret_status );
}
void iname_alloc ( state, bsize, buf, bcount ) /* Pipe Allocation Routine */
rpc_ss_pipe_state_t state; /* Pipe State */
idl_ulong_int bsize; /* Buffer Size */
FIX_STRNG_T **buf; /* Buffer Location */
idl_ulong_int *bcount; /* Buffer count */
{
bsize = 1; /* Size of one buffer */
*buf = &item_name; /* Where to write data */
*bcount = sizeof( item_name ); /* One HST_ITEM in buffer */
return;
}
void iname_push ( state, item, item_cnt ) /* Pipe Push Routine */
rpc_ss_pipe_state_t state; /* Pipe State */
FIX_STRNG_T *item; /* Data Item */
idl_ulong_int item_cnt; /* Item Count */
{
if ( item_cnt ) /* There is an item */
{
printf ( "---->%s\n", /* Print Item Name */
item );
}
return;
}
-------------------------- cut here ------------------------------
/* MLEAK_CLNT.C */
/* DESCRIPTION: This is the entry point for a test client of *
* the Memory Leak server program. */
#include "mleak_clnt_proto.h" /* function prototypes */
int main( )
{
int no_errors = TRUE; /* Error Status */
unsigned int status; /* Status Indicator */
rpc_binding_handle_t s_handle; /* Server Binding Handle */
if ( mleak_clnt_init_dce( &s_handle ) ) /* Attach to DCE */
{
no_errors = hndl_list_items ( s_handle );
}
exit (0);
}
-------------------------- cut here ------------------------------
/* MLEAK_CLNT_INIT_DCE.C */
/* DESCRIPTION: This function does everything needed to attach *
* the client to DCE. It fills in the passed in *
* binding handle if it is successful *
* RETURN VALUE: int ret_value - 0 if unsuccessful, *
* 1 if successful initialization */
#include <dce/sec_login.h> /* Secret Key login */
#include "mleak_clnt_proto.h" /* Function Prototypes */
#define BINDING_INFO "/.:/eti_servers/exp_servers/mleak"
/*#define BINDING_INFO "ncacn_ip_tcp:16.66.80.220[18911]"*/
int mleak_clnt_init_dce( s_hndl )
rpc_binding_handle_t *s_hndl; /* Server binding handle */
{
int ret_value = FALSE, /* Function return status */
tcp_found = FALSE; /* TCP Binding Found? */
unsigned32 status, /* DCE call status */
temp_status; /* Temporary DCE call status */
rpc_binding_vector_t *bindings; /* RPC Binding Vector */
rpc_ns_handle_t import_cxt; /* Import Context */
unsigned_char_t *str_binding, /* String Binding */
*obj_uuid, /* Object UUID */
*protocol_seq; /* Protocol Sequence */
rpc_ns_binding_import_begin ( /* Start Importing binding */
rpc_c_ns_syntax_dce,
(unsigned_char_t *)BINDING_INFO,
mleak_v1_0_c_ifspec,
NULL,
&import_cxt,
&status );
while ( (status == rpc_s_ok) && !tcp_found ) /* Search bindings for tcp */
{
rpc_ns_binding_import_next ( /* Get next binding */
import_cxt,
s_hndl,
&status );
if ( status == rpc_s_ok ) /* Next Binding found */
{
rpc_binding_to_string_binding ( /* Convert to string binding */
*s_hndl,
&str_binding,
&status );
}
if ( status == rpc_s_ok ) /* String Binding OK */
{
rpc_string_binding_parse ( /* Get protocol sequence */
str_binding,
NULL,
&protocol_seq,
NULL,
NULL,
NULL,
&status );
}
if ( status == rpc_s_ok ) /* Protocol Seq Parsed OK */
{
if ( !strcmp ( (char *)protocol_seq, /* TCP binding found */
"ncacn_ip_tcp" ) )
{
tcp_found = TRUE;
}
}
}
rpc_ns_binding_import_done ( /* Stop Importing binding */
&import_cxt,
&status );
if ( ( status == rpc_s_ok ) && tcp_found ) /* Binding Imported OK */
{
rpc_ep_resolve_binding ( /* Resolve Endpoint binding */
*s_hndl,
mleak_v1_0_c_ifspec,
&status );
}
if ( ( status == rpc_s_ok ) && tcp_found ) /* Binding Imported OK */
{
rpc_binding_to_string_binding ( /* Convert to string binding */
*s_hndl,
&str_binding,
&status );
}
if ( ( status == rpc_s_ok ) && tcp_found ) /* Binding Resolved OK */
{
rpc_binding_set_auth_info ( /* Set authentication info */
*s_hndl,
(unsigned_char_t *)NULL,
rpc_c_protect_level_pkt,
rpc_c_authn_dce_secret,
NULL,
rpc_c_authz_dce,
&status );
}
if ( ( status == rpc_s_ok ) && tcp_found ) /* Binding Resolved OK */
{
ret_value = TRUE;
}
return ( ret_value );
}
-------------------------- cut here ------------------------------
/* MLEAK_CSTUB.C */
/* Generated by IDL compiler version DEC DCE T1.2.0-06 */
#ifdef VMS
#pragma nostandard
#endif
#include <dce/idlddefs.h>
#include "mleak.h"
static rpc_syntax_id_t IDL_transfer_syntaxes[1] = {
{
{0x8a885d04u, 0x1ceb, 0x11c9, 0x9f, 0xe8, {0x8, 0x0, 0x2b, 0x10, 0x48, 0x60}},
2}};
static rpc_if_rep_t IDL_ifspec = {
1, /* ifspec rep version */
1, /* op count */
1, /* if version */
{0x0094ed00u, 0x14d6, 0x1340, 0xaa, 0x4f, {0x0, 0x4, 0xac, 0xb4, 0x76, 0xdf}},
2, /* stub/rt if version */
{0, NULL}, /* endpoint vector */
{1, IDL_transfer_syntaxes} /* syntax vector */
};
#if defined(__VMS) && (defined(__DECC) || defined(__cplusplus))
#pragma extern_model __save
#pragma extern_model __common_block __shr
#endif
/* global */ rpc_if_handle_t mleak_v1_0_c_ifspec = (rpc_if_handle_t)&IDL_ifspec;
#if defined(__VMS) && (defined(__DECC) || defined(__cplusplus))
#pragma extern_model __restore
#endif
static idl_ulong_int IDL_offset_vec[] = {
0,
0
};
static IDL_rtn_func_t IDL_rtn_vec[] = {
(IDL_rtn_func_t)NULL,
(IDL_rtn_func_t)NULL
};
static idl_byte IDL_type_vec[] = {
0xff,0xff,0xff,0xff,
1,
0,
0xff,0xff,
0x03,0x00,
0x02,0x00,
0x01,0x00,
0x00,0x00,
0x00,0xed,0x94,0x00,
0xd6,0x14,
0x40,0x13,
0xaa,
0x4f,
0x00,0x04,0xac,0xb4,0x76,0xdf,
0x94,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,
0x90,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,
0x01,0x00,0x00,0x00,
0x58,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,
IDL_DT_PIPE,
0|IDL_PROP_DEP_CHAR,
0xff,0xff,
0x65,0x00,0x00,0x00,
IDL_DT_EOL,
IDL_DT_STRING,
IDL_DT_VARYING_ARRAY,
0|IDL_PROP_DEP_CHAR,
0x73,0x00,0x00,0x00,
0x73,0x00,0x00,0x00,
0xff,0xff,0xff,
1,
0x00,0x00,0x00,0x00,
0x64,0x00,0x00,0x00,
IDL_LIMIT_FIXED,
0xff,0xff,0xff,
0x00,0x00,0x00,0x00,
IDL_LIMIT_STRING,
1,
0xff,0xff,
0xff,0xff,0xff,0xff,
IDL_DT_CHAR,
0xff,0xff,0xff,
0x10,0x00,0x00,0x00,
0xa9,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0xa8,0x00,0x00,0x00,
0
};
void list_items
#ifdef IDL_PROTOTYPES
(
/* [in] */ handle_t IDL_handle,
/* [out] */ STR_PIPE item_name
)
#else
(IDL_handle, item_name)
#endif
#ifndef IDL_PROTOTYPES
handle_t IDL_handle;
STR_PIPE item_name;
#endif
{
rpc_transfer_syntax_t IDL_transfer_syntax;
rpc_iovector_elt_t IDL_outs;
volatile ndr_ulong_int IDL_fault_code=error_status_ok;
volatile ndr_ulong_int IDL_user_fault_id;
volatile RPC_SS_THREADS_CANCEL_STATE_T IDL_async_cancel_state;
IDL_ms_t IDL_ms;
idl_byte IDL_stack_packet[IDL_STACK_PACKET_SIZE];
rpc_void_p_t IDL_param_vec[3];
RPC_SS_INIT_CLIENT
RPC_SS_THREADS_DISABLE_ASYNC(IDL_async_cancel_state);
rpc_ss_init_marsh_state(IDL_type_vec, &IDL_ms);
IDL_ms.IDL_stack_packet_status = IDL_stack_packet_unused_k;
IDL_ms.IDL_stack_packet_addr = IDL_stack_packet;
TRY
IDL_ms.IDL_call_h = 0;
IDL_ms.IDL_elt_p = NULL;
IDL_ms.IDL_offset_vec = IDL_offset_vec;
IDL_ms.IDL_rtn_vec = IDL_rtn_vec;
IDL_param_vec[1] = (rpc_void_p_t)&IDL_handle;
IDL_param_vec[2] = (rpc_void_p_t)&item_name;
IDL_ms.IDL_param_vec = IDL_param_vec;
IDL_ms.IDL_side = IDL_client_side_k;
IDL_ms.IDL_language = IDL_lang_c_k;
rpc_call_start((rpc_binding_handle_t) IDL_handle, 0,
(rpc_if_handle_t)&IDL_ifspec,0,(rpc_call_handle_t*)&IDL_ms.IDL_call_h,&IDL_transfer_syntax,(unsigned32*)&IDL_ms.IDL_status);
if (IDL_ms.IDL_status != error_status_ok) goto IDL_closedown;
rpc_ss_ndr_marsh_interp(
0,
0,
IDL_param_vec, &IDL_ms);
IDL_ms.IDL_elt_p = &IDL_outs;
rpc_call_transceive((rpc_call_handle_t)IDL_ms.IDL_call_h,(rpc_iovector_p_t)&IDL_ms.IDL_iovec,
IDL_ms.IDL_elt_p,&IDL_ms.IDL_drep,(unsigned32*)&IDL_ms.IDL_status);
if (IDL_ms.IDL_status != error_status_ok)
{
IDL_ms.IDL_elt_p = NULL;
goto IDL_closedown;
}
rpc_ss_ndr_unmar_interp(
1,
88,
IDL_param_vec, &IDL_ms);
IDL_closedown: ;
CATCH(rpc_x_ss_pipe_comm_error)
FINALLY
rpc_ss_ndr_clean_up(&IDL_ms);
rpc_ss_call_end_2(&IDL_ms.IDL_call_h,&IDL_fault_code,&IDL_user_fault_id,&IDL_ms.IDL_status);
if (IDL_ms.IDL_mem_handle.memory)
{
rpc_ss_mem_free(&IDL_ms.IDL_mem_handle);
}
rpc_ss_report_error_2(IDL_fault_code,IDL_user_fault_id,IDL_ms.IDL_status,
(RPC_SS_THREADS_CANCEL_STATE_T *)&IDL_async_cancel_state, NULL, NULL, NULL, &IDL_ms);
RPC_SS_THREADS_RESTORE_ASYNC(IDL_async_cancel_state);
ENDTRY
}
#ifdef VMS
#pragma standard
#endif
-------------------------- cut here ------------------------------
/* MLEAK_INIT_DCE.C */
/* DESCRIPTION: This function does everything needed to attach *
* the server to DCE. It does not actually listen *
* for RPCs. *
* RETURN VALUE: int ret_value - 0 if unsuccessful, *
* 1 if successful initialization *
*-----------------------------------------------------------------------*
* Set up Login Identity
* If Login Identity was not set up successfully, then
* Indicate an Error
* Endif
*
* If there are no errors, then
* Retrieve the key from the keytab file
* It the Key was not retrieved successfully, then
* Indicate an Error
* Endif
* Endif
*
* If there are no errors, then
* Validate the Login Identity using the key from the keytab file
* It the Login Identity was validated successfully, then
* Free the key
* Else
* Indicate an Error
* Endif
* Endif
*
* If there are no errors, then
* Set the Login Context
* It the Login Context was not set successfully, then
* Indicate an Error
* Endif
* Endif
*
* If there are no errors, then
* Register the Interface
* It the Interface was not registered successfully, then
* Indicate an Error
* Endif
* Endif
*
* If there are no errors, then
* Register the Authentication Information
* It the Authen. Info. was not registered successfully, then
* Indicate an Error
* Endif
* Endif
*
* If there are no errors, then
* Tell DCE to use all Protocol Sequences
* If all protocol sequences can not be used, then
* Indicate an Error
* Endif
* Endif
*
* If there are no errors, then
* Retrieve the Binding Vectors from the RPC Runtime
* It the Binding Vectors were not retrieved successfully, then
* Indicate an Error
* Endif
* Endif
*
* If there are no errors, then
* Register the endpoints with the endpoint map
* It the endpoints were not registered successfully, then
* Indicate an Error
* Endif
* Endif
*
* If there are no errors, then
* Export binding information to the namespace
* It the binding information was not exported successfully, then
* Indicate an Error
* Endif
* Endif
*
* Return Error to calling routine
*
************************************************************************/
#include "mleak_srvr_proto.h" /* Function Prototypes */
#define SERVER_NAME "Memory Leak Server" /* Server Name */
#define BINDING_STR "/.:/eti_servers/exp_servers/mleak"
/*#define BINDING_STR "ncacn_ip_tcp:16.66.80.220[18911]"*/
#define FALSE 0
#define TRUE 1
int mleak_init_dce( )
{
int ret_value = TRUE, /* Function return status */
binding_ndx; /* CDS Bindings counter */
unsigned32 status, /* DCE call status */
temp_status; /* Temporary DCE call status */
extern sec_login_handle_t login_context; /* Login Context */
sec_passwd_rec_t *key_data; /* Password rcrd from keytab */
boolean32 valid_id = FALSE, /* Is ID Valid? */
reset_pwd = FALSE; /* Reset the Password? */
sec_login_auth_src_t auth_src; /* Authorization Source */
rpc_binding_vector_t *bindings; /* RPC Binding Vector */
sec_login_net_info_t net_info; /* Network Info struct */
sec_login_setup_identity ( /* Set up Login Identity */
(unsigned_char_p_t)PRINCIPAL_NAME,
sec_login_no_flags,
&login_context,
&status );
if ( status == rpc_s_ok ) /* Got sealed ID */
{
sec_key_mgmt_get_key ( /* Get key from Keytab file */
rpc_c_authn_dce_secret,
KT_FILE_NAME,
(unsigned_char_p_t)PRINCIPAL_NAME,
0,
(void **)&key_data,
&status );
if ( status != rpc_s_ok ) /* Error occurred */
{
printf ( "\nERROR: Could not get key for %s from %s\n",
PRINCIPAL_NAME,
KT_FILE_NAME );
}
}
if ( status == rpc_s_ok ) /* Got Key from Keytab file */
{
valid_id = sec_login_valid_and_cert_ident( /* Unlock Sealed Login ID */
login_context,
key_data,
&reset_pwd,
&auth_src,
&status );
if ( status != rpc_s_ok ) /* Error occurred */
{
printf ( "\nERROR: Could not validate principal's identity\n" );
}
}
if ( ( status == rpc_s_ok ) && valid_id ) /* Key was validated */
{
sec_key_mgmt_free_key ( /* Free the key */
key_data,
&temp_status );
if ( auth_src != /* Validated locally only */
sec_login_auth_src_network )
{
valid_id = FALSE;
printf ( "\nERROR: Credentials validated locally only.\n" );
}
}
if ( ( status == rpc_s_ok ) && valid_id ) /* Key was truly validated */
{
sec_login_set_context ( /* Set default login context */
login_context,
&status );
if ( status != rpc_s_ok ) /* Error occurred */
{
printf ( "\nERROR: Could not set the login context\n" );
}
}
if ( ( status == rpc_s_ok ) && valid_id ) /* Login context set OK */
{
rpc_server_register_if ( /* Register the Interface */
mleak_v1_0_s_ifspec,
NULL, NULL,
&status );
if ( status != rpc_s_ok ) /* Error occurred */
{
printf ( "\nERROR: Could not register the MLeak interface\n" );
}
}
if ( ( status == rpc_s_ok ) && valid_id ) /* Interface Registered OK */
{
rpc_server_register_auth_info ( /* Register Authen. Info. */
(unsigned_char_p_t)PRINCIPAL_NAME,
rpc_c_authn_dce_secret,
NULL,
(unsigned char *)KT_FILE_NAME,
&status );
if ( status != rpc_s_ok ) /* Error occurred */
{
printf ( "\nERROR: Could not register authentication info.\n" );
}
}
if ( ( status == rpc_s_ok ) && valid_id ) /* Authen Info Registered OK */
{
rpc_server_use_all_protseqs ( /* Use all Protocol Sequences */
rpc_c_protseq_max_calls_default,
&status );
if ( status != rpc_s_ok ) /* Error occurred */
{
printf ( "\nERROR: Could not use all protocol sequences\n" );
}
}
if ( ( status == rpc_s_ok ) && valid_id ) /* Using all Protocol Seqs. */
{
rpc_server_inq_bindings ( /* Get binding Vectors */
&bindings,
&status );
if ( status != rpc_s_ok ) /* Error occurred */
{
printf ( "\nERROR: Can't get binding vectors\n" );
}
}
if ( ( status == rpc_s_ok ) && valid_id ) /* Got Binding Vectors */
{
rpc_ep_register ( /* Register the Endpoints */
mleak_v1_0_s_ifspec,
bindings,
NULL,
(unsigned_char_t *)SERVER_NAME,
&status );
if ( status != rpc_s_ok ) /* Error occurred */
{
printf ( "\nERROR: Can't register MLeak in endpoint mapper\n" );
}
}
if ( ( status == rpc_s_ok ) && valid_id )
{
rpc_ns_binding_export ( /* Export binding info */
rpc_c_ns_syntax_dce,
(unsigned_char_t *)BINDING_STR,
mleak_v1_0_s_ifspec,
bindings,
NULL,
&status );
if ( status != rpc_s_ok ) /* Could not export binding */
{
printf ( "\nERROR: Could not export MLeak binding %s\n",
BINDING_STR );
}
}
if ( ( status != rpc_s_ok ) ||
!valid_id ) ret_value = FALSE; /* Something went wrong */
return ( ret_value );
}
-------------------------- cut here ------------------------------
/* MLEAK_LIST_ITEMS.C */
/* DESCRIPTION: This function returns all the items in the data*
* list that are accessible to the requestor. */
#include "mleak_srvr_proto.h" /* function prototypes */
extern FIX_STRNG_T *data_list; /* Data Values */
void list_items ( client, items )
handle_t client; /* Client's Handle */
STR_PIPE items; /* List of items */
{
FIX_STRNG_T item_name; /* Item Name */
int ndx; /* Array Index */
for ( ndx = 0; /* Loop through Data List */
ndx < LIST_SIZE;
ndx++ )
{
memmove ( &item_name, /* Fill Item name */
data_list[ndx],
strlen(data_list[ndx]) + 1 );
items.push ( items.state, /* Send item name to client */
&item_name,
1 );
}
items.push ( items.state, &item_name, 0 ); /* close pipe */
return;
}
-------------------------- cut here ------------------------------
/* MLEAK_SRVR.C */
/* Content-Disposition: inline; filename="MLEAK_SRVR.C" */
/************************************************************************
* *
* FUNCTION: MLEAK_SRVR *
* *
* DESCRIPTION: This is the entry point for the Memory Leak *
* example server to be sent to DEC for analysis. *
* *
* EXTERNAL MODULES REFERENCED: NONE *
* *
* RETURN VALUE: NONE *
* *
* INPUT FILES NONE *
* *
* OUTPUT FILES: NONE *
* *
* LIBRARY: /usr/lib/libpthreads.a *
* *
* LINK INSTRUCTIONS: *
* *
* ARGUMENTS: NONE *
* *
*************************************************************************
* DESIGN *
*-----------------------------------------------------------------------*
*
*************************************************************************
* MODIFICATION LOG *
------------------------------------------------------------------------*
* DATE SE DESCRIPTION *
* -------- -------------------- ------------------------------- *
************************************************************************/
/************************************************************************
* HEADER FILES *
************************************************************************/
#include "mleak_srvr_proto.h" /* function prototypes */
/************************************************************************
* LOCAL MACROS *
************************************************************************/
/************************************************************************
* GLOBAL VARIABLES *
************************************************************************/
sec_login_handle_t login_context; /* Server's Login Cntxt */
FIX_STRNG_T *data_list; /* Data List */
/************************************************************************
* BEGIN: MLEAK_SRVR *
************************************************************************/
int main( )
{
/************************************************************************
* Declare Function Variables *
************************************************************************/
short ndx; /* Index Counter */
int errors = FALSE; /* Error Status */
unsigned int status; /* DCE Status */
FIX_STRNG_T *curr_item; /* Current List Item */
/************************************************************************
* Initialize Globals *
************************************************************************/
data_list = (FIX_STRNG_T *)malloc( LIST_SIZE * sizeof(FIX_STRNG_T) );
/************************************************************************
* Build Data List *
************************************************************************/
curr_item = data_list; /* Go to top of Data List */
for ( ndx = 0; /* Loop Through list */
ndx <= LIST_SIZE;
ndx++ )
{
sprintf ( (char *)curr_item, /* Fill Current Element */
"%06d\0",
ndx );
curr_item++; /* Go to next element */
}
/************************************************************************
* Plug into DCE *
************************************************************************/
if ( mleak_init_dce () ) /* DCE init was OK */
{
rpc_server_listen ( rpc_c_listen_max_calls_default,
&status );
}
else /* DCE Init failed */
{
errors = TRUE;
printf ( "\nDCE Initialization failed.\n" );
}
exit (0);
}
-------------------------- cut here ------------------------------
/* MLEAK_SSTUB.C*/
/* Generated by IDL compiler version DEC DCE T1.2.0-06 */
#ifdef VMS
#pragma nostandard
#endif
#include <dce/idlddefs.h>
#include "mleak.h"
static idl_ulong_int IDL_offset_vec[] = {
0,
0
};
static IDL_rtn_func_t IDL_rtn_vec[] = {
(IDL_rtn_func_t)NULL,
(IDL_rtn_func_t)NULL
};
static idl_byte IDL_type_vec[] = {
0xff,0xff,0xff,0xff,
1,
0,
0xff,0xff,
0x03,0x00,
0x02,0x00,
0x01,0x00,
0x00,0x00,
0x00,0xed,0x94,0x00,
0xd6,0x14,
0x40,0x13,
0xaa,
0x4f,
0x00,0x04,0xac,0xb4,0x76,0xdf,
0xad,0x00,0x00,0x00,
0x04,0x00,0x00,0x00,
0xa9,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,
0x01,0x00,0x00,0x00,
0x58,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,
IDL_DT_PIPE,
0|IDL_PROP_DEP_CHAR,
0xff,0xff,
0x65,0x00,0x00,0x00,
IDL_DT_EOL,
IDL_DT_STRING,
IDL_DT_VARYING_ARRAY,
0|IDL_PROP_DEP_CHAR,
0x73,0x00,0x00,0x00,
0x73,0x00,0x00,0x00,
0xff,0xff,0xff,
1,
0x00,0x00,0x00,0x00,
0x64,0x00,0x00,0x00,
IDL_LIMIT_FIXED,
0xff,0xff,0xff,
0x00,0x00,0x00,0x00,
IDL_LIMIT_STRING,
1,
0xff,0xff,
0xff,0xff,0xff,0xff,
IDL_DT_CHAR,
0xff,0xff,0xff,
0x10,0x00,0x00,0x00,
0xc2,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0xc1,0x00,0x00,0x00,
0
};
static mleak_v1_0_epv_t IDL_manager_epv = {
list_items
};
static void op0_ssr
#ifdef IDL_PROTOTYPES
(
handle_t IDL_handle,
rpc_call_handle_t IDL_call_h,
rpc_iovector_elt_p_t IDL_elt_p,
ndr_format_p_t IDL_drep_p,
rpc_transfer_syntax_p_t IDL_transfer_syntax_p,
rpc_mgr_epv_t IDL_mgr_epv,
error_status_t *IDL_status_p
)
#else
(IDL_handle, IDL_call_h, IDL_elt_p, IDL_drep_p, IDL_transfer_syntax_p, IDL_mgr_epv, IDL_status_p)
handle_t IDL_handle;
rpc_call_handle_t IDL_call_h;
rpc_iovector_elt_p_t IDL_elt_p;
ndr_format_p_t IDL_drep_p;
rpc_transfer_syntax_p_t IDL_transfer_syntax_p;
rpc_mgr_epv_t IDL_mgr_epv;
error_status_t *IDL_status_p;
#endif
{
IDL_ms_t IDL_ms;
volatile ndr_boolean IDL_manager_entered = ndr_false;
volatile RPC_SS_THREADS_CANCEL_STATE_T IDL_async_cancel_state;
volatile RPC_SS_THREADS_CANCEL_STATE_T IDL_general_cancel_state;
idl_byte IDL_stack_packet[IDL_STACK_PACKET_SIZE];
long IDL_current_pipe = 0;
rpc_void_p_t IDL_param_vec[3];
STR_PIPE item_name;
RPC_SS_INIT_SERVER
rpc_ss_init_marsh_state(IDL_type_vec, &IDL_ms);
IDL_ms.IDL_stack_packet_status = IDL_stack_packet_unused_k;
IDL_ms.IDL_stack_packet_addr = IDL_stack_packet;
TRY
IDL_ms.IDL_offset_vec = IDL_offset_vec;
IDL_ms.IDL_rtn_vec = IDL_rtn_vec;
IDL_ms.IDL_call_h = (volatile rpc_call_handle_t)IDL_call_h;
IDL_ms.IDL_drep = *IDL_drep_p;
IDL_ms.IDL_elt_p = IDL_elt_p;
IDL_param_vec[1] = (rpc_void_p_t)&IDL_handle;
IDL_param_vec[2] = (rpc_void_p_t)&item_name;
IDL_ms.IDL_param_vec = IDL_param_vec;
IDL_ms.IDL_side = IDL_server_side_k;
IDL_ms.IDL_language = IDL_lang_c_k;
item_name.push=(void (IDL_ENTRY * )(
#ifdef IDL_PROTOTYPES
rpc_ss_pipe_state_t state,
FIX_STRNG_T *buf,
idl_ulong_int ecount
#endif
))rpc_ss_ndr_ee_marsh_pipe_chunk;
item_name.pull=(void (IDL_ENTRY * )(
#ifdef IDL_PROTOTYPES
rpc_ss_pipe_state_t state,
FIX_STRNG_T *buf,
idl_ulong_int esize,
idl_ulong_int *ecount
#endif
))rpc_ss_ndr_ee_unmar_pipe_chunk;
rpc_ss_mts_init_callee_pipe(1,0,-32767,&IDL_current_pipe,&IDL_ms,
101,(rpc_ss_mts_ee_pipe_state_t**)&item_name.state);
IDL_current_pipe=(-1);
rpc_ss_ndr_unmar_interp(
0,
0,
IDL_param_vec, &IDL_ms);
/* manager call */
IDL_manager_entered = ndr_true;
RPC_SS_THREADS_DISABLE_ASYNC(IDL_async_cancel_state);
RPC_SS_THREADS_ENABLE_GENERAL(IDL_general_cancel_state);
(*((mleak_v1_0_epv_t *)IDL_mgr_epv)->list_items)(IDL_handle,
item_name);
RPC_SS_THREADS_RESTORE_GENERAL(IDL_general_cancel_state);
RPC_SS_THREADS_RESTORE_ASYNC(IDL_async_cancel_state);
if (IDL_current_pipe != -32767)
{
RAISE(rpc_x_ss_pipe_discipline_error);
}
{
rpc_ss_ndr_marsh_interp(
1,
88,
IDL_param_vec, &IDL_ms);
if (IDL_ms.IDL_iovec.num_elt != 0)
rpc_call_transmit((rpc_call_handle_t)IDL_ms.IDL_call_h,(rpc_iovector_p_t)&IDL_ms.IDL_iovec,
(unsigned32*)&IDL_ms.IDL_status); /* Send remaining outs */
}
IDL_closedown: ;
CATCH_ALL
if ( IDL_manager_entered )
{
RPC_SS_THREADS_RESTORE_GENERAL(IDL_general_cancel_state);
RPC_SS_THREADS_RESTORE_ASYNC(IDL_async_cancel_state);
}
rpc_ss_ndr_clean_up(&IDL_ms);
if (!RPC_SS_EXC_MATCHES(THIS_CATCH,&rpc_x_ss_pipe_comm_error))
{
if ( ! IDL_manager_entered )
{
}
{
rpc_ss_send_server_exception_2(IDL_call_h,THIS_CATCH,0,NULL,&IDL_ms);
IDL_ms.IDL_status = error_status_ok;
}
}
ENDTRY
if (IDL_ms.IDL_mem_handle.memory)
{
rpc_ss_mem_free(&IDL_ms.IDL_mem_handle);
}
if (IDL_ms.IDL_status != error_status_ok)
{
if (IDL_ms.IDL_status == rpc_s_call_cancelled)
{
rpc_ss_send_server_exception(IDL_call_h,&RPC_SS_THREADS_X_CANCELLED);
IDL_ms.IDL_status = error_status_ok;
}
else
{
{
rpc_ss_send_server_exception(IDL_call_h,&rpc_x_ss_remote_comm_failure);
IDL_ms.IDL_status = error_status_ok;
}
}
}
*IDL_status_p = IDL_ms.IDL_status;
}
static rpc_v2_server_stub_proc_t IDL_epva[] =
{
(rpc_v2_server_stub_proc_t)op0_ssr
};
static rpc_syntax_id_t IDL_transfer_syntaxes[1] = {
{
{0x8a885d04u, 0x1ceb, 0x11c9, 0x9f, 0xe8, {0x8, 0x0, 0x2b, 0x10, 0x48, 0x60}},
2}};
static rpc_if_rep_t IDL_ifspec = {
1, /* ifspec rep version */
1, /* op count */
1, /* if version */
{0x0094ed00u, 0x14d6, 0x1340, 0xaa, 0x4f, {0x0, 0x4, 0xac, 0xb4, 0x76, 0xdf}},
2, /* stub/rt if version */
{0, NULL}, /* endpoint vector */
{1, IDL_transfer_syntaxes} /* syntax vector */
,IDL_epva /* server_epv */
,(rpc_mgr_epv_t)&IDL_manager_epv /* manager epv */
};
#if defined(__VMS) && (defined(__DECC) || defined(__cplusplus))
#pragma extern_model __save
#pragma extern_model __common_block __shr
#endif
/* global */ rpc_if_handle_t mleak_v1_0_s_ifspec = (rpc_if_handle_t)&IDL_ifspec;
#if defined(__VMS) && (defined(__DECC) || defined(__cplusplus))
#pragma extern_model __restore
#endif
#ifdef VMS
#pragma standard
#endif
|