| From: SMTP%"[email protected]" 27-MAR-1997 14:21:24.33
To: karen dorhamer <[email protected]>
CC:
Subj: dce problem, letter #1 of 2
Karen:
I'm sending this in two letters.
Enclosed in this note are several files, each separated by uncommented "=="
lines. (See below this text.) They are:
RPC_SEC.CPP
RPC_SEC.H
ESIRPC.H
ESITYPE.H
ESIMACRO.H
ESIVMS.H
SERVER0.IDL
SERVER0.ACF
RPCESITYPE.IDL
REPESITYPE.ACF
MAIN.CPP
COMPILE.COM
Separate them out and use compile.com to build main. We are using the name
EsiServer0 to be registered with dce. The name should be added to the
cell.
Running MAIN should cause the problem.
stevep
========================================================================
====
======================= RPC_SEC.CPP
========================================
========================================================================
====
#include "esivms.h"
#include "esimacro.h"
#include "RPC_SEC.H"
extern "C" {
//=============================================================
void* SecurityRefreshIdentity(pthread_addr_t pTemp)
{
signed32 delay_time;
timespec t_val;
error_status_t status;
CRpcSecurity *pRpcSec;
ESITRACE0("crs:sri: entering security refresh id thread\n");
pRpcSec = (CRpcSecurity*)pTemp;
pRpcSec->m_bRefreshId = FALSE;
while (1)
{
ESITRACE0("crs:sri: getting expiration date\n");
status = pRpcSec->GetExpirationDelayTime(&delay_time);
if (status)
{
break;
}
else
{
pRpcSec->m_bRefreshId = TRUE;
ESITRACE1("crs:sri: waiting %i seconds\n",delay_time);
t_val.tv_sec = delay_time;
t_val.tv_nsec = 0;
pthread_delay_np(&t_val);
ESITRACE0("crs:src: wait complete. refreshing identity\n");
status = pRpcSec->RefreshIdentity();
if (status)
break;
}
}
pRpcSec->SecurityGate(FALSE,status);
pRpcSec->SecurityFail();
return (void*) status;
}
//=============================================================
void* SecurityRefreshKey(pthread_addr_t pTemp)
{
timespec t_val;
error_status_t status;
CRpcSecurity *pRpcSec;
ESITRACE0("crs:srk:entering security refresh key\n");
pRpcSec = (CRpcSecurity*)pTemp;
pRpcSec->m_bRefreshKey = TRUE;
ESITRACE1("crs:srk:security name = %s\n",pRpcSec->m_pszSecurityName);
ESITRACE1("crs:srk:security keytab = %s\n",pRpcSec->m_pszKeyTab);
ESITRACE0("crs:srk:waiting 10 seconds\n");
t_val.tv_sec = 10;
t_val.tv_nsec = 0;
pthread_delay_np(&t_val);
ESITRACE0("crs:srk:wait ended\n");
while (1)
{
// TRY
// {
ESITRACE0("crs:srk: making key management call\n");
sec_key_mgmt_manage_key(rpc_c_authn_dce_secret,
NULL,
(idl_char*)pRpcSec->m_pszSecurityName,
&status);
ESITRACE0("crs:srk: successful key management call\n");
// }
// CATCH_ALL
// {
// ESITRACE0("crs:srk:exception from sec call\n");
// status = ESISTAT_GENFAILURE;
// }
// ENDTRY
ESITRACE1("crs:srk: status check = %i\n",status);
if (!CHECK_STATUS(status))
{
if (status != ESISTAT_GENFAILURE)
PRINT_STATUS(status,"crs:srk:problem with key refresh:");
break;
}
}
pRpcSec->SecurityGate(FALSE,status);
pRpcSec->SecurityFail();
return (void*) status;
}
} //end extern
//=============================================================
CRpcSecurity::CRpcSecurity(ESIRETFUNC pReturn)
{
SecurityGate(FALSE,0);
m_pszSecurityName = NULL;
m_bRefreshId = FALSE;
m_bRefreshKey = FALSE;
m_pszProtLevel = NULL;
m_pszAuthnService = NULL;
m_pszAuthzService = NULL;
m_pszKeyTab = NULL;
m_iProtLevel = rpc_c_protect_level_none;
m_iAuthnService = rpc_c_authn_none;
m_iAuthzService = rpc_c_authz_none;
m_pSecurityFailReturn = pReturn;
}
//=============================================================
CRpcSecurity::~CRpcSecurity()
{
StopThreads();
DeleteString(&m_pszProtLevel);
DeleteString(&m_pszAuthnService);
DeleteString(&m_pszAuthzService);
DeleteString(&m_pszKeyTab);
SecurityFail();
}
//=============================================================
void CRpcSecurity::SecurityFail()
{
if (m_pSecurityFailReturn != NULL)
{
(*m_pSecurityFailReturn)(m_bSecurityGate);
}
}
//=============================================================
void CRpcSecurity::SecurityGate(BOOL bState,ESISTATUS status)
{
ESITRACE2("crs:sg: security gate value/status = %i/%i\n",bState,status);
m_bSecurityGate = bState;
m_esSecurityStatus = status;
}
//=============================================================
BOOL CRpcSecurity::SecurityCheck()
{
return m_bSecurityGate;
}
//=============================================================
BOOL CRpcSecurity::InitSecurity(char** gv)
{
//gv[0]:Security Name
//gv[1]:protection level
//gv[2]:authentication service
//gv[3]:authorization service
//gv[4]:keytab directory
BOOL bRV = TRUE;
ESITRACE0("crs:is:entering init security\n");
m_pszSecurityName = NULL;
if (strcmp(gv[0],"0") != 0)
{
m_pszSecurityName = CopyString(gv[0]);
}
else
{
ESITRACE0("crs:is: no security requested\n");
SecurityGate(TRUE,ESISTAT_SUCCESS);
return m_bSecurityGate;
}
ESITRACE1("crs:is: security name = %s\n",m_pszSecurityName);
ESITRACE1("crs:is: prot level = %s\n",gv[1]);
ESITRACE1("crs:is: authentication service = %s\n",gv[2]);
ESITRACE1("crs:is: authorization service = %s\n",gv[3]);
ESITRACE1("crs:is: key tab = %s\n",gv[4]);
m_pszProtLevel = CopyString(gv[1]);
m_pszAuthnService = CopyString(gv[2]);
m_pszAuthzService = CopyString(gv[3]);
if (strcmp(gv[4],"0") == 0)
{
m_pszKeyTab = NULL;
}
else
{
m_pszKeyTab = CopyString(gv[4]);
}
sscanf(gv[1],"%i",&m_iProtLevel);
sscanf(gv[2],"%i",&m_iAuthnService);
sscanf(gv[3],"%i",&m_iAuthzService);
bRV = ProcessSecurityLogin(m_pszSecurityName,&m_login_context);
ESITRACE1("crs:is: psl returned boolean = %i\n",bRV);
if (bRV)
{
bRV = StartThreads();
}
return bRV;
}
//=============================================================
BOOL CRpcSecurity::ProcessSecurityLogin(char* pName,
sec_login_handle_t* pLoginContext)
{
sec_login_auth_src_t auth_src;
void* server_key;
error_status_t status,status2;
boolean32 identity_valid;
boolean32 reset_passwd;
BOOL bRV = FALSE;
sec_login_handle_t login_context;
if (pName == NULL)
{
*pLoginContext = NULL;
ESITRACE0("crs:psl: no security\n");
return TRUE;
}
*pLoginContext = NULL;
ESITRACE0("crs:psl: security attempted.\n");
ESITRACE1("crs:psl: name = %s\n",pName);
bRV = FALSE;
ESITRACE0("crs:psl: setup identity call\n");
sec_login_setup_identity((unsigned char*)pName,
sec_login_no_flags,
&login_context,
&status);
ESITRACE0("crs:psl: setup identity complete\n");
if (CHECK_STATUS(status))
{
sec_key_mgmt_get_key(rpc_c_authn_dce_secret,
m_pszKeyTab,
(unsigned char*)pName,
0,
&server_key,
&status);
if (CHECK_STATUS(status))
{
// identity_valid = sec_login_validate_identity(login_context,
// (sec_passwd_rec_t *)server_key,
// &reset_passwd,
// &auth_src,
// &status);
identity_valid = sec_login_valid_and_cert_ident(login_context,
(sec_passwd_rec_t *)server_key,
&reset_passwd,
&auth_src,
&status);
sec_key_mgmt_free_key(&server_key,&status2);
if (CHECK_STATUS(status2))
{
if (identity_valid)
{
if (auth_src == sec_login_auth_src_network)
{
sec_login_set_context(login_context,&status);
if (CHECK_STATUS(status))
{
bRV = TRUE;
*pLoginContext = login_context;
}
}
else
{
PRINT_STATUS(status,"crs:psl:unable to set login context,");
}
}
else
{
PRINT_STATUS(status,"crs:psl:identity not valid,");
}
}
else
{
PRINT_STATUS(status2,"crs:psl:unable to free key,");
}
}
else
{
PRINT_STATUS(status,"crs:psl:unable to get key,");
}
}
else
{
PRINT_STATUS(status,"crs:psl:unable to set up identity,");
}
ESITRACE1("crs:psl: server startup status = %i\n",bRV);
SecurityGate(bRV,status);
return bRV;
}
//=============================================================
char* CRpcSecurity::CopyString(char* pszText)
{
char* pszRV = NULL;
if (pszText != NULL)
{
pszRV = (char*) malloc(strlen(pszText) + 1);
strcpy(pszRV,pszText);
}
return pszRV;
}
//=============================================================
void CRpcSecurity::DeleteString(char** pszText)
{
char* pszChar;
pszChar = *pszText;
if (pszChar != NULL)
{
delete(pszChar);
pszChar = NULL;
*pszText = pszChar;
}
}
//=============================================================
ESISTATUS CRpcSecurity::GetExpirationDelayTime(signed32 *delay_time)
{
signed32 expiration;
timeb_t current_time;
signed32 difftime;
signed32 lDelay = 0;
ESISTATUS status;
ESITRACE0("crs:gedt: entering get expiration date\n");
sec_login_get_expiration(m_login_context,&expiration,&status);
if (CHECK_STATUS(status))
{
ftime(¤t_time);
difftime = expiration - current_time.time;
if (difftime > 0)
{
lDelay = difftime - 600;
if (lDelay < 0)
lDelay = 0;
}
else
{
lDelay = 0;
}
}
else
{
PRINT_STATUS(status,"crs:gedt:problem getting expiration time:")
}
if (CHECK_STATUS(status))
{
SecurityGate(TRUE,status);
}
else
{
SecurityGate(FALSE,status);
}
*delay_time = lDelay;
return status;
}
//=============================================================
ESISTATUS CRpcSecurity::RefreshIdentity()
{
sec_login_auth_src_t auth_src;
void* server_key;
error_status_t status;
error_status_t status2;
boolean32 identity_valid;
boolean32 reset_passwd;
ESITRACE0("crs:ri: entering refresh identity\n");
sec_login_refresh_identity(m_login_context,&status);
if (CHECK_STATUS(status))
{
sec_key_mgmt_get_key(rpc_c_authn_dce_secret,
m_pszKeyTab,
(unsigned char*)m_pszSecurityName,
0,
&server_key,
&status);
if (CHECK_STATUS(status))
{
identity_valid = sec_login_validate_identity(m_login_context,
(sec_passwd_rec_t *)server_key,
&reset_passwd,
&auth_src,
&status);
sec_key_mgmt_free_key(&server_key,&status2);
if (!CHECK_STATUS(status))
{
PRINT_STATUS(status,"crs:ri: problem validating login:");
}
else
{
if (!CHECK_STATUS(status2))
{
status = status2;
PRINT_STATUS(status,"crs:ri: problem freeing management key:");
}
}
}
else
{
PRINT_STATUS(status,"crs:ri: problem getting management key:");
}
}
else
{
PRINT_STATUS(status,"crs:ri: problem refreshing identity:");
}
if (CHECK_STATUS(status))
{
SecurityGate(TRUE,status);
}
else
{
SecurityGate(FALSE,status);
}
return status;
}
//=============================================================
BOOL CRpcSecurity::StartThreads()
{
int stts;
BOOL bRV = TRUE;
ESITRACE0("crs:st:starting threads\n");
stts = pthread_create(
&m_IdRefreshThread,
pthread_attr_default,
SecurityRefreshIdentity,
(void*)this);
if (!stts)
{
stts = pthread_create(
&m_KeyRefreshThread,
pthread_attr_default,
SecurityRefreshKey,
(void*)this);
ESITRACE1("crs:st:key refresh thread start status = %i\n",stts);
if (!stts)
{
bRV = TRUE;
}
}
return bRV;
}
//=============================================================
void CRpcSecurity::StopThreads()
{
ESITRACE0("crs:st: stopping threads\n");
if (m_bRefreshId)
pthread_cancel(m_IdRefreshThread);
if (m_bRefreshKey)
pthread_cancel(m_KeyRefreshThread);
}
========================================================================
====
======================= RPC_SEC.H
==========================================
========================================================================
====
#ifndef _RPC_SEC_H_
#define _RPC_SEC_H_
#include <pthread.h>
#include <time.h>
#include <timeb.h>
#include "esitype.h"
#include "esirpc.h"
typedef void (*ESIRETFUNC)(BOOL);
extern "C" void* SecurityRefreshIdentity(pthread_addr_t pTemp);
extern "C" void* SecurityRefreshKey(pthread_addr_t pTemp);
class CRpcSecurity{
public:
CRpcSecurity(ESIRETFUNC pReturn = NULL);
~CRpcSecurity();
BOOL SecurityCheck();
BOOL InitSecurity(char** gv);
private:
void SecurityGate(BOOL bState,ESISTATUS status);
BOOL ProcessSecurityLogin(char* pName,
sec_login_handle_t* pLoginContext);
char* CopyString(char* pszText);
void DeleteString(char** pszText);
ESISTATUS GetExpirationDelayTime(signed32 *delay_time);
ESISTATUS RefreshIdentity();
BOOL StartThreads();
void StopThreads();
void SecurityFail();
pthread_t m_IdRefreshThread;
pthread_t m_KeyRefreshThread;
BOOL m_bRefreshId;
BOOL m_bRefreshKey;
BOOL m_bSecurityGate;
ESISTATUS m_esSecurityStatus;
unsigned32 m_iAuthnService;
unsigned32 m_iAuthzService;
unsigned32 m_iProtLevel;
sec_login_handle_t m_login_context;
char* m_pszAuthnService;
char* m_pszAuthzService;
char* m_pszKeyTab;
char* m_pszProtLevel;
char* m_pszSecurityName;
ESIRETFUNC m_pSecurityFailReturn;
friend void* SecurityRefreshIdentity(pthread_addr_t pTemp);
friend void* SecurityRefreshKey(pthread_addr_t pTemp);
};
#endif
========================================================================
====
======================= ESIRPC.H
===========================================
========================================================================
====
#ifndef _ESIRPC_H
#define _ESIRPC_H
//===============================================================
//======================== GRADIENT RPC =========================
//===============================================================
#ifdef ESIRPC_GRADIENT
#include <dce/rpc.h>
#include <pthread.h>
#include <dce/sec_login.h>
#include <dce/keymgmt.h>
#include <dce/dce_error.h>
#include "esimacro.h"
#define _RPC_H_
#define CHECK_STATUS(input_status) input_status == rpc_s_ok
#ifdef ESIDEBUG
#define PRINT_STATUS(input_status,comment) \
{ \
if (input_status != rpc_s_ok) \
{\
dce_error_inq_text(input_status,\
ESIRPCG_error_string,\
&ESIRPCG_error_stat);\
ESITRACE2("%s %s\n",comment,ESIRPCG_error_string);\
}\
}
#endif
#ifndef ESIDEBUG
#define PRINT_STATUS(input_status,comment)
#endif
#define GET_STATUS(input_status,error_string,error_stat) \
dce_error_inq_text(input_status,\
error_string,\
&error_stat);
static int ESIRPCG_error_stat;
static unsigned char ESIRPCG_error_string[dce_c_error_string_len];
typedef unsigned long RPC_STATUS;
#endif
//===============================================================
//======================== DEC RPC ==============================
//===============================================================
#ifdef ESIRPC_DEC
#include <rpc.h>
#include <sec_login.h>
#include <keymgmt.h>
#include <dce_error.h>
typedef unsigned int RPC_STATUS;
#define ESIS0_CONFIGFILE "ESI$RPC_CONFIGFILE"
#define CHECK_STATUS(input_status) input_status == 0
#ifdef ESIDEBUG
#define PRINT_STATUS(input_status,comment) \
{ \
if (input_status != rpc_s_ok) \
{\
dce_error_inq_text(input_status,\
ESIRPCG_error_string,\
&ESIRPCG_error_stat);\
ESITRACE2("%s %s\n",comment,ESIRPCG_error_string);\
}\
}
#endif
#ifndef ESIDEBUG
#define PRINT_STATUS(input_status,comment)
#endif
#define GET_STATUS(input_status,error_string,error_stat) \
dce_error_inq_text(input_status,\
error_string,\
&error_stat);
static int ESIRPCG_error_stat;
static unsigned char ESIRPCG_error_string[dce_c_error_string_len];
#endif
//===============================================================
//======================== MICROSOFT RPC ========================
//===============================================================
#ifdef ESIRPC_MS
#include <rpc.h>
typedef unsigned int unsigned32;
#endif
//===============================================================
//======================== GENERAL RPC ==========================
//===============================================================
#define ESI_MSGBUFFERSIZE 1024
#define ESI_MAXCALLS 20
#define ESI_PARMLIMIT 30
#define ESI_MAXCALLS 20
#define ESI_ENDPTBUFF 100
#define ESI_PROTSEQBUFF 100
#define ESI_STACKSIZE 100000
#endif
========================================================================
====
======================= ESITYPE.H
==========================================
========================================================================
====
#ifndef ESITYPE_H
#define ESITYPE_H
#include <string.h>
//include ESIOBJ.H
//===================================================================
#ifndef BOOL
#define BOOL int
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef ESILPTSTR
#define ESILPTSTR char*
#endif
#ifndef LPCVARIANT
#define LPCVARIANT ESIVARIANT *
#endif
#ifndef ESIDWORD
#define ESIDWORD unsigned long
#endif
#ifndef ESIBSTR
#define ESIBSTR char*
#endif
//===================================================================
//STATUS DEFINITIONS
#define ESISTAT_SUCCESS 0
#define ESISTAT_GENFAILURE 1001
#define ESISTAT_GTFAILURE 1002
#define ESISTAT_MXTIMEOUT 1003
#define ESISTAT_MTIMEOUT 1004
#define ESISTAT_INVALIDMIXED 1005
//SECURITY DEFINITIONS
#define ESISTAT_NOAUTH 5000
//TEXT OF STATUS DEFINITIONS
#define ESITXT_SUCCESS "operation successful"
#define ESITXT_GENFAILURE "general failure"
#define ESITXT_GTFAILURE "gateway failure"
#define ESITXT_MXTIMEOUT "mutex timeout error"
#define ESITXT_NOAUTH "no authorization for operation"
#define ESITXT_MTIMEOUT "M timeout"
#define ESITXT_INVALIDMIXED "positional parm's must preced key parms"
//variable handling definitions
#define ESIVARTYPE unsigned short
#define ESIPARAMCOUNT unsigned short
#define ESIEVTOKEN long
#define ESISESSIONID long
#define ESIEV_MAXPARMS 15
#define ESIEV_CELLINCR 50
//===================================================================
//general typedefs
typedef unsigned int UINT;
typedef short ESIDIRECTION;
typedef struct tagSession
{
unsigned long SessionID;
}SESSION;
typedef struct tagBSTR { void * buffer; }ESIBSTRSTRUCT;
typedef struct tagESICY
{
unsigned long lo;
long hi;
}ESICY;
enum ESIVTNUM {
ESIVT_EMPTY = 0,
ESIVT_NULL = 1,
ESIVT_I2 = 2,
ESIVT_I4 = 3,
ESIVT_R4 = 4,
ESIVT_R8 = 5,
ESIVT_CY = 6,
ESIVT_DATE = 7,
ESIVT_BSTR = 8,
ESIVT_DISPATCH = 9,
ESIVT_ERROR = 10,
ESIVT_BOOL = 11,
ESIVT_VARIANT = 12,
ESIVT_UNKNOWN = 13,
ESIVT_DECIMAL = 14,
ESIVT_I1 = 16,
ESIVT_UI1 = 17,
ESIVT_UI2 = 18,
ESIVT_UI4 = 19,
ESIVT_I8 = 20,
ESIVT_UI8 = 21,
ESIVT_INT = 22,
ESIVT_UINT = 23,
ESIVT_VOID = 24,
ESIVT_HRESULT = 25,
ESIVT_PTR = 26,
ESIVT_SAFEARRAY = 27,
ESIVT_CARRAY = 28,
ESIVT_USERDEFINED = 29,
ESIVT_LPSTR = 30,
ESIVT_LPWSTR = 31,
ESIVT_EOOBJECT = 48,
ESIVT_FILETIME = 64,
ESIVT_BLOB = 65,
ESIVT_STREAM = 66,
ESIVT_STORAGE = 67,
ESIVT_STEAMED_OBJECT = 68,
ESIVT_STORED_OBJECT = 69,
ESIVT_BLOB_OBJECT = 70,
ESIVT_CF = 71,
ESIVT_CLSID = 72
};
typedef struct tagESISAFEARRAYBOUND {
long cElements;
long lLbound;
}ESISAFEARRAYBOUND;
typedef struct tagESIVTARRAY {
void * pData; //the pointer to the data
//ESIVARIANT * PData;
ESISAFEARRAYBOUND rgsabound[1]; //struct array that include up and low bounds
unsigned long cLocks ; //count of the array has been locked
unsigned short cDims ; //count of dimensions in this array
unsigned short fFeatures ; //Flags for data contants
unsigned long cbElements ; //default size of an element of the array //dose
not include size of pointed to data
}ESISAFEARRAY;
//#define ESIVARIANT struct tagESIVARIANT
typedef struct tagESIVARIANT ESIVARIANT;
typedef char * ESIOBJCT;
struct tagESIVARIANT {
ESIVTNUM vt;
unsigned short wReserved1;
unsigned short wReserved2;
unsigned short wReserved3;
union {
long bEmpty; //ESIVT_EMPTY
// bNull; //ESIVT_NULL
short iVal; //ESIVT_I2
long lVal; //ESIVT_I4
float fltlVal; //ESIVT_R4
double dblVal; //ESIVT_R8
ESICY cyVal; //ESIVT_CY
double date; //ESIVT_DATE
ESIBSTR bstrVal; //ESIVT_BSTR
//Idispatch pdispVal; //ESIVT_DISPATCH
//ESIERRO preturn; //ESIVT_ERROR
BOOL bVal; //ESIVT_BOOL
ESIVARIANT * pvarVal; //ESIVT_VARIANT
//Iunknown punkVal; //ESIVT_UNKNOWN
//ESIVT_DECIMAL
//ESIVT_I1
//ESIVT_UI1
//ESIVT_UI2
ESIDWORD dVal; //ESIVT_UI4
//ESIVT_I8
//ESIVT_UI8
int plVal; //ESIVT_INT
unsigned int puVal; //ESIVT_UINT
void * pvoid; //ESIVT_VOID
//ESIVT_HRESULT
//ESIVT_PTR
ESISAFEARRAY* parrVal; //ESIVT_SAFEARRAY
//ESIVT_CARRAY
//ESIVT_USERDEFINED
ESILPTSTR plstrVal; //ESIVT_LPSTR
//ESILPWSTR plpwstrVal; //ESIVT_LPWSTR
ESIOBJCT pobjVal; //ESIVT_EOOBJECT
//ESIFILETIME pftVal; //ESIVT_FILETIME
//ESIVT_BLOB
//ESIVT_STREAM
//ESIVT_STORAGE
//ESIVT_STEAMED_OBJECT
//ESIVT_STORED_OBJECT
//ESIVT_BLOB_OBJECT
//ESIVT_CF
//UUID puidVal; //ESIVT_CLSID
};
};
//===================================================================
//------------------- Structures used in client/server calls --------------//
typedef ESIVARIANT ESIVARVAR[];
typedef struct tagESIPARAMETER {
ESIVARIANT* pParam;
short IsNamed;
char* pName;
} ESIPARAMETER;
typedef ESIPARAMETER ESIPARAMETERARRAY[];
typedef UINT ESISTATUS;
typedef struct tagINVOCATIONFRAME {
ESILPTSTR szTarget;
ESILPTSTR szService;
ESIVARIANT vaReturn;
short nParamCount;
ESISTATUS eStatus;
ESIPARAMETER* pParamArray;
} INVOCATIONFRAME;
typedef struct tagSTATUSSUBBLOCK{
ESISTATUS eStatus;
}STATUS_SUBBLOCK;
typedef struct tagSTATUSFRAME {
char* cIssuer;
char* cMessage;
ESISTATUS eSuccess;
UINT eSubCode;
STATUS_SUBBLOCK* pSubBlock;
}STATUSFRAME;
#define LPCSTATUS STATUSFRAME *
//===================================================================
//CREATE FRAME
#define ESICR_PARMLIMIT 20
#define ESICR_PARMPOS 0
#define ESICR_PARMKEY 1
enum ESICREATETYPE{
ESICR_KEYPARM =0,
ESICR_POSPARM =1,
ESICR_PRPPARM =2,
ESICR_PRPVAL =3,
ESICR_CREATEKEYWORDS =4
};
typedef struct tagESICREATEKEYWORDPARM{
char* Name; //name of keyword parameter
ESIVARIANT Value; //value of keyword parameter
}ESICREATEKEYWORDPARM;
typedef struct tagESICREATEPOSPARM{
short Pos; //position of parameter
ESIVARIANT Value; //value of positional parameter
}ESICREATEPOSPARM;
typedef struct tagESICREATEKEYWORD{
char* Name; //name of create keyword
ESIVARIANT Value; //value of create keyword
}ESICREATEKEYWORD;
typedef struct tagESICREATEPROPSPARM{
short PropParmType; //property calling type
short PropParmPos; //property parameter position
ESIVARIANT Value; //value of property parameter
short PropPos; //property position
char* PropKeyWord; //prop keyword
}ESICREATEPROPSPARM;
typedef struct tagESICREATEPROPSVAL{
char* Name; //property name
short Pos; //property position
ESIVARIANT Value; //property value
}ESICREATEPROPSVAL ;
typedef struct tagESICREATEPARM {
ESICREATETYPE ParmType; //structure type
union {
ESICREATEKEYWORD KeyWord; //keyword on create
ESICREATEKEYWORDPARM KeyParm; //keyword parm on create
ESICREATEPOSPARM PosParm; //position parm on create
ESICREATEPROPSPARM PropParm;//parameters on property
ESICREATEPROPSVAL PropVal; //value of prop param's
};
} ESICREATEPARM;
typedef ESICREATEPARM ESICREATEPARMARRAY[];
typedef struct tagESICREATEFRAME {
ESILPTSTR className;
short iNumElements;
ESICREATEPARM* createArray;
}ESICREATEFRAME;
typedef struct tagCREATE_LOCALKEYPARM{
char* Name;
ESIVARIANT Value;
}CREATE_LOCALKEYPARM;
typedef struct tagCREATE_LOCALPOSPARM{
ESIVARIANT Value;
}CREATE_LOCALPOSPARM;
typedef struct tagCREATE_LOCALKEYWORD{
char* Name;
ESIVARIANT Value;
}CREATE_LOCALKEYWORD;
typedef struct tagCREATE_LOCALPROPS{
char* Name;
ESIVARIANT Value;
}CREATE_LOCALPROPS;
typedef struct tagCREATE_LOCALPROPPARM{
BOOL Used;
int NumParms;
int Type;
ESIVARIANT Value;
char* Name;
CREATE_LOCALPROPS Parm[ESICR_PARMLIMIT];
}CREATE_LOCALPROPPARM;
//===================================================================
//event frames and logic
#define ESIEV_EVENT "$EVENT"
#define ESIEV_PROPERTIES "$PROPERTIES"
#define ESIEV_PROPTYPE 2
typedef void* ESIWATCHTOKEN;
typedef void* ESIGENTOKEN;
typedef struct tagESIEVENTFRAME{
ESIWATCHTOKEN wToken;
ESIOBJCT pObject;
ESIPARAMCOUNT sNumParams;
ESIVARTYPE eType;
char* cEventName;
ESIVARIANT* pVarArray;
}ESIEVENTFRAME;
class CClientTransportAdapter;
typedef ESISTATUS (*ESIEVFUNC)(ESIGENTOKEN,ESIEVENTFRAME*);
typedef ESISTATUS (*ESIEVROUTER)(ESIGENTOKEN,ESIEVENTFRAME*);
typedef int ESICTAWATCHID;
typedef struct tagESICTAWATCH{
ESIEVROUTER pRouter;
ESICTAWATCHID pId;
ESIWATCHTOKEN pSTA;
ESISESSIONID Session;
}ESICTAWATCH;
typedef ESICTAWATCH* ESICTATOKEN;
typedef struct tagESIWATCHSTRUCT{
ESIEVFUNC pProc;
ESIOBJCT pObject;
char* cEventName;
ESICTATOKEN wToken;
ESICTAWATCHID pId;
ESISESSIONID Session;
}ESIWATCHSTRUCT;
#endif //ESITYPE_H
|
| From: SMTP%"[email protected]" 27-MAR-1997 14:16:24.36
To: karen dorhamer <[email protected]>
CC:
Subj: dce problem, letter #2 of 2
Karen:
I'm sending this in two letters.
Enclosed in this note are several files, each separated by uncommented "=="
lines. (See below this text.) They are:
RPC_SEC.CPP
RPC_SEC.H
ESIRPC.H
ESITYPE.H
ESIMACRO.H
ESIVMS.H
SERVER0.IDL
SERVER0.ACF
RPCESITYPE.IDL
REPESITYPE.ACF
MAIN.CPP
COMPILE.COM
Separate them out and use compile.com to build main. We are using the name
EsiServer0 to be registered with dce. The name should be added to the
cell.
Running MAIN should cause the problem.
stevep
========================================================================
====
======================= ESIMACRO.H
=========================================
========================================================================
====
#ifndef _ESIMACRO_H_
#define _ESIMACRO_H_
//------------------------------------------------
#ifdef ESIDEBUG
#define ESITRACE0(string) \
printf(string);
#define ESITRACE1(string,val1) \
printf(string,val1);
#define ESITRACE2(string,val1,val2) \
printf(string,val1,val2);
#define ESITRACE3(string,val1,val2,val3) \
printf(string,val1,val2,val3);
#define ESITRACE4(string,val1,val2,val3,val4) \
printf(string,val1,val2,val3,val4);
#define ESITRACE5(string,val1,val2,val3,val4,val5) \
printf(string,val1,val2,val3,val4,val5);
#endif
//------------------------------------------------
#ifndef ESIDEBUG
#define ESITRACE0(string)
#define ESITRACE1(string,val1)
#define ESITRACE2(string,val1,val2)
#define ESITRACE3(string,val1,val2,val3)
#define ESITRACE4(string,val1,val2,val3,val4)
#define ESITRACE5(string,val1,val2,val3,val4,val5)
#endif
//------------------------------------------------
#endif
========================================================================
====
======================= ESIVMS.H
===========================================
========================================================================
====
#ifndef _ESIVMS_H_
#define _ESIVMS_H_
#include <starlet.h>
#include <LNMDEF.h>
#include <libdef.h>
#include <cmbdef.h>
#include <agndef.h>
#include <descrip.h>
#include <ssdef.h>
#include <iodef.h>
#include <stsdef.h>
#include <prcdef.h>
#include <stddef.h>
#include <unistd.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <iostream.h>
#include <memory.h>
#include <ssdef.h>
#define ESIVMS_ACCESS 0
#define ESIVMS_USCORE "_"
#define ESIVMS_NULL 0
#define ESIVMS_CHARWIDTH 512
#define ESIVMS_CR 13
#define ESIVMS_LF 10
#define ESIVMS_MAILBOXROOT "ESIMBX"
#define ESIVMS_MBMXMSG 1024
#define ESIVMS_MBBFQUO 0
#define ESIVMS_MBFLPROT 0
#define ESIVMS_MBMASK 0
#define ESIVMS_IOEVTFLG 0
#define ESIVMS_IOWRTFNC IO$_WRITEVBLK|IO$M_NOW
#define ESIVMS_IOREADFNC IO$_READVBLK|IO$M_NOW
#define ESIVMS_IOWASTA 0
#define ESIVMS_IOWASTP 0
#define ESIVMS_IOWEOF IO$_WRITEOF|IO$M_NOW
#define ESIVMS_DETACH PRC$M_DETACH
#define ESIVMS_NAMEROOT "ESIGT"
#define ESIVMS_S0ROOT "ESICB"
#define ESIVMS_BASPRI 10
#define ESIVMS_LNMTABL "LNM$PROCESS_TABLE"
#define ESIVMS_LNMTLIST "LNM$SYSTEM"
#define ESIVMS_NULLDEV "NL0"
#define ESIVMS_SYSINPUT "SYS$INPUT"
#define ESIVMS_SYSOUTPUT "SYS$OUTPUT"
#define ESIVMS_SYSERROR "SYS$ERROR"
typedef struct tagESI_IOSB { /* I/O status block */
short int sStatus;
short int sByteCount;
int iPID;
} ESI_IOSB;
#endif
========================================================================
====
======================= SERVER0.IDL
========================================
========================================================================
====
[
uuid(9d548fe0-40d5-11d0-afc0-e00567000000),
version(1.0)
]
interface Server0
{
import "rpcesitype.idl";
/*---------------- database definitions -----------------------*/
typedef struct tagCONNECTION {
[string,unique] unsigned char * IpAddress;
[string,unique] unsigned char * Port;
[string,unique] unsigned char * GTName;
[string,unique] unsigned char * GTProtection;
[string,unique] unsigned char * GTAuthnService;
[string,unique] unsigned char * GTAuthzService;
}CONNECTION;
typedef short rpcESIPOINTSTATE;
typedef struct tagRpcPortNode {
[string,unique] char* port;
[string,unique] char* coup;
[string,unique] char* ClientIp;
[string,unique] char* GatewayIp;
rpcESIPOINTSTATE currentState;
rpcESIOPERCOUNTER ctTotal;
rpcESIOPERCOUNTER ctTimer;
rpcESIOPERCOUNTER ctEO;
rpcESIOPERCOUNTER ctM;
}rpcPORTNODE;
typedef [string,unique] char* rpcPtrToChar;
/*---------------- function definitions -----------------------*/
CONNECTION * RpcServer0Connection(
[in, string, unique] unsigned char* user
);
rpcESISTATUS RpcPortRestore(
[in, string, unique] char* rsPort
);
rpcESISTATUS RpcShutdownServerGateway(
[in, string, unique] char* Port
);
rpcESISTATUS RpcServer0Shutdown();
rpcESISTATUS RpcShutdownAllGateways();
char* RpcServer0GetPortListString();
rpcESISTATUS RpcServer0SetPortList(
[in,out,unique] char* pSetList,
[in,out,ref] rpcDataReturn* pNumSet
);
void RpcServer0GetPortRange(
[in,out,unique] rpcPtrToChar* pStartPort,
[in,out,unique] rpcPtrToChar* pEndPort
);
void RpcServer0SetPortRange(
[in,out,string] char* pStartPort,
[in,out,string] char* pEndPort,
[in,out,ref] rpcDataReturn* pNumSet
);
rpcESISTATUS RpcServer0DeletePort(
[in,out,unique] char* port
);
rpcESISTATUS RpcServer0InsertPort(
[in,out,unique] char* port
);
void RpcServer0DeletePortRange(
[in,out,unique] char* sport,
[in,out,unique] char* eport
);
rpcESISTATUS RpcServer0InsertPortRange(
[in,out,unique] char* sport,
[in,out,unique] char* eport
);
void RpcGatewayNotify(
[in, string, unique] char *port
);
void RpcServer0DisableLogin();
void RpcServer0EnableLogin();
rpcBOOL RpcServer0GetLoginState();
/*the following change need to be made after demo:
CONNECTION * RpcServer0Connection(
[in] unsigned char* user,
[in] unsigned char* passward
[in] unsigned char* clientIpAddress);
//this struct will be return back to client by server0
typedef struct tagCONNECTION {
[string,unique] unsigned char * ServerIpAddress; //to one of servers
[string,unique] unsigned char * ServerPort; //to one of ports of
//servers
[string,unique] ussigned char * SessionId; //from M side
}CONNECTION;
*/
void RpcServer0GetPortInfo(
[in, string, unique] char* Port,
[in,out,ref] rpcPORTNODE* rtPortNode
);
}
========================================================================
====
======================= SERVER0.ACF
========================================
========================================================================
====
/*file: Server0.acf*/
[implicit_handle (handle_t Server0_IfHandle)
] interface Server0
{
[explicit_handle]RpcServer0Connection();
[explicit_handle]RpcPortRestore( );
[explicit_handle]RpcShutdownServerGateway( );
[explicit_handle]RpcServer0Shutdown();
[explicit_handle]RpcShutdownAllGateways();
[explicit_handle]RpcServer0GetPortListString();
[explicit_handle]RpcServer0SetPortList();
[explicit_handle]RpcServer0GetPortRange();
[explicit_handle]RpcServer0SetPortRange();
[explicit_handle]RpcServer0DeletePort();
[explicit_handle]RpcServer0InsertPort();
[explicit_handle]RpcServer0DeletePortRange();
[explicit_handle]RpcServer0InsertPortRange();
[explicit_handle]RpcGatewayNotify();
[explicit_handle]RpcServer0DisableLogin();
[explicit_handle]RpcServer0EnableLogin();
[explicit_handle]RpcServer0GetLoginState();
[explicit_handle]RpcServer0GetPortInfo();
}
========================================================================
====
======================= RPCESITYPE.IDL
=====================================
========================================================================
====
[
version(1.0),
pointer_default(unique)
]
interface RpcEsiType
{
/* -------------------------- base definitions -----------------------*/
typedef short rpcBOOL;
typedef long rpcSessionId;
typedef short rpcParamCount;
typedef short rpcDirection;
typedef long rpcDataReturn;
typedef unsigned long rpcESIDWORD;
typedef unsigned short rpcESIVARTYPE ;
typedef [string,ptr] char* rpcESILPTSTR;
typedef [string,ptr] char* rpcESIBSTR;
typedef [string,ptr] char* rpcESIOBJCT;
typedef short rpcESIEVTYPE;
typedef long rpcESIEVTOKEN;
typedef unsigned long rpcESISTATUS;
typedef struct rpctagSTATUSSUBBLOCK{
rpcESISTATUS eStatus;
}rpcSTATUS_SUBBLOCK;
typedef struct rpctagSTATUSFRAME {
[string,unique] char* cIssuer;
[string,unique] char* cMessage;
rpcESISTATUS eSuccess;
rpcESISTATUS eSubCode;
[unique] rpcSTATUS_SUBBLOCK* pSubBlock;
}rpcSTATUSFRAME;
typedef rpcSTATUSFRAME* rpcLPCSTATUS;
/*typedef struct tagBSTR { void * buffer; }rpcESIBSTRSTRUCT;*/
typedef struct tagrpcESICY
{
unsigned long lo;
long hi;
}rpcESICY;
const short rpcTRUE = 1;
const short rpcFALSE = 0;
const short rpcESIVT_EMPTY = 0;
const short rpcESIVT_NULL = 1;
const short rpcESIVT_I2 = 2;
const short rpcESIVT_I4 = 3;
const short rpcESIVT_R4 = 4;
const short rpcESIVT_R8 = 5;
const short rpcESIVT_CY = 6;
const short rpcESIVT_DATE = 7;
const short rpcESIVT_BSTR = 8;
const short rpcESIVT_DISPATCH = 9;
const short rpcESIVT_ERROR = 10;
const short rpcESIVT_BOOL = 11;
const short rpcESIVT_VARIANT = 12;
const short rpcESIVT_UNKNOWN = 13;
const short rpcESIVT_DECIMAL = 14;
const short rpcESIVT_I1 = 16;
const short rpcESIVT_UI1 = 17;
const short rpcESIVT_UI2 = 18;
const short rpcESIVT_UI4 = 19;
const short rpcESIVT_I8 = 20;
const short rpcESIVT_UI8 = 21;
const short rpcESIVT_INT = 22;
const short rpcESIVT_UINT = 23;
const short rpcESIVT_VOID = 24;
const short rpcESIVT_HRESULT = 25;
const short rpcESIVT_PTR = 26;
const short rpcESIVT_SAFEARRAY = 27;
const short rpcESIVT_CARRAY = 28;
const short rpcESIVT_USERDEFINED = 29;
const short rpcESIVT_LPSTR = 30;
const short rpcESIVT_LPWSTR = 31;
const short rpcESIVT_EOOBJECT = 48;
const short rpcESIVT_FILETIME = 64;
const short rpcESIVT_BLOB = 65;
const short rpcESIVT_STREAM = 66;
const short rpcESIVT_STORAGE = 67;
const short rpcESIVT_STEAMED_OBJECT= 68;
const short rpcESIVT_STORED_OBJECT = 69;
const short rpcESIVT_BLOB_OBJECT = 70;
const short rpcESIVT_CF = 71;
const short rpcESIVT_CLSID = 72;
/*----------------- structure and variant definitions ---------------------*/
typedef [switch_type(rpcESIVARTYPE)]
union {
[case (rpcESIVT_EMPTY)] long bEmpty; /*rpcESIVT_EMPTY
/* [case (rpcESIVT_NULL)] bNull; /*rpcESIVT_NULL*/
[case (rpcESIVT_I2)] short iVal; /*rpcESIVT_I2*/
[case (rpcESIVT_I4)] long lVal; /*rpcESIVT_I4*/
[case (rpcESIVT_R4)] float fltlVal; /*rpcESIVT_R4*/
[case (rpcESIVT_R8)] double dblVal; /*rpcESIVT_R8*/
[case (rpcESIVT_CY)] rpcESICY cyVal; /*rpcESIVT_CY*/
[case (rpcESIVT_DATE)] double date; /*rpcESIVT_DATE*/
[case (rpcESIVT_BSTR)] rpcESIBSTR bstrVal; /*rpcESIVT_BSTR*/
/* [case (rpcESIVT_DISPATCH)] Idispatch pdispVal; /*rpcESIVT_DISPATCH*/
/* [case (rpcESIVT_DISPATCH)] ESIERRO preturn; /*rpcESIVT_ERROR*/
[case (rpcESIVT_BOOL)] rpcBOOL bVal; /*rpcESIVT_BOOL*/
/* [case (rpcESIVT_UNKNOWN)] Iunknown punkVal; /*rpcESIVT_UNKNOWN*/
/* [case (rpcESIVT_DECIMAL)] /*rpcESIVT_DECIMAL*/
/* [case (rpcESIVT_I1)] /*rpcESIVT_I1*/
/* [case (rpcESIVT_UI1)] /*rpcESIVT_UI1*/
/* [case (rpcESIVT_UI2)] /*rpcESIVT_UI2*/
[case (rpcESIVT_UI4)] rpcESIDWORD dVal; /*rpcESIVT_UI4*/
/* [case (rpcESIVT_I8)] /*rpcESIVT_I8*/
/* [case (rpcESIVT_UI8)] /*rpcESIVT_UI8*/
[case (rpcESIVT_INT)] long plVal; /*rpcESIVT_INT*/
[case (rpcESIVT_UINT)] unsigned long puVal; /*rpcESIVT_UINT*/
/* [case (rpcESIVT_VOID)] void * pvoid; /*rpcESIVT_VOID*/
/* [case (rpcESIVT_HRESULT)] /*rpcESIVT_HRESULT*/
/* [case (rpcESIVT_PTR)] /*rpcESIVT_PTR*/
/* [case (rpcESIVT_SAFEARRAY)] rpcESISAFEARRAY* parrVal; /*rpcESIVT_SAFEARRAY*/
/* [case (rpcESIVT_CARRAY)] /*rpcESIVT_CARRAY*/
/* [case (rpcESIVT_USERDEFINED)] /*rpcESIVT_USERDEFINED*/
[case (rpcESIVT_LPSTR)] rpcESILPTSTR plstrVal; /*rpcESIVT_LPSTR*/
/* [case (rpcESIVT_LPWSTR)] ESILPWSTR plpwstrVal; /*rpcESIVT_LPWSTR*/
[case (rpcESIVT_EOOBJECT)] rpcESIOBJCT pobjVal; /*rpcESIVT_EOOBJECT*/
/* [case (rpcESIVT_FILETIME)] ESIFILETIME pftVal; /*rpcESIVT_FILETIME*/
/* [case (rpcESIVT_BLOB)] /*rpcESIVT_BLOB*/
/* [case (rpcESIVT_STREAM)] /*rpcESIVT_STREAM*/
/* [case (rpcESIVT_STORAGE)] /*rpcESIVT_STORAGE*/
/* [case (rpcESIVT_STEAMED_OBJECT)] /*rpcESIVT_STEAMED_OBJECT*/
/* [case (rpcESIVT_STORED_OBJECT)] /*rpcESIVT_STORED_OBJECT*/
/* [case (rpcESIVT_BLOB_OBJECT)] /*rpcESIVT_BLOB_OBJECT*/
/* [case (rpcESIVT_CF)] /*rpcESIVT_CF*/
/* [case (rpcESIVT_CLSID)] UUID puidVal; /*rpcESIVT_CLSID*/
[default] ;
} rpcCasedESIVARIANT2;
typedef struct tagrpcESIVARIANT2 {
rpcESIVARTYPE vt;
unsigned short wReserved1;
unsigned short wReserved2;
unsigned short wReserved3;
[switch_is(vt)] rpcCasedESIVARIANT2 u;
}rpcESIVARIANT2;
typedef [ptr] rpcESIVARIANT2* prpcESI2;
typedef [switch_type(rpcESIVARTYPE)]
union {
[case (rpcESIVT_EMPTY)] long bEmpty; /*rpcESIVT_EMPTY
/* [case (rpcESIVT_NULL)] bNull; /*rpcESIVT_NULL*/
[case (rpcESIVT_I2)] short iVal; /*rpcESIVT_I2*/
[case (rpcESIVT_I4)] long lVal; /*rpcESIVT_I4*/
[case (rpcESIVT_R4)] float fltlVal; /*rpcESIVT_R4*/
[case (rpcESIVT_R8)] double dblVal; /*rpcESIVT_R8*/
[case (rpcESIVT_CY)] rpcESICY cyVal; /*rpcESIVT_CY*/
[case (rpcESIVT_DATE)] double date; /*rpcESIVT_DATE*/
[case (rpcESIVT_BSTR)] rpcESIBSTR bstrVal; /*rpcESIVT_BSTR*/
/* [case (rpcESIVT_DISPATCH)] Idispatch pdispVal; /*rpcESIVT_DISPATCH*/
/* [case (rpcESIVT_DISPATCH)] ESIERRO preturn; /*rpcESIVT_ERROR*/
[case (rpcESIVT_BOOL)] rpcBOOL bVal; /*rpcESIVT_BOOL*/
/* [case (rpcESIVT_UNKNOWN)] Iunknown punkVal; /*rpcESIVT_UNKNOWN*/
/* [case (rpcESIVT_DECIMAL)] /*rpcESIVT_DECIMAL*/
/* [case (rpcESIVT_I1)] /*rpcESIVT_I1*/
/* [case (rpcESIVT_UI1)] /*rpcESIVT_UI1*/
/* [case (rpcESIVT_UI2)] /*rpcESIVT_UI2*/
[case (rpcESIVT_UI4)] rpcESIDWORD dVal; /*rpcESIVT_UI4*/
/* [case (rpcESIVT_I8)] /*rpcESIVT_I8*/
/* [case (rpcESIVT_UI8)] /*rpcESIVT_UI8*/
[case (rpcESIVT_INT)] long plVal; /*rpcESIVT_INT*/
[case (rpcESIVT_UINT)] unsigned long puVal; /*rpcESIVT_UINT*/
/* [case (rpcESIVT_VOID)] void * pvoid; /*rpcESIVT_VOID*/
/* [case (rpcESIVT_HRESULT)] /*rpcESIVT_HRESULT*/
/* [case (rpcESIVT_PTR)] /*rpcESIVT_PTR*/
/* [case (rpcESIVT_SAFEARRAY)] rpcESISAFEARRAY* parrVal; /*rpcESIVT_SAFEARRAY*/
/* [case (rpcESIVT_CARRAY)] /*rpcESIVT_CARRAY*/
/* [case (rpcESIVT_USERDEFINED)] /*rpcESIVT_USERDEFINED*/
[case (rpcESIVT_LPSTR)] rpcESILPTSTR plstrVal; /*rpcESIVT_LPSTR*/
/* [case (rpcESIVT_LPWSTR)] ESILPWSTR plpwstrVal; /*rpcESIVT_LPWSTR*/
[case (rpcESIVT_EOOBJECT)] rpcESIOBJCT pobjVal; /*rpcESIVT_EOOBJECT*/
[case (rpcESIVT_VARIANT)] prpcESI2 pvarVal; /*rpcESIVT_VARIANT*/
/* [case (rpcESIVT_FILETIME)] ESIFILETIME pftVal; /*rpcESIVT_FILETIME*/
/* [case (rpcESIVT_BLOB)] /*rpcESIVT_BLOB*/
/* [case (rpcESIVT_STREAM)] /*rpcESIVT_STREAM*/
/* [case (rpcESIVT_STORAGE)] /*rpcESIVT_STORAGE*/
/* [case (rpcESIVT_STEAMED_OBJECT)] /*rpcESIVT_STEAMED_OBJECT*/
/* [case (rpcESIVT_STORED_OBJECT)] /*rpcESIVT_STORED_OBJECT*/
/* [case (rpcESIVT_BLOB_OBJECT)] /*rpcESIVT_BLOB_OBJECT*/
/* [case (rpcESIVT_CF)] /*rpcESIVT_CF*/
/* [case (rpcESIVT_CLSID)] UUID puidVal; /*rpcESIVT_CLSID*/
[default] ;
} rpcCasedESIVARIANT;
typedef struct tagrpcESIVARIANT {
rpcESIVARTYPE vt;
unsigned short wReserved1;
unsigned short wReserved2;
unsigned short wReserved3;
[switch_is(vt)] rpcCasedESIVARIANT u;
}rpcESIVARIANT;
typedef struct tagrpcESIPARAMETER {
rpcESIVARIANT Param;
short IsNamed;
[string] char* pName;
} rpcESIPARAMETER;
typedef rpcESIPARAMETER rpcESIPARAMETERARRAY[];
typedef rpcESIVARIANT* rpcLPCVARIANT;
typedef rpcESIVARIANT rpcESIVARVAR[];
typedef rpcESIVARIANT rpcESIVARARRAY[1];
/*----------------------- CREATE FRAME --------------------------*/
const short rpcESICR_KEYPARM =0;
const short rpcESICR_POSPARM =1;
const short rpcESICR_PRPPARM =2;
const short rpcESICR_PRPVAL =3;
const short rpcESICR_CREATEKEYWORDS =4;
const short rpcESI_PARMLIMIT =30;
typedef struct tagrpcESICREATEKEYWORDPARM{
[string,ptr] char* Name; /*name of keyword parameter*/
rpcESIVARIANT Value; /*value of keyword parameter*/
}rpcESICREATEKEYWORDPARM;
typedef struct tagrpcESICREATEPOSPARM{
rpcParamCount Pos; /*position of parameter*/
rpcESIVARIANT Value; /*value of positional parameter*/
}rpcESICREATEPOSPARM;
typedef struct tagrpcESICREATEKEYWORD{
[string,ptr] char* Name; /*name of create keyword*/
rpcESIVARIANT Value; /*value of create keyword*/
}rpcESICREATEKEYWORD;
typedef struct tagrpcESICREATEPROPSPARM{
rpcParamCount PropParmType; /*property calling type*/
rpcParamCount PropParmPos; /*property parameter position*/
[string,ptr] char* PropKeyWord; /*prop parameter keyword*/
rpcESIVARIANT Value; /*value of property parameter*/
rpcParamCount PropPos; /*property position*/
}rpcESICREATEPROPSPARM;
typedef struct tagrpcESICREATEPROPSVAL{
[string,ptr] char* Name; /*property name*/
rpcParamCount Pos; /*property position*/
rpcESIVARIANT Value; /*property value*/
}rpcESICREATEPROPSVAL ;
typedef [switch_type(rpcESIVARTYPE)]
union{
[case (rpcESICR_CREATEKEYWORDS)] rpcESICREATEKEYWORD KeyWord; /*keyword
on create*/
[case (rpcESICR_KEYPARM)] rpcESICREATEKEYWORDPARM KeyParm; /*keyword
parm on create*/
[case (rpcESICR_POSPARM)] rpcESICREATEPOSPARM PosParm; /*position parm on
create*/
[case (rpcESICR_PRPPARM)] rpcESICREATEPROPSPARM PropParm;/*parameters on
property*/
[case (rpcESICR_PRPVAL)] rpcESICREATEPROPSVAL PropVal; /*value of prop
param's*/
[default] ;
} rpcCasedESICREATEPARM;
typedef struct tagrpcESICREATEPARM {
rpcESIVARTYPE ParmType; /*structure type*/
[switch_is(ParmType)] rpcCasedESICREATEPARM u;
} rpcESICREATEPARM;
typedef rpcESICREATEPARM rpcESICREATEPARMARRAY[];
/*---------------------- MANAGEMENT DEFINITIONS --------------------*/
typedef long rpcESIOPERCOUNTER;
typedef struct tagrpcESICOUNTER{
rpcESIOPERCOUNTER ctTotal;
rpcESIOPERCOUNTER ctTimer;
rpcESIOPERCOUNTER ctEO;
rpcESIOPERCOUNTER ctM;
}rpcESICOUNTER;
}
========================================================================
====
======================= RPCESITYPE.ACF
=====================================
========================================================================
====
[implicit_handle (handle_t RpcEsiType_IfHandle)
] interface RpcEsiType
{
}
========================================================================
====
======================= MAIN.CPP
===========================================
========================================================================
====
#include "esivms.h"
#include "esimacro.h"
#include "esirpc.h"
#include "rpc_sec.h"
#include "server0.h"
void returnFunction(BOOL bValue)
{
printf("main: this is a return function: %i\n",bValue);
}
main()
{
CRpcSecurity* pRpcSec;
char* gv[5];
char gv1[10];
char gv2[10];
char gv3[10];
BOOL bSecurity;
RPC_STATUS status;
char* pszProtocol = "ncacn_ip_tcp";
char* pszServer0Port = "24386";
sprintf(gv1,"%i",rpc_c_protect_level_connect);
sprintf(gv2,"%i",rpc_c_authn_dce_secret);
sprintf(gv3,"%i",rpc_c_authz_dce);
gv[0] = "EsiServer0";
gv[1] = gv1;
gv[2] = gv2;
gv[3] = gv3;
gv[4] = "0";
pRpcSec = new CRpcSecurity(returnFunction);
bSecurity = pRpcSec->InitSecurity(gv);
ESITRACE1("main: security return = %i\n",bSecurity);
ESITRACE0("s0: ss0: server use\n");
rpc_server_use_protseq_ep( (unsigned char *)pszProtocol,
5,
(unsigned char*)pszServer0Port,
&status);
if (CHECK_STATUS(status))
{
ESITRACE0("s0: ss0: register\n");
rpc_server_register_if( Server0_v1_0_s_ifspec, //chek after producing .h
NULL,
NULL,
&status);
if (CHECK_STATUS(status))
{
if (gv[0] != NULL)
{
ESITRACE0("s0:ss0 registering authorization information\n");
ESITRACE1("s0:ss0:s0 security name = %s\n",gv[0]);
ESITRACE1("s0:ss0:s0 authn service = %s\n",gv[2]);
rpc_server_register_auth_info((unsigned char *) gv[0],
rpc_c_authn_dce_secret,
NULL,
NULL,
&status);
ESITRACE1("s0:ss0: authorization status = %i\n",status);
if (!CHECK_STATUS(status))
{
PRINT_STATUS(status,"s0:ss0: failure of authorization,");
}
}
else
{
ESITRACE0("s0:ss0: running without security\n");
}
if (CHECK_STATUS(status))
{
ESITRACE0("s0: ss0: starting listen\n");
rpc_server_listen(5, &status);
ESITRACE0("s0:ss0:listen exited\n");
if (!CHECK_STATUS(status))
PRINT_STATUS(status,"s0:ss0:listen problem:\n");
}
}
else
{
PRINT_STATUS(status,"s0:ss0:problem with reg. if:");
}
}
else
{
PRINT_STATUS(status,"s0:ss0: problem with use: ");
}
}
========================================================================
====
======================= COMPILE.COM
========================================
========================================================================
====
$ set verify
$! note: dce logical is define on our system. should also be defined on
$! yours. Below is our define.
$! define dce ESI$DKA200:[VMS$COMMON.DCE$LIBRARY]
$ IDL RPCESITYPE.IDL/OUT/KEEP=ALL
$ IDL SERVER0.IDL /OUT/KEEP=ALL
$ cxx/inc=(dce,[])/nooptimize/list/define=(ESIRPC_DEC,ESIDEBUG)/debug RPC_SEC.CPP
$ cxx/inc=(dce,[])/nooptimize/list/define=(ESIRPC_DEC,ESIDEBUG)/debug MAIN.CPP
$ cxxlink/map/exec=maintest.exe -
main.obj,-
rpc_sec.obj,-
server0_sstub.obj, -
dce:dce_cxx.opt/opt
|