////////////////////////////////////////////////////////////////////////////////// // If this program works it was written by Ranjeet Sonone, otherwise I do not // who wrote this program...:-) December 5, 2000 ////////////////////////////////////////////////////////////////////////////////// #include #include "asn-incl.h" #include "PSEEngine.h" using std::cout; int main(void) { // Prepare command envelope for all the commands PSESQLCommands *pobjCommands = new PSESQLCommands; // command 1 ConnectRequest *pobjConnectRequest = new ConnectRequest; AsnOcts dsnOcts("TestDSN", strlen("TestDSN")); AsnOcts uidOcts("cn=directory manager", strlen("cn=directory manager")); AsnOcts pwdOcts("password", strlen("password")); pobjConnectRequest->dsn = dsnOcts; pobjConnectRequest->uid = uidOcts; pobjConnectRequest->pwd = pwdOcts; PSESQLMessage *pcommand = pobjCommands->Append(); pcommand->messageID = 10; pcommand->protocolOp = new PSESQLMessageChoice; pcommand->protocolOp->choiceId = PSESQLMessageChoice::connectRequestCid; pcommand->protocolOp->connectRequest = pobjConnectRequest; // command 2 ConnectRequest *pobjConnectRequest1 = new ConnectRequest; pobjConnectRequest1->dsn = dsnOcts; pobjConnectRequest1->uid = uidOcts; pobjConnectRequest1->pwd = pwdOcts; PSESQLMessage *pcommand1 = pobjCommands->Append(); pcommand1->messageID = 11; pcommand1->protocolOp = new PSESQLMessageChoice; pcommand1->protocolOp->choiceId = PSESQLMessageChoice::connectRequestCid; pcommand1->protocolOp->connectRequest = pobjConnectRequest1; // encode it AsnBuf cmdencBuf; char *cmdencBuffer = new char[2048]; cmdencBuf.Init(cmdencBuffer, 2048); AsnLen encLen = 0; ///////////////////////////////////////////////////// // Refer to line number 6726 for change in encoding // in PSEEngine.cpp pobjCommands->BEncPdu(cmdencBuf, encLen); // show me the commands.. std::cout<<*pobjCommands; // now send the command over the wire. Actually not sending but simulating..:-) // ........ // ........ // ........ // now we have recieved the command over the wire. But where is the wire?..:-) // get all the messages and decode them AsnBuf decBuf; int len = cmdencBuf.DataLen(); decBuf.InstallData(cmdencBuf.DataPtr(), cmdencBuf.DataLen()); AsnLen recvLen = 0; PSESQLCommands *pobjRecvCommands = new PSESQLCommands; int ret = pobjRecvCommands->BDecPdu(decBuf, recvLen); // show them again std::cout<<*pobjRecvCommands; // never hold the resources with you, free it.... delete cmdencBuffer; cmdencBuffer = NULL; delete pobjCommands; pobjCommands = NULL; // everything is spic and span.. return 0; }