Bindings API Functions
int pr_ipbind_open(p_in_addr_t *addr, unsigned int port, conn_t listen_conn, unsigned char isdefault, unsigned char islocalhost); int pr_ipbind_close(p_in_addr_t *addr, unsigned int port, unsigned char close_namebinds); int pr_ipbind_add_binds(server_rec *server); server_rec *pr_ipbind_get_server(p_in_addr_t *addr, unsigned int port); pr_ipbind_t *pr_find_ipbind(p_in_addr_t *addr, unsigned int port); int pr_ipbind_listen(fd_set *readfds); conn_t *pr_ipbind_accept_conn(fd_set *readfds, int *listenfd); int pr_namebind_open(server_rec *server, const char *name, p_in_addr_t *addr, unsigned int port); int pr_namebind_close(const char *name, p_in_addr_t *addr, unsigned int port); server_rec *pr_namebind_get_server(const char *name, p_in_addr_t *addr, unsigned int port); pr_namebind_t *pr_find_namebind(const char *name, p_in_addr_t *addr, unsigned int port);
The pr_ipbind_open()
function creates a new IP-based binding for
the server given, using the provided information. The isdefault Boolean
argument signals whether the given server is the default server, as per the
DefaultServer
configuration directive. The islocalhost
Boolean argument signals whether the given server is for the local machine.
The created binding is inserted into a list of bindings maintained by the
Bindings layer. This function returns 0
on success,
-1
on failure.
The pr_ipbind_close()
function closes all bindings associated with
the given IP address/port combination. The bindings are then marked as
inactive so that future lookups via pr_find_ipbind()
skips these
bindings. Returns 0
on success, -1
on failure
(e.g. there were no bindings for that address/port found). As a special
case, a NULL addr can be passed to this function, which causes
all bindings to be closed.
The pr_ipbind_add_binds()
function searches through server's
configuration records, and for each Bind
directive found, creates
an additional pr_ipbind_t
for the configured Bind
address. The SocketBindTight
directive is honoured, if present.
Returns 0
on success, -1
on failure (e.g.
server == NULL
, for example).
The pr_ipbind_get_server()
function searchs the list of bindings
maintained by the Bindings layer, and returns the server_rec *
that is bound to the given IP address/port combination. Returns
NULL
if no binding was found for that address/port.
The pr_find_ipbind()
function searchs the list of bindings
maintained by the Bindings layer, and returns a pointer to the
pr_ipbind_t
associated with the given address and port. Returns
NULL
if no matching pr_ipbind_t
was found.
The pr_ipbind_listen()
function causes the server to
listen()
on each file descriptor in readfds, and returns
the relevant file descriptor when a connection request has arrived. Returns
-1
on error, such as when the fd_set
argument is
NULL
.
The pr_ipbind_accept_conn()
function uses a file descriptor
returned by select()
, accept()
s it, and returns
a pointer to the conn_t
from the binding associated with that
file descriptor. Returns the conn_t *
if successful,
NULL
if not found or if the arguments were NULL
.
The pr_namebind_open()
function opens a pr_namebind_t
,
similar to an pr_ipbind_t
, which associates the given name
(usually a DNS hostname) to the server. The addr and port
specified are used to associate this pr_namebind_t
with an IP
address, to which the DNS hostname should resolve.
The pr_namebind_close()
function marks the
pr_namebind_t
with the given name, addr, and
port as inactive, so that future lookups of pr_namebind_t
s
via pr_find_namebind()
passes over it. Returns 0
on
success or -1
on failure, such as when there was no matching
pr_namebind_t
found.
The pr_namebind_get_server()
function searches the list of bindings
maintained by the Bindings layer, and returns the server_rec *
associated with the given name, addr, and port. If none
are found, NULL
will be returned.
The pr_find_namebind()
function searches the list of bindings
maintained by the Bindings layer, and returns a pointer to the
pr_namebind_t
for the given name, address, and port. Returns
NULL
if no matching pr_namebind_t
is found.