//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project
//
//File: client.cpp
//
//Version: $Revision: 1.11 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/10/08 13:22:37 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Jussi Turunen
//
//Description:
//      A client implementation for testing en/decoding mechanisms
//      for the tester program. Sends a requested PDU to an object
//      whose reference has been read from a file defined in the
//      command line.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 
#include <OB/CORBA.h>
#include <OB/Util.h>

#include <typeinfo>
#include <string>
#include <stdio.h>
#include <stdlib.h>

#ifdef HAVE_FSTREAM
#   include <fstream>
#else
#   include <fstream.h>
#endif
#include "pf/bitstring.h"
#include "pf/debug.h"
#include "pf/exception.h"
#include "pf/bytes.h"
#include "pf/frame.h"

#include "../adapter/taprimitives.h"
#include "../adapter/msg.h"
#include "sscoppducoder.h"

otMessage::SerializedMessage decodeSSCOPpdu(pfFrame frame_);

void printUsage(void);

otMessage::SerializedMessage sendPDU(char choice_,
                                     CORBA_String_var &identifier_)
{
    pfFrame frame;
    otMessage::SerializedMessage msg;
    
    if (choice_ == 'a')
    {
        // N_S 3 octet.
        frame.putFirst(B1111_0000); // F0
        frame.putFirst(B0000_1111); // 0F
        frame.putFirst(B0000_1111); // 0F
        // PDU-header 1 octet. PL(2 bytes) + RSVD(2 bytes) + type(4 bytes).
        frame.putFirst(B1000_1000); // B8
        // PAD 2 octet.
        frame.putFirst16bit(0);
        // Information 6 octet.
        frame.putFirst24bit(0);
        frame.putFirst24bit(0);
        
        debugFrame("SD-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLSD");
    }
    else if (choice_ == 'b')
    {
        // RESERVED3 3 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B1111_1111); // FF
        // PDU-header 1 octet. RESERVED2(4 bytes) + type(4 bytes).
        frame.putFirst(B1010_0100); // A4
        // RESERVED1 4 octet.
        frame.putFirst32bit(0);
        debugFrame("ENDAK-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLENDAK");
    }
    else if (choice_ == 'c')
    {
        // N_MR 3 octet.
        frame.putFirst(B1010_0101); // A5
        frame.putFirst(B0001_0010); // 12
        frame.putFirst(B0100_1111); // 3F
        // PDU-header 1 octet. Rsvd(4 bytes) + type(4 bytes).
        frame.putFirst(B0000_1001); // D9
        // N_SQ 1 octet.
        frame.putFirst(B1111_0000); // F0
        // RESERVED 3 octet.
        frame.putFirst24bit(0);
        
        debugFrame("ER-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLER");
    }
    else if (choice_ == 'd')
    {
        // N_MR 3 octet.
        frame.putFirst(B1010_0101); // A5
        frame.putFirst(B0001_0010); // 12
        frame.putFirst(B0100_1111); // 3F
        // PDU-header 1 octet. Rsvd(4 bytes) + type(4 bytes).
        frame.putFirst(B1101_1111); // DF
        // RESERVED 4 octet
        frame.putFirst32bit(0);
        debugFrame("ERAK-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLERAK");
    }
    else if (choice_ == 'e')
    {
        // N_MR 3 octet.
        frame.putFirst(B1111_0000); // F0
        frame.putFirst(B0000_1111); // 0F
        frame.putFirst(B0000_1111); // 0F
        // PDU-header 1 octet. PL(2 bytes) + RSVD(2 bytes) + type(4 bytes).
        frame.putFirst(B0000_0001); // 71
        // N_SQ 1 octet
        frame.putFirst(B1101_1111); // DF
        // RESERVED 3 octets
        frame.putFirst24bit(0);
        
        debugFrame("BGN-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLBGN");            
    }
    else if (choice_ == 'f')
    {
        // N_MR 3 octet.
        frame.putFirst(B1111_0000); // F0
        frame.putFirst(B0000_1111); // 0F
        frame.putFirst(B0000_1111); // 0F
        // PDU-header 1 octet. PL(2 bytes) + RSVD(2 bytes) + type(4 bytes).
        frame.putFirst(B1100_0010); // F2
        // RESERVED 4 octet
        frame.putFirst32bit(0);
        // PAD 3 octet.
        frame.putFirst24bit(0);
        // UU 5 octet.
        frame.putFirst24bit(0);
        frame.putFirst16bit(0);
        
        debugFrame("BGAK-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLBGAK");
    }
    else if (choice_ == 'g')
    {
        // RESERVED2 3 octet.
        frame.putFirst24bit(0);
        // PDU-header 1 octet. PL(2 bytes) + RR(1 bytes) + S(1 bytes)
        // + type(4 bytes).
        frame.putFirst(B0000_0011); // 13
        // RESERVED 4 octet
        frame.putFirst32bit(0);
        // PAD 0 octet.

        // UU 8 octet.
        frame.putFirst32bit(0);
        frame.putFirst32bit(0);
        
        debugFrame("END-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLEND1");
    }
    else if (choice_ == 'h')
    {
        // N_MR 3 octet.
        frame.putFirst(B1111_0000); // F0
        frame.putFirst(B0000_1111); // 0F
        frame.putFirst(B0000_1111); // 0F
        // PDU-header 1 octet. PL(2 bytes) + RSVD(2 bytes) + type(4 bytes).
        frame.putFirst(B0100_0101); // 75
        // N_SQ 1 octet
        frame.putFirst(B1101_1111); // DF
        // RESERVED 3 octet
        frame.putFirst24bit(0);
        // PAD 1 octet.
        frame.putFirst(B0000_0000); // 00
        // UU 3 octet.
        frame.putFirst24bit(0);
        
        debugFrame("RS-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLRS");
    }
    else if (choice_ == 'i')
    {
        // N_MR 3 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B1111_1111); // FF
        // PDU-header 1 octet. RESERVED2(4 bytes) + type(4 bytes).
        frame.putFirst(B0000_0110); // A6
        // RESERVED1 4 octet.
        frame.putFirst32bit(0);
        debugFrame("RSAK-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLRSAK");
    }
    else if (choice_ == 'j')
    {
        // RESERVED2 3 octet.
        frame.putFirst24bit(0);
        // PDU-header 1 octet. PL(2 bytes) +  RSVD(2 bytes) + type(4 bytes)
        frame.putFirst(B0100_0111); // 67
        // RESERVED1 4 octet.
        frame.putFirst32bit(0);
        // PAD 1 octet.
        frame.putFirst(B0000_0000); // 00
        // UU 3 octet.
        frame.putFirst24bit(0);

        debugFrame("BGREJ-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLBGREJ");
    }
    else if (choice_ == 'k')
    {
        // N_S 3 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B1111_1111); // FF
        // PDU-header 1 octet. RESERVED2(4 bytes) + type(4 bytes).
        frame.putFirst(B0000_1010); // 6A
        // N_PS 3 octet.
        frame.putFirst(B1100_0011); // C3
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B0011_1100); // 3C
        // RESERVED1 1 octet.
        frame.putFirst(0);
        
        debugFrame("POLL-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLPOLL");
    }
    else if (choice_ == 'l')
    {
        // N_R 3 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B1111_1111); // FF
        // PDU-header 1 octet. RESERVED(4 bytes) + type(4 bytes).
        frame.putFirst(B0000_1011); // 6B
        // N_MR 3 octet.
        frame.putFirst(B1100_0011); // C3
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B0011_1100); // 3C
        // RSVD2 1 octet.
        frame.putFirst(0); // E7
        // N_PS 3 octet.
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B0010_0001); // 21
        // RSVD1 1 octet.
        frame.putFirst(0); // 00
        // LE2 3 octet.
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B0010_0001); // 21
        // PAD2 1 octet.
        frame.putFirst(0); // 41
        // LE1 3 octet.
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B0010_0001); // 21
        // PAD1 1 octet.
        frame.putFirst(0); // 41

        debugFrame("STAT-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLSTAT");
    }
    else if (choice_ == 'm')
    {
        // N_R 3 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B1111_1111); // FF
        // PDU-header 1 octet. RESERVED(4 bytes) + type(4 bytes).
        frame.putFirst(B0000_1100); // 6C
        // N_MR 3 octet.
        frame.putFirst(B1100_0011); // C3
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B0011_1100); // 3C
        // RESERVED1 1 octet.
        frame.putFirst(0);
        // LE2 3 octet.
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B0010_0001); // 21
        // PAD2 1 octet.
        frame.putFirst(0); // 00
        // LE1 3 octet.
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B0010_0001); // 21
        // PAD1 1 octet.
        frame.putFirst(0); // 41
        
        debugFrame("USTAT-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLUSTAT");
    }
    else if (choice_ == 'n')
    {
        // RESERVED 3 octet.
        frame.putFirst24bit(0);
        // PDU-header 1 octet. PL(2 bytes) + RSVD(2 bytes) + type(4 bytes).
        frame.putFirst(B1000_1101); // BD
        // PAD 2 octet.
        frame.putFirst16bit(0);
        // Information 6 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B1100_1100); // CC
        frame.putFirst(B1000_1000); // 88
        frame.putFirst(B0010_0010); // 22
        frame.putFirst(B0001_0001); // 11

        debugFrame("UD-pdu created", frame);

        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLUD");
    }
    else if (choice_ == 'o')
    {
        // RESERVED 3 octet.
        frame.putFirst24bit(0);
        // PDU-header 1 octet. PL(2 bytes) + RSVD(2 bytes) + type(4 bytes).
        frame.putFirst(B1000_1110); // BE
        // PAD 2 octet.
        frame.putFirst16bit(0);
        // Information 6 octet.
        frame.putFirst24bit(0);
        frame.putFirst24bit(0);
        debugFrame("MD-pdu created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLMD");
    }
    else if (choice_ == 'p')
    {
        frame.putFirst(B1010_0101); // A5
        frame.putFirst(B0001_0010); // 12
        frame.putFirst(B0100_1111); // 3F
        // type 0000
        frame.putFirst(B1101_0000); // DF
        frame.putFirst(B1111_0000); // F0
        frame.putFirst(B1011_0000); // B0
        frame.putFirst(B0011_1100); // 3C
        frame.putFirst(B1110_0111); // E7
        
        debugFrame("unknown-pdu created (type 0000)", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLUNKNOWN");
    }
    else if (choice_ == 'q')
    {
        frame.putFirst(B1010_0101); // A5
        frame.putFirst(B0001_0010); // 12
        frame.putFirst(B0100_1111); // 3F
        
        debugFrame("unknown-pdu created (too short)", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLUNKNOWN");
    }
    else if (choice_ == 'r')
    {
        // RESERVED2 3 octet.
        frame.putFirst24bit(0);
        // PDU-header 1 octet. PL(2 bytes) +
        // RSVD(2 bytes) + type(4 bytes).
        frame.putFirst(B0010_0111); // 27
        frame.putFirst32bit(0);
        // PAD 0 octet.
        // UU 0 octet.
        
        debugFrame("BGREJ-pdu (UULength = 0) created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLBGREJ");
    }
    else if (choice_ == 's')
    {
        // N_R 3 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B1111_1111); // FF
        // PDU-header 1 octet. RESERVED(4 bytes) + type(4 bytes).
        frame.putFirst(B0000_1011); // 6B
        // N_MR 3 octet.
        frame.putFirst(B1100_0011); // C3
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B0011_1100); // 3C
        // RSVD2 1 octet.
        frame.putFirst(0);
        // N_PS 3 octet.
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B0010_0001); // 21
        // RSVD1 1 octet.
        frame.putFirst(0);
        // LE1 0 octet.
        // PAD1 0 octet.
        
        debugFrame("STAT-pdu (listLength = 0) created", frame);

        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLSTAT");
    }
    else if (choice_ == 't')
    {
        // N_R 3 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B1111_1111); // FF
        // PDU-header 1 octet. RESERVED(4 bytes) + type(4 bytes).
        frame.putFirst(B0000_1011); // 6B
        // N_MR 3 octet.
        frame.putFirst(B1100_0011); // C3
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B0011_1100); // 3C
        // RSVD2 1 octet.
        frame.putFirst(0);
        // N_PS 3 octet.
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B0010_0001); // 21
        // RSVD1 1 octet.
        frame.putFirst(0);
        // LE1 3 octet.
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B0010_0001); // 21
        // PAD1 1 octet.
        frame.putFirst(0);
        
        debugFrame("STAT-pdu (listLength = 5) created", frame);

        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLSTAT");
    }
    else if (choice_ == 'u')
    {
        // N_R 3 octet.
        frame.putFirst(B1111_1111); // FF
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B1111_1111); // FF
        // PDU-header 1 octet. RESERVED(4 bytes) + type(4 bytes).
        frame.putFirst(B0000_1011); // 6B
        // N_MR 3 octet.
        frame.putFirst(B1100_0011); // C3
        frame.putFirst(B0000_0000); // 00
        frame.putFirst(B0011_1100); // 3C
        // RSVD2 1 octet.
        frame.putFirst(0);
        // N_PS 3 octet.
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B0010_0001); // 21
        // RSVD1 1 octet.
        frame.putFirst(0); // 00
        // LE1 2 octet.
        frame.putFirst(B1000_0000); // 80
        frame.putFirst(B1111_1100); // FC
        frame.putFirst(B0101_0101); // 55
        frame.putFirst(B0101_0101); // 55
        // PAD1 0 octet.
        
        debugFrame("STAT-pdu (listLength = 2) created", frame);
        
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("NLSTAT");
    }
    else if (choice_ == 'v')
    {
        debugUser("$OES_START_OF_CASE");
        pfFrame frame;
        frame.putFirst32bit(0);
            
        msg = decodeSSCOPpdu(frame);
        identifier_ = CORBA_string_dup("$OES_START_OF_CASE");
    }
    else if (choice_ == 'x')
    {
        char *big = (char *)malloc(8200*sizeof(char));
        memset((void*) big, 'O', 8200);
        pfFrame special((pfByte *)big, 8200, 8300);

        // PDU-header 1 octet. PL(2 bytes) + RSVD(2 bytes) + type(4 bytes).
        special.putLast(B1000_1000); // B8
        // N_S 3 octet.
        special.putLast(B1111_0000); // F0
        special.putLast(B0000_1111); // 0F
        special.putLast(B0000_1111); // 0F
#if 0
        // PAD 2 octet.
        special.putLast16bit(0);
        // Information 6 octet.
        special.putLast24bit(0);
        special.putLast24bit(0);
#endif        
        debugFrame("IVSD-pdu created", special);
        
        msg = decodeSSCOPpdu(special);
        identifier_ = CORBA_string_dup("NLSD");
    }    
    else if (choice_ == 'F')
    {
        // N_MR
        frame.putFirst24bit(0);
        // PDU-header 1 octet. PL(2 bytes) + RSVD(2 bytes) + type(4 bytes).
        frame.putFirst(B0000_0001); // 71
        // N_SQ 1 octet
        frame.putFirst(B0001_1111); // DF
        // RESERVED 3 octets
        frame.putFirst24bit(0);
        
        msg = decodeSSCOPpdu(frame);
        debugFrame("BGN-pdu created", frame);
        identifier_ = CORBA_string_dup("IBGN");
    }
    else
    {
        printUsage();
    }

    return msg;
}


