1

我使用了libosmo-as​​n1-map中的 C 代码来获得 GSM_MAP 协议的实现。然后我尝试对“发送身份验证信息”消息进行编码。如3GPP TS 29.002中所述,该消息包含一些强制性部分(例如'imsi')和一些可选部分(例如'requestingNodeType')。

/* SendAuthenticationInfoArg */
typedef struct SendAuthenticationInfoArg {
    IMSI_t   imsi;
    NumberOfRequestedVectors_t   numberOfRequestedVectors;
    NULL_t  *segmentationProhibited /* OPTIONAL */;
    NULL_t  *immediateResponsePreferred /* OPTIONAL */;
    struct Re_synchronisationInfo   *re_synchronisationInfo /* OPTIONAL */;
    struct ExtensionContainer   *extensionContainer /* OPTIONAL */;
    /*
     * This type is extensible,
     * possible extensions are below.
     */
    RequestingNodeType_t    *requestingNodeType /* OPTIONAL */;
    PLMN_Id_t   *requestingPLMN_Id  /* OPTIONAL */;
    NumberOfRequestedVectors_t  *numberOfRequestedAdditional_Vectors    /* OPTIONAL */;
    NULL_t  *additionalVectorsAreForEPS /* OPTIONAL */;

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

我使用了以下受osmo-tcap-map项目启发的 C 代码。

SendAuthenticationInfoArg_t ula;
memset(&ula, 0, sizeof(ula));

ASN1Common::OCTET_STRING_fromRevVal(&ula.imsi, 202015604083166);
ula.requestingNodeType = 0;
ula.numberOfRequestedVectors = 5;    
xer_fprint(stdout, &asn_DEF_SendAuthenticationInfoArg, &ula);

但是 XER 输出中没有可选部分,而“ requestingNodeType ”已被​​初始化:

<SendAuthenticationInfoArg>
    <imsi>02 02 51 06 04 38 61 F6</imsi>
    <numberOfRequestedVectors>5</numberOfRequestedVectors>
</SendAuthenticationInfoArg>

如何启用可选部分(即在消息中添加“requestingNodeType”)?

4

1 回答 1

1

requestingNodeType和都是numberOfRequestedVectors指针

RequestingNodeType_t    *requestingNodeType /* OPTIONAL */;
PLMN_Id_t   *requestingPLMN_Id  /* OPTIONAL */;
NumberOfRequestedVectors_t  *numberOfRequestedAdditional_Vectors    /* OPTIONAL */;
NULL_t  *additionalVectorsAreForEPS /* OPTIONAL */;

所以你首先需要分配它们,它应该是这样的

ula.requestingNodeType = malloc(sizeof(RequestingNodeType_t));
asn_long2INTEGER(ula.requestingNodeType, RequestingNodeType_vlr);

RequestingNodeType_tis typedef'd as ENUMERATED_tthat is typedef'd as这INTEGER_t就是为什么我们不能直接分配值而是使用asn_long2INTEGER

ula.numberOfRequestedVectors = malloc(sizeof(NumberOfRequestedVectors_t));
*ula.numberOfRequestedVectors = 5;

NumberOfRequestedVectors_t是 typedef 的,所以long在这里我们可以直接赋值

于 2018-12-11T16:43:26.130 回答