Beispiel #1
0
AAssociate
::AAssociate(std::istream & stream)
{
    this->_item.read(stream, "PDU-type", Item::Field::Type::unsigned_int_8);
    auto const type = this->_item.as_unsigned_int_8("PDU-type");
    if(type != 0x01 && type != 0x02)
    {
        throw Exception("Invalid PDU type");
    }

    this->_item.read(stream, "Reserved-1", Item::Field::Type::unsigned_int_8);
    this->_item.read(stream, "PDU-length", Item::Field::Type::unsigned_int_32);

    auto const begin = stream.tellg();

    this->_item.read(
        stream, "Protocol-version", Item::Field::Type::unsigned_int_16);
    this->_item.read(stream, "Reserved-2", Item::Field::Type::unsigned_int_16);
    this->_item.read(stream, "Called-AE-title", Item::Field::Type::string, 16);
    this->_item.read(stream, "Calling-AE-title", Item::Field::Type::string, 16);
    this->_item.read(stream, "Reserved-3", Item::Field::Type::string, 32);

    auto const length = this->_item.as_unsigned_int_32("PDU-length");

    this->_item.add("Variable-items", std::vector<Item>());
    auto & variable_items = this->_item.as_items("Variable-items");
    while(stream.tellg()-begin < length)
    {
        auto const type = stream.peek();
        Item sub_item;
        if(type == 0x10)
        {
            sub_item = ApplicationContext(stream).get_item();
        }
        else if(type == 0x20 || type == 0x21)
        {
            sub_item = PresentationContext(stream).get_item();
        }
        else if(type == 0x50)
        {
            sub_item = UserInformation(stream).get_item();
        }
        else
        {
            throw Exception("Invalid sub-item");
        }

        variable_items.push_back(sub_item);
    }

    this->_item.as_unsigned_int_32("PDU-length") = this->_compute_length();
}
Beispiel #2
0
	void perform() {
		ReturnCode rc;
		PSAPAddr psapaddr;
		const char* addr = "#128//TELEX+00728722+RFC-1006+03+127.0.0.1";
		psapaddr.parse(addr);
		SSAPAddr calling;
		SSAPAddr called = psapaddr.ssapaddr();
		OssEncOID oid;

		applicationContext.setDotValNotation("1.17.0.1.1");

		OssEncOID syntax("");
		OssIndex ossno;

		for(int no = 0; no < PresentationContext::NPCTX; no++) {
			datactxs[no] = PresentationContext(no * 2 + 1, asn, 
				TRANSFERT_SYNTAX_NAMES[no % TRANSFERT_SYNTAX_NAMES_LENGTH ]);
			Presentation_context_definition_list::component context;
			context.set_presentation_context_identifier(no * 2  + 1);
			context.set_abstract_syntax_name(syntax);
			contexts.insert_after(ossno, context);
		}

		Association_information information;
		for (int no = 0; no < sizeof(udata) / sizeof(udata[0]); no++) {
			OssHugeInt integer(1, (const unsigned char*)"1");
			//udata[no] = integer; // = new Asn1IntegerType(no);
			Association_information::component element;
			//element.set_indirect_reference((no % contexts.size()) * 2 + 1);
			//element.single_ASN1_type().setValue(udata[no]);
			//element.set_data_value_descriptor(udata[no])
			information.insert_after(ossno, element);
		}

		rc = initiator->AAssociateRequest(
			mode, applicationContext, applicationContexts, 
			callingAPtitle, callingAEqualifier, callingAPInvocationIdentifier, callingAEInvocationIdentifier, 
			calledAPtitle, calledAEqualifier, calledAPInvocationIdentifier, calledAEInvocationIdentifier, 
			senderACSERequirements, mechanism, authentification, implementation,
			callingPresentationAddress, calledPresentationAddress, 
			presentationContexts, defaultContext, 
			*presentationRequirements, *sessionRequirements, 
			isn, settings, reference, qualityOfService, 
			&information);

	}
Beispiel #3
0
std::vector<PresentationContext>
AAssociate
::get_presentation_contexts() const
{
    std::vector<PresentationContext> result;
    for(auto const & item: this->_item.as_items("Variable-items"))
    {
        if(item.as_unsigned_int_8("Item-type") == 0x20 ||
            item.as_unsigned_int_8("Item-type") == 0x21)
        {
            std::stringstream stream;
            stream << item;
            result.push_back(PresentationContext(stream));
        }
    }

    return result;
}