[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference azur::mcc

Title:DECmcc user notes file. Does not replace IPMT.
Notice:Use IPMT for problems. Newsletter location in note 6187
Moderator:TAEC::BEROUD
Created:Mon Aug 21 1989
Last Modified:Wed Jun 04 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:6497
Total number of notes:27359

1015.0. "Sample code to call AMs ?" by SUBWAY::REILLY (Mike Reilly - New York Bank District) Wed May 15 1991 14:29

    I am looking for some sample code that queries an AM for a counter 
    value and prints the resulting value.  A simple example that prints 
    the 'Seconds Operating' for a LAN bridge would do.  If sample code
    does not exist, can somebody describe the steps required to allow a
    user application to call an AM and request counter information.
    
    - Mike

    
    
    
    
    
    
    
    
    
    
    
    
                                                
T.RTitleUserPersonal
Name
DateLines
1015.1What are you trying to do?BIKINI::KRAUSERobert, TSSC-NaC @MUHFri May 17 1991 09:3916
>    A simple example that prints 
>    the 'Seconds Operating' for a LAN bridge would do.

I'm sure you meant something different, but couldn't resist:

	MCC> show bridge MCC:.muh.lb.cr2 seconds operating

	BRIDGE MCC:.muh.lb.cr2
	AT 17-MAY-1991 12:34:22 Counters

	                      Seconds Operating = 7632827 Seconds
	MCC>

What are you trying to do?  Write an FM?

*Robert
1015.2SUBWAY::REILLYMike Reilly - New York Bank DistrictFri May 17 1991 14:3425
    
    >
    > What are you trying to do?  Write an FM?

      I guess I'm trying to avoid writing an FM.  I am currently working
    on a number of customer applications that use network counters etc.
    as input data.  These applications cannot be rewritten as FM's as
    they rely on 3rd party AI packages etc.  I need a simple way to get
    information from DECmcc into these applications.
    
    The least elegant solution would be to spawn/fork a process from
    within the application which would use the FCL to show the counter 
    required to a file and then read in the file and locate the result.
    
    A better solution may be to write a small FM which reads application
    information reqests from a mailbox/pipe, executes a MCC call to the 
    AM and sends the results back via the mailbox/pipe.   
    
    Using Shared memory and some form of a signalling mechanism is 
    another idea.
    
    Is there a better way to do this ?
    
    - Mike
          
1015.3callable mccTOOK::CALLANDERMon May 20 1991 18:589
Around here we call it "callable-MCC". What you do is link in a small
portion of MCC into your existing application. Doing this gives you access
to the MCC dispatching mechanism and therefore access to any of the
mcc functions. This is documented in the guide to writing a management
module. I am sorry I don't have a copy of the spec here to give you
a section number. (Keith, Darryl, one of you guys reading along happen
to have the section number?)

jill
1015.4pointer to documentationNETCUR::WADEBill Wade T&N Course DevelopmentTue May 21 1991 12:116
    
    Section 3.8 in  MM Programming found on -
    
    WORDY::USER$657:[PUBLIC.NMS.DECMCC_V1_1]DECMCC_MM_PROGRAMMING_V11_FINAL.PS
    
                
1015.5thanks billTOOK::CALLANDERTue May 21 1991 18:130
1015.6SUBWAY::REILLYMike Reilly - New York Bank DistrictWed May 22 1991 17:1012
    Thanks Bill, Jill,
    	I've just read the section mentioned in .4 and .5 and am now
    eager to start coding... but where do I start.  Could somebody take
    a few minutes and describe the functions my code must perform to
    access an AM and get back one counter?  There is no mention of any
    initialization routines which my code should call, Are there any?
    	As usual I'm under the gun at a customer site and am eager to
    show that DECmcc can integrate with their existing network
    applications. 
    
    Thanks,
    Mike
1015.7TOOK::GUERTINI do this for a living -- reallyWed May 22 1991 17:397
    I seem to remember that the (mcc_kernel_init?).obj module you link with
    declares a LIB$INITIALIZE PSECT and an initialization routine which
    gets run "automatically" upon image activation.  I would just (blindly)
    follow the directions, and see if it works.
    
    -Matt.
    
1015.8Here it is ...RIVAGE::LAVILLATThu May 23 1991 07:3521
Following replies contain something that should be nearly what you want.

GET_COUNTER.C is the main C program
GET_COUNTER.OPT is the option file
GET_COUNTER.MMS the makefile

You simply have to extract the files and type :

$ mms/descr=get_counter.mms
$ run get_counter.exe

And see if it works ...

My example will dump you the counter partition of my favorite node : TENERE.
The name is hardcoded, change it to your favorite one ...

Have fun, tell me if something does not work.

Regards

Pierre
1015.9GET_COUNTER.CRIVAGE::LAVILLATThu May 23 1991 07:36165
#module GET_COUNTER "V01.0.0"

	/* 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>

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,
			prepare_mcc_call();


    
    instance_descriptor.mcc_b_dtype = DSC_K_DTYPE_Z;
    instance_descriptor.mcc_b_class = DSC_K_CLASS_S;
    instance_descriptor.mcc_a_pointer = &"TENERE";
    instance_descriptor.mcc_w_maxstrlen = 6;
    instance_descriptor.mcc_w_curlen = 6;
    instance_descriptor.mcc_l_id = 1;
    instance_descriptor.mcc_l_dt = MCC_K_DT_PHASE4NAME;
    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,
		 &12,  /* Node4 */
		 &instance_descriptor,
		&MCC_K_AES_NOT_WILD);

  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 );

    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 );

  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 );

}

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 */
1015.10GET_COUNTER.OPTRIVAGE::LAVILLATThu May 23 1991 07:373
sys$library:mcc_kernel_init.obj
sys$share:mcc_kernel_shr.exe/share
sys$share:vaxcrtl/share
1015.11GET_COUNTER.MMSRIVAGE::LAVILLATThu May 23 1991 07:376
get_counter.exe : get_counter.obj,-
		  get_counter.opt
        $(link) $(linkflags) /exe=$(mms$target) -
		get_counter.obj, -
		get_counter.opt/opt
