This file is indexed.

/usr/include/olad/OlaServer.h is in libola-dev 0.9.8-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * OlaServer.h
 * Interface for the ola server class
 * Copyright (C) 2005 Simon Newton
 */

#ifndef OLAD_OLASERVER_H_
#define OLAD_OLASERVER_H_

#if HAVE_CONFIG_H
#include <config.h>
#endif

#include <ola/Constants.h>
#include <ola/ExportMap.h>
#include <ola/base/Macro.h>
#include <ola/io/SelectServer.h>
#include <ola/network/InterfacePicker.h>
#include <ola/network/Socket.h>
#include <ola/network/TCPSocketFactory.h>
#include <ola/plugin_id.h>
#include <ola/rdm/PidStore.h>
#include <ola/rdm/UID.h>
#include <ola/rpc/RpcSessionHandler.h>

#include <map>
#include <memory>
#include <string>
#include <vector>

namespace ola {

namespace rpc {
class RpcSession;
class RpcServer;
}

#ifdef HAVE_LIBMICROHTTPD
typedef class OladHTTPServer OladHTTPServer_t;
#else
typedef int OladHTTPServer_t;
#endif

/**
 * @brief The main OlaServer class.
 */
class OlaServer : public ola::rpc::RpcSessionHandlerInterface {
 public:
  /**
   * @brief Options for the OlaServer.
   */
  struct Options {
    bool http_enable;  /** @brief Run the HTTP server */
    bool http_localhost_only;  /** @brief Restrict access to localhost only */
    bool http_enable_quit;  /** @brief Enable /quit URL */
    unsigned int http_port;  /** @brief Port to run the HTTP server on */
    /** @brief Directory that contains the static content */
    std::string http_data_dir;
    std::string network_interface;
    std::string pid_data_dir;  /** @brief Directory with the PID definitions */
  };

  /**
   * @brief Create a new instance of the OlaServer.
   * @param plugin_loaders A list of PluginLoaders to use to find plugins.
   * @param preferences_factory The factory to use when creating Preference
   *   objects.
   * @param ss The SelectServer.
   * @param ola_options The OlaServer options.
   * @param socket An optional TCPAcceptingSocket in the listen state to use
   *   for client RPC calls. Ownership is transferred.
   * @param export_map An optional ExportMap. If set to NULL a new ExportMap
   *   will be created.
   */
  OlaServer(const std::vector<class PluginLoader*> &plugin_loaders,
            class PreferencesFactory *preferences_factory,
            ola::io::SelectServer *ss,
            const Options &ola_options,
            ola::network::TCPAcceptingSocket *socket = NULL,
            ExportMap *export_map = NULL);

  /**
   * @brief Shutdown the server
   */
  ~OlaServer();

  /**
   * @brief Initialize the OlaServer.
   * @returns true if initialization succeeded, false if it failed.
   */
  bool Init();

  /**
   * @brief Reload all plugins.
   *
   * This method is thread safe.
   */
  void ReloadPlugins();

  /**
   * @brief Reload the pid store.
   *
   * This method is thread safe.
   */
  void ReloadPidStore();

  /**
   * @brief Stop the OLA Server.
   *
   * This terminates the underlying SelectServer.
   */
  void StopServer() { m_ss->Terminate(); }

  /**
   * @brief Add a new ConnectedDescriptor to this Server.
   * @param descriptor the new ConnectedDescriptor, ownership is transferred.
   */
  void NewConnection(ola::io::ConnectedDescriptor *descriptor);

  /**
   * @brief Return the socket address the RPC server is listening on.
   * @returns A socket address, which is empty if the server hasn't been
   *   initialized.
   */
  ola::network::GenericSocketAddress LocalRPCAddress() const;

  // Called by the RpcServer when clients connect or disconnect.
  void NewClient(ola::rpc::RpcSession *session);
  void ClientRemoved(ola::rpc::RpcSession *session);

  /**
   * @brief Get the instance name
   * @return a string which is the instance name
   */
  const std::string InstanceName() {
    return m_instance_name;
  }

  /**
   * @brief Get the preferences factory
   * @return a pointer to the preferences factory
   */
  const PreferencesFactory* GetPreferencesFactory() {
    return m_preferences_factory;
  }

  static const unsigned int DEFAULT_HTTP_PORT = 9090;

  static const unsigned int DEFAULT_RPC_PORT = OLA_DEFAULT_PORT;

 private :
  struct ClientEntry {
    ola::io::ConnectedDescriptor *client_descriptor;
    class OlaClientService *client_service;
  };

  typedef std::map<ola::io::DescriptorHandle, ClientEntry> ClientMap;

  // These are all passed to the constructor.
  const Options m_options;
  std::vector<class PluginLoader*> m_plugin_loaders;
  class PreferencesFactory *m_preferences_factory;
  ola::io::SelectServer *m_ss;
  ola::network::TCPAcceptingSocket *m_accepting_socket;
  class ExportMap *m_export_map;

  std::auto_ptr<class ExportMap> m_our_export_map;
  ola::rdm::UID m_default_uid;

  // These are all populated in Init.
  std::auto_ptr<class DeviceManager> m_device_manager;
  std::auto_ptr<class PluginManager> m_plugin_manager;
  std::auto_ptr<class PluginAdaptor> m_plugin_adaptor;
  std::auto_ptr<class UniverseStore> m_universe_store;
  std::auto_ptr<class PortManager> m_port_manager;
  std::auto_ptr<class OlaServerServiceImpl> m_service_impl;
  std::auto_ptr<class ClientBroker> m_broker;
  std::auto_ptr<class PortBroker> m_port_broker;
  std::auto_ptr<const ola::rdm::RootPidStore> m_pid_store;
  std::auto_ptr<class DiscoveryAgentInterface> m_discovery_agent;
  std::auto_ptr<ola::rpc::RpcServer> m_rpc_server;
  class Preferences *m_server_preferences;
  class Preferences *m_universe_preferences;
  std::string m_instance_name;

  ola::thread::timeout_id m_housekeeping_timeout;
  std::auto_ptr<OladHTTPServer_t> m_httpd;

  bool RunHousekeeping();

#ifdef HAVE_LIBMICROHTTPD
  bool StartHttpServer(ola::rpc::RpcServer *server,
                       const ola::network::Interface &iface);
#endif
  /**
   * @brief Stop and unload all the plugins
   */
  void StopPlugins();
  bool InternalNewConnection(ola::rpc::RpcServer *server,
                             ola::io::ConnectedDescriptor *descriptor);
  void ReloadPluginsInternal();
  /**
   * @brief Update the Pid store with the new values.
   */
  void UpdatePidStore(const ola::rdm::RootPidStore *pid_store);

  static const char INSTANCE_NAME_KEY[];
  static const char K_INSTANCE_NAME_VAR[];
  static const char K_DISCOVERY_SERVICE_TYPE[];
  static const char K_UID_VAR[];
  static const char SERVER_PREFERENCES[];
  static const char UNIVERSE_PREFERENCES[];
  static const unsigned int K_HOUSEKEEPING_TIMEOUT_MS;

  DISALLOW_COPY_AND_ASSIGN(OlaServer);
};
}  // namespace ola
#endif  // OLAD_OLASERVER_H_