-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
8,463 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright - See the COPYRIGHT that is included with this distribution. | ||
* pvxs is distributed subject to a Software License Agreement found | ||
* in file LICENSE that is included with this distribution. | ||
* | ||
* Author George S. McIntyre <george@level-n.com>, 2023 | ||
* | ||
*/ | ||
|
||
#include <string> | ||
|
||
#include "channel.h" | ||
#include "utilpvt.h" | ||
|
||
namespace pvxs { | ||
namespace ioc { | ||
/** | ||
* Construct a group channel from a given db channel name | ||
* | ||
* @param name the db channel name | ||
*/ | ||
Channel::Channel(const std::string& name) | ||
:pDbChannel(std::shared_ptr<dbChannel>(dbChannelCreate(name.c_str()), | ||
[](dbChannel* ch) { | ||
if (ch) { | ||
dbChannelDelete(ch); | ||
} | ||
})) | ||
{ | ||
if(!pDbChannel) | ||
throw std::runtime_error(SB()<<"Invalid PV: "<<name); | ||
if (dbChannelOpen(pDbChannel.get())) | ||
throw std::invalid_argument(SB() << "Failed dbChannelOpen(\"" << dbChannelName(pDbChannel) <<"\")"); | ||
} | ||
|
||
} // pvxs | ||
} // ioc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
/* | ||
* Copyright - See the COPYRIGHT that is included with this distribution. | ||
* pvxs is distributed subject to a Software License Agreement found | ||
* in file LICENSE that is included with this distribution. | ||
* | ||
* Author George S. McIntyre <george@level-n.com>, 2023 | ||
* | ||
*/ | ||
|
||
#ifndef PVXS_CHANNEL_H | ||
#define PVXS_CHANNEL_H | ||
|
||
#include <string> | ||
#include <memory> | ||
|
||
#include <dbChannel.h> | ||
|
||
namespace pvxs { | ||
namespace ioc { | ||
|
||
/** | ||
* This class encapsulates a shared pointer to a dbChannel but provides constructors | ||
* from string and dbChannel to make its use simpler. It can be used wherever a dbChannel is used. | ||
* As a bonus when constructed with parameters it provides an already open dbChannel. | ||
*/ | ||
class Channel { | ||
private: | ||
std::shared_ptr<dbChannel> pDbChannel; | ||
|
||
public: | ||
Channel() = default; | ||
// This constructor calls dbChannelOpen() | ||
explicit Channel(const std::string& name); | ||
|
||
/** | ||
* Destructor is default because pDbChannel cleans up after itself. | ||
*/ | ||
~Channel() = default; | ||
|
||
/** | ||
* Cast as a shared pointer to a dbChannel. This returns the pDbChannel member | ||
* | ||
* @return the pDbChannel member | ||
*/ | ||
operator dbChannel*() const { | ||
return pDbChannel.get(); | ||
} | ||
/** | ||
* Const pointer indirection operator | ||
* @return pointer to the dbChannel associated with this group channel | ||
*/ | ||
const dbChannel* operator->() const { | ||
return pDbChannel.get(); | ||
} | ||
|
||
explicit operator bool() const { | ||
return pDbChannel.operator bool(); | ||
} | ||
|
||
/** | ||
* Move constructor | ||
* | ||
* @param other other Channel | ||
*/ | ||
Channel(Channel&& other) noexcept | ||
:pDbChannel(std::move(other.pDbChannel)) { | ||
} | ||
|
||
/** | ||
* Move assignment operator | ||
* | ||
* @param other the other channel | ||
* @return the moved channel | ||
*/ | ||
Channel& operator=(Channel&& other) noexcept { | ||
pDbChannel = std::move(other.pDbChannel); | ||
other.pDbChannel = nullptr; | ||
return *this; | ||
} | ||
|
||
// Disallowed methods. Copy and move constructors | ||
Channel(const Channel&) = delete; | ||
const std::shared_ptr<dbChannel>& shared_ptr() const { | ||
return pDbChannel; | ||
}; | ||
}; | ||
|
||
} // pvxs | ||
} // ioc | ||
|
||
#endif //PVXS_CHANNEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright - See the COPYRIGHT that is included with this distribution. | ||
* pvxs is distributed subject to a Software License Agreement found | ||
* in file LICENSE that is included with this distribution. | ||
* | ||
* Author George S. McIntyre <george@level-n.com>, 2023 | ||
* | ||
*/ | ||
|
||
#include <utilpvt.h> | ||
|
||
#include "credentials.h" | ||
|
||
namespace pvxs { | ||
namespace ioc { | ||
|
||
/** | ||
* eg. | ||
* "username" implies "ca/" prefix | ||
* "krb/principle" | ||
* "role/groupname" | ||
* | ||
* @param clientCredentials | ||
*/ | ||
|
||
Credentials::Credentials(const server::ClientCredentials& clientCredentials) { | ||
// Extract host name part (or whole thing if no colon present) | ||
auto pos = clientCredentials.peer.find_first_of(':'); | ||
host = clientCredentials.peer.substr(0, pos); | ||
|
||
// "ca" style credentials | ||
if (clientCredentials.method == "ca") { | ||
pos = clientCredentials.account.find_last_of('/'); | ||
if (pos == std::string::npos) { | ||
cred.emplace_back(clientCredentials.account); | ||
} else { | ||
cred.emplace_back(clientCredentials.account.substr(pos + 1)); | ||
} | ||
} else { | ||
cred.emplace_back(SB() << clientCredentials.method << '/' << clientCredentials.account); | ||
} | ||
|
||
for (const auto& role: clientCredentials.roles()) { | ||
cred.emplace_back(SB() << "role/" << role); | ||
} | ||
} | ||
} // pvxs | ||
} // ioc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright - See the COPYRIGHT that is included with this distribution. | ||
* pvxs is distributed subject to a Software License Agreement found | ||
* in file LICENSE that is included with this distribution. | ||
* | ||
* Author George S. McIntyre <george@level-n.com>, 2023 | ||
* | ||
*/ | ||
|
||
#ifndef PVXS_CREDENTIALS_H | ||
#define PVXS_CREDENTIALS_H | ||
|
||
#include <vector> | ||
#include <string> | ||
|
||
#include <pvxs/source.h> | ||
|
||
namespace pvxs { | ||
namespace ioc { | ||
|
||
/** | ||
* eg. | ||
* "username" implies "ca/" prefix | ||
* "krb/principle" | ||
* "role/groupname" | ||
*/ | ||
class Credentials { | ||
public: | ||
std::vector<std::string> cred; | ||
std::string host; | ||
explicit Credentials(const server::ClientCredentials& clientCredentials); | ||
Credentials(const Credentials&) = delete; | ||
Credentials(Credentials&&) = default; | ||
}; | ||
|
||
} // pvxs | ||
} // ioc | ||
|
||
#endif //PVXS_CREDENTIALS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright - See the COPYRIGHT that is included with this distribution. | ||
* pvxs is distributed subject to a Software License Agreement found | ||
* in file LICENSE that is included with this distribution. | ||
* | ||
* Author George S. McIntyre <george@level-n.com>, 2023 | ||
* | ||
*/ | ||
|
||
#ifndef PVXS_DBENTRY_H | ||
#define PVXS_DBENTRY_H | ||
|
||
#include <dbStaticLib.h> | ||
#include <dbAccess.h> | ||
|
||
namespace pvxs { | ||
namespace ioc { | ||
|
||
/** | ||
* Wrapper class for DBENTRY that is a type that encapsulates an IOC database entry. | ||
*/ | ||
class DBEntry { | ||
DBENTRY ent{}; | ||
public: | ||
DBEntry() { | ||
dbInitEntry(pdbbase, &ent); | ||
} | ||
DBEntry(const DBEntry&) = delete; | ||
DBEntry(DBEntry&&) = delete; | ||
|
||
~DBEntry() { | ||
dbFinishEntry(&ent); | ||
} | ||
|
||
operator DBENTRY*() { | ||
return &ent; | ||
} | ||
|
||
DBENTRY* operator->() { | ||
return &ent; | ||
} | ||
|
||
}; | ||
|
||
} // ioc | ||
} // pvxs | ||
#endif //PVXS_DBENTRY_H |
Oops, something went wrong.