1015.12Thanks.SUBWAY::REILLYMike Reilly - New York Bank DistrictThu May 23 1991 22:464
    Thanks,
    	The code in .9+ was exactly what I needed.
    
    - Mike
1015.13Now that we got Ultrix....RIVAGE::LAVILLATMon Jun 24 1991 08:318
Since MCC is run now also on Ultrix, since examples seem to be welcome ^) ,
next replies will contain a new portable version of GET_COUNTER.C
(maybe not very clean because callable MCC for Ultrix is not documented)
and also an Ultrix Makefile.

Regards

Pierre.
1015.14GET_COUNTER.CRIVAGE::LAVILLATMon Jun 24 1991 08:32189
	/* C library include files */
#include <stdio.h>
#ifdef VMS
#include <ssdef.h>
#include <stsdef.h>
#else
#include <signal.h>
#endif
#include <mcc_descrip.h>

	/* MCC include files */
#include <mcc_interface_def.h>
#include <mcc_vea_def.h>
#include <mcc_msg.h>

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_PRT_COUNTERS,
			handle_state = MCC_K_HANDLE_FIRST,
			mcc_class,
			aes_type,
			prepare_mcc_call();


    
#ifndef VMS
    mcc_fw_init();
#endif

    instance_descriptor.mcc_b_dtype = DSC_K_DTYPE_Z;
    instance_descriptor.mcc_b_class = DSC_K_CLASS_S;
    instance_descriptor.mcc_a_pointer = (unsigned char *) "TENERE";
    instance_descriptor.mcc_w_maxstrlen = 6;
    instance_descriptor.mcc_w_curlen = 6;
    instance_descriptor.mcc_l_id = 1;
    instance_descriptor.mcc_l_dt = MCC_K_DT_PHASE4NAME;
    instance_descriptor.mcc_b_flags = 0;
    instance_descriptor.mcc_b_ver = MCC_K_VER_DESCRIPTOR;
    instance_descriptor.mcc_a_link = MCC_K_NULL_PTR;

    mcc_class = 12; /* Node4 */
    aes_type = MCC_K_AES_NOT_WILD;

    if ( stat == MCC_S_NORMAL )  
      stat = mcc_aes_create (
		&p_in_entity,
		&mcc_class, 
		&instance_descriptor,
		&aes_type);

  if ( stat == MCC_S_NORMAL )
      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 );

    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 );

  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 );

}

