inetaddr.h File Reference

This file contains the internet address handling module. More...

`#include <gwenhywfar/gwenhywfarapi.h>`
`#include "gwenhywfar/error.h"`

Go to the source code of this file.

## Macros

Error Codes
#define | GWEN_INETADDR_ERROR_BAD_ADDRESS 2
#define | GWEN_INETADDR_ERROR_BAD_ADDRESS_FAMILY 9
#define | GWEN_INETADDR_ERROR_BUFFER_OVERFLOW 3
#define | GWEN_INETADDR_ERROR_HOST_NOT_FOUND 4
#define | GWEN_INETADDR_ERROR_MEMORY_FULL 1
#define | GWEN_INETADDR_ERROR_NO_ADDRESS 5
#define | GWEN_INETADDR_ERROR_NO_RECOVERY 6
#define | GWEN_INETADDR_ERROR_TRY_AGAIN 7
#define | GWEN_INETADDR_ERROR_TYPE "InetAddr"
#define | GWEN_INETADDR_ERROR_UNKNOWN_DNS_ERROR 8
#define | GWEN_INETADDR_ERROR_UNSUPPORTED 10

## Functions

Construction and destruction
These functions allocate and free administrative data about IP addresses.
GWENHYWFAR_API GWEN_INETADDRESS * | GWEN_InetAddr_dup (const GWEN_INETADDRESS *ia)
GWENHYWFAR_API void | GWEN_InetAddr_free (GWEN_INETADDRESS *ia)
GWENHYWFAR_API GWEN_INETADDRESS * | GWEN_InetAddr_new (GWEN_AddressFamily af)
Get and set address
These functions allow getting and setting of IP addresses either by hostname or host address.
GWENHYWFAR_API int | GWEN_InetAddr_GetAddress (const GWEN_INETADDRESS *ia, char *buffer, unsigned int bsize)
GWENHYWFAR_API int | GWEN_InetAddr_GetName (const GWEN_INETADDRESS *ia, char *buffer, unsigned int bsize)
GWENHYWFAR_API int | GWEN_InetAddr_SetAddress (GWEN_INETADDRESS *ia, const char *addr)
GWENHYWFAR_API int | GWEN_InetAddr_SetName (GWEN_INETADDRESS *ia, const char *name)
Get and set port
These functions allow getting and setting of the port.
GWENHYWFAR_API int | GWEN_InetAddr_GetPort (const GWEN_INETADDRESS *ia)
GWENHYWFAR_API int | GWEN_InetAddr_SetPort (GWEN_INETADDRESS *ia, int port)

## Capabilities of this module

enum | GWEN_AddressFamily { GWEN_AddressFamilyIP =0 , GWEN_AddressFamilyUnix }
#define | GWEN_INETADDR_CAPS_AF_TCP 0x00000001
#define | GWEN_INETADDR_CAPS_AF_UNIX 0x00000002
GWENHYWFAR_API uint32_t | GWEN_InetAddr_GetCapabilities (void)
typedef struct GWEN_INETADDRESSSTRUCT | GWEN_INETADDRESS

## Detailed Description

This file contains the internet address handling module.

Definition in file inetaddr.h.

## Macro Definition Documentation

## GWEN_INETADDR_CAPS_AF_TCP

#define GWEN_INETADDR_CAPS_AF_TCP 0x00000001

Definition at line 73 of file inetaddr.h.

## GWEN_INETADDR_CAPS_AF_UNIX

#define GWEN_INETADDR_CAPS_AF_UNIX 0x00000002

Definition at line 74 of file inetaddr.h.

## GWEN_INETADDR_ERROR_BAD_ADDRESS

#define GWEN_INETADDR_ERROR_BAD_ADDRESS 2

Definition at line 58 of file inetaddr.h.

## GWEN_INETADDR_ERROR_BAD_ADDRESS_FAMILY

#define GWEN_INETADDR_ERROR_BAD_ADDRESS_FAMILY 9

Definition at line 65 of file inetaddr.h.

## GWEN_INETADDR_ERROR_BUFFER_OVERFLOW

#define GWEN_INETADDR_ERROR_BUFFER_OVERFLOW 3

Definition at line 59 of file inetaddr.h.

## GWEN_INETADDR_ERROR_HOST_NOT_FOUND

#define GWEN_INETADDR_ERROR_HOST_NOT_FOUND 4

Definition at line 60 of file inetaddr.h.

## GWEN_INETADDR_ERROR_MEMORY_FULL

#define GWEN_INETADDR_ERROR_MEMORY_FULL 1

Definition at line 57 of file inetaddr.h.

## GWEN_INETADDR_ERROR_NO_ADDRESS

#define GWEN_INETADDR_ERROR_NO_ADDRESS 5

Definition at line 61 of file inetaddr.h.

## GWEN_INETADDR_ERROR_NO_RECOVERY

