• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ der_encode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中der_encode函数的典型用法代码示例。如果您正苦于以下问题:C++ der_encode函数的具体用法?C++ der_encode怎么用?C++ der_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了der_encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: mmsClient_createMmsGetNameListRequestAssociationSpecific

int
mmsClient_createMmsGetNameListRequestAssociationSpecific(long invokeId, ByteBuffer* writeBuffer)
{
	MmsPdu_t* mmsPdu = mmsClient_createConfirmedRequestPdu(invokeId);

	mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.present =
				ConfirmedServiceRequest_PR_getNameList;

	GetNameListRequest_t* request;

	request = &(mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.choice.getNameList);

	request->continueAfter = NULL;
	request->objectScope.present = GetNameListRequest__objectScope_PR_aaSpecific;
	request->objectClass.present = ObjectClass_PR_basicObjectClass;

	asn_long2INTEGER(&request->objectClass.choice.basicObjectClass,
				ObjectClass__basicObjectClass_namedVariableList);

	asn_enc_rval_t rval;

	rval = der_encode(&asn_DEF_MmsPdu, mmsPdu,
				mmsClient_write_out, (void*) writeBuffer);

	if (DEBUG) xer_fprint(stdout, &asn_DEF_MmsPdu, mmsPdu);

	asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0);

	return rval.encoded;
}
开发者ID:andy-w,项目名称:libiec61850,代码行数:30,代码来源:mms_client_get_namelist.c


示例2: ANY_fromType

int
ANY_fromType(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr) {
	struct _callback_arg arg;
	asn_enc_rval_t erval;

	if(!st || !td) {
		errno = EINVAL;
		return -1;
	}

	if(!sptr) {
		if(st->buf) FREEMEM(st->buf);
		st->size = 0;
		return 0;
	}

	arg.offset = arg.size = 0;
	arg.buffer = 0;

	erval = der_encode(td, sptr, ANY__consume_bytes, &arg);
	if(erval.encoded == -1) {
		if(arg.buffer) FREEMEM(arg.buffer);
		return -1;
	}
	assert((size_t)erval.encoded == arg.offset);

	if(st->buf) FREEMEM(st->buf);
	st->buf = arg.buffer;
	st->size = arg.offset;

	return 0;
}
开发者ID:bibou1324,项目名称:clienteafirma,代码行数:32,代码来源:ANY.c


示例3: namespace_info_marshall

GByteArray *
namespace_info_marshall(namespace_info_t * namespace_info, const char *version, GError ** err)
{
	asn_enc_rval_t encRet;
	GByteArray *result = NULL;
	NamespaceInfo_t asn1_namespace_info;

	/*sanity checks */
	if (!namespace_info) {
		GSETERROR(err, "Invalid parameter");
		goto error_params;
	}

	memset(&asn1_namespace_info, 0x00, sizeof(NamespaceInfo_t));

	/* convert version to an int to easy compare */
	// FIXME ugly piece of code! 
	gint64 versint64 = 0;
	if(NULL != version) {
		char *r = strchr(version,'.');
		if(r) {
			char tmp[256];
			memset(tmp, '\0', 256);
			g_snprintf(tmp, 256, "%.*s%s", (int)(r - version), version, r + 1);
			versint64 = g_ascii_strtoll(tmp, NULL, 10);
			TRACE("marshalling int64 : %"G_GINT64_FORMAT, versint64);
		}
	}

	/*fills an ASN.1 structure */
	if (!namespace_info_API2ASN(namespace_info, versint64, &asn1_namespace_info)) {
		GSETERROR(err, "API to ASN.1 mapping error");
		goto error_mapping;
	}

	/*serialize the ASN.1 structure */
	if (!(result = g_byte_array_sized_new(4096))) {
		GSETERROR(err, "memory allocation failure");
		goto error_alloc_gba;
	}
	encRet = der_encode(&asn_DEF_NamespaceInfo, &asn1_namespace_info, write_in_gba, result);
	if (encRet.encoded == -1) {
		GSETERROR(err, "ASN.1 encoding error");
		goto error_encode;
	}

	/*free the ASN.1 structure */
	namespace_info_cleanASN(&asn1_namespace_info, TRUE);

	return result;

      error_encode:
	g_byte_array_free(result, TRUE);
      error_alloc_gba:
      error_mapping:
	namespace_info_cleanASN(&asn1_namespace_info, TRUE);
      error_params:

	return NULL;
}
开发者ID:amogrid,项目名称:redcurrant,代码行数:60,代码来源:comm_namespace_info.c


示例4: test_P2pResponse_dnm

