Presentation is loading. Please wait.

Presentation is loading. Please wait.

Elementary Name and Address Conversions

Similar presentations


Presentation on theme: "Elementary Name and Address Conversions"— Presentation transcript:

1 Elementary Name and Address Conversions
Chapter9 Elementary Name and Address Conversions

2 Introduction Domain Name Server gethostbyname Function.
gethostbyaddr Function. uname Function. gethostname Function. getsvrbyname & getsvrbyport Function.

3 Domain Name System FQDN(Fully qualified domain name) ex) comedu.chungbuk.ac.kr. RRs(Resource Records)

4 Resolvers and Name Servers
Application code Resolver Local name server Other configuration files Function call Function return UDP request UDP reply /etc/resolv.conf Typical arrangement of clients, resolvers, and name servers

5 gethostbyname Function
#include <netdb.h> struct hostent *gethostbyname (const char *hostname); struct hostent { char *h_name; /* official (canonical) name of host */ char **h_aliases; /* pointer to arrayof opinters to alises names */ int h_addrtype; /* host address type : AF_INET or AF_INET6 */ int h_length; /* length of address : 4 or 6 */ char **h_addr_list; /* ptr to array of ptrs with IPv4 or IPv6 addrs */ }; hostent{} h_name h_aliases h_addrtype h_length h_addr_list official hostname \0 NULL Alises #1 \0 Alises #2 \0 IP addr #1 IP addr #2 IP addr #3 h_length =4 In_addr{} AF_INET 4

6 RES_USE_INET6 Resolver Option
1. #include <resolv.h> res_init(); _res.option |= RES_USE_INET6; 2. export RES_OPTION=inet6; (shell once) (in .profile One User Only) 3. options inet6 (in /etc/resolv.conf) if all program support IPv6

7 gethostbyname2 Function
#include <netdb.h> struct hostent *gethostbyname2 (const char *hostname, int family);

8 gethostbyaddr Function
#include <netdb.h> struct hostent *gethostbyaddr(const chr *addr, size_t len,int family); The field of interest in this structure is normally h_name, the canonical hostname

9 uname Function gethostname Function #include <netdb.h>
int uname(struct utsname *name); #define _UTS_NAMESIZE 16 #define _UTS_NODESIZE 256 struct ntsname { char sysname[_UTS_NAMESIZE]; /* name of this operationg system */ char sysname[_UTS_NAMESIZE]; /* name of this node */ char sysname[_UTS_NAMESIZE]; /* O. S. release level */ char sysname[_UTS_NAMESIZE]; /* O. S. version level */ char sysname[_UTS_NAMESIZE]; /* hardware type */ }; gethostname Function #include <netdb.h> int gethostname(char *name, size_t namelen);

10 getservbyname Function
#include <netdb.h> struct servent *getservbyname(const char *servname, const char *protoname); struct servent { char *s_name; /* official service name */ char **s_ aliases; /* aliases list*/ int s_port; /* port number, network by order */ char *s_proto; /* protocol to use */ }; getservbyport Function #include <netdb.h> struct servent *getservbyport(int port, const char *protoname);


Download ppt "Elementary Name and Address Conversions"

Similar presentations


Ads by Google