]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - Source/charon/network/host.h
4 * @brief Interface of host_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <arpa/inet.h>
36 typedef struct host_t host_t
;
39 * @brief Representates a Host
41 * Host object, identifies a host and defines some useful functions on it.
47 * @brief Build a clone of this host object.
49 * @param this object to clone
52 host_t
*(*clone
) (host_t
*this);
55 * @brief Get a pointer to the internal sockaddr struct.
57 * This is used for sending and receiving via sockets.
59 * @param this object to clone
60 * @return pointer to the internal sockaddr structure
62 sockaddr_t
*(*get_sockaddr
) (host_t
*this);
65 * @brief Get the length of the sockaddr struct.
67 * Sepending on the family, the length of the sockaddr struct
68 * is different. Use this function to get the length of the sockaddr
69 * struct returned by get_sock_addr.
71 * This is used for sending and receiving via sockets.
73 * @param this object to clone
74 * @return length of the sockaddr struct
76 socklen_t
*(*get_sockaddr_len
) (host_t
*this);
79 * @brief get the address of this host
81 * Mostly used for debugging purposes.
82 * @warging string must NOT be freed
84 * @param this object to clone
85 * @return address string,
87 char* (*get_address
) (host_t
*this);
90 * @brief get the port of this host
92 * Mostly used for debugging purposes.
94 * @param this object to clone
97 u_int16_t (*get_port
) (host_t
*this);
100 * @brief Destroy this host object
102 * @param this calling
103 * @return SUCCESS in any case
105 void (*destroy
) (host_t
*this);
109 * @brief Constructor to create a host_t object
111 * Currently supports only IPv4!
113 * @param family Address family to use for this object, such as AF_INET or AF_INET6
114 * @param address string of an address, such as "152.96.193.130"
115 * @param port port number
117 * - the host_t object, or
118 * - NULL, when family not supported.
122 host_t
*host_create(int family
, char *address
, u_int16_t port
);