blob: b3754033b35215a9976b2a5da019495be2113909 [file] [log] [blame]
Tomas Cejkaaf7a1562013-04-13 02:27:43 +02001/*!
2 * \file mod_netconf.c
3 * \brief NETCONF Apache modul for Netopeer
4 * \author Tomas Cejka <cejkat@cesnet.cz>
5 * \author Radek Krejci <rkrejci@cesnet.cz>
6 * \date 2011
7 * \date 2012
8 * \date 2013
9 */
10/*
11 * Copyright (C) 2011-2013 CESNET
12 *
13 * LICENSE TERMS
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
23 * distribution.
24 * 3. Neither the name of the Company nor the names of its contributors
25 * may be used to endorse or promote products derived from this
26 * software without specific prior written permission.
27 *
28 * ALTERNATIVELY, provided that this notice is retained in full, this
29 * product may be distributed under the terms of the GNU General Public
30 * License (GPL) version 2 or later, in which case the provisions
31 * of the GPL apply INSTEAD OF those given above.
32 *
33 * This software is provided ``as is'', and any express or implied
34 * warranties, including, but not limited to, the implied warranties of
35 * merchantability and fitness for a particular purpose are disclaimed.
36 * In no event shall the company or contributors be liable for any
37 * direct, indirect, incidental, special, exemplary, or consequential
38 * damages (including, but not limited to, procurement of substitute
39 * goods or services; loss of use, data, or profits; or business
40 * interruption) however caused and on any theory of liability, whether
41 * in contract, strict liability, or tort (including negligence or
42 * otherwise) arising in any way out of the use of this software, even
43 * if advised of the possibility of such damage.
44 *
45 */
46#ifndef __MOD_NETCONF_COMMON_H
47#define __MOD_NETCONF_COMMON_H
48
49#include <pthread.h>
50#include <httpd.h>
51#include <http_log.h>
52#include <http_config.h>
53#include <apr_hash.h>
Tomas Cejka45ab59f2013-05-15 00:10:49 +020054#include <json/json.h>
Tomas Cejkaaf7a1562013-04-13 02:27:43 +020055
56struct pass_to_thread {
57 int client; /**< opened socket */
58 apr_pool_t * pool; /**< ?? */
59 server_rec * server; /**< ?? */
60 apr_hash_t * netconf_sessions_list; /**< ?? */
61};
62
63typedef struct notification {
64 time_t eventtime;
65 char* content;
66} notification_t;
67
68struct session_with_mutex {
69 struct nc_session * session; /**< netconf session */
70 apr_array_header_t *notifications;
Tomas Cejka45ab59f2013-05-15 00:10:49 +020071 json_object *hello_message;
Tomas Cejka654f84e2013-04-19 11:55:01 +020072 char ntfc_subscribed; /**< 0 when notifications are not subscribed */
Tomas Cejkabdedcd32013-06-09 11:54:53 +020073 char closed;; /**< 0 when session is terminated */
Tomas Cejkaaf7a1562013-04-13 02:27:43 +020074 apr_time_t last_activity;
75 pthread_mutex_t lock; /**< mutex protecting the session from multiple access */
76};
77
78typedef struct {
79 apr_pool_t *pool;
80 apr_proc_t *forkproc;
81 char* sockname;
82} mod_netconf_cfg;
83
84
85extern pthread_rwlock_t session_lock; /**< mutex protecting netconf_session_list from multiple access errors */
86
87#endif
88