der_encode_to_buffer returns 错误0。错误0到底是什么?
The der_encode_to_buffer returns an error 0. What exactly is error 0?
MyTest DEFINITIONS ::=
BEGIN
Client ::= CHOICE {
clientInt INTEGER,
clientStr OCTET STRING,
clientOID OBJECT IDENTIFIER
}
END
Client_t *newClient; //new client struct
newClient = calloc(1, sizeof(Client_t));
asn_enc_rval_t encode_rtn;
printf("input integer: ");
scanf("%d", &((*newClient).choice.clientInt));
encode_rtn = der_encode_to_buffer(&asn_DEF_Client, newClient,
send_buffer, BUFFER_SIZE);
if (encode_rtn.encoded == -1){
printf("Error while encoding %s: %s\n", encode_rtn.failed_type->name, strerror(errno));
exit(1);
}
嗨,你好。这段代码可以编译,但我输入一个整数后总是得到"Client: Error 0"。错误0到底是什么?谢谢。
我想做的是使用 BER 将整数编码为串行字节序列并存储在发送缓冲区中。
我今天开始使用 asn1 编译器。我阅读的唯一文档是使用开源 ASN.1 编译器,它没有提供太多信息。如果您能提供有用的信息,我将不胜感激。
没有得到与您完全相同的错误。但是,您缺少选择选项:
Client_t *newClient; //new client struct
newClient = calloc(1, sizeof(Client_t));
asn_enc_rval_t encode_rtn;
printf("input integer: ");
scanf("%d", &((*newClient).choice.clientInt));
/* CHANGE: select clientInt on the CHOICE */
(*newClient).present = Client_PR_clientInt;
encode_rtn = der_encode_to_buffer(&asn_DEF_Client, newClient,
send_buffer, BUFFER_SIZE);
if (encode_rtn.encoded == -1){
printf("Error while encoding %s: %s\n", encode_rtn.failed_type->name, strerror(errno));
exit(1);
}
有了这个改变,我没有收到任何错误。
MyTest DEFINITIONS ::=
BEGIN
Client ::= CHOICE {
clientInt INTEGER,
clientStr OCTET STRING,
clientOID OBJECT IDENTIFIER
}
END
Client_t *newClient; //new client struct
newClient = calloc(1, sizeof(Client_t));
asn_enc_rval_t encode_rtn;
printf("input integer: ");
scanf("%d", &((*newClient).choice.clientInt));
encode_rtn = der_encode_to_buffer(&asn_DEF_Client, newClient,
send_buffer, BUFFER_SIZE);
if (encode_rtn.encoded == -1){
printf("Error while encoding %s: %s\n", encode_rtn.failed_type->name, strerror(errno));
exit(1);
}
嗨,你好。这段代码可以编译,但我输入一个整数后总是得到"Client: Error 0"。错误0到底是什么?谢谢。
我想做的是使用 BER 将整数编码为串行字节序列并存储在发送缓冲区中。 我今天开始使用 asn1 编译器。我阅读的唯一文档是使用开源 ASN.1 编译器,它没有提供太多信息。如果您能提供有用的信息,我将不胜感激。
没有得到与您完全相同的错误。但是,您缺少选择选项:
Client_t *newClient; //new client struct
newClient = calloc(1, sizeof(Client_t));
asn_enc_rval_t encode_rtn;
printf("input integer: ");
scanf("%d", &((*newClient).choice.clientInt));
/* CHANGE: select clientInt on the CHOICE */
(*newClient).present = Client_PR_clientInt;
encode_rtn = der_encode_to_buffer(&asn_DEF_Client, newClient,
send_buffer, BUFFER_SIZE);
if (encode_rtn.encoded == -1){
printf("Error while encoding %s: %s\n", encode_rtn.failed_type->name, strerror(errno));
exit(1);
}
有了这个改变,我没有收到任何错误。