Back to index

nagios-plugins  1.4.16
Defines | Typedefs | Functions
inet_ntop.c File Reference
#include <config.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

Go to the source code of this file.


#define NS_IN6ADDRSZ   16
#define NS_INT16SZ   2


typedef int verify_int_size [2 *sizeof(int)-7]


static const char * inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
const char * inet_ntop (int af, const void *restrict src, char *restrict dst, socklen_t cnt)

Define Documentation

#define NS_IN6ADDRSZ   16

Definition at line 45 of file inet_ntop.c.

#define NS_INT16SZ   2

Definition at line 46 of file inet_ntop.c.

Typedef Documentation

typedef int verify_int_size[2 *sizeof(int)-7]

Definition at line 52 of file inet_ntop.c.

Function Documentation

const char* inet_ntop ( int  af,
const void *restrict  src,
char *restrict  dst,
socklen_t  cnt 

Definition at line 69 of file inet_ntop.c.

  switch (af)
    case AF_INET:
      return (inet_ntop4 (src, dst, cnt));

    case AF_INET6:
      return (inet_ntop6 (src, dst, cnt));

      errno = EAFNOSUPPORT;
      return (NULL);

Here is the call graph for this function:

Here is the caller graph for this function:

static const char * inet_ntop4 ( const unsigned char *  src,
char *  dst,
socklen_t  size 
) [static]

Definition at line 103 of file inet_ntop.c.

  char tmp[sizeof ""];
  int len;

  len = sprintf (tmp, "%u.%u.%u.%u", src[0], src[1], src[2], src[3]);
  if (len < 0)
    return NULL;

  if (len > size)
      errno = ENOSPC;
      return NULL;

  return strcpy (dst, tmp);

Here is the caller graph for this function: