Sleds/K2Daemon/ClientMap.h

42 lines
1.2 KiB
C
Raw Normal View History

2025-03-13 21:28:38 +00:00
/*
Copyright (c) 2013 IOnU Security Inc. All rights reserved
Created October 2013 by Kendrick Webster
K2Daemon/ClientMap.h - header for client map module
This module facilitates efficient (hashed) bidirectional mapping
of client device URN strings to/from numeric IDs.
The outside world (CloudGuard and the client devices themselves) use
device URN strings as unique client identifiers. Internally this
daemon uses client ID numbers for efficiency.
*/
#pragma once
namespace ClientMap
{
typedef uint64_t id_t;
// valid IDs are non-zero
static const id_t NULL_ID = 0;
// get URN from ID
// returns NULL if the client is not mapped
// CAUTION: the returned pointer will become invalid (must be discarded) if the client is later unmapped
const char* UrnFromId(id_t id);
// get ID from URN
// returns NULL_ID if the client is not mapped
id_t IdFromUrn(const char* urn);
// get ID from URN
// adds client to map if it isn't already mapped
id_t Map(const char* urn);
// remove client from map
void Unmap(const char* urn);
// returns the number of connected (mapped) clients
unsigned int Count(void);
}