dcmqrscp 支持IP地址

 

dcmqrscp默認只支持hostname

簡單的修改了一下就可以支持IP了

dul.cc

receiveTransportConnectionTCP

 

  OFString client_dns_name;
    char client_ip_address[20];
    sprintf(client_ip_address, "%-d.%-d.%-d.%-d",  // this code is ugly but thread safe
       ((int) from.sa_data[2]) & 0xff,
       ((int) from.sa_data[3]) & 0xff,
       ((int) from.sa_data[4]) & 0xff,
       ((int) from.sa_data[5]) & 0xff);

    if (! dcmDisableGethostbyaddr.get()) remote = gethostbyaddr(&from.sa_data[2], 4, 2);
    //@20190617 to supported IP
    //if (remote == NULL)
    {
        // reverse DNS lookup disabled or host not found, use numerical address
        OFStandard::strlcpy(params->callingPresentationAddress, client_ip_address,
          sizeof(params->callingPresentationAddress));
        OFStandard::strlcpy((*association)->remoteNode, client_ip_address, sizeof((*association)->remoteNode));
    }
    //else
    //{
    //    client_dns_name = remote->h_name;

    //    char node[128];
    //    if ((*network)->options & DUL_FULLDOMAINNAME)
    //        OFStandard::strlcpy(node, remote->h_name, sizeof(node));
    //    else {
    //        if (sscanf(remote->h_name, "%[^.]", node) != 1)
    //            node[0] = '\0';
    //    }

    //    OFStandard::strlcpy((*association)->remoteNode, node, sizeof((*association)->remoteNode));
    //    OFStandard::strlcpy(params->callingPresentationAddress, node, sizeof(params->callingPresentationAddress));
    //}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章