Commit 1414bf93 authored by sigiesec's avatar sigiesec

Problem: use of unqualified "id" in code example

Solution: use "routing_id" instead
parent d6694e7d
......@@ -559,16 +559,16 @@ void *socket = zmq_socket (ctx, ZMQ_STREAM);
assert (socket);
int rc = zmq_bind (socket, "tcp://*:8080");
assert (rc == 0);
/* Data structure to hold the ZMQ_STREAM ID */
uint8_t id [256];
size_t id_size = 256;
/* Data structure to hold the ZMQ_STREAM routing id */
uint8_t routing_id [256];
size_t routing_id_size = 256;
/* Data structure to hold the ZMQ_STREAM received data */
uint8_t raw [256];
size_t raw_size = 256;
while (1) {
/* Get HTTP request; ID frame and then request */
id_size = zmq_recv (socket, id, 256, 0);
assert (id_size > 0);
/* Get HTTP request; routing id frame and then request */
routing_id_size = zmq_recv (socket, routing_id, 256, 0);
assert (routing_id_size > 0);
do {
raw_size = zmq_recv (socket, raw, 256, 0);
assert (raw_size >= 0);
......@@ -579,11 +579,11 @@ while (1) {
"Content-Type: text/plain\r\n"
"\r\n"
"Hello, World!";
/* Sends the ID frame followed by the response */
zmq_send (socket, id, id_size, ZMQ_SNDMORE);
/* Sends the routing id frame followed by the response */
zmq_send (socket, routing_id, routing_id_size, ZMQ_SNDMORE);
zmq_send (socket, http_response, strlen (http_response), 0);
/* Closes the connection by sending the ID frame followed by a zero response */
zmq_send (socket, id, id_size, ZMQ_SNDMORE);
/* Closes the connection by sending the routing id frame followed by a zero response */
zmq_send (socket, routing_id, routing_id_size, ZMQ_SNDMORE);
zmq_send (socket, 0, 0, 0);
}
zmq_close (socket);
......
......@@ -372,7 +372,7 @@ void test_simultaneous_connect_bind_threads ()
assert (rc == 0);
}
void test_identity ()
void test_routing_id ()
{
// Create the infrastructure
void *ctx = zmq_ctx_new ();
......@@ -381,13 +381,13 @@ void test_identity ()
void *sc = zmq_socket (ctx, ZMQ_DEALER);
assert (sc);
int rc = zmq_connect (sc, "inproc://identity");
int rc = zmq_connect (sc, "inproc://routing_id");
assert (rc == 0);
void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb);
rc = zmq_bind (sb, "inproc://identity");
rc = zmq_bind (sb, "inproc://routing_id");
assert (rc == 0);
// Send 2-part message.
......@@ -396,7 +396,7 @@ void test_identity ()
rc = zmq_send (sc, "B", 1, 0);
assert (rc == 1);
// Identity comes first.
// Routing id comes first.
zmq_msg_t msg;
rc = zmq_msg_init (&msg);
assert (rc == 0);
......@@ -527,7 +527,7 @@ int main (void)
test_multiple_connects ();
test_multiple_threads ();
test_simultaneous_connect_bind_threads ();
test_identity ();
test_routing_id ();
test_connect_only ();
test_unbind ();
test_shutdown_during_pend ();
......
......@@ -57,12 +57,12 @@ int main (void)
// Repeat often enough to be sure this works as it should
for (int cycle = 0; cycle < 100; cycle++) {
// Create dealer with unique explicit identity
// Create dealer with unique explicit routing id
// We assume the router learns this out-of-band
void *dealer = zmq_socket (ctx2, ZMQ_DEALER);
char identity [10];
sprintf (identity, "%09d", cycle);
rc = zmq_setsockopt (dealer, ZMQ_ROUTING_ID, identity, 10);
char routing_id [10];
sprintf (routing_id, "%09d", cycle);
rc = zmq_setsockopt (dealer, ZMQ_ROUTING_ID, routing_id, 10);
assert (rc == 0);
int rcvtimeo = 1000;
rc = zmq_setsockopt (dealer, ZMQ_RCVTIMEO, &rcvtimeo, sizeof (int));
......@@ -77,7 +77,7 @@ int main (void)
// a very slow system).
for (int attempt = 0; attempt < 500; attempt++) {
zmq_poll (0, 0, 2);
rc = zmq_send (router, identity, 10, ZMQ_SNDMORE);
rc = zmq_send (router, routing_id, 10, ZMQ_SNDMORE);
if (rc == -1 && errno == EHOSTUNREACH)
continue;
assert (rc == 10);
......
......@@ -46,7 +46,7 @@ zap_handler (void *handler)
char *sequence = s_recv (handler);
char *domain = s_recv (handler);
char *address = s_recv (handler);
char *identity = s_recv (handler);
char *routing_id = s_recv (handler);
char *mechanism = s_recv (handler);
assert (streq (version, "1.0"));
......@@ -70,7 +70,7 @@ zap_handler (void *handler)
free (sequence);
free (domain);
free (address);
free (identity);
free (routing_id);
free (mechanism);
}
close_zero_linger (handler);
......
......@@ -54,7 +54,7 @@ int main (void)
rc = zmq_send (sc, "B", 1, 0);
assert (rc == 1);
// Identity comes first.
// Routing id comes first.
zmq_msg_t msg;
rc = zmq_msg_init (&msg);
assert (rc == 0);
......
......@@ -56,7 +56,7 @@ int main (void)
rc = zmq_connect (client, my_endpoint);
assert (rc == 0);
// We expect an identity=X + empty message from client
// We expect a routing id=X + empty message from client
unsigned char buffer [255];
rc = zmq_recv (server, buffer, 255, 0);
assert (rc == 1);
......
......@@ -44,8 +44,8 @@
#define CONTENT_SIZE 13
#define CONTENT_SIZE_MAX 32
#define ID_SIZE 10
#define ID_SIZE_MAX 32
#define ROUTING_ID_SIZE 10
#define ROUTING_ID_SIZE_MAX 32
#define QT_WORKERS 5
#define QT_CLIENTS 3
#define is_verbose 0
......@@ -104,10 +104,10 @@ client_task (void *db)
assert (rc == 0);
char content [CONTENT_SIZE_MAX];
// Set random identity to make tracing easier
char identity [ID_SIZE];
sprintf (identity, "%04X-%04X", rand() % 0xFFFF, rand() % 0xFFFF);
rc = zmq_setsockopt (client, ZMQ_IDENTITY, identity, ID_SIZE); // includes '\0' as an helper for printf
// Set random routing id to make tracing easier
char routing_id [ROUTING_ID_SIZE];
sprintf (routing_id, "%04X-%04X", rand() % 0xFFFF, rand() % 0xFFFF);
rc = zmq_setsockopt (client, ZMQ_ROUTING_ID, routing_id, ROUTING_ID_SIZE); // includes '\0' as an helper for printf
assert (rc == 0);
linger = 0;
rc = zmq_setsockopt (client, ZMQ_LINGER, &linger, sizeof (linger));
......@@ -129,7 +129,7 @@ client_task (void *db)
size_t sz = sizeof (rcvmore);
rc = zmq_recv (client, content, CONTENT_SIZE_MAX, 0);
assert (rc == CONTENT_SIZE);
if (is_verbose) printf("client receive - identity = %s content = %s\n", identity, content);
if (is_verbose) printf("client receive - routing_id = %s content = %s\n", routing_id, content);
// Check that message is still the same
assert (memcmp (content, "request #", 9) == 0);
rc = zmq_getsockopt (client, ZMQ_RCVMORE, &rcvmore, &sz);
......@@ -142,7 +142,7 @@ client_task (void *db)
if (rc > 0)
{
content[rc] = 0; // NULL-terminate the command string
if (is_verbose) printf("client receive - identity = %s command = %s\n", identity, content);
if (is_verbose) printf("client receive - routing_id = %s command = %s\n", routing_id, content);
if (memcmp (content, "TERMINATE", 9) == 0) {
run = false;
break;
......@@ -158,7 +158,7 @@ client_task (void *db)
if (keep_sending)
{
sprintf(content, "request #%03d", ++request_nbr); // CONTENT_SIZE
if (is_verbose) printf("client send - identity = %s request #%03d\n", identity, request_nbr);
if (is_verbose) printf("client send - routing_id = %s request #%03d\n", routing_id, request_nbr);
zmq_atomic_counter_inc(g_clients_pkts_out);
rc = zmq_send (client, content, CONTENT_SIZE, 0);
......@@ -285,7 +285,7 @@ server_worker (void *ctx)
assert (rc == 0);
char content [CONTENT_SIZE_MAX]; // bigger than what we need to check that
char identity [ID_SIZE_MAX]; // the size received is the size sent
char routing_id [ROUTING_ID_SIZE_MAX]; // the size received is the size sent
bool run = true;
bool keep_sending = true;
......@@ -302,12 +302,12 @@ server_worker (void *ctx)
}
// The DEALER socket gives us the reply envelope and message
// if we don't poll, we have to use ZMQ_DONTWAIT, if we poll, we can block-receive with 0
rc = zmq_recv (worker, identity, ID_SIZE_MAX, ZMQ_DONTWAIT);
if (rc == ID_SIZE) {
rc = zmq_recv (worker, routing_id, ROUTING_ID_SIZE_MAX, ZMQ_DONTWAIT);
if (rc == ROUTING_ID_SIZE) {
rc = zmq_recv (worker, content, CONTENT_SIZE_MAX, 0);
assert (rc == CONTENT_SIZE);
if (is_verbose)
printf ("server receive - identity = %s content = %s\n", identity, content);
printf ("server receive - routing_id = %s content = %s\n", routing_id, content);
// Send 0..4 replies back
if (keep_sending)
......@@ -318,11 +318,11 @@ server_worker (void *ctx)
msleep (rand () % 10 + 1);
// Send message from server to client
if (is_verbose) printf("server send - identity = %s reply\n", identity);
if (is_verbose) printf("server send - routing_id = %s reply\n", routing_id);
zmq_atomic_counter_inc(g_workers_pkts_out);
rc = zmq_send (worker, identity, ID_SIZE, ZMQ_SNDMORE);
assert (rc == ID_SIZE);
rc = zmq_send (worker, routing_id, ROUTING_ID_SIZE, ZMQ_SNDMORE);
assert (rc == ROUTING_ID_SIZE);
rc = zmq_send (worker, content, CONTENT_SIZE, 0);
assert (rc == CONTENT_SIZE);
}
......
......@@ -65,7 +65,7 @@ int main (void)
zmq_msg_t msg;
zmq_msg_init (&msg);
// Receive peer identity
// Receive peer routing id
rc = zmq_msg_recv (&msg, router, 0);
assert (rc != -1);
assert (zmq_msg_size (&msg) > 0);
......
......@@ -68,7 +68,7 @@ int main (void)
rc = zmq_recv (router, buffer, 255, 0);
assert (rc == 5);
// Now create a second dealer that uses the same identity
// Now create a second dealer that uses the same routing id
void *dealer_two = zmq_socket (ctx, ZMQ_DEALER);
assert (dealer_two);
rc = zmq_setsockopt (dealer_two, ZMQ_ROUTING_ID, "X", 1);
......@@ -85,7 +85,7 @@ int main (void)
rc = zmq_recv (router, buffer, 255, 0);
assert (rc == 5);
// Send a message to 'X' identity. This should be delivered
// Send a message to 'X' routing id. This should be delivered
// to the second dealer, instead of the first beccause of the handover.
rc = zmq_send (router, "X", 1, ZMQ_SNDMORE);
assert (rc == 1);
......
......@@ -30,15 +30,15 @@
#include "testutil.hpp"
#ifdef ZMQ_BUILD_DRAFT_API
bool send_msg_to_peer_if_ready (void *router, const char *peer_identity)
bool send_msg_to_peer_if_ready (void *router, const char *peer_routing_id)
{
int rc = zmq_socket_get_peer_state (router, peer_identity, 1);
int rc = zmq_socket_get_peer_state (router, peer_routing_id, 1);
if (rc == -1)
printf ("zmq_socket_get_peer_state failed for %s: %i\n", peer_identity,
printf ("zmq_socket_get_peer_state failed for %s: %i\n", peer_routing_id,
errno);
assert (rc != -1);
if (rc & ZMQ_POLLOUT) {
rc = zmq_send (router, peer_identity, 1, ZMQ_SNDMORE | ZMQ_DONTWAIT);
rc = zmq_send (router, peer_routing_id, 1, ZMQ_SNDMORE | ZMQ_DONTWAIT);
assert (rc == 1);
rc = zmq_send (router, "Hello", 5, ZMQ_DONTWAIT);
assert (rc == 5);
......@@ -81,17 +81,17 @@ void test_get_peer_state ()
rc = zmq_setsockopt (dealer2, ZMQ_RCVHWM, &hwm, sizeof (int));
assert (rc == 0);
const char *dealer1_identity = "X";
const char *dealer2_identity = "Y";
const char *dealer1_routing_id = "X";
const char *dealer2_routing_id = "Y";
// Name dealer1 "X" and connect it to our router
rc = zmq_setsockopt (dealer1, ZMQ_ROUTING_ID, dealer1_identity, 1);
rc = zmq_setsockopt (dealer1, ZMQ_ROUTING_ID, dealer1_routing_id, 1);
assert (rc == 0);
rc = zmq_connect (dealer1, my_endpoint);
assert (rc == 0);
// Name dealer2 "Y" and connect it to our router
rc = zmq_setsockopt (dealer2, ZMQ_ROUTING_ID, dealer2_identity, 1);
rc = zmq_setsockopt (dealer2, ZMQ_ROUTING_ID, dealer2_routing_id, 1);
assert (rc == 0);
rc = zmq_connect (dealer2, my_endpoint);
assert (rc == 0);
......@@ -102,7 +102,7 @@ void test_get_peer_state ()
assert (rc == 5);
rc = zmq_recv (router, buffer, 255, 0);
assert (rc == 1);
assert (0 == memcmp (buffer, dealer1_identity, rc));
assert (0 == memcmp (buffer, dealer1_routing_id, rc));
rc = zmq_recv (router, buffer, 255, 0);
assert (rc == 5);
......@@ -110,7 +110,7 @@ void test_get_peer_state ()
assert (rc == 5);
rc = zmq_recv (router, buffer, 255, 0);
assert (rc == 1);
assert (0 == memcmp (buffer, dealer2_identity, rc));
assert (0 == memcmp (buffer, dealer2_routing_id, rc));
rc = zmq_recv (router, buffer, 255, 0);
assert (rc == 5);
......@@ -135,10 +135,10 @@ void test_get_peer_state ()
const zmq_poller_event_t &current_event = events[event_no];
if (current_event.socket == router
&& current_event.events & ZMQ_POLLOUT) {
if (send_msg_to_peer_if_ready (router, dealer1_identity))
if (send_msg_to_peer_if_ready (router, dealer1_routing_id))
++dealer1_sent;
if (send_msg_to_peer_if_ready (router, dealer2_identity))
if (send_msg_to_peer_if_ready (router, dealer2_routing_id))
++dealer2_sent;
else
dealer2_blocked = true;
......@@ -180,11 +180,11 @@ void test_get_peer_state ()
void test_get_peer_state_corner_cases ()
{
#ifdef ZMQ_BUILD_DRAFT_API
const char peer_identity[] = "foo";
const char peer_routing_id[] = "foo";
// call get_peer_state with NULL socket
int rc =
zmq_socket_get_peer_state (NULL, peer_identity, strlen (peer_identity));
zmq_socket_get_peer_state (NULL, peer_routing_id, strlen (peer_routing_id));
assert (rc == -1 && errno == ENOTSOCK);
void *ctx = zmq_ctx_new ();
......@@ -196,12 +196,12 @@ void test_get_peer_state_corner_cases ()
// call get_peer_state with a non-ROUTER socket
rc =
zmq_socket_get_peer_state (dealer, peer_identity, strlen (peer_identity));
zmq_socket_get_peer_state (dealer, peer_routing_id, strlen (peer_routing_id));
assert (rc == -1 && errno == ENOTSUP);
// call get_peer_state for an unknown identity
// call get_peer_state for an unknown routing id
rc =
zmq_socket_get_peer_state (router, peer_identity, strlen (peer_identity));
zmq_socket_get_peer_state (router, peer_routing_id, strlen (peer_routing_id));
assert (rc == -1 && errno == EHOSTUNREACH);
rc = zmq_close (router);
......
......@@ -67,7 +67,7 @@ int main (void)
// Create dealer called "X" and connect it to our router, configure HWM
void *dealer = zmq_socket (ctx, ZMQ_DEALER);
assert (dealer);
rc = zmq_setsockopt (dealer, ZMQ_IDENTITY, "X", 1);
rc = zmq_setsockopt (dealer, ZMQ_ROUTING_ID, "X", 1);
assert (rc == 0);
int rcvhwm = 1;
rc = zmq_setsockopt (dealer, ZMQ_RCVHWM, &rcvhwm, sizeof (rcvhwm));
......
......@@ -45,7 +45,7 @@
#include "../src/curve_client_tools.hpp"
#include "../src/random.hpp"
const char large_identity[] = "0123456789012345678901234567890123456789"
const char large_routing_id[] = "0123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789"
......@@ -53,9 +53,9 @@ const char large_identity[] = "0123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789"
"012345678901234";
static void zap_handler_large_identity (void *ctx)
static void zap_handler_large_routing_id (void *ctx)
{
zap_handler_generic (ctx, zap_ok, large_identity);
zap_handler_generic (ctx, zap_ok, large_routing_id);
}
void expect_new_client_curve_bounce_fail (void *ctx,
......@@ -769,13 +769,13 @@ int main (void)
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
handler);
// test with a large identity (resulting in large metadata)
// test with a large routing id (resulting in large metadata)
fprintf (stderr,
"test_curve_security_with_valid_credentials (large identity)\n");
"test_curve_security_with_valid_credentials (large routing id)\n");
setup_context_and_server_side (
&ctx, &handler, &zap_thread, &server, &server_mon, my_endpoint,
&zap_handler_large_identity, &socket_config_curve_server,
&valid_server_secret, large_identity);
&zap_handler_large_routing_id, &socket_config_curve_server,
&valid_server_secret, large_routing_id);
test_curve_security_with_valid_credentials (ctx, my_endpoint, server,
server_mon, timeout);
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
......
......@@ -111,7 +111,7 @@ static void zap_handler (void *handler)
char *sequence = s_recv (handler);
char *domain = s_recv (handler);
char *address = s_recv (handler);
char *identity = s_recv (handler);
char *routing_id = s_recv (handler);
char *mechanism = s_recv (handler);
char *principal = s_recv (handler);
......@@ -139,7 +139,7 @@ static void zap_handler (void *handler)
free (sequence);
free (domain);
free (address);
free (identity);
free (routing_id);
free (mechanism);
free (principal);
}
......
......@@ -52,7 +52,7 @@ zap_handler (void *handler)
char *sequence = s_recv (handler);
char *domain = s_recv (handler);
char *address = s_recv (handler);
char *identity = s_recv (handler);
char *routing_id = s_recv (handler);
char *mechanism = s_recv (handler);
assert (streq (version, "1.0"));
......@@ -76,7 +76,7 @@ zap_handler (void *handler)
free (sequence);
free (domain);
free (address);
free (identity);
free (routing_id);
free (mechanism);
}
close_zero_linger (handler);
......
......@@ -57,14 +57,14 @@ zap_handler (void *ctx)
char *sequence = s_recv (zap);
char *domain = s_recv (zap);
char *address = s_recv (zap);
char *identity = s_recv (zap);
char *routing_id = s_recv (zap);
char *mechanism = s_recv (zap);
char *username = s_recv (zap);
char *password = s_recv (zap);
assert (streq (version, "1.0"));
assert (streq (mechanism, "PLAIN"));
assert (streq (identity, "IDENT"));
assert (streq (routing_id, "IDENT"));
s_sendmore (zap, version);
s_sendmore (zap, sequence);
......@@ -85,7 +85,7 @@ zap_handler (void *ctx)
free (sequence);
free (domain);
free (address);
free (identity);
free (routing_id);
free (mechanism);
free (username);
free (password);
......
......@@ -92,16 +92,16 @@ test_stream_to_dealer (void)
assert (rc == 5);
// Connecting sends a zero message
// First frame is identity
zmq_msg_t identity;
rc = zmq_msg_init (&identity);
// First frame is routing id
zmq_msg_t routing_id;
rc = zmq_msg_init (&routing_id);
assert (rc == 0);
rc = zmq_msg_recv (&identity, stream, 0);
rc = zmq_msg_recv (&routing_id, stream, 0);
assert (rc > 0);
assert (zmq_msg_more (&identity));
assert (zmq_msg_more (&routing_id));
// Verify the existence of Peer-Address metadata
char const *peer_address = zmq_msg_gets (&identity, "Peer-Address");
char const *peer_address = zmq_msg_gets (&routing_id, "Peer-Address");
assert (peer_address != 0);
assert (streq (peer_address, "127.0.0.1"));
......@@ -111,18 +111,18 @@ test_stream_to_dealer (void)
assert (rc == 0);
// Verify the existence of Peer-Address metadata
peer_address = zmq_msg_gets (&identity, "Peer-Address");
peer_address = zmq_msg_gets (&routing_id, "Peer-Address");
assert (peer_address != 0);
assert (streq (peer_address, "127.0.0.1"));
// Real data follows
// First frame is identity
rc = zmq_msg_recv (&identity, stream, 0);
// First frame is routing id
rc = zmq_msg_recv (&routing_id, stream, 0);
assert (rc > 0);
assert (zmq_msg_more (&identity));
assert (zmq_msg_more (&routing_id));
// Verify the existence of Peer-Address metadata
peer_address = zmq_msg_gets (&identity, "Peer-Address");
peer_address = zmq_msg_gets (&routing_id, "Peer-Address");
assert (peer_address != 0);
assert (streq (peer_address, "127.0.0.1"));
......@@ -132,7 +132,7 @@ test_stream_to_dealer (void)
assert (memcmp (buffer, greeting.signature, 10) == 0);
// Send our own protocol greeting
rc = zmq_msg_send (&identity, stream, ZMQ_SNDMORE);
rc = zmq_msg_send (&routing_id, stream, ZMQ_SNDMORE);
assert (rc > 0);
rc = zmq_send (stream, &greeting, sizeof (greeting), 0);
assert (rc == sizeof (greeting));
......@@ -141,10 +141,10 @@ test_stream_to_dealer (void)
// We want the rest of greeting along with the Ready command
int bytes_read = 0;
while (bytes_read < 97) {
// First frame is the identity of the connection (each time)
rc = zmq_msg_recv (&identity, stream, 0);
// First frame is the routing id of the connection (each time)
rc = zmq_msg_recv (&routing_id, stream, 0);
assert (rc > 0);
assert (zmq_msg_more (&identity));
assert (zmq_msg_more (&routing_id));
// Second frame contains the next chunk of data
rc = zmq_recv (stream, buffer + bytes_read, 255 - bytes_read, 0);
assert (rc >= 0);
......@@ -167,16 +167,16 @@ test_stream_to_dealer (void)
memcpy (buffer + 30, "\10Identity\0\0\0\0", 13);
// Send Ready command
rc = zmq_msg_send (&identity, stream, ZMQ_SNDMORE);
rc = zmq_msg_send (&routing_id, stream, ZMQ_SNDMORE);
assert (rc > 0);
rc = zmq_send (stream, buffer, 43, 0);
assert (rc == 43);
// Now we expect the data from the DEALER socket
// First frame is, again, the identity of the connection
rc = zmq_msg_recv (&identity, stream, 0);
// First frame is, again, the routing id of the connection
rc = zmq_msg_recv (&routing_id, stream, 0);
assert (rc > 0);
assert (zmq_msg_more (&identity));
assert (zmq_msg_more (&routing_id));
// Third frame contains Hello message from DEALER
rc = zmq_recv (stream, buffer, sizeof buffer, 0);
......@@ -188,7 +188,7 @@ test_stream_to_dealer (void)
assert (memcmp (buffer + 2, "Hello", 5) == 0);
// Send "World" back to DEALER
rc = zmq_msg_send (&identity, stream, ZMQ_SNDMORE);
rc = zmq_msg_send (&routing_id, stream, ZMQ_SNDMORE);
assert (rc > 0);
byte world [] = { 0, 5, 'W', 'o', 'r', 'l', 'd' };
rc = zmq_send (stream, world, sizeof (world), 0);
......@@ -209,7 +209,7 @@ test_stream_to_dealer (void)
memset (msgin, 0, 9 + size);
bytes_read = 0;
while (bytes_read < 9 + size) {
// Get identity frame
// Get routing id frame
rc = zmq_recv (stream, buffer, 256, 0);
assert (rc > 0);
// Get next chunk
......@@ -264,22 +264,22 @@ test_stream_to_stream (void)
uint8_t buffer [256];
// Connecting sends a zero message
// Server: First frame is identity, second frame is zero
// Server: First frame is routing id, second frame is zero
id_size = zmq_recv (server, id, 256, 0);
assert (id_size > 0);
rc = zmq_recv (server, buffer, 256, 0);
assert (rc == 0);
// Client: First frame is identity, second frame is zero
// Client: First frame is routing id, second frame is zero
id_size = zmq_recv (client, id, 256, 0);
assert (id_size > 0);
rc = zmq_recv (client, buffer, 256, 0);
assert (rc == 0);
// Sent HTTP request on client socket
// Get server identity
// Get server routing id
rc = zmq_getsockopt (client, ZMQ_ROUTING_ID, id, &id_size);
assert (rc == 0);
// First frame is server identity
// First frame is server routing id
rc = zmq_send (client, id, id_size, ZMQ_SNDMORE);
assert (rc == (int) id_size);
// Second frame is HTTP GET request
......
......@@ -55,7 +55,7 @@ bool has_more (void* socket)
return more != 0;
}
bool get_identity (void* socket, char* data, size_t* size)
bool get_routing_id (void* socket, char* data, size_t* size)
{
int rc = zmq_getsockopt (socket, ZMQ_ROUTING_ID, data, size);
return rc == 0;
......@@ -97,7 +97,7 @@ int main(int, char**)
assert (rc == 0);
// wait for connect notification
// Server: Grab the 1st frame (peer identity).
// Server: Grab the 1st frame (peer routing id).
zmq_msg_t peer_frame;
rc = zmq_msg_init (&peer_frame);
assert (rc == 0);
......@@ -118,7 +118,7 @@ int main(int, char**)
rc = zmq_msg_close (&data_frame);
assert (rc == 0);
// Client: Grab the 1st frame (peer identity).
// Client: Grab the 1st frame (peer routing id).
rc = zmq_msg_init (&peer_frame);
assert (rc == 0);
rc = zmq_msg_recv (&peer_frame, sockets [CLIENT], 0);
......@@ -176,7 +176,7 @@ int main(int, char**)
if (items [SERVER].revents & ZMQ_POLLIN) {
assert (dialog [step].turn == CLIENT);
// Grab the 1st frame (peer identity).
// Grab the 1st frame (peer routing id).
zmq_msg_t peer_frame;
rc = zmq_msg_init (&peer_frame);
assert (rc == 0);
......@@ -237,7 +237,7 @@ int main(int, char**)
if (items [CLIENT].revents & ZMQ_POLLIN) {
assert (dialog [step].turn == SERVER);
// Grab the 1st frame (peer identity).
// Grab the 1st frame (peer routing id).
zmq_msg_t peer_frame;
rc = zmq_msg_init (&peer_frame);
assert (rc == 0);
......
......@@ -163,7 +163,7 @@ void *zap_requests_handled;
void zap_handler_generic (void *ctx,
zap_protocol_t zap_protocol,
const char *expected_identity = "IDENT")
const char *expected_routing_id = "IDENT")
{
void *control = zmq_socket (ctx, ZMQ_REQ);
assert (control);
......@@ -210,7 +210,7 @@ void zap_handler_generic (void *ctx,
char *sequence = s_recv (handler);
char *domain = s_recv (handler);
char *address = s_recv (handler);
char *identity = s_recv (handler);
char *routing_id = s_recv (handler);
char *mechanism = s_recv (handler);
bool authentication_succeeded = false;
if (streq (mechanism, "CURVE")) {
......@@ -245,7 +245,7 @@ void zap_handler_generic (void *ctx,
}
assert (streq (version, "1.0"));
assert (streq (identity, expected_identity));
assert (streq (routing_id, expected_routing_id));
s_sendmore (handler, zap_protocol == zap_wrong_version
? "invalid_version"
......@@ -288,7 +288,7 @@ void zap_handler_generic (void *ctx,
free (sequence);
free (domain);
free (address);
free (identity);
free (routing_id);
free (mechanism);
zmq_atomic_counter_inc (zap_requests_handled);
......@@ -528,7 +528,7 @@ void setup_context_and_server_side (
zmq_thread_fn zap_handler_ = &zap_handler,
socket_config_fn socket_config_ = &socket_config_curve_server,
void *socket_config_data_ = valid_server_secret,
const char *identity = "IDENT")
const char *routing_id = "IDENT")
{
*ctx = zmq_ctx_new ();
assert (*ctx);
......@@ -558,7 +558,8 @@ void setup_context_and_server_side (
socket_config_ (*server, socket_config_data_);
rc = zmq_setsockopt (*server, ZMQ_ROUTING_ID, identity, strlen (identity));
rc =
zmq_setsockopt (*server, ZMQ_ROUTING_ID, routing_id, strlen (routing_id));
assert (rc == 0);
rc = zmq_bind (*server, "tcp://127.0.0.1:*");
......
Markdown is supported
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