void test_P2pResponse_dnm()
{
	/// Building a P2pRequest ///

	uint8_t macAddrDst[ETH_ALEN] = { 0xaf, 0xbe, 0xcd, 0xdc, 0xeb, 0xfa };

	DNDSMessage_t *msg;	// a DNDS Message

	DNDSMessage_new(&msg);
	DNDSMessage_set_channel(msg, 0);
	DNDSMessage_set_pdu(msg, pdu_PR_dnm);	// Dynamic Network Message

	DNMessage_set_seqNumber(msg, 0);
	DNMessage_set_ackNumber(msg, 801);
	DNMessage_set_operation(msg, dnop_PR_p2pResponse);

	P2pResponse_set_macAddrDst(msg, macAddrDst);
	P2pResponse_set_result(msg, DNDSResult_success);

	/// 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);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:30,代码来源:test.c


示例5: compare

static void
compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) {
	asn_enc_rval_t erval;
	int i;

	buf_size = cmp_buf_size + 100;
	buf = alloca(buf_size);
	buf_pos = 0;

	/*
	 * Try to re-create using DER encoding.
	 */
	erval = der_encode(&asn_DEF_T, tp, buf_fill, 0);
	assert(erval.encoded != -1);
	if(erval.encoded != cmp_buf_size) {
		printf("%lld != %d\n", (long long)erval.encoded, cmp_buf_size);
	}
	assert(erval.encoded == cmp_buf_size);
	for(i = 0; i < cmp_buf_size; i++) {
		if(buf[i] != cmp_buf[i]) {
			fprintf(stderr, "Recreated buffer content mismatch:\n");
			fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n",
				i,
				buf[i], cmp_buf[i],
				buf[i], cmp_buf[i]
			);
		}
		assert(buf[i] == cmp_buf[i]);
	}
}
开发者ID:seantek,项目名称:asn1c,代码行数:30,代码来源:check-41.-fnative-types.c


示例6: encode_GSSSessionData

static bool encode_GSSSessionData(apr_pool_t *mempool,
                                  GSSSessionData_t *gsessdata,
                                  unsigned char **buf, int *len)
{
    asn_enc_rval_t rval;
    unsigned char *buffer = NULL;
    size_t buflen;
    bool ret = false;

    /* dry run to compute the size */
    rval = der_encode(&asn_DEF_GSSSessionData, gsessdata, NULL, NULL);
    if (rval.encoded == -1) goto done;

    buflen = rval.encoded;
    buffer = apr_pcalloc(mempool, buflen);

    /* now for real */
    rval = der_encode_to_buffer(&asn_DEF_GSSSessionData,
                                gsessdata, buffer, buflen);
    if (rval.encoded == -1) goto done;

    *buf = buffer;
    *len = buflen;
    ret = true;

done:
    return ret;
}
开发者ID:frenche,项目名称:mod_auth_gssapi,代码行数:28,代码来源:sessions.c


示例7: save_object

static int
save_object(void *bs, asn_TYPE_descriptor_t *td) {
	asn_enc_rval_t rval; /* Return value */
	int i;
	
	rval = der_encode(td, bs, _buf_writer, 0);
	if (rval.encoded == -1) {
		fprintf(stderr,
			"Cannot encode %s: %s\n",
			rval.failed_type->name, strerror(errno));
		assert(rval.encoded != -1);
		return -1;	/* JIC */
	}

	buf[buf_offset++] = 123;	/* Finalize with garbage */

	asn_fprint(stderr, td, bs);
	xer_fprint(stderr, td, bs);

	printf("OUT: [");
	for(i = 0; i < buf_offset; i++)
		printf(" %02x", buf[i]);
	printf("]\n");

	return 0;
}
开发者ID:Arcen,项目名称:asn1c,代码行数:26,代码来源:check-48.c


示例8: test_ModifyResponse

void test_ModifyResponse()
{
	/// Building a ModifyResponse ///

	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, 300);
	DSMessage_set_operation(msg, dsop_PR_modifyResponse);

	ModifyResponse_set_result(msg, DNDSResult_success);

	/// 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);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:27,代码来源:test.c


示例9: test_NetinfoRequest