void printUsage(void)
{
    string usage = "Usage: sendPDU(type)";

    debugUser(usage);
    debugUser("a <-> SD-pdu");
    debugUser("b <-> ENDAK-pdu");
    debugUser("c <-> ER-pdu");
    debugUser("d <-> ERAK-pdu");
    debugUser("e <-> BGN-pdu");
    debugUser("f <-> BGAK-pdu");
    debugUser("g <-> END-pdu");
    debugUser("h <-> RS-pdu");
    debugUser("i <-> RSAK-pdu");
    debugUser("j <-> BGREJ-pdu");
    debugUser("k <-> POLL-pdu");
    debugUser("l <-> STAT-pdu");
    debugUser("m <-> USTAT-pdu");
    debugUser("n <-> UD-pdu");
    debugUser("o <-> MD-pdu");
    debugUser("p <-> unknown-pdu (type 0000)");
    debugUser("q <-> unknown-pdu (too short)");
    debugUser("r <-> BGREJ-pdu (UULength = 0)");
    debugUser("s <-> STAT-pdu (listLength = 0)");
    debugUser("t <-> STAT-pdu (listLength = 5)");
    debugUser("u <-> STAT-pdu (listLength = 2)");

    debugUser("A <-> RS-pdu");
    debugUser("B <-> POLL-pdu");
    debugUser("C <-> BGN-pdu");
    debugUser("D <-> SD-pdu");
    debugUser("E <-> END-pdu");
    debugUser("F <-> BGN-pdu with constraint BGN_R_GEN");
    return;
}

//pfFrame
otMessage::SerializedMessage decodeSSCOPpdu(pfFrame frame_)
{
    // Why new??
    sscopPDUcoder *testCoder = new sscopPDUcoder;

    otMessage::SerializedMessage testMessage = testCoder->decode(frame_);

    debugUser("Printing created otMessage::SerializedMessage...");
    for (pfUlong i = 0; i < testMessage.length(); ++i)
    {
        otMessage::ElementKind kind = testMessage[i].kind;
        string id = testMessage[i].identifier.in();
        string value = testMessage[i].value.in();
        pfUlong number = testMessage[i].number;

        //debugPfUlong("Parameter", i );
        //debugPfUlong("kind", kind);
        debugString("id", id);
        debugString("value", value);
        debugPfUlong("number", number);
    }
    debugUser("otMessage::SerializedMessage printed.");

    delete testCoder;

    return testMessage;
}

otMessage_var readOneRef(char *refFile_, CORBA_ORB_var orb_)
{
    otMessage_var adapter;
    try
    {
        FILE *fp = fopen(refFile_, "r");
        if (fp == 0)
        {
            debugString("can't open ", refFile_);
            exit(1);
        }
	
	char s[1000];
        fscanf(fp, "%s", s);
        fclose(fp);
	
	CORBA_Object_var obj = orb_->string_to_object(s);
	assert(!CORBA_is_nil(obj));
	
	adapter = otMessage::_narrow(obj);
	assert(!CORBA_is_nil(adapter));
    }
    catch (...)
    {
        debugUser("catch");
    }
    return adapter;
}

