1 / 10

Chapter9 Elementary Name and Address Conversions

Chapter9 Elementary Name and Address Conversions. Introduction. Domain Name Server gethostbyname Function. gethostbyaddr Function. uname Function. gethostname Function. getsvrbyname & getsvrbyport Function. Domain Name System. FQDN(Fully qualified domain name) ex) comedu.chungbuk.ac.kr.

Download Presentation

Chapter9 Elementary Name and Address Conversions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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. Application Application code UDP request Function call Function return Resolver code Local name server Other name server UDP reply Resolver configuration files Resolvers and Name Servers /etc/resolv.conf Typical arrangement of clients, resolvers, and name servers

  5. official hostname \0 Alises #1 \0 hostent{} Alises #2 \0 h_name h_aliases NULL h_addrtype AF_INET In_addr{} IP addr #1 h_length 4 In_addr{} h_addr_list IP addr #2 In_addr{} IP addr #3 NULL h_length =4 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 */ };

  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 • The field of interest in this structure is normally h_name, the canonical hostname #include <netdb.h> struct hostent *gethostbyaddr(const chr *addr, size_t len,int family);

  9. uname 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);

More Related