From Fedora Project Wiki
< Networking | Ideas
Line 26: | Line 26: | ||
=== Resolve a service name to a port number === | === Resolve a service name to a port number === | ||
Input parameters | ==== Use cases ==== | ||
* any software that works with TCP or UDP port numbers | |||
==== Input parameters ==== | |||
* service | * service | ||
* protocol (socktype?) | * protocol (socktype?) | ||
Output parameter | ==== Output parameter ==== | ||
* port | * port | ||
* protocol | * protocol | ||
Current | ==== Current API ==== | ||
<pre> | <pre> |
Revision as of 21:37, 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
Use cases
- any software that works with TCP or UDP port numbers
Input parameters
- service
- protocol (socktype?)
Output parameter
- port
- protocol
Current API
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