Networking/Ideas/NetworkNameResolution

From FedoraProject

Jump to: navigation, search

Contents

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