/****************************************************************************** * * (c) Copyright 1992, 1995 DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. * ALL RIGHTS RESERVED * * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT * NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL * OR ITS THIRD PARTY SUPPLIERS * * DIGITAL AND ITS THIRD PARTY SUPPLIERS, ASSUME NO RESPONSIBILITY FOR * THE USE OR INABILITY TO USE ANY OF ITS SOFTWARE . THIS SOFTWARE IS PROVIDED * "AS IS" WITHOUT WARRANTY OF ANY KIND, AND DIGITAL EXPRESSLY DISCLAIMS ALL * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Notice: Notwithstanding any other lease or license that may pertain to, * or accompany the delivery of, this computer software, the rights of the * Government regarding its use, reproduction and disclosure are as set * forth in Section 52.227-19 of the FARS Computer Software-Restricted * Rights clause. * * (c) Copyright 1992. Unpublished - all * rights reserved under the Copyright laws of the United States. * * RESTRICTED RIGHTS NOTICE: Use, duplication, or disclosure by the * Government is subject to the restrictions as set forth in subparagraph * (c)(1)(ii) of the Rights in Technical Data and Computer Software clause * at DFARS 52.227-7013. * * DIGITAL EQUIPMENT CORP. * 550 KING ST. * LITTLETON, MA * (508)486-5330 * * RESTRICTED RIGHTS LEGEND: This computer software is submitted with * "restricted rights." Use, duplication or disclosure is subject to the * restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985) * "Commercial Computer Software- Restricted Rights (April 1985)." * * * DEC is a registered trademark of Digital Equipment Corporation * DIGITAL is a registered trademark of Digital Equipment Corporation * * DIGITAL distributes this software as a sample program for a remote * source to inter-operate with DECmcc Data Collector AM. Digital expects * no revenue from this program, and grants the rights to anyone who * has licenses for DECmcc to copy, distribute, or modify this program * at their risk. Digital retains the rights of authorship of the * program with its current functionality. It can not be resold without * the obtaining permission from Digital Equipment Corp. * Digital does not claim the rights of derivative works * which substantially alter the functionality of the original program. * Although this program works with the V1.2 release of DECmcc, Digital * makes no claims that it will perform any particular function, will * perform a similar function with another release of DECmcc, that * DECmcc future versions will interoperate with this sample, or that * a similar sample will be made available in any future releases. * The user of the sample is responsible to modify and test it adequately * for any desired functions that they desire. * * Access to this sample in no way implies a limit to Digital's ownership * of the Data Collector AM, any DECmcc software component, or DECmcc * as a whole. Nor does access to this sample imply any current or * future rights to use DECmcc. All rights to use DECmcc and/or any * of its componenents are detailed in the various licenses of those * components and are in no way abrogated by access to this sample. * ******************************************************************************/ /****************************************************************************** * * * Routine: mcc_evc_api * * FACILITY: MCC -- Management Control Center * * ABSTRACT: * * DECmcc Event Collection AM (COLLECTION_AM) provides an application the * capability of sending its event and event arguments to a selected * DECmcc event sink. At the DECmcc, the event report can be presented * and consumed. The goal of COLLECITON_AM is to support open platforms * and open transport mechanisms. It only support DECnet task-to-task * and UDP/IP connections. * * ENVIRONMENT: * * AUTHOR: MCC Development * * CREATION DATE: June 1991 * * MODIFICATION HISTORY: * * Version Date Reviser Reason * -------- ----------- ------------- ---------------------------- * 1.0 June 91 J. L. creation * 1.31 Feb 94 V Depagne Porting to OSF * T1.4.0 Sept-1994 F. Amrani Back porting from OSF to VMS/ULTRIX * T1.4.1 Nov-1994 F. Amrani MCC_FT_QAR_140 #12 * Redesign to allow mcc_evc_send * to support dual lan operation * V1.4-n Sep-1995 B. Durif add cma.h include for DECC * V3.0 Aug-1996 JMS Lower the waiting period on Alpha (JMS001) ******************************************************************************/ #include #include #ifdef __DECC #include /* QAR.351 cma declaration are not in */ #endif /* mcc_interface_def.h for DECC */ #if _MCC_OS_==_MCC__VMS #include #include #include #include #include #include #include #include #include "mcc_evc_api_dna.h" #else #include #include #include #include #include #include #include "mcc_evc_api_dna_unix.h" #endif #include #include #include "mcc_evc_api_def.h" #include "mcc_evc_api_udpip.h" #include "inet_io_def.h" #define EVC_UDP_PORT 1630 /* temporary port number for collector server */ #define UDP_TIMEOUT_DEF 5 #ifndef __alpha /*JMS001*/ #define DNA_WAIT_DEF 5 #else /*JMS001*/ #define DNA_WAIT_DEF 1 /*JMS001*/ #endif /*JMS001*/ static MCC_T_Unsigned32 mcc_evc_validate_arg( evc_t_cs* pI_destination, MCC_T_Unsigned32* pI_protocol, evc_t_cs* pI_collection_name, evc_t_cs* pI_event_title, MCC_T_CHAR* pI_event_time, MCC_T_Unsigned32* pI_event_severity, evc_t_cs* pI_event_text ) { /* local variables */ MCC_T_Unsigned32 rs,step; MCC_T_Integer32 right_size; step= 0; rs = MCC_S_NORMAL; do { switch(step++) { case 0: /* validate collection name */ if ((pI_collection_name->cs_count <= 0) || (pI_collection_name->cs_count > MAX_FULLNAME_SIZE)) { right_size = MAX_FULLNAME_SIZE; printf("Collection name is required, max byte size is %d\n", right_size); rs = MCC_S_FULLNAME_ERROR; } break; case 1: /* validate the event title size */ if ((pI_event_title->cs_count <= 0) || (pI_event_title->cs_count > MAX_TITLE_SIZE)) { right_size = MAX_TITLE_SIZE; printf("Event Title is required, max byte size:%d\n", right_size); rs = MCC_S_INVALIDVALUE; } break; case 2: /* validate the event text size */ if (pI_event_text->cs_count > MAX_TEXT_SIZE) { right_size = MAX_TITLE_SIZE; printf( "Event text data is too long (%d), max byte size is %d\n", pI_event_text->cs_count, right_size); rs = MCC_S_INVALIDVALUE; } break; case 3: /* validate the event severity */ switch(*pI_event_severity) { case (SEVRTY_INDETERMINATE): case (SEVRTY_CRITICAL): case (SEVRTY_MAJOR): case (SEVRTY_MINOR): case (SEVRTY_WARNING): case (SEVRTY_CLEAR): break; default: printf("Invalid severity value - %d \n", *pI_event_severity); rs = MCC_S_INVALIDVALUE; break; } break; case 4: /* validate the protocol that's currently supported */ switch(*pI_protocol) { case (EVC_PROTOCOL_DNA ): case (EVC_PROTOCOL_UDP ): /* Aug-10-92 Jean */ break; default: printf("Invalid protocol value - %d\n", *pI_protocol ); rs = MCC_S_INVPROTOCOL; break; } break; case 5: /* validate the destination, time, target entity ? */ break; } } while ((rs == MCC_S_NORMAL) && (step <= 5)); return (rs); } /* end mcc_evc_validate_arg */ static MCC_T_Unsigned32 mcc_evc_write_rpt(evc_t_cs* pI_collection_name, evc_t_cs* pI_event_title, MCC_T_CHAR* pI_event_time, MCC_T_Unsigned32* pI_event_severity, evc_t_cs* pI_event_text, evc_t_cs* pI_event_target_ent, MCC_T_Descriptor* pO_dsc_msg) { /* Local variables */ MCC_T_UNSBYTE *p_rpt, event_code, tag; MCC_T_Unsigned32 total_size; MCC_T_Unsigned32 rs; /* Pack the event and event arguments to an event report in this format: +-----+-+----------+-+-+-----+-+-+-----+-+-+-----+-+-+------+-+-+--------+ |event|L|collection|T|L|event|T|L|event|T|L|event|T|L|target|T|L|event | |code | |name | | |title| | |time | | |data | | |entity| | |severity| +-----+-+----------+-+-+-----+-+-+-----+-+-+-----+-+-+------+-+-+--------+ | \ / V \ / (out for now) (optional) * * where T = tag id field, L = length field * */ rs = MCC_S_NORMAL; /* First, figure out the minimum size of the final event report will be */ /* 14-03-94 : modify the size */ total_size = pI_collection_name->cs_count + pI_event_title->cs_count + sizeof(MCC_T_Unsigned16) + /* severity */ 6 * sizeof(MCC_T_UNSBYTE) + /* 5 length fields +code*/ 4 * sizeof(MCC_T_UNSBYTE); /* 4 tag fields */ /* add up the size of the optional field */ if (pI_event_text != MCC_K_NULL_PTR ) total_size = total_size + pI_event_text->cs_count; if (pI_event_target_ent != MCC_K_NULL_PTR ) total_size = total_size + pI_event_target_ent->cs_count; /* allocate memory */ p_rpt = (MCC_T_UNSBYTE *)malloc(total_size); if (p_rpt == MCC_K_NULL_PTR) { rs = MCC_S_MEM_ALLOC_FAILED; return(rs); } pO_dsc_msg -> mcc_w_maxstrlen = pO_dsc_msg -> mcc_w_curlen =(MCC_T_Unsigned16)total_size; pO_dsc_msg -> mcc_a_pointer = (MCC_T_UNSBYTE *)p_rpt; /* write in event code */ event_code = MCC_K_EVC_CEVE_GENERAL; PUT8(p_rpt,event_code); /* write in collection name and its length */ PUT8(p_rpt,pI_collection_name->cs_count); memcpy(p_rpt,pI_collection_name->cs_string, pI_collection_name->cs_count); p_rpt += pI_collection_name->cs_count; /* string field */ /* write in event title and its tag, length */ tag = MCC_K_EVC_CEVE_GEN_TITLE; /* tag for event title */ PUT8(p_rpt,tag); PUT8(p_rpt,pI_event_title->cs_count); /* length */ memcpy(p_rpt,pI_event_title->cs_string, pI_event_title->cs_count); p_rpt += pI_event_title->cs_count; /* increment pointer */ /* write in event text tag, and its length and text if any */ tag = MCC_K_EVC_CEVE_GEN_TEXT; /* tag for event text */ PUT8(p_rpt,tag); if ((pI_event_text != MCC_K_NULL_PTR) && (pI_event_text->cs_count > 0)) { PUT8(p_rpt,pI_event_text->cs_count); memcpy(p_rpt,pI_event_text->cs_string, pI_event_text->cs_count); p_rpt += pI_event_text->cs_count; /* increment pointer */ } else PUT8(p_rpt,0); /* length field 0 */ /* write in event target entity, and its length and string if any */ tag = MCC_K_ARG_TARGET_ENTITY; /* event target entity */ PUT8(p_rpt,tag); if ((pI_event_target_ent != MCC_K_NULL_PTR) && (pI_event_target_ent->cs_count > 0)) { PUT8(p_rpt,pI_event_target_ent->cs_count); memcpy( p_rpt, pI_event_target_ent->cs_string, pI_event_target_ent->cs_count); p_rpt += pI_event_target_ent->cs_count; /* increment pointer */ } else PUT8(p_rpt,0); /* length field 0 */ /* write in severity and its tag, length */ tag = MCC_K_ARG_TARGET_SEVERITY; PUT8(p_rpt,tag); PUT8(p_rpt,sizeof(MCC_T_Unsigned32)); PUT16(p_rpt,*pI_event_severity); return(rs); } /* end mcc_evc_write_rpt */ /* ============================================================================== UDP routines ============================================================================== */ /************************************************************************* * * Name: mcc_evc_udp_open * * Description: open the udp communication towards a specific host * * Params: * Input * pI_destination : name of the destination host + name length * pIO_assc_handle : handle for a context to be used for the comm * * Output * pO_address : primary IP address of host in network format * * Returns CVR MCC_S_NORMAl, MCC_S_FAILED * MCC_S_ALERT_TERMREQ in multithread context ************************************************************************* */ /**** BEGIN-MCC_FT_QAR_140_#12-FA-112894 ****/ static MCC_T_CVR mcc_evc_udp_open(evc_t_cs *pI_destination, evc_t_handle *pIO_assc_handle, MCC_T_Unsigned32 *pO_address, MCC_T_Unsigned32 *pO_nb_address) { /* local variables */ struct mcc_tcpip_IO_int_ctx *p_udp_handle; mcc_tcpip_IO_ClassType class = UDP_IP; mcc_tcpip_IO_PortType port = 0; MCC_T_CVR stat = MCC_S_NORMAL; /* Resolve destination host into IP address */ stat = mcc_tcpip_IO_host( (MCC_T_CHAR*)pI_destination->cs_string, pO_address, pO_nb_address ); if( *pO_nb_address == 0 ) { printf( "\nCannot resolve host name - status = %d.\n", stat ); return( stat ); } /**** END-MCC_FT_QAR_140_#12-FA-112894 ****/ p_udp_handle = ( struct mcc_tcpip_IO_int_ctx* ) mcc_malloc (sizeof (struct mcc_tcpip_IO_int_ctx)); /* setup socket and bind local address */ stat = mcc_tcpip_IO_init( p_udp_handle, class, 0, port ); if (stat != MCC_S_NORMAL ) { printf("Error opening communication - sts = %d\n", stat ); } else { pIO_assc_handle->net_io.p_inet_handle = (_tcpip_IO_HandleType *)p_udp_handle; } return (stat); } /* end mcc_evc_udp_open */ /************************************************************************* * * Name: mcc_evc_get_udp_port * * Description: Get the port to use to send data to the data collector * * Params: * Output * pO_IO_Port Pointer to the number of the port use to send * data to the Data Collector (host format) * * Returns CVR MCC_S_NORMAl, MCC_S_FAILED * ************************************************************************* */ static MCC_T_CVR mcc_evc_get_udp_port(mcc_tcpip_IO_PortType *pO_IO_Port) { /* * Local variables */ MCC_T_CHAR *p_s_name = "mcc_evc_udp_sink", /* Service name */ *p_s_proto = "udp", /* Service protocol */ *p_s_port, /* Port from env var */ *p_s_endp; /* strtol arg */ MCC_T_Integer32 base; /* strtol arg */ MCC_T_CVR rs; /* return status */ MCC_T_Unsigned32 llong; /* Convert port */ #if (_MCC_OSIMPL_==_MCC__OS_OSF) && EVC_KERNEL int rc; struct servent serv; struct servent *p_servent; struct servent_data serv_data; #else struct servent *p_servent; #endif MCC_T_UNSBYTE validate_port; /* Flag = TRUE if default port used */ /* * Initialisation */ rs = MCC_S_NORMAL; /* Assume success */ validate_port = FALSE; /* Assume not using default */ p_s_port = ( MCC_T_CHAR * ) MCC_K_NULL_PTR; p_servent = ( struct servent * ) MCC_K_NULL_PTR; /*************************************************** * Check services file for port to use ***************************************************/ p_servent = getservbyname( p_s_name, p_s_proto ); base = (int)p_servent; if (( p_servent != MCC_K_NULL_PTR ) && (base != -1)) { /* Validate range */ if ( p_servent->s_port <= 32767 ) /* Convert to host byte order for tcpip_IO rtns */ llong = (MCC_T_Unsigned32)ntohs((unsigned short) p_servent->s_port ); else p_servent = (struct servent *) MCC_K_NULL_PTR; /* Ignore */ } else { p_servent = (struct servent *) MCC_K_NULL_PTR; /* Ignore */ } /* * If no entry or invalid entry check for environment variable */ if ( p_servent == ( struct servent * ) MCC_K_NULL_PTR ) { validate_port = TRUE; p_s_port = (MCC_T_CHAR * ) mcc_get_lognam_str( "MCC_EVC_UDP_PORT" ); if ( p_s_port != ( MCC_T_CHAR * ) MCC_K_NULL_PTR ) { /* Convert to long */ base = 0; llong = strtol( p_s_port, &p_s_endp, base ); if ( llong <= 0 ) /* Use default if not specified or error */ llong = EVC_UDP_PORT; } else /* No env var set */ { llong = EVC_UDP_PORT; } } if ( llong <= 32767 ) /* Check range */ *pO_IO_Port = ( MCC_T_Unsigned16 ) llong; /* Port is a short */ else { /* if error, Use default */ *pO_IO_Port = EVC_UDP_PORT; validate_port = TRUE; } /* Make sure specified port not already in use */ if ( validate_port ) { /* Validate specified port */ /* Validate default port UDP: it must not be reserved by another service */ p_servent = (struct servent *) MCC_K_NULL_PTR; p_servent = getservbyport( htons( *pO_IO_Port ), p_s_proto ); if ( p_servent != MCC_K_NULL_PTR ) { rs =MCC_S_FAILED ; } } return ( rs ); } /* END get_evc_port() */ /************************************************************************* * * Name: mcc_evc_udp_send_dtgrm * * Description: send a udp datagram and wait for the acknowledgment * * Params: * Input * pI_dsc_msg : descriptor carrying the datagram * pIO_assc_handle : handle for a context to be used for the comm * * pI_address : primary IP address of host in network format * * Returns CVR MCC_S_NORMAL, MCC_S_FAILED, MCC_S_TIMEOUT * MCC_S_ALERT_TERMREQ in multithread context ************************************************************************* */ /**** BEGIN-MCC_FT_QAR_140_#12-FA-112894 ****/ static MCC_T_CVR mcc_evc_udp_send_dtgrm( MCC_T_Descriptor *pI_dsc_msg, evc_t_handle *pIO_assc_handle, /* protocol and a pointer */ MCC_T_Unsigned32 *pI_address, /* network format address */ MCC_T_Unsigned32 nb_addresses) /* number of addresses */ { /* Local variables */ struct mcc_tcpip_IO_int_ctx *p_udp_handle; mcc_tcpip_IO_PortType port = 0; MCC_T_CHAR recv_msg[255], *p_s_timer = (MCC_T_CHAR * ) MCC_K_NULL_PTR, *p_s_endp; MCC_T_Unsigned32 size, base = 0, mtiic_i = 0; MCC_T_LONG timer; MCC_T_CVR stat,mtiic_stat=MCC_S_NORMAL; /* get the port to use : it is returned in host format*/ stat = mcc_evc_get_udp_port( &port ); if ( stat != MCC_S_NORMAL ) { printf("Error finding EVC port, status = %d\n", stat); return ( stat ); } p_udp_handle = (struct mcc_tcpip_IO_int_ctx*)pIO_assc_handle->net_io.p_inet_handle; /* initialize timer value */ p_s_timer = (MCC_T_CHAR*) mcc_get_lognam_str( "MCC_EVC_UDP_TIMEOUT" ); if ( p_s_timer != ( char * ) MCC_K_NULL_PTR ) { timer = strtol( p_s_timer, &p_s_endp, base ); if ( timer < 0 ) timer = UDP_TIMEOUT_DEF; } else timer = UDP_TIMEOUT_DEF; do { size = pI_dsc_msg->mcc_w_curlen; /* Send a UDP datagram containing the Collector event pass the remote address and port to reach */ stat = mcc_tcpip_IO_write( p_udp_handle, (MCC_T_CHAR*) pI_dsc_msg->mcc_a_pointer, &size, (pI_address + mtiic_i), port ); if (stat != MCC_S_NORMAL) { printf("Error writing to the sink server, status = %d\n", stat); return ( stat ); } /* wait for a UDP datagram ( hopefully ) containing a confirm msg. */ size = sizeof( recv_msg ); stat = mcc_tcpip_IO_read( p_udp_handle, &recv_msg[0], &size, (MCC_T_Unsigned32)timer, pI_address, &port); if ( stat != MCC_S_NORMAL) { printf("Error reading ACK from the sink - status = %d\n", stat); mtiic_stat=MCC_S_NORMAL; } else { if ( size == 0 ) { mtiic_stat=MCC_S_TIMEOUT; #ifdef VMS stat = SS$_TIMEOUT; #else stat = MCC_S_TIMEOUT; /* ETIMEDOUT */ #endif } else { mtiic_stat=MCC_S_NORMAL; stat = MCC_S_NORMAL; } } mtiic_i ++; } while ((mtiic_stat==MCC_S_TIMEOUT) &&(mtiic_i < nb_addresses)); return ( stat ); } /* end of mcc_evc_udp_send_dtgrm */ /**** END-MCC_FT_QAR_140_#12-FA-112894 ****/ /************************************************************************* * * Name: mcc_evc_udp_close * * Description: close the udp communication * * Params: * Input * pIO_assc_handle : handle for a context to be used for the comm * * * Returns CVR MCC_S_NORMAl, MCC_S_FAILED * MCC_S_ALERT_TERMREQ in multithread context ************************************************************************* */ static MCC_T_CVR mcc_evc_udp_close(evc_t_handle* pIO_assc_handle ) { struct mcc_tcpip_IO_int_ctx *p_udp_handle; MCC_T_CVR sts = MCC_S_NORMAL; p_udp_handle = (struct mcc_tcpip_IO_int_ctx *)pIO_assc_handle->net_io.p_inet_handle; sts = mcc_tcpip_IO_term( p_udp_handle); mcc_free(p_udp_handle); pIO_assc_handle->net_io.p_inet_handle = MCC_K_NULL_PTR; return ( sts ); } /* end mcc_evc_udp_close */ /* ----------------------------------------------------------------------------- -- exported routine ----------------------------------------------------------------------------- */ /* Routine: mcc_send_event Description: This is the API service to be called for delivering an event and its arguments to a targeted DECmcc event sink. Input: destination - destination to which the connection attempt is to be made usage: string data type: Latin1String access: read only mechanism: by reference protocol type - communication protocol used to encode data and transmit the event usage: unsigned long data type: enumeration ( 0 = EVC_PROTOCOL_ANY, 1 = EVC_PROTOCOL_DNA, 2 = EVC_PROTOCOL_UDP) access: read only mechanism: by value collection name - address of a simple name structure containing the name and the length of the event collection; this name is to be used as the entity instance name of the global entity COLLECTION usage: counted string structure data type: evc_t_cs access: read only mechanism: by reference event title - one line text describing the event usage: counted string structure data type: evc_t_cs access: read only mechanism: by descriptor event data - additional text description of the event usage: counted string structure data type: evc_t_cs access: read only mechanism: by descriptor event severity - the event severity usage: MCC_T_Unsigned32 data type: enumeration ( 0 = indeterminate 1 = critical 2 = major 3 = minor 4 = warning 5 = clearing ) access: read only mechanism: by reference event timestamp - the time instance when the event occurs usage: CharAbsTime data type: CharbsTime access: read only mechanism: by reference Service call and its major Algorithm: mcc_connect(&p_mcc_handle, protocol, destination) - establish a logical link with the target - return a handle that holds the necessary information for the connectivity mcc_send(&p_mcc_handle, collection_name,event_title,event_time, event_severity, event_text, &p_mcc_handle) - send out the event report using the connectiviy information in the handle mcc_disconnect (&p_mcc_handle) - close out the communication between the two parties */ MCC_T_Unsigned32 mcc_send_event ( evc_t_cs* pI_destination, MCC_T_Unsigned32* pI_protocol, evc_t_cs* pI_collection_name, evc_t_cs* pI_event_title, MCC_T_CHAR* pI_event_time, MCC_T_Unsigned32* pI_event_severity, evc_t_cs* pI_event_text, evc_t_cs* pI_event_target_ent) { /* local variable */ MCC_T_Unsigned32 rs, step; evc_t_handle mcc_assc_handle; /* protocol and a pointer */ /**** BEGIN-MCC_FT_QAR_140_#12-FA-112894 ****/ # define NUMBER_OF_DESTINATION_ADDR 10 MCC_T_Unsigned32 destination_inet_address[NUMBER_OF_DESTINATION_ADDR]; MCC_T_Unsigned32 nb_destination_inet_address=NUMBER_OF_DESTINATION_ADDR; /**** END-MCC_FT_QAR_140_#12-FA-112894 ****/ MCC_T_Descriptor dsc_msg; struct evc_event_rpt local_rpt; MCC_T_CHAR *p_wait_sec; MCC_T_UNSBYTE *p_temp; MCC_T_Integer32 base; MCC_T_LONG wait_sec; step = 0; rs = MCC_S_NORMAL; memset((char*)&mcc_assc_handle, 0, sizeof( evc_t_handle)); do switch(step++) { case 0: /* validate the arguments */ rs = mcc_evc_validate_arg( pI_destination, pI_protocol, pI_collection_name, pI_event_title, pI_event_time, pI_event_severity, pI_event_text); break; case 1: /* construct an event report which is a fixed format item * list */ _INIT_S_DESC(dsc_msg); /* in ops_dna4_def.h */ rs = mcc_evc_write_rpt( pI_collection_name,pI_event_title, pI_event_time,pI_event_severity, pI_event_text,pI_event_target_ent, &dsc_msg); if (rs == MCC_S_NORMAL) { /* For debugging purpose, dump data to a local structure */ memset(&local_rpt,0,sizeof(struct evc_event_rpt)); p_temp = dsc_msg.mcc_a_pointer; /* working pointer */ _GET_EVC_RPT(p_temp,local_rpt); /* (p_src, dst_str) */ } break; case 2: /* connect initiate */ mcc_assc_handle.protocol = *pI_protocol; switch(*pI_protocol) { case EVC_PROTOCOL_DNA: /* DECnet task-to-task to connect to the target */ rs = mcc_evc_dna_connect(pI_destination,&mcc_assc_handle); break; case EVC_PROTOCOL_UDP: /* Aug-10-92 jean open communication */ /**** BEGIN-MCC_FT_QAR_140_#12-FA-112894 ****/ rs = mcc_evc_udp_open(pI_destination,&mcc_assc_handle, destination_inet_address,&nb_destination_inet_address); /**** END-MCC_FT_QAR_140_#12-FA-112894 ****/ break; default: printf("Protocol not supported - %d\n", *pI_protocol ); rs = MCC_S_INVPROTOCOL; break; } break; case 3: /* send event report */ switch(*pI_protocol) { case EVC_PROTOCOL_DNA: /* DECnet task-to-task, send out an event report * using network/mailbox channels saved in handle */ rs = mcc_evc_dna_send_msg((struct dsc_descriptor *)&dsc_msg, &mcc_assc_handle); break; case EVC_PROTOCOL_UDP: /* for UDP, write to the socket*/ /**** BEGIN-MCC_FT_QAR_140_#12-FA-112894 ****/ rs = mcc_evc_udp_send_dtgrm(&dsc_msg, &mcc_assc_handle, destination_inet_address,nb_destination_inet_address); /**** END-MCC_FT_QAR_140_#12-FA-112894 ****/ if (rs == MCC_S_TIMEOUT) { /*means no answer was received back, but the connection must be closed anyway*/ rs = MCC_S_NORMAL; } break; } break; case 4: /* disconnect the logical link */ switch(*pI_protocol) { case EVC_PROTOCOL_DNA: p_wait_sec = MCC_K_NULL_PTR; p_temp = MCC_K_NULL_PTR; p_wait_sec = (MCC_T_CHAR *) mcc_get_lognam_str( "MCC_EVC_DNA_WAIT" ); if ( p_wait_sec != ( MCC_T_CHAR * ) MCC_K_NULL_PTR ) { base = 0; wait_sec = strtol( p_wait_sec, (char**)&p_temp, base ); if ( wait_sec <= 0 ) wait_sec = DNA_WAIT_DEF; } else wait_sec = DNA_WAIT_DEF; /* for DECnet task-to-task, abort the link using * the network/mailbox channels */ #ifndef NOT_MCC /* thread context : an alert may be sent during the delay */ TRY cma_delay( (cma_t_interval)wait_sec) ; CATCH (cma_e_alerted) { /* do nothing : at that point, the thread should terminate */ } ENDTRY #else sleep ((int)wait_sec); /* 6-nov-1991, if the link is * disconnected before the receiver * finishing recevieing msg, receiving * end of DECnet return link_abort */ #endif rs = mcc_evc_dna_disconnect(&mcc_assc_handle); break; case EVC_PROTOCOL_UDP: /* for UDP, simply close the socket */ rs = mcc_evc_udp_close(&mcc_assc_handle); break; } break; } while (((rs == MCC_S_NORMAL) || (rs == TRUE) ) && (step <= 4)); /* clean up, moved from case 5 to here, Aug-10-92 Jean */ if (dsc_msg.mcc_a_pointer != MCC_K_NULL_PTR) mcc_free(dsc_msg.mcc_a_pointer); if (mcc_assc_handle.net_io.p_iob != MCC_K_NULL_PTR) mcc_free(mcc_assc_handle.net_io.p_iob); if (rs == MCC_S_NORMAL) rs = TRUE; return(rs); } /* end mcc_send_event */