libgnunetcadet_la_SOURCES = \
cadet_api.c \
+ cadet_api_drop_message.c \
cadet_api_get_channel.c \
cadet_api_get_path.c \
cadet_api_list_peers.c \
GNUNET_NETWORK_STRUCT_BEGIN
-
/**
* Number uniquely identifying a channel of a client.
*/
uint32_t channel_of_client GNUNET_PACKED;
};
+/**
+ * Opaque handle to a channel.
+ */
+struct GNUNET_CADET_Channel
+{
+
+ /**
+ * Other end of the channel.
+ */
+ struct GNUNET_PeerIdentity peer;
+
+ /**
+ * Handle to the cadet this channel belongs to
+ */
+ struct GNUNET_CADET_Handle *cadet;
+
+ /**
+ * Channel's port, if incoming.
+ */
+ struct GNUNET_CADET_Port *incoming_port;
+
+ /**
+ * Any data the caller wants to put in here, used for the
+ * various callbacks (@e disconnects, @e window_changes, handlers).
+ */
+ void *ctx;
+
+ /**
+ * Message Queue for the channel (which we are implementing).
+ */
+ struct GNUNET_MQ_Handle *mq;
+
+ /**
+ * Task to allow mq to send more traffic.
+ */
+ struct GNUNET_SCHEDULER_Task *mq_cont;
+
+ /**
+ * Pending envelope with a message to be transmitted to the
+ * service as soon as we are allowed to. Should only be
+ * non-NULL if @e allow_send is 0.
+ */
+ struct GNUNET_MQ_Envelope *pending_env;
+
+ /**
+ * Window change handler.
+ */
+ GNUNET_CADET_WindowSizeEventHandler window_changes;
+
+ /**
+ * Disconnect handler.
+ */
+ GNUNET_CADET_DisconnectEventHandler disconnects;
+
+ /**
+ * Local ID of the channel, #GNUNET_CADET_LOCAL_CHANNEL_ID_CLI bit is set if outbound.
+ */
+ struct GNUNET_CADET_ClientChannelNumber ccn;
+
+ /**
+ * How many messages are we allowed to send to the service right now?
+ */
+ unsigned int allow_send;
+};
/**
* Message for a client to create and destroy channels.
struct GNUNET_TIME_Relative reconnect_time;
};
-
-/**
- * Opaque handle to a channel.
- */
-struct GNUNET_CADET_Channel
-{
-
- /**
- * Other end of the channel.
- */
- struct GNUNET_PeerIdentity peer;
-
- /**
- * Handle to the cadet this channel belongs to
- */
- struct GNUNET_CADET_Handle *cadet;
-
- /**
- * Channel's port, if incoming.
- */
- struct GNUNET_CADET_Port *incoming_port;
-
- /**
- * Any data the caller wants to put in here, used for the
- * various callbacks (@e disconnects, @e window_changes, handlers).
- */
- void *ctx;
-
- /**
- * Message Queue for the channel (which we are implementing).
- */
- struct GNUNET_MQ_Handle *mq;
-
- /**
- * Task to allow mq to send more traffic.
- */
- struct GNUNET_SCHEDULER_Task *mq_cont;
-
- /**
- * Pending envelope with a message to be transmitted to the
- * service as soon as we are allowed to. Should only be
- * non-NULL if @e allow_send is 0.
- */
- struct GNUNET_MQ_Envelope *pending_env;
-
- /**
- * Window change handler.
- */
- GNUNET_CADET_WindowSizeEventHandler window_changes;
-
- /**
- * Disconnect handler.
- */
- GNUNET_CADET_DisconnectEventHandler disconnects;
-
- /**
- * Local ID of the channel, #GNUNET_CADET_LOCAL_CHANNEL_ID_CLI bit is set if outbound.
- */
- struct GNUNET_CADET_ClientChannelNumber ccn;
-
- /**
- * How many messages are we allowed to send to the service right now?
- */
- unsigned int allow_send;
-};
-
-
/**
* Opaque handle to a port.
*/
* @author t3sserakt
*/
#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_constants.h"
-#include "gnunet_cadet_service.h"
#include "cadet.h"
-#include "cadet_protocol.h"
/**
- * Operation handle.
- */
-struct GNUNET_CADET_ChannelMonitor
-{
-
- /**
- * Channel callback.
- */
- GNUNET_CADET_ChannelCB channel_cb;
-
- /**
- * Info callback closure for @c channel_cb.
- */
- void *channel_cb_cls;
-
- /**
- * Configuration we use.
- */
- const struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * Message queue to talk to CADET service.
- */
- struct GNUNET_MQ_Handle *mq;
-
- /**
- * Task to reconnect.
- */
- struct GNUNET_SCHEDULER_Task *reconnect_task;
-
- /**
- * Backoff for reconnect attempts.
- */
- struct GNUNET_TIME_Relative backoff;
-
- /**
- * Peer we want information about.
- */
- struct GNUNET_PeerIdentity peer;
-
-};
-
-
-/**
- * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE request.
+ * Drop the next cadet message of a given type..
*
- * @param cls client Identification of the client.
- * @param message The actual message.
+ * @param mq message queue
+ * @param ccn client channel number.
+ * @param type of cadet message to be dropped.
*/
-static void
-handle_drop_message (void *cls,
- const struct GNUNET_CADET_RequestDropCadetMessage *message)
+void
+GNUNET_CADET_drop_message (struct GNUNET_MQ_Handle *mq,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
+ uint16_t type)
{
- struct CadetClient *c = cls;
- struct CadetChannel *ch;
+ struct GNUNET_CADET_RequestDropCadetMessage *message;
+ struct GNUNET_MQ_Envelope *env;
- ch = lookup_channel (c,
- message->ccn);
+ env = GNUNET_MQ_msg (message, GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE);
- GCCH_assign_type_to_drop(ch, message);
+ message->ccn = ccn;
+ message->type = type;
- GNUNET_SERVICE_client_continue (c->client);
-}
-
-/**
- * Reconnect to the service and try again.
- *
- * @param cls a `struct GNUNET_CADET_ChannelMonitor` operation
- */
-static void
-reconnect (struct GNUNET_CADET_Handle *h);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Dropping message for channel of type \n");
-
-/**
- * Function called on connection trouble. Reconnects.
- *
- * @param cls a `struct GNUNET_CADET_ChannelMonitor``
- * @param error error code from MQ
- */
-static void
-error_handler (void *cls,
- enum GNUNET_MQ_Error error)
-{
- struct GNUNET_CADET_ChannelMonitor *cm = cls;
-
- GNUNET_MQ_destroy (cm->mq);
- cm->mq = NULL;
- cm->backoff = GNUNET_TIME_randomized_backoff (cm->backoff,
- GNUNET_TIME_UNIT_MINUTES);
- cm->reconnect_task = GNUNET_SCHEDULER_add_delayed (cm->backoff,
- &reconnect,
- cm);
-}
-
-
-/**
- * Reconnect to the service and try again.
- *
- * @param cls a `struct GNUNET_CADET_ChannelMonitor` operation
- */
-static void
-reconnect (void *clsstruct GNUNET_CADET_Handle *h)
-{
+ GNUNET_MQ_send (mq, env);
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_fixed_size (drop_message,
- GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE,
- struct GNUNET_CADET_RequestDropCadetMessage,
- NULL),
- GNUNET_MQ_handler_end ()
- };
- GNUNET_assert (NULL == h->mq);
- h->mq =
- GNUNET_CLIENT_connect (h->cfg, "cadet", handlers, &error_handler, h);
-}
-
-
-/**
- * Request information about a specific channel of the running cadet peer.
- *
- * @param cfg configuration to use
- * @param peer ID of the other end of the channel.
- * @param callback Function to call with the requested data.
- * @param callback_cls Closure for @c callback.
- * @return NULL on error
- */
-struct GNUNET_CADET_ChannelMonitor *
-GNUNET_CADET_get_channel (const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_PeerIdentity *peer,
- GNUNET_CADET_ChannelCB callback,
- void *callback_cls)
-{
- struct GNUNET_CADET_ChannelMonitor *cm;
-
- if (NULL == callback)
- {
- GNUNET_break (0);
- return NULL;
- }
- cm = GNUNET_new (struct GNUNET_CADET_ChannelMonitor);
- cm->channel_cb = callback;
- cm->channel_cb_cls = callback_cls;
- cm->cfg = cfg;
- cm->peer = *peer;
- reconnect (cm);
- if (NULL == cm->mq)
- {
- GNUNET_free (cm);
- return NULL;
- }
- return cm;
}
-/* end of cadet_api_get_channel.c */
+/* end of cadet_api_drop_message.c */
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHsendANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
* @param other the other peer
* @return #GNUNET_YES for Alice, #GNUNET_NO for Betty, #GNUNET_SYSERR if talking to myself
*/
-static int
-alice_or_betty (const struct GNUNET_PeerIdentity *other)
+int
+GCT_alice_or_betty (const struct GNUNET_PeerIdentity *other)
{
+
if (0 > GNUNET_memcmp (&my_full_id,
other))
return GNUNET_YES;
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
- }
+ }
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Will we ever send a KX message?\n");
- if (GNUNET_YES != alice_or_betty (GCP_get_id (t->destination)))
+ if (GNUNET_YES != GCT_alice_or_betty (GCP_get_id (t->destination)))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Only Alice may send KX to %s!\n",
const char salt[] = "CADET Axolotl salt";
int am_I_alice;
- if (GNUNET_SYSERR == (am_I_alice = alice_or_betty (pid)))
+ if (GNUNET_SYSERR == (am_I_alice = GCT_alice_or_betty (pid)))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
1,
GNUNET_NO);
if (GNUNET_YES ==
- alice_or_betty (GCP_get_id (t->destination)))
+ GCT_alice_or_betty (GCP_get_id (t->destination)))
{
/* Betty/Bob is not allowed to send KX! */
GNUNET_break_op (0);
};
+/**
+ * Am I Alice or Betty (some call her Bob), or talking to myself?
+ *
+ * @param other the other peer
+ * @return #GNUNET_YES for Alice, #GNUNET_NO for Betty, #GNUNET_SYSERR if talking to myself
+ */
+int
+GCT_alice_or_betty (const struct GNUNET_PeerIdentity *other);
/**
* Get the static string for the peer this tunnel is directed.
*/
#include <stdio.h>
#include "platform.h"
+#include "cadet.h"
#include "cadet_test_lib.h"
#include "gnunet_cadet_service.h"
#include "gnunet_statistics_service.h"
*/
static struct GNUNET_CADET_Handle *h1;
-/**
- * Cadet handle for the first leaf peer
- */
-static struct GNUNET_CADET_Handle *h2;
-
/**
* Channel handle for the root peer
*/
*/
static unsigned int msg_dropped;
+/**
+ * Drop the next cadet message of a given type..
+ *
+ * @param mq message queue
+ * @param ccn client channel number.
+ * @param type of cadet message to be dropped.
+ */
+void
+GNUNET_CADET_drop_message (struct GNUNET_MQ_Handle *mq,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
+ uint16_t type);
/******************************************************************************/
ch->ch = outgoing_ch;
+ /*if (DESTROY == test)
+ {
+
+ GNUNET_CADET_drop_message (GNUNET_CADET_get_mq (outgoing_ch),
+ outgoing_ch->ccn,
+ GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE);
+ GNUNET_CADET_channel_destroy(outgoing_ch);
+
+ outgoing_ch = GNUNET_CADET_channel_create (h1,
+ ch,
+ p_id[1],
+ &port,
+ NULL,
+ &disconnect_handler,
+ handlers);
+
+ ch->ch = outgoing_ch;
+
+ }*/
+
+
disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
&gather_stats_and_exit,
(void *) __LINE__);
if (KEEPALIVE == test)
return; /* Don't send any data. */
-
- if (DESTROY == test)
- {
-
-
-
- }
data_received = 0;
data_sent = 0;
peers_running = num_peers;
GNUNET_assert (peers_running == peers_requested);
testbed_peers = peers;
- h1 = cadets[0];
- h2 = cadets[num_peers - 1];
+ if (0 < GNUNET_memcmp (p_id[0], p_id[num_peers - 1]))
+ {
+ h1 = cadets[0];
+ }else
+ {
+ h1 = cadets[num_peers - 1];
+ }
disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
&disconnect_cadet_peers,
(void *) __LINE__);
REST_ECHO_ORIGIN_WEBEXT=YES
REST_ALLOW_ORIGIN=http://localhost:4200
REST_ALLOW_CREDENTIALS=true
+
+# Do we require users that want to access the rest service to run this process
+# (usually not a good idea)
+UNIX_MATCH_UID = NO
+
+# Do we require users that want to access the rest service to be in the 'gnunet' group?
+UNIX_MATCH_GID = YES
\ No newline at end of file