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

getaddrinfo POSIX problems #93

Open
ryniker opened this issue Dec 19, 2016 · 3 comments
Open

getaddrinfo POSIX problems #93

ryniker opened this issue Dec 19, 2016 · 3 comments

Comments

@ryniker
Copy link

ryniker commented Dec 19, 2016

pkg/minoca/os/apps/libc/dynamic/gaddrinf.c contains:

if ((Hints != NULL) && ((Hints->ai_flags & AI_NUMERICSERV) != 0)) {
    return EAI_SERVICE;
}

POSIX says:

The ai_flags field to which the hints parameter points shall be set to zero or be the bitwise-inclusive OR of one or more of the values AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST, AI_NUMERICSERV, AI_V4MAPPED, AI_ALL, and AI_ADDRCONFIG.

Minoca defines AI_ADDRCONFIG in apps/libc/include/netdb.h and should support its use in the hints argument of getaddrinfo.

I have not looked at whether Minoca supports IP6, but that is not the issue here. Support for AI_ADDRCONFIG is needed so Minoca can run POSIX-compliant programs that want to adapt to whatever network facilities are available in the current platform.

@evangreen
Copy link
Collaborator

Hi Richard,
The description of AI_NUMERICSERV I found says:

If the AI_NUMERICSERV flag is specified, then a non-null servname string supplied shall be a numeric port string. Otherwise, an [EAI_NONAME] error shall be returned.

The code you pointed at happens after trying (and failing) to use strtoul to convert the ServiceName into a numeric value. What are you passing in to the second argument of getaddrinfo?

I'm realizing now that I think I got the error code wrong. That quote wants EAI_NONAME, not EAI_SERVICE as I'm returning (though EAI_SERVICE still makes more sense to me, as it's the service that failed translation, not the name)

Sorry my responses are a little delayed, I was travelling yesterday. I'm travelling a bit today too, but had some time this morning to peek at my email. My internet access might be slightly more sporadic for the next week or so.

@ryniker
Copy link
Author

ryniker commented Dec 22, 2016

Sorry, I read the condition incorrectly. Looking more carefully, I now believe the problem is failure in getservbyname. This is another case where documentation (http://www.minocacorp.com/doc/1375/api/LIBC_API/element/362073/) describes something that does not exist. In os/apps/libc/dynamic/netent.c is:
//
// TODO: Implement getservbyname.
//
OK, documentation disagrees with reality - this is not a novelty. But other code, specifically getaddrinfo, depends on the not-implemented function. "Service not available" is certainly a plausible response when a remote host does not implement the requested service; it is definitely wrong to say this because the local host does not (unless the getaddrinfo call specified the local host) and wonderfully misleading in this case where it looks like getaddrinfo is implemented, but it is actually broken because a required function does nothing.

@evangreen
Copy link
Collaborator

Yes, sorry about that. As a workaround until someone implements getservbyname you can pass the service name parameter as a port number string directly, ie "80" instead of "www".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants