Tomas Cejka | af7a156 | 2013-04-13 02:27:43 +0200 | [diff] [blame] | 1 | /*! |
| 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 Cejka | 45ab59f | 2013-05-15 00:10:49 +0200 | [diff] [blame] | 54 | #include <json/json.h> |
Tomas Cejka | af7a156 | 2013-04-13 02:27:43 +0200 | [diff] [blame] | 55 | |
| 56 | struct 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 | |
| 63 | typedef struct notification { |
| 64 | time_t eventtime; |
| 65 | char* content; |
| 66 | } notification_t; |
| 67 | |
| 68 | struct session_with_mutex { |
| 69 | struct nc_session * session; /**< netconf session */ |
| 70 | apr_array_header_t *notifications; |
Tomas Cejka | 45ab59f | 2013-05-15 00:10:49 +0200 | [diff] [blame] | 71 | json_object *hello_message; |
Tomas Cejka | 654f84e | 2013-04-19 11:55:01 +0200 | [diff] [blame] | 72 | char ntfc_subscribed; /**< 0 when notifications are not subscribed */ |
Tomas Cejka | 6e8f426 | 2013-07-10 09:20:19 +0200 | [diff] [blame] | 73 | char closed; /**< 0 when session is terminated */ |
Tomas Cejka | af7a156 | 2013-04-13 02:27:43 +0200 | [diff] [blame] | 74 | apr_time_t last_activity; |
| 75 | pthread_mutex_t lock; /**< mutex protecting the session from multiple access */ |
| 76 | }; |
| 77 | |
| 78 | typedef struct { |
| 79 | apr_pool_t *pool; |
| 80 | apr_proc_t *forkproc; |
| 81 | char* sockname; |
| 82 | } mod_netconf_cfg; |
| 83 | |
| 84 | |
| 85 | extern pthread_rwlock_t session_lock; /**< mutex protecting netconf_session_list from multiple access errors */ |
| 86 | |
| 87 | #endif |
| 88 | |