RetroShare/retroshare-nogui/src/rpcsystem.h

65 lines
1.9 KiB
C
Raw Normal View History

Added first version of RPC system for external control of retroshare-nogui. The protocol message format is as follows: [HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] [ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ] MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol. MsgID = Corresponds to the format of the Body. ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates) BodySize = Byte Length of Body. The Body will consist of a protobuf encoded message. For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes. Usage: * Create SSH connection to retroshare-nogui. * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. * They will processed, and responses sent back (potentially in an arbitary order). Specific Changes here: * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms). * Added rpc directory, with server, setup and echo service. * Modified Menu System to use the new interface to rssshd * Wrote new matching interface for Terminal Usage. - NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO. * Added -C commandline option to switch on RPC system. This is the first version - so I expect there will be bugs. Please report for a prompt fix! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2012-08-20 10:59:41 -04:00
/*
* RetroShare External Interface.
*
* Copyright 2012-2012 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef RS_RPC_SYSTEM_H
#define RS_RPC_SYSTEM_H
#include <list>
Added first version of RPC system for external control of retroshare-nogui. The protocol message format is as follows: [HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] [ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ] MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol. MsgID = Corresponds to the format of the Body. ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates) BodySize = Byte Length of Body. The Body will consist of a protobuf encoded message. For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes. Usage: * Create SSH connection to retroshare-nogui. * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. * They will processed, and responses sent back (potentially in an arbitary order). Specific Changes here: * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms). * Added rpc directory, with server, setup and echo service. * Modified Menu System to use the new interface to rssshd * Wrote new matching interface for Terminal Usage. - NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO. * Added -C commandline option to switch on RPC system. This is the first version - so I expect there will be bugs. Please report for a prompt fix! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2012-08-20 10:59:41 -04:00
#include <string>
#include <inttypes.h>
class RpcComms
{
public:
virtual int isOkay() = 0;
virtual int error(uint32_t chan_id, std::string msg) = 0;
Added first version of RPC system for external control of retroshare-nogui. The protocol message format is as follows: [HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] [ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ] MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol. MsgID = Corresponds to the format of the Body. ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates) BodySize = Byte Length of Body. The Body will consist of a protobuf encoded message. For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes. Usage: * Create SSH connection to retroshare-nogui. * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. * They will processed, and responses sent back (potentially in an arbitary order). Specific Changes here: * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms). * Added rpc directory, with server, setup and echo service. * Modified Menu System to use the new interface to rssshd * Wrote new matching interface for Terminal Usage. - NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO. * Added -C commandline option to switch on RPC system. This is the first version - so I expect there will be bugs. Please report for a prompt fix! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2012-08-20 10:59:41 -04:00
virtual int active_channels(std::list<uint32_t> &chan_ids) = 0;
virtual int recv_ready(uint32_t chan_id) = 0;
virtual int recv(uint32_t chan_id, uint8_t *buffer, int bytes) = 0;
virtual int recv(uint32_t chan_id, std::string &buffer, int bytes) = 0;
Added first version of RPC system for external control of retroshare-nogui. The protocol message format is as follows: [HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] [ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ] MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol. MsgID = Corresponds to the format of the Body. ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates) BodySize = Byte Length of Body. The Body will consist of a protobuf encoded message. For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes. Usage: * Create SSH connection to retroshare-nogui. * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. * They will processed, and responses sent back (potentially in an arbitary order). Specific Changes here: * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms). * Added rpc directory, with server, setup and echo service. * Modified Menu System to use the new interface to rssshd * Wrote new matching interface for Terminal Usage. - NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO. * Added -C commandline option to switch on RPC system. This is the first version - so I expect there will be bugs. Please report for a prompt fix! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2012-08-20 10:59:41 -04:00
// these make it easier...
virtual int recv_blocking(uint32_t chan_id, uint8_t *buffer, int bytes) = 0;
virtual int recv_blocking(uint32_t chan_id, std::string &buffer, int bytes) = 0;
Added first version of RPC system for external control of retroshare-nogui. The protocol message format is as follows: [HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] [ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ] MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol. MsgID = Corresponds to the format of the Body. ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates) BodySize = Byte Length of Body. The Body will consist of a protobuf encoded message. For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes. Usage: * Create SSH connection to retroshare-nogui. * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. * They will processed, and responses sent back (potentially in an arbitary order). Specific Changes here: * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms). * Added rpc directory, with server, setup and echo service. * Modified Menu System to use the new interface to rssshd * Wrote new matching interface for Terminal Usage. - NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO. * Added -C commandline option to switch on RPC system. This is the first version - so I expect there will be bugs. Please report for a prompt fix! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2012-08-20 10:59:41 -04:00
virtual int send(uint32_t chan_id, uint8_t *buffer, int bytes) = 0;
virtual int send(uint32_t chan_id, const std::string &buffer) = 0;
Added first version of RPC system for external control of retroshare-nogui. The protocol message format is as follows: [HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] [ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ] MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol. MsgID = Corresponds to the format of the Body. ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates) BodySize = Byte Length of Body. The Body will consist of a protobuf encoded message. For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes. Usage: * Create SSH connection to retroshare-nogui. * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. * They will processed, and responses sent back (potentially in an arbitary order). Specific Changes here: * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms). * Added rpc directory, with server, setup and echo service. * Modified Menu System to use the new interface to rssshd * Wrote new matching interface for Terminal Usage. - NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO. * Added -C commandline option to switch on RPC system. This is the first version - so I expect there will be bugs. Please report for a prompt fix! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2012-08-20 10:59:41 -04:00
virtual int setSleepPeriods(float /* busy */, float /* idle */) { return 0; }
};
class RpcSystem
{
public:
/* this must be regularly ticked to update the display */
virtual void reset(uint32_t chan_id) = 0;
Added first version of RPC system for external control of retroshare-nogui. The protocol message format is as follows: [HEADER: 16 bytes: 4 x Network Order uint32_t][ VARIABLE LENGTH BODY ] [ MAGIC_CODE ] [ MSG_ID ] [ REQ_ID ] [ BODY_SIZE ] [ ........ BODY ......... ] MagicCode = 0x137f0001 ... this will be incremented for new versions of the protocol. MsgID = Corresponds to the format of the Body. ReqID = Generated by Requester, Returned in Response, make sure its unique. (undefined behaviour for duplicates) BodySize = Byte Length of Body. The Body will consist of a protobuf encoded message. For the moment, the RPC server just ECHOs the request back to the sender - for testing purposes. Usage: * Create SSH connection to retroshare-nogui. * Create Request Message(s), and send over SSH channel - You can send as meny requests as you want. * They will processed, and responses sent back (potentially in an arbitary order). Specific Changes here: * Modified rssshd to support arbitary recv/send applications. (interface is RpcComms). * Added rpc directory, with server, setup and echo service. * Modified Menu System to use the new interface to rssshd * Wrote new matching interface for Terminal Usage. - NOTE: Strange BUG in Terminal version.... causes stderr to disappear. TODO. * Added -C commandline option to switch on RPC system. This is the first version - so I expect there will be bugs. Please report for a prompt fix! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5444 b45a01b8-16f6-495d-af2f-9b41ad6348cc
2012-08-20 10:59:41 -04:00
virtual int tick() = 0;
};
#endif // RS_RPC_SERVER_H