Commit fa569b7f authored by user's avatar user
Browse files

* Code now (fully) compatible with czmq c3.0.2

parent df604d4c
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/platform.h.in" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relaymq_selftest.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_auth.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/rmq_msg.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_crypto.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_source.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_auth.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/application_template.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/librelaymq.pc.in" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_protocol.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_protocol.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_source.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_context.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/peer_table.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_crypto.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_event.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_identity.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_target.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_peer.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_target.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_context.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_peer.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_handle.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/peer_table.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_event.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/relay_handle.c" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/rmq_msg.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Findlibzmq.cmake" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/CMakeLists.txt" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Findczmq.cmake" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="Header Search Paths">
<CLASSES>
<root url="file:///usr/include" />
<root url="file:///usr/lib/gcc/x86_64-linux-gnu/5/include" />
<root url="file:///usr/lib/gcc/x86_64-linux-gnu/5/include-fixed" />
<root url="file:///usr/local/include" />
</CLASSES>
<SOURCES>
<root url="file:///usr/include" />
<root url="file:///usr/lib/gcc/x86_64-linux-gnu/5/include" />
<root url="file:///usr/lib/gcc/x86_64-linux-gnu/5/include-fixed" />
<root url="file:///usr/local/include" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
......@@ -13,37 +13,38 @@ extern "C" {
typedef struct _relay_event_handler_t relay_event_handler_t;
relay_event_handler_t*
RELAYMQ_EXPORT relay_event_handler_t*
relay_event_handler_new(relay_event_type_t event, ...);
void
RELAYMQ_EXPORT void
relay_event_handler_destroy(relay_event_handler_t** self_p);
int
RELAYMQ_EXPORT int
relay_event_handler_add(relay_event_handler_t* self,
relay_t* relay);
int
RELAYMQ_EXPORT int
relay_event_handler_remove(relay_event_handler_t* self, relay_t* relay);
int
RELAYMQ_EXPORT int
relay_event_handler_wait(relay_event_handler_t* self, int timeo);
int
RELAYMQ_EXPORT int
relay_event_handler_next(relay_event_handler_t* self);
int
RELAYMQ_EXPORT int
relay_event_handler_has_next(relay_event_handler_t* self);
relay_event_type_t
RELAYMQ_EXPORT relay_event_type_t
relay_event_handler_type(relay_event_handler_t* self);
relay_t*
RELAYMQ_EXPORT relay_t*
relay_event_handler_source(relay_event_handler_t* self);
zsock_t*
RELAYMQ_EXPORT zsock_t*
relay_event_handler_sock(relay_event_handler_t* self);
#ifdef __cplusplus
}
#endif
......
......@@ -94,7 +94,9 @@ s_send(relay_t* self, zuuid_t* sender, zhashx_t* header, zmsg_t* message, void*
if(!message) {
msg_frame = zframe_from(EMPTY_MSG);
}else{
msg_frame = zmsg_encode(message);
byte* buffer;
size_t size = zmsg_encode(message, &buffer);
msg_frame = zframe_new(buffer, size);
}
assert(msg_frame);
......
......@@ -285,12 +285,15 @@ relay_crypto_encrypt(relay_crypto_t* self,byte* key, zmsg_t** msg){
case ENCRYPTED:
clear = zframe_dup(current);//Make a copy of the data
break;
case NONE://First layer of encryption
case NONE: {//First layer of encryption
/*
* Make single frame out of message to reduce overhead.
* Otherwise we would need to iterate ver each frame and everytime and had a lot more memory allocations
*/
clear = zmsg_encode(*msg);//Creates copy
byte *buffer;
size_t size = zmsg_encode(*msg, &buffer);
clear = zframe_new(buffer, size);
}
break;
}
assert(clear);
......@@ -331,7 +334,7 @@ relay_crypto_decrypt(relay_crypto_t* self, byte* key, zmsg_t** msg){
case CLEAR:
cleartext = s_process_message (self, key, current);
assert(cleartext);
real_msg = zmsg_decode(cleartext);
real_msg = zmsg_decode(zframe_data(cleartext), zframe_size(cleartext));
break;
case ENCRYPTED://Frame is encrypted
......
......@@ -1354,7 +1354,7 @@ s_handle_introduce(relay_protocol_t *self, relay_peer_t *peer, zuuid_t* sender,
assert(payload);
zframe_t* message_frame = zmsg_pop(payload);
zmsg_t* message = zmsg_decode(message_frame);
zmsg_t* message = zmsg_decode(zframe_data(message_frame), zframe_size(message_frame));
//Decode Indentites
zlistx_t* ident_list = s_process_identities(self, payload);
......@@ -1413,7 +1413,7 @@ s_handle_message(relay_protocol_t *self, relay_peer_t *peer, zuuid_t* sender, zm
assert(payload);//There must still be something left in the message
zframe_t* message_frame = zmsg_pop(payload);
zmsg_t* message = message_frame ? zmsg_decode(message_frame) : NULL;
zmsg_t* message = message_frame ? zmsg_decode(zframe_data(message_frame), zframe_size(message_frame)) : NULL;
//Decode Indentites
zlistx_t* ident_list = s_process_identities(self, payload);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment