Пример #1
0
test_AddRequest_context()
{
	/// Building context AddRequest ///

	DNDSMessage_t *msg;
	DNDSObject_t *obj;

	DNDSMessage_new(&msg);
	DNDSMessage_set_channel(msg, 0);
	DNDSMessage_set_pdu(msg, pdu_PR_dsm);

	DSMessage_set_seqNumber(msg, 0);
	DSMessage_set_ackNumber(msg, 0);
	DSMessage_set_operation(msg, dsop_PR_addRequest);

	AddRequest_set_objectType(msg, DNDSObject_PR_context, &obj);

	Context_set_clientId(obj, 100);
	Context_set_description(obj, "home network1", 13);
	Context_set_network(obj, "44.128.0.0");
	Context_set_netmask(obj, "255.255.255.0");

	/// Encoding part

	asn_enc_rval_t ec;	// Encoder return value
	FILE *fp = fopen("dnds.ber", "wb"); // BER output
	ec = der_encode(&asn_DEF_DNDSMessage, msg, write_out, fp);
	fclose(fp);

	xer_fprint(stdout, &asn_DEF_DNDSMessage, msg);

	DNDSMessage_del(msg);
}
Пример #2
0
void test_SearchResponse_context()
{
	/// Building a SearchResponse

	DNDSMessage_t *msg;	// A DNDS Message

	DNDSMessage_new(&msg);
	DNDSMessage_set_channel(msg, 0);
	DNDSMessage_set_pdu(msg, pdu_PR_dsm);

	DSMessage_set_seqNumber(msg, 0);
	DSMessage_set_ackNumber(msg, 400);
	DSMessage_set_operation(msg, dsop_PR_searchResponse);

	SearchResponse_set_result(msg, DNDSResult_success);

	DNDSObject_t *objContext;
	DNDSObject_new(&objContext);
	DNDSObject_set_objectType(objContext, DNDSObject_PR_context);

	Context_set_id(objContext, 10);
	Context_set_topology(objContext, Topology_mesh);
	Context_set_description(objContext, "home network", 12);
	Context_set_network(objContext, "44.128.0.0");
	Context_set_netmask(objContext, "255.255.0.0");
	Context_set_serverCert(objContext, "serverCert", 10);
	Context_set_serverPrivkey(objContext, "serverPrivkey", 13);
	Context_set_trustedCert(objContext, "trustedCert", 11);

	SearchResponse_add_object(msg, objContext);

	/// Encoding part

	asn_enc_rval_t ec;	// Encoder return value
	FILE *fp = fopen("dnds.ber", "wb"); // BER output
	ec = der_encode(&asn_DEF_DNDSMessage, msg, write_out, fp);
	fclose(fp);

	xer_fprint(stdout, &asn_DEF_DNDSMessage, msg);

	DNDSMessage_del(msg);

}