int main(int argc, char* argv[], char*[])
{
    try
    {
	//
	// Create ORB
	//
	CORBA_ORB_var orb = CORBA_ORB_init(argc, argv);
	
	//
	// Get loop object
	//
        char* refFile = (char *) malloc (30*sizeof(char));
        
        otMessage_var tester;
        otMessage_var IUT;
        
        if (argc == 2)
        {
            strcpy(refFile, argv[1]);
            tester = readOneRef(refFile, orb);
        }
        else if (argc == 3)
        {
            // 2xreadOneRef
            strcpy(refFile, argv[1]);
            tester = readOneRef(refFile, orb);
            strcpy(refFile, argv[2]);
            IUT = readOneRef(refFile, orb);
        }
        else
        {
            // something abt. usage
        }

	//
	// Main loop
	//
        char c;

        debugOutputCout();
        debugUser("X exits and U prints usage instructions");
        while (1)
        {
            cout << "send primitive >";
            cin >> c;
            cout << endl;
            if (c == 'X')
            {
                break;
            }
            else if (c == 'U')
            {
                printUsage();
            }
            else if (c >= 'a' && c <= 'x')
            {
                CORBA_String_var identifierXX;// = CORBA_string_dup("PDU");
                otMessage::SerializedMessage
                    messageXX = sendPDU(c, identifierXX);
                tester->send(identifierXX, messageXX);
            }
            else if (c == 'A')
            {
                otMessage::SerializedMessage messageXX;
                CORBA_String_var identifierXX = CORBA_string_dup("NLRS");
                IUT->send(identifierXX, messageXX);
            }
            else if (c == 'B')
            {
                otMessage::SerializedMessage messageXX;
                CORBA_String_var identifierXX = CORBA_string_dup("NLPOLL");
                IUT->send(identifierXX, messageXX);
            }
            else if (c == 'C')
            {
                otMessage::SerializedMessage messageXX;
                CORBA_String_var identifierXX = CORBA_string_dup("NLBGN");
                IUT->send(identifierXX, messageXX);
            }
            else if (c == 'D')
            {
                otMessage::SerializedMessage messageXX;
                CORBA_String_var identifierXX = CORBA_string_dup("NLSD");
                IUT->send(identifierXX, messageXX);
            }
            else if (c == 'E')
            {
                otMessage::SerializedMessage messageXX;
                CORBA_String_var identifierXX = CORBA_string_dup("NLEND1");
                IUT->send(identifierXX, messageXX);
            }
            else if (c == 'F')
            {
                CORBA_String_var identifierXX;// = CORBA_string_dup("END");
                otMessage::SerializedMessage
                    messageXX=sendPDU(c, identifierXX);
                IUT->send(identifierXX, messageXX);
            }
            else
            {
                continue;
            }
        }
    }
#ifdef __GNUG__
    catch(CORBA_COMM_FAILURE& ex)
#else
    catch(CORBA_SystemException& ex)
#endif
    {
	OBPrintException(ex);
	return 1;
    }
    return 0;
}

