如何判断我收到的 asn1 类型
我慢慢地了解了 asn1 表示法。从结构体编码 asn1 似乎很容易。但是将 asn1 解码到我的应用程序则更困难。我想知道我是否有一个在 udp 端口 600 上接收数据的应用程序,并且这可以是多个 asn1 结构,我如何知道我应该解码为哪个 asn1 结构?
那么,当我收到 asn1 数据包时,我们是否首先确定它的类型并根据其类型对其进行解码?
或者我的 asn1 编译器会帮我处理这个问题吗?
即使对于谷歌来说,找到这些东西的例子也很困难;-)。
概述使用 asn1 构建简单网络服务器的教程会很棒!
Im slowly getting my head around asn1 notation. Encoding asn1 from an struct seems to quite easy.However decoding asn1 to my application is harder. I want to know if I have an application that receives data on say udp port 600, and this can be a number of asn1 structures, how do i tell which asn1 structure i should be decoding into?
So, when i receive asn1 packets, do we first determine it's type and the decode it depending on its type?
or does my asn1 compiler handle of this for me?
finding examples of this stuff is hard...even for google ;-) .
A tutorial that outlines the building of simple network server using asn1 would be awesome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ASN.1 大致对应于 表示层 .wikipedia.org/wiki/OSI_model" rel="nofollow">OSI 七层蛋糕。它依赖应用层来确定端点之间交换的信息类型。因此,没有通用标头或标识符来指示 ASN.1 流正在呈现哪个协议或语法。这可以通过端口号暗示,或者通过附加协议层(例如 HTTP)明确表示。
编辑(回应您的评论): ASN.1 标准定义了四个标签“类别”:通用、应用、私有、并针对具体情况。 APPLICATION 基本上意味着该标签被定义为在特定应用程序中使用(即,它不是预定义为 ASN.1 的一部分。)但是 APPLICATION 标签没有携带足够的信息来指定(甚至暗示)正在使用哪个应用程序。
(实际上,“APPLICATION”、“PRIVATE”和“CONTEXT-SPECIFIC”之间的语义差异非常小;这三个类主要出于历史和风格原因而使用。)
ASN.1 corresponds roughly to the Presentation Layer of the OSI seven-layer cake. It relies on the Application Layer to determine what types of information is being exchanged between the endpoints. So, there's no universal header or identifier that would indicate which protocol or syntax is being presented by the ASN.1 stream. That could be implied by the port number, or made explicit by an additional protocol layer (e.g., HTTP.)
EDIT (responding to your comment): The ASN.1 standard defines four "classes" of tags: UNIVERSAL, APPLICATION, PRIVATE, and CONTEXT-SPECIFIC. APPLICATION basically means that the tag is defined for use within a specific application (i.e., it's not pre-defined as part of ASN.1.) But an APPLICATION tag doesn't carry enough information to specify (or even hint at) which application is in use.
(Actually, there's very little semantic difference among "APPLICATION", "PRIVATE", and "CONTEXT-SPECIFIC"; these three classes are used mostly for historical and stylistic reasons.)