static unsigned long int prepare_mcc_call ( pp_in_entity, pp_time_spec,
             pp_dsc_in_q, pp_dsc_in_p, pp_handle, pp_out_entity, 
	     pp_time_stamp, pp_dsc_out_p, pp_dsc_out_q, dsc_out_p_buff, 
	     dsc_out_p_buff_len )
 /* 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;
	unsigned 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,
			  aes_type,
			  mcc_dt;
	
     
      *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;
      aes_type = MCC_K_AES_CLASS_WILD;

      if ( stat == MCC_S_NORMAL )  
        stat = mcc_aes_create (
		 pp_out_entity,
		 MCC_K_NULL_PTR,
		 MCC_K_NULL_PTR,
		&aes_type);

      if ( stat == MCC_S_NORMAL )
	stat = mcc_ats_create_frame ( pp_time_spec );

      if ( stat == MCC_S_NORMAL )
	stat = mcc_ahs_create ( pp_handle );

      mcc_dt = MCC_K_DT_BIN_ABS_TIM;
      if ( stat == MCC_S_NORMAL )
	stat = mcc_time_create ( pp_time_stamp , 
				 &mcc_dt,
				 MCC_K_NULL_PTR,
				 MCC_K_NULL_PTR );

      if ( stat == MCC_S_NORMAL )
      {
	    (*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 */

extern unsigned long int mcc_xmm_log ( bit_mask )
unsigned long int bit_mask;
{
 printf("Don't call me\n");
 return MCC_S_NORMAL;
}
1015.15get_counter.makeRIVAGE::LAVILLATMon Jun 24 1991 08:3359
#*****************************************************************************
# *  Copyright (c) Digital Equipment Corporation, 1991
# *  All Rights Reserved.  Unpublished rights reserved
# *  under the copyright laws of the United States.
#
# *  The software contained on this media is proprietary
# *  to and embodies the confidential technology of
# *  Digital Equipment Corporation.  Possession, use,
# *  duplication or dissemination of the software and
# *  media is authorized only pursuant to a valid written
# *  license from Digital Equipment Corporation.
#
# *  RESTRICTED RIGHTS LEGEND   Use, duplication, or
# *  disclosure by the U.S. Government is subject to
# *  restrictions as set forth in Subparagraph (c)(1)(ii)
# *  of DFARS 252.227-7013, or in FAR 52.227-19, as
# *  applicable.
#
#*****************************************************************************
#*
#
EXE = /usr/mcc/mmexe
L = /usr/include
PLIBA = /usr/lib/libplib.a
TIME = /usr/lib/libutc.a
EXEC = /usr/lib/mcc_exec.a
LKOPT = -V lkobject
DBG = -g
GOPT = -G 0
CFLAGS = -v $*.lis -I$L -I. $(DBG) $(GOPT)

O = o-$(MACHINE)

.SUFFIXES: .o-$(MACHINE)

.c.o-mips:
	$(CC) -c $(CFLAGS) $*.c -o $@ 

.c.o-vax:
	cc -c $(CFLAGS) $*.c
	mv $*.o $*.o-vax
#

MCC_INCLUDES = $L/mcc_interface_def.h $L/mcc_vea_def.h $L/mcc_msg.h


get_counter.exe-$(MACHINE): get_counter.$O $(EXEC)
	- test "$(MACHINE)" = "vax" && \
	vcc  $(LKOPT) get_counter.$O  /usr/lib/mcc_lmf.o \
	-o $@ $(EXEC) $(TIME) $(PLIBA) -lm -llmf > get_counter.lkout

	- test "$(MACHINE)" = "mips" && \
	cc get_counter.$O /usr/lib/mcc_lmf.o \
	-o $@ $(EXEC) $(TIME) $(SQL) -lm -llmf -lc $(PLIBA) /usr/lib/libots.a >\
	get_counter.lkout

	chmod +x get_counter.exe-$(MACHINE)
	@ echo "$@ rebuilt"