2014-07-05 20:14:48 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Glyptodon LLC
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-03-01 05:40:39 +00:00
|
|
|
#ifndef _GUACD_PROC_MAP_H
|
|
|
|
#define _GUACD_PROC_MAP_H
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "guac_list.h"
|
2016-03-01 05:40:39 +00:00
|
|
|
#include "proc.h"
|
|
|
|
#include "user.h"
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
#include <guacamole/client.h>
|
|
|
|
|
2016-03-01 05:40:39 +00:00
|
|
|
/**
|
|
|
|
* The number of hash buckets in each process map.
|
|
|
|
*/
|
|
|
|
#define GUACD_PROC_MAP_BUCKETS GUACD_CLIENT_MAX_CONNECTIONS*2
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set of all active connections to guacd, indexed by connection ID.
|
|
|
|
*/
|
2016-03-01 05:40:39 +00:00
|
|
|
typedef struct guacd_proc_map {
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal hash buckets. Each bucket is a linked list containing all
|
|
|
|
* guac_client instances which hash to this bucket location.
|
|
|
|
*/
|
2016-03-01 05:40:39 +00:00
|
|
|
guac_common_list* __buckets[GUACD_PROC_MAP_BUCKETS];
|
2014-07-05 20:14:48 +00:00
|
|
|
|
2016-03-01 05:40:39 +00:00
|
|
|
} guacd_proc_map;
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
/**
|
2016-03-01 05:40:39 +00:00
|
|
|
* Allocates a new client process map, which persists for the life of guacd.
|
2014-07-05 20:14:48 +00:00
|
|
|
*/
|
2016-03-01 05:40:39 +00:00
|
|
|
guacd_proc_map* guacd_proc_map_alloc();
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
/**
|
2016-03-01 05:40:39 +00:00
|
|
|
* Adds the given process to the client process map. On success, zero is returned. If
|
|
|
|
* adding the client fails (due to lack of space, or duplicate ID), a non-zero
|
|
|
|
* value is returned instead. The client process is stored by the connection ID
|
|
|
|
* of the underlying guac_client.
|
2014-07-05 20:14:48 +00:00
|
|
|
*/
|
2016-03-01 05:40:39 +00:00
|
|
|
int guacd_proc_map_add(guacd_proc_map* map, guacd_proc* proc);
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
/**
|
2016-03-01 05:40:39 +00:00
|
|
|
* Retrieves the client process having the client with the given ID, or NULL if
|
|
|
|
* no such process is stored.
|
2014-07-05 20:14:48 +00:00
|
|
|
*/
|
2016-03-01 05:40:39 +00:00
|
|
|
guacd_proc* guacd_proc_map_retrieve(guacd_proc_map* map, const char* id);
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
/**
|
2016-03-01 05:40:39 +00:00
|
|
|
* Removes the client process having the client with the given ID, returning
|
|
|
|
* the corresponding process. If no such process exists, NULL is returned.
|
2014-07-05 20:14:48 +00:00
|
|
|
*/
|
2016-03-01 05:40:39 +00:00
|
|
|
guacd_proc* guacd_proc_map_remove(guacd_proc_map* map, const char* id);
|
2014-07-05 20:14:48 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|