Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPV6 Unknown host error #99

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions dcmnet/libsrc/dulfsm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2255,8 +2255,22 @@ requestAssociationTCP(PRIVATE_NETWORKKEY ** network,
int s;
#endif
struct linger sockarg;

if (sscanf(params->calledPresentationAddress, "%[^:]:%d", node, &port) != 2)

// ipv6 address was not parsing properly, so corrected the below code.
// convert the char array to a std::string
std::string addressString(params->calledPresentationAddress);
// find the last colon in the string to split the node and port
size_t lastColonPos = addressString.find_last_of(':');
if (lastColonPos != std::string::npos) {
// extract node and port from the string
std::string nodeStr = addressString.substr(0, lastColonPos);
std::string portStr = addressString.substr(lastColonPos + 1);
// copy node string into node char array
strncpy_s(node, sizeof(node), nodeStr.c_str(), _TRUNCATE);
// convert port string to integer
port = std::stoi(portStr);
}
else
{
char buf[1024];
OFStandard::snprintf(buf, sizeof(buf), "Illegal service parameter: %s", params->calledPresentationAddress);
Expand Down
7 changes: 3 additions & 4 deletions ofstd/libsrc/ofstd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2905,11 +2905,10 @@ void OFStandard::getAddressByHostname(const char *name, OFSockAddr& result)
struct addrinfo *result_list = NULL;
int err = EAI_AGAIN;
int rep = DCMTK_MAX_EAI_AGAIN_REPETITIONS;

// filter for the DNS lookup. Since DCMTK does not yet fully support IPv6,
// we only look for IPv4 addresses.

::addrinfo hint = {};
hint.ai_family = AF_INET;
// in order to support IPV6 address too in DNS lookup we are changing ai_family to AF_UNSPEC.
hint.ai_family = AF_UNSPEC;

// perform DNS lookup. Repeat while we receive temporary failures.
while ((EAI_AGAIN == err) && (rep-- > 0)) err = getaddrinfo(name, NULL, &hint, &result_list);
Expand Down
Loading