#define GWEN_INETADDR_ERROR_NO_RECOVERY 6

Definition at line 62 of file inetaddr.h.

## GWEN_INETADDR_ERROR_TRY_AGAIN

#define GWEN_INETADDR_ERROR_TRY_AGAIN 7

Definition at line 63 of file inetaddr.h.

## GWEN_INETADDR_ERROR_TYPE

#define GWEN_INETADDR_ERROR_TYPE "InetAddr"

Definition at line 56 of file inetaddr.h.

## GWEN_INETADDR_ERROR_UNKNOWN_DNS_ERROR

#define GWEN_INETADDR_ERROR_UNKNOWN_DNS_ERROR 8

Definition at line 64 of file inetaddr.h.

## GWEN_INETADDR_ERROR_UNSUPPORTED

#define GWEN_INETADDR_ERROR_UNSUPPORTED 10

Definition at line 66 of file inetaddr.h.

## Typedef Documentation

## GWEN_INETADDRESS

typedef struct GWEN_INETADDRESSSTRUCT GWEN_INETADDRESS

You shoukd treat this type as opaque. Its members are not part of the API, i.e. they are subject to changes without notice !

Definition at line 95 of file inetaddr.h.

## Enumeration Type Documentation

## GWEN_AddressFamily

enum GWEN_AddressFamily

Address family (in most cases this is AddressFamilyIP)

Enumerator
GWEN_AddressFamilyIP | Internet Protocol (IP)
GWEN_AddressFamilyUnix |

Definition at line 83 of file inetaddr.h.

## Function Documentation

## GWEN_InetAddr_dup()

GWENHYWFAR_API GWEN_INETADDRESS * GWEN_InetAddr_dup | ( | const GWEN_INETADDRESS * | ia | ) |

References GWENHYWFAR_API.

## GWEN_InetAddr_free()

GWENHYWFAR_API void GWEN_InetAddr_free | ( | GWEN_INETADDRESS * | ia | ) |

References GWENHYWFAR_API.

## GWEN_InetAddr_GetAddress()

GWENHYWFAR_API int GWEN_InetAddr_GetAddress | ( | const GWEN_INETADDRESS * | ia,
|  | char * | buffer,
|  | unsigned int | bsize )

Gets the IP address stored in the INETADDRESS.

Returns
  error code

Parameters

  ia | INETADDRESS to use
  buffer | pointer to a buffer to receive the address
  bsize | size of the buffer in bytes

References GWENHYWFAR_API.

## GWEN_InetAddr_GetCapabilities()

GWENHYWFAR_API uint32_t GWEN_InetAddr_GetCapabilities | ( | void |  | ) |

References GWENHYWFAR_API.

## GWEN_InetAddr_GetName()

GWENHYWFAR_API int GWEN_InetAddr_GetName | ( | const GWEN_INETADDRESS * | ia,
|  | char * | buffer,
|  | unsigned int | bsize )

Gets the host name stored in the INETADDRESS. If there is none, then the IP address stored in the INETADDRESS will be used to resolve the hostname.

Returns
  error code

Parameters

  ia | INETADDRESS to use
  buffer | pointer to a buffer to receive the name
  bsize | size of the buffer in bytes

## GWEN_InetAddr_GetPort()

GWENHYWFAR_API int GWEN_InetAddr_GetPort | ( | const GWEN_INETADDRESS * | ia | ) |

Return the port stored in the INETADDRESS

Parameters

  ia | INETADDRESS to use

References GWENHYWFAR_API.

## GWEN_InetAddr_new()

GWENHYWFAR_API GWEN_INETADDRESS * GWEN_InetAddr_new | ( | GWEN_AddressFamily | af | ) |

References GWENHYWFAR_API.

## GWEN_InetAddr_SetAddress()

GWENHYWFAR_API int GWEN_InetAddr_SetAddress | ( | GWEN_INETADDRESS * | ia,
|  | const char * | addr )

Sets the IP address.

Returns
  error code

Parameters

  ia | INETADDRESS to manipulate
  addr | IP address in 3-dot-notation ("1.2.3.4")

References GWENHYWFAR_API.

## GWEN_InetAddr_SetName()

GWENHYWFAR_API int GWEN_InetAddr_SetName | ( | GWEN_INETADDRESS * | ia,
|  | const char * | name )

Sets the IP name and resolves its address.

Returns
  error code

Parameters

  ia | INETADDRESS to manipulate
  name | hostname whose address is to be resolved in 3-dot-notation

References GWENHYWFAR_API.

## GWEN_InetAddr_SetPort()

GWENHYWFAR_API int GWEN_InetAddr_SetPort | ( | GWEN_INETADDRESS * | ia,
|  | int | port )

Set the port in the given INETADDRESS.

Returns
  error code

Parameters

  ia | INETADDRESS to manipulate
  port | port to set (0-65535)

References GWENHYWFAR_API.