Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

security channel exit

Status
Not open for further replies.

Myqns

Programmer
Jul 28, 2004
23
GB
Any one has any experience creating a security channel exit?
I have the following code.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef AIX
#include <langinfo.h>
#endif

#include <sys/types.h>
#include <sys/timeb.h>
#include <time.h>

/* MQSeries headers */
#include <cmqc.h>
#include <cmqxc.h>

/*  testing headers  */
#include <time.h>

/* dummy function used as entry point to exit, only needed  AIX boxes */
void MQStart() {;}    /* dummy entry point */

void MQENTRY ChannelExit( PMQCXP     pChannelExitParms,
                       PMQCD      pChannelDefinition,
                       PMQLONG    pDataLength,
                       PMQLONG    pAgentBufferLength,
                       PMQBYTE    AgentBuffer,
                       PMQLONG    pExitBufferLength,
                       PMQPTR     pExitBufferAddr)

{
    char Channel_Logfile[] = "c:\\temp\\scylog.log";
    FILE * fp; 

    /* for test purposes */
    char TimeBuffer[100];
    struct tm *pNow=NULL;
    time_t MyTime;

	PMQCXP pParms;
	PMQCD pChDef;
	pParms = (PMQCXP)pChannelExitParms;
	pChDef = (PMQCD)pChannelDefinition;

    /* open the log file */
    fp = fopen(Channel_Logfile,"a+");

    pChannelExitParms->ExitResponse = MQXCC_OK;

    pChannelExitParms->Feedback = 0;

    switch( pChannelExitParms-> ExitReason )
    {
        case MQXR_INIT:
               MyTime=time(NULL);
               pNow=localtime(&MyTime);
               strftime(TimeBuffer, sizeof(TimeBuffer),
                   "\nScy exit called for INIT at %A %B %d, %Y at %I:%M %p\n", pNow);
               fprintf(fp, "%s", TimeBuffer);
               break;
        case MQXR_INIT_SEC:
               *pDataLength = 9;
               pChannelExitParms->ExitResponse = MQXCC_SEND_SEC_MSG;
               strncpy((char *)AgentBuffer, "WHOAREYOU\0", 10);
               fprintf(fp,"Scy exit called for INIT_SEC, resp=%d, buff=%s\n", pChannelExitParms->ExitResponse, (char *)AgentBuffer);
               break;
        case MQXR_SEC_MSG:
               fprintf(fp,"Scy exit called for SEC_MSG, resp=%d, buff=%.10s\n", pChannelExitParms->ExitResponse, (char *)AgentBuffer);
               *pDataLength = 20;
               pChannelExitParms->ExitResponse = MQXCC_SEND_SEC_MSG;

               /******CHANGE userid/password in the following line:********/
			   strncpy((char *)AgentBuffer, "A000MATA6P207712100\0", 21);
			   //strncpy((char *)AgentBuffer, "A000MATA6P  207712100\0", 21);
			   //strncpy((char *)AgentBuffer, "A000Userid  Password\0", 21);
               /******END OF CHANGE userid/password: **********************/

               fprintf(fp,"Scy exit called for SEC_MSG, resp=%d, buff=%.10s\n", pChannelExitParms->ExitResponse, (char *)AgentBuffer);
               break;
        case MQXR_TERM:
               fprintf(fp,"Scy exit called for TERM\n");
               break;
        default:
               fprintf(fp,"Scy exit called with invalid reason code: %d\n", pChannelExitParms-> ExitReason);
               break;
    } /* switch */
    fclose(fp);
    return;      
} /* END OF void MQENTRY MQMDH001(

I created the dll and when I load it on the MQ queue manager, I get an error: return code 127. I don't know what it means. Basically the dll was not loaded on the queue manager. I am new to MQ and C++. Anyone has done this before and has something to tell?

Please, your help is requested.
 
How are you specifying it on the channel? If this is Windows and you linked this into a DLL called myexits.dll I would expect you to specify it like this:

alter channel .... scyexit('myexits(ChannelExit)')

Cheers,
Paul
 
... and... is it in the exits directory or are you providing a fully qualified path as well?

Cheers,
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top