Linux 和 Solaris 之间的 RPC 调用

Posted

技术标签:

【中文标题】Linux 和 Solaris 之间的 RPC 调用【英文标题】:RPC calls between Linux and Solaris 【发布时间】:2013-07-05 06:38:26 【问题描述】:

我有一个在 Solaris 中运行的 RPC 服务器。我有一个在 Solaris 中运行良好的 RPC 客户端。 当我在 Linux(RHEL 5 或 6)中编译和运行相同的代码时,我在服务器中收到错误解码参数。 我应该如何发现问题?

部分代码是:

    /* now allocate a LoopListRequestStruct and fill it with request data */

    llrs = malloc(sizeof(LoopListRequestStruct));

    fill_llrs(llrs);

    /* Now, make the client request to the bossServer   */

    client_call_status = clnt_call(request_client, ModifyDhctState,
            (xdrproc_t)xdr_LoopListRequestStruct,
            (caddr_t)llrs, 
            (xdrproc_t)xdr_void,
            0,
            dummy_timeval
        );

void fill_llrs(LoopListRequestStruct* llrs)


    Descriptor_Loop* dl = 0;
    DhctState_d *dhct_state_ptr = 0;
    PackageAuthorization_d *pkg_auth_ptr = 0; 

    llrs->TRANS_NUM = 999999;   /* strictly arbitraty, use whatever you want */
                                /* the bossServer simply passes this back in */
                                /* in the response you use it to match       */
                                /* request/response if you want or you can   */
                                /* choose to ignore it if you want           */

    /* now set the response program number, this is the program number of  */
    /* transient program that was set up using the svc_reg_utils.[ch]      */
    /* it is that program that the response will be sent to                */

    llrs->responseProgramNum = response_program_number; 

    /* now allocate some memory for the data structures that will actually */
    /* carry the request data */

    llrs->ARG_PTR = malloc(sizeof(LoopListRequestArgs));

    dl = llrs->ARG_PTR->loopList.Loop_List_val;

    /* we are using a single descriptor loop at a time, this should always */
    /* be the case */

    llrs->ARG_PTR->loopList.Loop_List_len = 1;
    llrs->ARG_PTR->loopList.Loop_List_val = malloc(sizeof(Descriptor_Loop));

    /* now allocate memory and set the size for the ModifyDhctConfiguration */
    /* this transaction always has 3 descriptors, the DhctMacAddr_d, the    */
    /* DhctState_d, and the PackageAuthorization_d                          */

    dl = llrs->ARG_PTR->loopList.Loop_List_val;
    dl->Descriptor_Loop_len = 2;
    dl->Descriptor_Loop_val = 
        malloc((2 * sizeof(Resource_descriptor_union)));

    /* now, populate each descriptor */
    /* the order doesn't really matter I'm just doing it in the order I    */
    /* always have done */

    /* first the mac address descriptor */

    dl->Descriptor_Loop_val->type = 
        dhct_mac_addr_type;

    strcpy(
    dl->Descriptor_Loop_val[0].Resource_descriptor_union_u.dhctMacAddr.dhctMacAddr,
        dhct_mac_addr
    );

    /* second the dhct state descriptor */

    dl->Descriptor_Loop_val[1].type = 
        dhct_state_type;

    dhct_state_ptr =
        &(dl->Descriptor_Loop_val[1].Resource_descriptor_union_u.dhctState);

    if(dis_enable)
        dhct_state_ptr->disEnableFlag = DIS_Enabled;
    else
        dhct_state_ptr->disEnableFlag = DIS_Disabled;

    if(dms_enable)
        dhct_state_ptr->dmsEnableFlag = DMS_Enabled;
    else
        dhct_state_ptr->dmsEnableFlag = DMS_Disabled;

    if(analog_enable)
        dhct_state_ptr->analogEnableFlag = AEF_Enabled;
    else
        dhct_state_ptr->analogEnableFlag = AEF_Disabled;

    if(ippv_enable)
        dhct_state_ptr->ippvEnableFlag = IEF_Enabled;
    else
        dhct_state_ptr->ippvEnableFlag = IEF_Disabled;

    dhct_state_ptr->creditLimit = credit_limit;
    dhct_state_ptr->maxIppvEvents = max_ippv_events;

    /* we don't currently use the powerkey pin, instead we use an      */
    /* application layer pin for purchases and blocking so always turn */   
    /* pinEnable off */

    dhct_state_ptr->pinEnable = PE_Disabled;
    dhct_state_ptr->pin = 0;


    if(fast_refresh_enable)
        dhct_state_ptr->fastRefreshFlag = FRF_Enabled;
    else
        dhct_state_ptr->fastRefreshFlag = FRF_Disabled;

    dhct_state_ptr->locationX = location_x;
    dhct_state_ptr->locationY = location_y;


【问题讨论】:

您能否更准确地描述错误信息? 在 Solaris 方面,我有一些提供 rpc 服务器的 cisco 应用程序,在其日志中我看到解码参数时出错,但我不知道如何理解参数有什么问题。 如果您知道,请告诉我如何获取带有参数的 RPC 调用消息以了解从 solaris 或 linux 发送的消息中的差异? 各位,有谁能帮帮我吗? 可以用wireshark分析流量 【参考方案1】:

Set PIN = ""; //而不是零,它将起作用:)

头端和客户端的 c 编译器之间存在差异。他们处理字符串的方式不同。

BR, 钱丹·查布拉

【讨论】:

以上是关于Linux 和 Solaris 之间的 RPC 调用的主要内容,如果未能解决你的问题,请参考以下文章

使 bash 脚本在 Linux 和 Solaris 上运行

solaris 11.2怎么调分辨率

nfs

Linux下NFS的搭建与配置

HDFS(二) 底层通信原理——RPC 及 动态代理

RPC