blob: 62730f54149b22473c625d40d94aa4f495abf744 [file] [log] [blame]
Harald Welte7b94dc22018-09-24 16:46:55 +02001
2#include <sys/types.h>
3#include <sys/stat.h>
4#include <fcntl.h>
5#include <unistd.h>
6
7#include <asn1defs.h>
8
9#include "rspro.h"
10
11
12static void transcode(const uint8_t *buf, unsigned int len)
13{
14 ASN1Error err;
15 struct RsproPDU *pdu;
16 int rc;
17 char *gserbuf;
18
19 rc = asn1_ber_decode((void **)&pdu, asn1_type_RsproPDU, buf, len, &err);
20 printf("rc=%d\n", rc);
21
22 rc = asn1_gser_encode((uint8_t **) &gserbuf, asn1_type_RsproPDU, pdu);
23 printf("rc=%d\n", rc);
24 printf("%s\n", gserbuf);
25}
26
27int main(int argc, char **argv)
28{
29 uint8_t buf[2048];
30 int fd, rc;
31
32 fd = open(argv[1], O_RDONLY);
33 if (fd < 0)
34 exit(1);
35 rc = read(fd, buf, sizeof(buf));
36 close(fd);
37
38 transcode(buf, rc);
39}