1/*
2 * Copyright (C) 2006-2008, 2014  Internet Systems Consortium, Inc. ("ISC")
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/* $Id: httpd.h,v 1.9 2008/08/08 05:06:49 marka Exp $ */
18
19#ifndef ISC_HTTPD_H
20#define ISC_HTTPD_H 1
21
22/*! \file */
23
24#include <isc/event.h>
25#include <isc/eventclass.h>
26#include <isc/types.h>
27#include <isc/mutex.h>
28#include <isc/task.h>
29#include <isc/time.h>
30
31/*%
32 * HTTP urls.  These are the URLs we manage, and the function to call to
33 * provide the data for it.  We pass in the base url (so the same function
34 * can handle multiple requests), and a structure to fill in to return a
35 * result to the client.  We also pass in a pointer to be filled in for
36 * the data cleanup function.
37 */
38struct isc_httpdurl {
39	char			       *url;
40	isc_httpdaction_t	       *action;
41	void			       *action_arg;
42	isc_boolean_t			isstatic;
43	isc_time_t			loadtime;
44	ISC_LINK(isc_httpdurl_t)	link;
45};
46
47#define HTTPD_EVENTCLASS		ISC_EVENTCLASS(4300)
48#define HTTPD_SHUTDOWN			(HTTPD_EVENTCLASS + 0x0001)
49
50#define ISC_HTTPDMGR_FLAGSHUTTINGDOWN	0x00000001
51
52/*
53 * Create a new http daemon which will send, once every time period,
54 * a http-like header followed by HTTP data.
55 */
56isc_result_t
57isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task,
58		    isc_httpdclientok_t *client_ok,
59		    isc_httpdondestroy_t *ondestory, void *cb_arg,
60		    isc_timermgr_t *tmgr, isc_httpdmgr_t **httpdp);
61
62void
63isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdp);
64
65isc_result_t
66isc_httpdmgr_addurl(isc_httpdmgr_t *httpdmgr, const char *url,
67		    isc_httpdaction_t *func, void *arg);
68
69isc_result_t
70isc_httpdmgr_addurl2(isc_httpdmgr_t *httpdmgr, const char *url,
71		     isc_boolean_t isstatic,
72		     isc_httpdaction_t *func, void *arg);
73
74isc_result_t
75isc_httpd_response(isc_httpd_t *httpd);
76
77isc_result_t
78isc_httpd_addheader(isc_httpd_t *httpd, const char *name,
79		    const char *val);
80
81isc_result_t
82isc_httpd_addheaderuint(isc_httpd_t *httpd, const char *name, int val);
83
84isc_result_t isc_httpd_endheaders(isc_httpd_t *httpd);
85
86#endif /* ISC_HTTPD_H */
87