| #module GET_COUNTER "V02.0.0"
/*
* Example of use of callable MCC.
*
* Derived from an example by Pierre Lavillat posted as note 1015.8 (et seq)
* in the TOOK::MCC conference.
*
* Modifed by Graham Cobb to show information about Phase V nodes
*
*/
/* C library include files */
#include <stdio>
#include <ssdef>
#include <stsdef>
#include <mcc_descrip>
/* MCC include files */
#include <mcc_interface_def.h>
#include <mcc_vea_def.h>
#include <mcc_msg.h>
#include <mcc_common_definitions>
#include <mcc_dna5am_node>
/* DNS include files */
#include "dnsclerk.h"
#include "dnsmessage.h"
void dump_mcc_call_result ( MCC_A_AES p_in_entity, unsigned long int stat,
MCC_A_AES p_out_entity, MCC_T_Descriptor *p_time_stamp,
MCC_T_Descriptor *p_dsc_out_p);
unsigned long int prepare_mcc_call (
MCC_A_AES *pp_in_entity,
MCC_A_TIMEFRAME *pp_time_spec,
MCC_T_Descriptor **pp_dsc_in_q,
MCC_T_Descriptor **pp_dsc_in_p,
MCC_A_HANDLE *pp_handle,
MCC_A_AES *pp_out_entity,
MCC_T_Descriptor **pp_time_stamp,
MCC_T_Descriptor **pp_dsc_out_p,
MCC_T_Descriptor **pp_dsc_out_q,
char *dsc_out_p_buff,
int dsc_out_p_buff_len );
unsigned long int get_attribute_value (
MCC_T_Descriptor *p_dsc_out_p,
unsigned long int attr_code,
unsigned long int data_type,
char *p_attr_value,
unsigned long int data_size );
main()
{
unsigned long int stat = MCC_S_NORMAL;
MCC_A_AES p_in_entity = MCC_K_NULL_PTR;
MCC_A_TIMEFRAME p_time_spec;
MCC_T_Descriptor *p_dsc_in_q;
MCC_T_Descriptor *p_dsc_in_p;
MCC_A_HANDLE p_handle;
MCC_A_AES p_out_entity = MCC_K_NULL_PTR;
MCC_T_Descriptor *p_time_stamp;
MCC_T_Descriptor dsc_out_p;
MCC_T_Descriptor *p_dsc_out_p = &dsc_out_p;
MCC_T_Descriptor *p_dsc_out_q;
MCC_T_Descriptor instance_descriptor;
char buff[1024];
int buff_len = 1024;
unsigned long int verb = MCC_K_VERB_SHOW,
partition = MCC_K_ATTR_PRT_COUNTERS,
handle_state = MCC_K_HANDLE_FIRST;
char *node_name = "dec:.reo.msrv26";
char name_buf[400];
int name_buf_len = 400;
unsigned char *End;
unsigned long int changes_of_addr = 0;
char counter_buff[8];
/* Convert nodename to internal form */
if ($VMS_STATUS_SUCCESS (stat))
stat = dnsCvtStrFullToOpq ( node_name, 0, name_buf, &name_buf_len, &End);
/* Create input entity name */
instance_descriptor.mcc_b_dtype = DSC_K_DTYPE_Z;
instance_descriptor.mcc_b_class = DSC_K_CLASS_S;
instance_descriptor.mcc_a_pointer = name_buf;
instance_descriptor.mcc_w_maxstrlen = name_buf_len;
instance_descriptor.mcc_w_curlen = name_buf_len;
instance_descriptor.mcc_l_id = 1;
instance_descriptor.mcc_l_dt = MCC_K_DT_FULL_NAME;
instance_descriptor.mcc_b_flags = 0;
instance_descriptor.mcc_b_ver = MCC_K_VER_DESCRIPTOR;
instance_descriptor.mcc_a_link = MCC_K_NULL_PTR;
if ($VMS_STATUS_SUCCESS (stat))
stat = mcc_aes_create (
&p_in_entity,
&MCC_K_CLASS_DNA5_NODE, /* Node */
&instance_descriptor,
&MCC_K_AES_NOT_WILD);
/* Set up all the other arcane stuff MCC needs before you can call it */
if ($VMS_STATUS_SUCCESS (stat))
stat = prepare_mcc_call (
&p_in_entity,
&p_time_spec,
&p_dsc_in_q,
&p_dsc_in_p,
&p_handle,
&p_out_entity,
&p_time_stamp,
&p_dsc_out_p,
&p_dsc_out_q,
buff,
buff_len );
/* Call the MCC function we want */
if ($VMS_STATUS_SUCCESS (stat))
stat = mcc_call_function (
&verb,
p_in_entity,
&partition,
p_time_spec,
p_dsc_in_q,
p_dsc_in_p,
p_handle,
p_out_entity,
p_time_stamp,
p_dsc_out_p,
p_dsc_out_q );
/* dump out results */
#ifdef DUMP_RESULT
dump_mcc_call_result( p_in_entity, stat, p_out_entity, p_time_stamp, p_dsc_out_p);
#endif
/* Find the Changes of Address attribute */
if ($VMS_STATUS_SUCCESS (stat))
stat = get_attribute_value(
p_dsc_out_p,
MCC_K_DN5_NCT_ADDR_CHNGS,
MCC_K_DT_COUNTER64,
counter_buff,
sizeof(counter_buff)
);
memcpy(&changes_of_addr, counter_buff, sizeof(changes_of_addr));
if ($VMS_STATUS_SUCCESS (stat))
printf("Changes of Address = %d\n", changes_of_addr);
return(stat);
}
static unsigned long int prepare_mcc_call (
/* Arguments */
MCC_A_AES *pp_in_entity,
MCC_A_TIMEFRAME *pp_time_spec,
MCC_T_Descriptor **pp_dsc_in_q,
MCC_T_Descriptor **pp_dsc_in_p,
MCC_A_HANDLE *pp_handle,
MCC_A_AES *pp_out_entity,
MCC_T_Descriptor **pp_time_stamp,
MCC_T_Descriptor **pp_dsc_out_p,
MCC_T_Descriptor **pp_dsc_out_q,
char *dsc_out_p_buff,
int dsc_out_p_buff_len )
{ /* Begin function PREPARE_MCC_CALL */
/* Local variables */
unsigned long int stat = MCC_S_NORMAL, /* general returns sts */
cvr;
*pp_out_entity = MCC_K_NULL_PTR;
*pp_time_stamp = MCC_K_NULL_PTR;
*pp_handle = MCC_K_NULL_PTR;
*pp_dsc_in_q = *pp_dsc_in_p = MCC_K_NULL_PTR;
if ($VMS_STATUS_SUCCESS (stat))
stat = mcc_aes_create (
pp_out_entity,
MCC_K_NULL_PTR,
MCC_K_NULL_PTR,
&MCC_K_AES_CLASS_WILD);
if ($VMS_STATUS_SUCCESS (stat))
stat = mcc_ats_create_frame ( pp_time_spec );
if ($VMS_STATUS_SUCCESS (stat))
stat = mcc_ahs_create ( pp_handle );
if ($VMS_STATUS_SUCCESS (stat))
stat = mcc_time_create ( pp_time_stamp ,
&MCC_K_DT_BIN_ABS_TIM,
MCC_K_NULL_PTR,
MCC_K_NULL_PTR );
if ($VMS_STATUS_SUCCESS (stat))
{
(*pp_dsc_out_p)->mcc_b_dtype = DSC_K_DTYPE_Z;
(*pp_dsc_out_p)->mcc_b_class = DSC_K_CLASS_S;
(*pp_dsc_out_p)->mcc_a_pointer = dsc_out_p_buff;
(*pp_dsc_out_p)->mcc_w_maxstrlen = dsc_out_p_buff_len;
(*pp_dsc_out_p)->mcc_w_curlen = dsc_out_p_buff_len;
(*pp_dsc_out_p)->mcc_l_id = 0;
(*pp_dsc_out_p)->mcc_l_dt = MCC_K_DT_ILV;
(*pp_dsc_out_p)->mcc_b_flags = 0;
(*pp_dsc_out_p)->mcc_b_ver = MCC_K_VER_DESCRIPTOR;
(*pp_dsc_out_p)->mcc_a_link = MCC_K_NULL_PTR;
}
return stat;
}; /* End function PREPARE_MCC_CALL */
static unsigned long int get_attribute_value (
/* Arguments */
MCC_T_Descriptor *p_dsc_out_p,
unsigned long int attr_code,
unsigned long int data_type,
char *p_attr_value,
unsigned long int data_size )
{ /* Begin function get_attribute_value */
/* Local variables */
unsigned long int stat = MCC_S_NORMAL;
struct MCC_R_ILV_CONTEXT ILVctx;
unsigned long id_code;
unsigned long mode = MCC_K_ILV_LIST_VALUE; /* mode of operation */
MCC_T_Descriptor value_desc;
unsigned long reason_code; /* ilv reason code */
/* Begin ILV get for getting info from out_p */
if ($VMS_STATUS_SUCCESS(stat))
stat = mcc_ilv_get_param_begin(&ILVctx, p_dsc_out_p);
/* Get the id code of the first value, id code should be attribute list */
if ($VMS_STATUS_SUCCESS(stat))
stat = mcc_ilv_get_id(&ILVctx, &id_code);
/* Id code not checked! */
/* now look at attribute list of values */
if($VMS_STATUS_SUCCESS(stat))
stat = mcc_ilv_get_cons_begin(&ILVctx, MCC_K_NULL_PTR, &mode);
/* Find required attribute in list */
if($VMS_STATUS_SUCCESS(stat))
stat = mcc_ilv_fnd_id(&ILVctx, &attr_code);
/* Create descriptor for value */
value_desc.mcc_b_dtype = DSC_K_DTYPE_Z;
value_desc.mcc_b_class = DSC_K_CLASS_S;
value_desc.mcc_a_pointer = p_attr_value;
value_desc.mcc_w_maxstrlen = data_size;
value_desc.mcc_w_curlen = data_size;
value_desc.mcc_l_id = attr_code;
value_desc.mcc_l_dt = data_type;
value_desc.mcc_b_flags = 0;
value_desc.mcc_b_ver = MCC_K_VER_DESCRIPTOR;
value_desc.mcc_a_link = MCC_K_NULL_PTR;
if($VMS_STATUS_SUCCESS(stat))
stat = mcc_ilv_get(&ILVctx, &value_desc, &reason_code);
return stat;
}; /* End function get_attribute_value */
static void dump_mcc_call_result
(
MCC_A_AES p_in_entity,
unsigned long int stat,
MCC_A_AES p_out_entity,
MCC_T_Descriptor *p_time_stamp,
MCC_T_Descriptor *p_dsc_out_p
)
{
printf("Calling mcc_call_access\n");
printf("In Entity : \n");
mcc_aes_dump( p_in_entity );
printf ( "Return status : %d \n",stat);
printf ("Out Entity : \n");
mcc_aes_dump ( p_out_entity );
printf("Timestamp :\n ");
mcc_time_dump ( p_time_stamp );
printf("Out_p : \n");
mcc_ilv_dump ( p_dsc_out_p );
printf("\n");
}
|