From Fedora Project Wiki
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Some ideas for name resolution in linux distributions ==
== Some ideas for name resolution in linux distributions ==


=== Resolve a host name to a list of network layer addresses ===
=== Resolve a service name to a port number ===


==== Use cases ====
==== Use cases ====


* IP-based access lists
* any software that works with TCP or UDP port numbers
* Network layer testing tools
* Any tools working with non-TCP non-UDP protocols
* Possibly even tools working with TCP and UDP


==== Input parameters ====
==== 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
* service
* protocol (socktype?)
* protocol (socktype?)


Output parameter:
==== Output parameter ====


* port
* port
* protocol
* protocol


Current status:
==== Current interface ====


<pre>
<pre>
Line 86: Line 67:
* *gethostinfo (name, family=0, flags=0) → list of sockaddr, canonical name
* *gethostinfo (name, family=0, flags=0) → list of sockaddr, canonical name
* *getservinfo (name, protocol=0, ?socktype=0) → port, protocol, ?socktype
* *getservinfo (name, protocol=0, ?socktype=0) → port, protocol, ?socktype
* *getconninfo (host, service, family, socktype, protocol, flags) → list of sockaddr, ?socktype, ?protocol, canonical name
* *getsockinfo (host, service, family, socktype, protocol, flags) → list of sockaddr, ?socktype, ?protocol, canonical name

Latest revision as of 08:17, 29 July 2014

Some ideas for name resolution in linux distributions

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 interface

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
  • *getsockinfo (host, service, family, socktype, protocol, flags) → list of sockaddr, ?socktype, ?protocol, canonical name