【问题标题】:ASN1C compilingASN1C 编译
【发布时间】:2013-10-15 18:31:21
【问题描述】:

我有一个小的 asn1 代码:

----------ASN1 文件------------------------ ------

RectangleModule1 DEFINITIONS ::= 
BEGIN
Rectangle ::= SEQUENCE (SIZE(1..10)) OF SEQUENCE {

 item CHOICE    {

  height INTEGER,

  width  IA5String

 } --# UNTAGGED
}

END

当我用 asn1c 编译它时,它给了我 Rectangle.c 和 Rectangle.h 文件。 Rectangle 的输出如下所示:

-----------矩形.h---------- ---------

/* Dependencies */

typedef enum item_PR {
  item_PR_NOTHING,    /* No components present */
item_PR_height,
item_PR_width
  } item_PR;

/* Rectangle */
typedef struct Rectangle {
  A_SEQUENCE_OF(struct Member {
    struct item {
        item_PR present;
        union item_u {
            long     height;
            IA5String_t  width;
        } choice;

        /* Context for parsing across buffer boundaries */
        asn_struct_ctx_t _asn_ctx;
    } item;

    /* Context for parsing across buffer boundaries */
    asn_struct_ctx_t _asn_ctx;
  } ) list;

  /* Context for parsing across buffer boundaries */
  asn_struct_ctx_t _asn_ctx;
 } Rectangle_t;

但我希望我的输出看起来像这样:

  /* Dependencies */
  typedef enum item_PR_sl {
  item_PR_NOTHING_sl,    /* No components present */
  item_PR_height_sl,
  item_PR_width_sl
  } item_PR_sl;

  /* Rectangle */
  typedef struct Rectangle {
  A_SEQUENCE_OF(struct Member {
        struct item_sl {
        item_PR_sl present;
        union item_u_sl {
            long     height;
            IA5String_t  width;
        } choice;

        /* Context for parsing across buffer boundaries */
        asn_struct_ctx_t _asn_ctx;
    } item;

    /* Context for parsing across buffer boundaries */
    asn_struct_ctx_t _asn_ctx;
} ) list;

/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
  } Rectangle_t;

即 _sl 连接到项目字段。我无法通过更改 asn 文件来做到这一点。我不知道constr_CHOICEconstr_SEQUENCE 是如何工作的。任何帮助将不胜感激。

【问题讨论】:

  • 你用什么asn1c?
  • 为什么生成的代码具有特定的名称很重要?
  • @Errandir:ASN.1 编译器,v0.9.24。版权所有 (c) 2003、2004、2005、2006 Lev Walkin

标签: c++ c encoding asn.1


【解决方案1】:

花了几个小时后,我发现不能通过修改 asn 文件来完成。只能通过编辑编译 asn 文件生成的 .h.c 文件来完成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-09
    • 1970-01-01
    • 1970-01-01
    • 2012-03-12
    • 1970-01-01
    • 2013-07-10
    • 2018-05-02
    • 1970-01-01
    相关资源
    最近更新 更多