From Fedora Project Wiki
< Networking | Ideas
Line 3: | Line 3: | ||
=== Resolve a host name to a list of network layer addresses === | === Resolve a host name to a list of network layer addresses === | ||
Input parameters | ==== Use cases ==== | ||
* IP-based access lists | |||
* Network layer testing tools | |||
* Any tools working with non-TCP non-UDP protocols | |||
* Possibly even tools working with TCP and UDP | |||
==== Input parameters ==== | |||
* host | * host | ||
* family | * family | ||
Output parameters | ==== Output parameters ==== | ||
* List of sockaddr pointers (zero ports, zero protocols, etc) | * List of sockaddr pointers (zero ports, zero protocols, etc) | ||
* Canonical name (why?) | * Canonical name (why?) | ||
==== Current interface ==== | |||
Unfortunately, gethostbyname() has been deprecated and getaddrinfo() is not a good alternative. | Unfortunately, gethostbyname() has been deprecated and getaddrinfo() is not a good alternative. | ||
=== Resolve a service name to a port number === | === Resolve a service name to a port number === |
Revision as of 21:14, 21 December 2012
Some ideas for name resolution in linux distributions
Resolve a host name to a list of network layer addresses
Use cases
- IP-based access lists
- Network layer testing tools
- Any tools working with non-TCP non-UDP protocols
- Possibly even tools working with TCP and UDP
Input parameters
- host
- family
Output parameters
- List of sockaddr pointers (zero ports, zero protocols, etc)
- Canonical name (why?)
Current interface
Unfortunately, gethostbyname() has been deprecated and getaddrinfo() is not a good alternative.
Resolve a service name to a port number
Input parameters:
- service
- protocol (socktype?)
Output parameter:
- port
- protocol
Current status:
struct servent *getservbyname(const char *name, const char *proto); struct servent { char *s_name; /* official service name */ char **s_aliases; /* alias list */ int s_port; /* port number */ char *s_proto; /* protocol to use */ }
Resolve an address for connect() or sendto()
Input parameters (network layer):
- host (IP address or some sort of host name)
- family (to implement -4 and -6 switches)
Input parameters (transport layer):
- socktype
- protocol
- service (TCP/UDP port number or service name)
- whether to use SRV records
Output parameters:
- List of sockaddr pointers
- Canonical name (why?)
- socktype
- protocol
Resolve an address for IP ACLs
Input parameters:
- host
- family
Output parameters:
- List of sockaddr pointers (zero ports, zero protocols, etc)
- Canonical name (why?)
How name resolution API should work
- *gethostinfo (name, family=0, flags=0) → list of sockaddr, canonical name
- *getservinfo (name, protocol=0, ?socktype=0) → port, protocol, ?socktype
- *getconninfo (host, service, family, socktype, protocol, flags) → list of sockaddr, ?socktype, ?protocol, canonical name