void test_NetinfoRequest()
{
	/// Building a NetinfoRequest ///

	DNDSMessage_t *msg;	// a DNDS Message

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

	DNMessage_set_seqNumber(msg, 600);
	DNMessage_set_ackNumber(msg, 0);
	DNMessage_set_operation(msg, dnop_PR_netinfoRequest);

	uint8_t macAddr[ETH_ALEN] = { 0xd, 0xe, 0xa, 0xd, 0xb, 0xe };

	NetinfoRequest_set_ipLocal(msg, "192.168.10.10");
	NetinfoRequest_set_macAddr(msg, macAddr);

	/// 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);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:30,代码来源:test.c


示例10: test_DelRequest

void test_DelRequest()
{
#if 0
	/// Building a DelRequest ///

	DNDSMessage_t *msg;	// a DNDS Message
	DNDSObject_t *objAcl;	// a DNDS Object

	DNDSMessage_new(&msg);
	DNDSMessage_set_channel(msg, 0);
	DNDSMessage_set_pdu(msg, pdu_PR_dsm);	// Directory Service Message

	DSMessage_set_seqNumber(msg, 200);
	DSMessage_set_ackNumber(msg, 0);
	DSMessage_set_operation(msg, dsop_PR_delRequest);

	DelRequest_set_objectType(msg, DNDSObject_PR_acl, &objAcl);

	Acl_set_id(objAcl, 1);
	Acl_set_contextId(objAcl, 2);
	Acl_set_description(objAcl, "une description", 15);

	/// 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);
#endif
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:34,代码来源:test.c


示例11: test_ModifyRequest

void test_ModifyRequest()
{
#if 0
	/// Building a ModifyRequest ///

	DNDSMessage_t *msg;		// a DNDS Message
	DNDSObject_t *objAclGroup;

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

	DSMessage_set_seqNumber(msg, 300);
	DSMessage_set_ackNumber(msg, 0);
	DSMessage_set_operation(msg, dsop_PR_modifyRequest);

	ModifyRequest_set_objectType(msg, DNDSObject_PR_aclgroup, &objAclGroup);

	AclGroup_set_id(objAclGroup, 1);
	AclGroup_set_contextId(objAclGroup, 1);
	AclGroup_set_name(objAclGroup, "group-name", 10);
	AclGroup_set_description(objAclGroup, "a description", 13);

	/// 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);
#endif
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:35,代码来源:test.c


示例12: test_TerminateRequest

void test_TerminateRequest()
{
	/// Building a TerminateRequest ///

	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_terminateRequest);

	/// 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);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:25,代码来源:test.c


示例13: mmsClient_createReadRequestAlternateAccessIndex

int
mmsClient_createReadRequestAlternateAccessIndex(uint32_t invokeId, const char* domainId, const char* itemId,
		uint32_t index, uint32_t elementCount, ByteBuffer* writeBuffer)
{
	MmsPdu_t* mmsPdu = mmsClient_createConfirmedRequestPdu(invokeId);
	ReadRequest_t* readRequest = createReadRequest(mmsPdu);

	readRequest->specificationWithResult = NULL;

	readRequest->variableAccessSpecification.present = VariableAccessSpecification_PR_listOfVariable;

	readRequest->variableAccessSpecification.choice.listOfVariable.list.array = (ListOfVariableSeq_t**) GLOBAL_CALLOC(1, sizeof(ListOfVariableSeq_t*));
	readRequest->variableAccessSpecification.choice.listOfVariable.list.count = 1;

	ListOfVariableSeq_t* variableIdentifier = createVariableIdentifier(domainId, itemId);

	readRequest->variableAccessSpecification.choice.listOfVariable.list.array[0] = variableIdentifier;

	variableIdentifier->alternateAccess = createAlternateAccess(index, elementCount);

	asn_enc_rval_t rval;

	rval = der_encode(&asn_DEF_MmsPdu, mmsPdu,
		(asn_app_consume_bytes_f*) mmsClient_write_out, (void*) writeBuffer);

	variableIdentifier->variableSpecification.choice.name.choice.domainspecific.domainId.buf = 0;
	variableIdentifier->variableSpecification.choice.name.choice.domainspecific.domainId.size = 0;
	variableIdentifier->variableSpecification.choice.name.choice.domainspecific.itemId.buf = 0;
	variableIdentifier->variableSpecification.choice.name.choice.domainspecific.itemId.size = 0;

	asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0);

	return rval.encoded;
}
开发者ID:feuvan,项目名称:libiec61850,代码行数:34,代码来源:mms_client_read.c


示例14: test_P2pRequest_dnm

void test_P2pRequest_dnm()
{
	/// Building a P2pRequest ///
	int ret;
	uint8_t macAddrSrc[ETH_ALEN] = { 0xe6, 0x1b, 0x23, 0x0c, 0x0c, 0x5d };
	uint8_t macAddrDst[ETH_ALEN] = { 0xe6, 0x1b, 0x23, 0x0c, 0x0c, 0x5d };

	DNDSMessage_t *msg;	// a DNDS Message

	DNDSMessage_new(&msg);
	DNDSMessage_set_channel(msg, 0);
	DNDSMessage_set_pdu(msg, pdu_PR_dnm);	// Dynamic Network Message

	DNMessage_set_seqNumber(msg, 801);
	DNMessage_set_ackNumber(msg, 0);
	DNMessage_set_operation(msg, dnop_PR_p2pRequest);

	P2pRequest_set_ipAddrDst(msg, "66.55.44.33");
	P2pRequest_set_port(msg, 9000);
	P2pRequest_set_side(msg, P2pSide_client);
	P2pRequest_set_macAddrDst(msg, macAddrDst);

	/// 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);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:33,代码来源:test.c


示例15: save_object_as

static void
save_object_as(PDU_t *st, enum der_or_xer how) {
	asn_enc_rval_t rval; /* Return value */

	buf_offset = 0;

	/*
	 * Save object using specified method.
	 */
	switch(how) {
	case AS_DER:
		rval = der_encode(&asn_DEF_PDU, st,
			_buf_writer, 0);
		break;
	case AS_XER:
		rval = xer_encode(&asn_DEF_PDU, st, XER_F_BASIC,
			_buf_writer, 0);
		break;
	case AS_CXER:
		rval = xer_encode(&asn_DEF_PDU, st, XER_F_CANONICAL,
			_buf_writer, 0);
		break;
	}
	if (rval.encoded == -1) {
		fprintf(stderr,
			"Cannot encode %s: %s\n",
			rval.failed_type->name, strerror(errno));
		assert(rval.encoded != -1);
		return;
	}

	fprintf(stderr, "SAVED OBJECT IN SIZE %d\n", buf_offset);
}
开发者ID:ArtemPisarenko,项目名称:asn1c,代码行数:33,代码来源:check-70.c


示例16: test_SearchRequest_context

void test_SearchRequest_context()
{
	/// Building a SearchRequest context ///
	int ret;

	DNDSMessage_t *msg;	// a DNDS Message

	DNDSMessage_new(&msg);
	DNDSMessage_set_channel(msg, 0);
	DNDSMessage_set_pdu(msg, pdu_PR_dsm);	// Directory Service Message

	DSMessage_set_seqNumber(msg, 800);
	DSMessage_set_ackNumber(msg, 0);
	DSMessage_set_operation(msg, dsop_PR_searchRequest);

	SearchRequest_set_searchType(msg, SearchType_all);
	SearchRequest_set_objectName(msg, ObjectName_context);

	/// 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);

}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:30,代码来源:test.c


示例17: test_NodeConnectInfo

void test_NodeConnectInfo()
{
	/// Building a NodeConnectInfo ///
	int ret;

	DNDSMessage_t *msg;

	DNDSMessage_new(&msg);
	DNDSMessage_set_channel(msg, 0);
	DNDSMessage_set_pdu(msg, pdu_PR_dsm);	// Directory Service Message

	DSMessage_set_seqNumber(msg, 800);
	DSMessage_set_ackNumber(msg, 0);
	//DSMessage_set_operation(msg, dsop_PR_nodeConnectInfo);

	//NodeConnectInfo_set_certName(msg, "[email protected]", 19);
	//NodeConnectInfo_set_ipAddr(msg, "44.128.0.1");
	//NodeConnectInfo_set_state(msg, ConnectState_connected);

	/// 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);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:30,代码来源:test.c


示例18: test_AddRequest_context

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);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:33,代码来源:test.c


示例19: test_AddRequest_node

test_AddRequest_node()
{
	/// Building node 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_node, &obj);

	Node_set_contextId(obj, 100);
	Node_set_description(obj, "voip node 1", 11);

	/// 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);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:31,代码来源:test.c


示例20: test_DNDS_ethernet

void test_DNDS_ethernet()
{
	/// Building an message ethernet frame ///

	DNDSMessage_t *msg;	// a DNDS Message

	DNDSMessage_new(&msg);
	DNDSMessage_set_channel(msg, 0);
	DNDSMessage_set_pdu(msg, pdu_PR_ethernet);	// ethernet frame

	uint8_t *frame = strdup("0110101010101");
	size_t frame_size = 13;

	DNDSMessage_set_ethernet(msg, frame, frame_size);

	/// 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);

	// XXX free(frame)
	DNDSMessage_del(msg);
}
开发者ID:mathieujobin,项目名称:netvirt,代码行数:27,代码来源:test.c



注:本文中的der_encode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ der_heim_oid_cmp函数代码示例发布时间:2022-05-30
下一篇:
C++ depFn函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap