diff options
Diffstat (limited to 'src/service/messenger/messenger_api_cmd_join_room.c')
-rw-r--r-- | src/service/messenger/messenger_api_cmd_join_room.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/service/messenger/messenger_api_cmd_join_room.c b/src/service/messenger/messenger_api_cmd_join_room.c index 4e9cf1e22..8151dc88e 100644 --- a/src/service/messenger/messenger_api_cmd_join_room.c +++ b/src/service/messenger/messenger_api_cmd_join_room.c | |||
@@ -46,9 +46,9 @@ join_room_run (void *cls, | |||
46 | struct GNUNET_HashCode key; | 46 | struct GNUNET_HashCode key; |
47 | 47 | ||
48 | if (jrs->room_key) | 48 | if (jrs->room_key) |
49 | GNUNET_CRYPTO_hash(jrs->room_key, strlen(jrs->room_key), &key); | 49 | GNUNET_CRYPTO_hash (jrs->room_key, strlen (jrs->room_key), &key); |
50 | else | 50 | else |
51 | memset(&key, 0, sizeof(key)); | 51 | memset (&key, 0, sizeof(key)); |
52 | 52 | ||
53 | const struct GNUNET_TESTING_Command *service_cmd; | 53 | const struct GNUNET_TESTING_Command *service_cmd; |
54 | service_cmd = GNUNET_TESTING_interpreter_lookup_command (is, | 54 | service_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
@@ -59,17 +59,17 @@ join_room_run (void *cls, | |||
59 | 59 | ||
60 | unsigned int peer_index; | 60 | unsigned int peer_index; |
61 | unsigned int stage_index; | 61 | unsigned int stage_index; |
62 | |||
63 | struct GNUNET_MESSENGER_RoomState *rs; | 62 | struct GNUNET_MESSENGER_RoomState *rs; |
64 | rs = rs = GNUNET_CONTAINER_multihashmap_get (sss->rooms, &key); | 63 | |
64 | rs = GNUNET_CONTAINER_multihashmap_get (sss->rooms, &key); | ||
65 | if (rs) | 65 | if (rs) |
66 | goto skip_room_state; | 66 | goto skip_room_state; |
67 | 67 | ||
68 | rs = GNUNET_MESSENGER_create_room_state(sss->topology); | 68 | rs = GNUNET_MESSENGER_create_room_state (sss->topology); |
69 | if ((!rs) && (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (sss->rooms, | 69 | if ((! rs) && (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (sss->rooms, |
70 | &key, | 70 | &key, |
71 | rs, | 71 | rs, |
72 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))) | 72 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))) |
73 | { | 73 | { |
74 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 74 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
75 | "Testing library failed to create a room state with key '%s'\n", | 75 | "Testing library failed to create a room state with key '%s'\n", |
@@ -82,22 +82,24 @@ skip_room_state: | |||
82 | peer_index = sss->peer_index; | 82 | peer_index = sss->peer_index; |
83 | stage_index = sss->stage_index; | 83 | stage_index = sss->stage_index; |
84 | 84 | ||
85 | const unsigned int index = stage_index * sss->topology->peer_amount + peer_index; | 85 | const unsigned int index = stage_index * sss->topology->peer_amount |
86 | const struct GNUNET_MESSENGER_TestStage *stage = &(sss->topology->peer_stages[index]); | 86 | + peer_index; |
87 | const struct GNUNET_MESSENGER_TestStage *stage = | ||
88 | &(sss->topology->peer_stages[index]); | ||
87 | 89 | ||
88 | unsigned int door_index = stage->door_id; | 90 | unsigned int door_index = stage->door_id; |
89 | 91 | ||
90 | if (door_index == 0) | 92 | if (door_index == 0) |
91 | door_index = (peer_index + GNUNET_CRYPTO_random_u32 ( | 93 | door_index = (peer_index + GNUNET_CRYPTO_random_u32 ( |
92 | GNUNET_CRYPTO_QUALITY_WEAK, | 94 | GNUNET_CRYPTO_QUALITY_WEAK, |
93 | sss->topology->peer_amount - 1 | 95 | sss->topology->peer_amount - 1 |
94 | ) + 1) % sss->topology->peer_amount; | 96 | ) + 1) % sss->topology->peer_amount; |
95 | else | 97 | else |
96 | door_index = (door_index - 1) % sss->topology->peer_amount; | 98 | door_index = (door_index - 1) % sss->topology->peer_amount; |
97 | 99 | ||
98 | struct GNUNET_PeerIdentity *door; | 100 | struct GNUNET_PeerIdentity *door; |
99 | door = GNUNET_TESTING_get_peer(door_index, sss->tl_system); | 101 | door = GNUNET_TESTING_get_peer (door_index, sss->tl_system); |
100 | if (!door) | 102 | if (! door) |
101 | { | 103 | { |
102 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 104 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
103 | "Testing library failed to get peer identity of index '%u'\n", | 105 | "Testing library failed to get peer identity of index '%u'\n", |
@@ -112,7 +114,7 @@ skip_room_state: | |||
112 | case GNUNET_MESSENGER_STAGE_JOIN_OPEN_ROOM: | 114 | case GNUNET_MESSENGER_STAGE_JOIN_OPEN_ROOM: |
113 | room = GNUNET_MESSENGER_open_room (sss->msg, &key); | 115 | room = GNUNET_MESSENGER_open_room (sss->msg, &key); |
114 | 116 | ||
115 | if (!room) | 117 | if (! room) |
116 | { | 118 | { |
117 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 119 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
118 | "Testing library failed to open room with key '%s'\n", | 120 | "Testing library failed to open room with key '%s'\n", |
@@ -124,9 +126,9 @@ skip_room_state: | |||
124 | 126 | ||
125 | break; | 127 | break; |
126 | case GNUNET_MESSENGER_STAGE_JOIN_ENTER_ROOM: | 128 | case GNUNET_MESSENGER_STAGE_JOIN_ENTER_ROOM: |
127 | room = GNUNET_MESSENGER_enter_room(sss->msg, door, &key); | 129 | room = GNUNET_MESSENGER_enter_room (sss->msg, door, &key); |
128 | 130 | ||
129 | if (!room) | 131 | if (! room) |
130 | { | 132 | { |
131 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 133 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
132 | "Testing library failed to enter room with key '%s'\n", | 134 | "Testing library failed to enter room with key '%s'\n", |
@@ -143,11 +145,12 @@ skip_room_state: | |||
143 | } | 145 | } |
144 | 146 | ||
145 | jrs->room = room; | 147 | jrs->room = room; |
146 | TODO: sss->stage_index++; | 148 | TODO: sss->stage_index++; |
147 | 149 | ||
148 | GNUNET_free (door); | 150 | GNUNET_free (door); |
149 | } | 151 | } |
150 | 152 | ||
153 | |||
151 | static void | 154 | static void |
152 | join_room_cleanup (void *cls) | 155 | join_room_cleanup (void *cls) |
153 | { | 156 | { |
@@ -158,6 +161,7 @@ join_room_cleanup (void *cls) | |||
158 | GNUNET_free (jrs); | 161 | GNUNET_free (jrs); |
159 | } | 162 | } |
160 | 163 | ||
164 | |||
161 | struct GNUNET_TESTING_Command | 165 | struct GNUNET_TESTING_Command |
162 | GNUNET_MESSENGER_cmd_join_room (const char *label, | 166 | GNUNET_MESSENGER_cmd_join_room (const char *label, |
163 | const char *service_label, | 167 | const char *service_label, |