Click here to Skip to main content
15,896,606 members
Articles / Programming Languages / C++

RCF - Interprocess Communication for C++

Rate me:
Please Sign up or sign in to vote.
4.94/5 (147 votes)
25 Oct 2011CPOL20 min read 4.7M   8.4K   331  
A server/client IPC framework, using the C++ preprocessor as an IDL compiler.
//*****************************************************************************
// RCF - Remote Call Framework
// Copyright (c) 2005. All rights reserved.
// Developed by Jarl Lindrud.
// Contact: jlindrud@hotmail.com .
//*****************************************************************************

#ifndef INCLUDE_RCF_OPENSSLENCRYPTIONFILTER_HPP
#define INCLUDE_RCF_OPENSSLENCRYPTIONFILTER_HPP

#include <memory>
#include <string>

#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>

#include <RCF/AsyncFilter.hpp>

namespace RCF {

    static const int RCF_FILTER_OPENSSL_ENCRYPTION = 2;

    /// Enumeration describing the role in a SSL conversation that an endpoint is playing.
    enum SslRole
    {
        SslServer,
        SslClient
    };

    /// Filter implementing the SSL encryption protocol, through the OpenSSL library.
    class OpenSslEncryptionFilter : public IdentityFilter, boost::noncopyable
    {
    public:
        static FilterDescription sGetFilterDescription();
        FilterDescription getFilterDescription() const;
        OpenSslEncryptionFilter(SslRole sslRole, const std::string &certificateFile, const std::string &certificateFilePassword, unsigned int bioBufferSize = 2048);
        void read(char *buffer, std::size_t bufferLen);
        void write(const char *buffer, std::size_t bufferLen);
        void onReadWriteCompleted(std::size_t bytesTransferred, int error);

    private:
        friend class OpenSslEncryptionFilterImpl;
        boost::shared_ptr<OpenSslEncryptionFilterImpl> implPtr;
    };

    /// Filter factory for OpenSslEncryptionFilter.
    class OpenSslEncryptionFilterFactory : public FilterFactory
    {
    public:
        OpenSslEncryptionFilterFactory(const std::string &certificateFile, const std::string &certificateFilePassword, bool serverRole = true);
        FilterPtr createFilter();
        FilterDescription getFilterDescription();

    private:
        std::string mCertificateFile;
        std::string mCertificateFilePassword;
        SslRole mRole;
    };


} // namespace RCF

#endif // ! INCLUDE_RCF_OPENSSLENCRYPTIONFILTER_HPP

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Australia Australia
Software developer, from Sweden and now living in Canberra, Australia, working on distributed C++ applications. When he is not programming, Jarl enjoys skiing and playing table tennis. He derives immense satisfaction from referring to himself in third person.

Comments and Discussions