~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to libntp/socktoa.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-10-11 16:10:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041011161027-icyjbji8ujym633o
Tags: 1:4.2.0a-10ubuntu2
Use ntp.ubuntulinux.org instead of pool.ntp.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * socktoa - return a numeric host name from a sockaddr_storage structure
 
3
 */
 
4
 
 
5
#include <config.h>
 
6
 
 
7
#include <sys/types.h>
 
8
#include <sys/socket.h>
 
9
#include <netdb.h>
 
10
#include <netinet/in.h>
 
11
 
 
12
#include <arpa/inet.h>
 
13
 
 
14
#ifdef ISC_PLATFORM_NEEDNTOP
 
15
#include <isc/net.h>
 
16
#endif
 
17
 
 
18
#include <stdio.h>
 
19
 
 
20
#include "ntp_fp.h"
 
21
#include "lib_strbuf.h"
 
22
#include "ntp_stdlib.h"
 
23
#include "ntp.h"
 
24
 
 
25
char *
 
26
socktoa(
 
27
        struct sockaddr_storage* sock
 
28
        )
 
29
{
 
30
        register char *buffer;
 
31
 
 
32
        LIB_GETBUF(buffer);
 
33
 
 
34
        if (sock == NULL) printf("null");
 
35
 
 
36
        switch(sock->ss_family) {
 
37
 
 
38
                case AF_INET :
 
39
                        inet_ntop(AF_INET, &GET_INADDR(*sock), buffer,
 
40
                            LIB_BUFLENGTH);
 
41
                        break;
 
42
 
 
43
                case AF_INET6 :
 
44
                        inet_ntop(AF_INET6, &GET_INADDR6(*sock), buffer,
 
45
                            LIB_BUFLENGTH);
 
46
        }
 
47
        return buffer;
 
48
}