/* Copyright (c) 2013, 2014 IOnU Security Inc. All rights reserved. Copyright (c) 2015, 2016 Sequence Logic, Inc. Created August 2013 by Kendrick Webster K2Daemon/MongoDeviceStatus.h - database interface for ionu device status collection in MongoDB. */ #pragma once #include #include "MongoDB.h" namespace MongoDB { namespace devstatus { /* Database and collection names A collection is a group of documents (BSON objects). A database contains zero or more named collections. These hard-coded values are agreed upon between CloudGuard and this application. */ constexpr const char* DATABASE_NAME = "sequencelogic"; constexpr const char* COLLECTION_NAME = "devstatus"; // Values for the "status" field of devstatus documents constexpr const char* STATUS_ONLINE = "online"; // device is logged in constexpr const char* STATUS_ONLINE_AUTH = "online_auth"; // device just logged in constexpr const char* STATUS_NOTIFIED = "online_ntf"; // device acknowledged a notification constexpr const char* STATUS_OFFLINE = "offline"; // offline due to graceful shutdown (logout) constexpr const char* STATUS_NO_ACK = "no_ack"; // offline due to timed out notification attempt constexpr const char* STATUS_TIMEOUT = "timeout"; // offline due to heartbeat timeout // Updates the field of the DB document matching // (within this collection, the device URN is the document _id) void Update(const char* device, const char* status, const char *pIpAddy); // Resets the field of all "online" DB documents // (cleanup at startup) void Clean(void); // Call periodically to do background stuff (i.e. flush updates that may have been deferred due to transient connectivity issues) void Timer(void); } }