diff options
Diffstat (limited to 'Source/charon/utils/host.h')
-rw-r--r-- | Source/charon/utils/host.h | 74 |
1 files changed, 68 insertions, 6 deletions
diff --git a/Source/charon/utils/host.h b/Source/charon/utils/host.h index 1ef9676a3..27d20d731 100644 --- a/Source/charon/utils/host.h +++ b/Source/charon/utils/host.h @@ -37,22 +37,84 @@ */ typedef struct host_s host_t; struct host_s { + /** + * @brief Build a clone of this host object. + * + * @param this object to clone + * @param [out]other address where to allocate the clone + * @return + * - SUCCESS, or + * - OUT_OF_RES + */ + status_t (*clone) (host_t *this, host_t **other); + /** + * @brief Get a pointer to the internal sockaddr struct. + * + * This is used for sending and receiving via sockets. + * + * @param this object to clone + * @return pointer to the internal sockaddr structure + */ sockaddr_t *(*get_sockaddr) (host_t *this); + + /** + * @brief Get the length of the sockaddr struct. + * + * Sepending on the family, the length of the sockaddr struct + * is different. Use this function to get the length of the sockaddr + * struct returned by get_sock_addr. + * + * This is used for sending and receiving via sockets. + * + * @param this object to clone + * @return length of the sockaddr struct + */ socklen_t *(*get_sockaddr_len) (host_t *this); + + /** + * @brief get the address of this host + * + * Mostly used for debugging purposes. + * @warging string must NOT be freed + * + * @param this object to clone + * @return address string, + */ + char* (*get_address) (host_t *this); + + /** + * @brief get the port of this host + * + * Mostly used for debugging purposes. + * + * @param this object to clone + * @return port number + */ + u_int16_t (*get_port) (host_t *this); + + /** + * @brief Destroy this host object + * + * @param this calling + * @return SUCCESS in any case + */ status_t (*destroy) (host_t *this); }; /** - * @brief Constructor to create a logger_t object. + * @brief Constructor to create a host_t object + * + * currently supports only IPv4! * - * @param logger_name Name for the logger_t object - * @param log_level or'ed set of log_levels to assign to the new logger_t object - * @param output FILE * if log has to go on a file output, NULL for syslog - * @return logger_t object or NULL if failed + * @param family Address family to use for this object, such as AF_INET or AF_INET6 + * @param address string of an address, such as "152.96.193.130" + * @param port port number + * @return the host_t object or NULL, when + * not enough ressources, or + * family not supported. */ host_t *host_create(int family, char *address, u_int16_t port); - #endif /*HOST_H_*/ |