+#define LOG(kind,...) GNUNET_log_from (kind, "core-api",__VA_ARGS__)
+
+/**
+ * Information we track for each peer.
+ */
+struct PeerRecord
+{
+
+ /**
+ * We generally do NOT keep peer records in a DLL; this
+ * DLL is only used IF this peer's 'pending_head' message
+ * is ready for transmission.
+ */
+ struct PeerRecord *prev;
+
+ /**
+ * We generally do NOT keep peer records in a DLL; this
+ * DLL is only used IF this peer's 'pending_head' message
+ * is ready for transmission.
+ */
+ struct PeerRecord *next;
+
+ /**
+ * Peer the record is about.
+ */
+ struct GNUNET_PeerIdentity peer;
+
+ /**
+ * Corresponding core handle.
+ */
+ struct GNUNET_CORE_Handle *ch;
+
+ /**
+ * Head of doubly-linked list of pending requests.
+ * Requests are sorted by deadline *except* for HEAD,
+ * which is only modified upon transmission to core.
+ */
+ struct GNUNET_CORE_TransmitHandle *pending_head;
+
+ /**
+ * Tail of doubly-linked list of pending requests.
+ */
+ struct GNUNET_CORE_TransmitHandle *pending_tail;
+
+ /**
+ * ID of timeout task for the 'pending_head' handle
+ * which is the one with the smallest timeout.
+ */
+ GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+
+ /**
+ * ID of task to run 'next_request_transmission'.
+ */
+ GNUNET_SCHEDULER_TaskIdentifier ntr_task;
+
+ /**
+ * Current size of the queue of pending requests.
+ */
+ unsigned int queue_size;
+
+ /**
+ * SendMessageRequest ID generator for this peer.
+ */
+ uint16_t smr_id_gen;
+
+};
+
+
+/**
+ * Type of function called upon completion.
+ *
+ * @param cls closure
+ * @param success GNUNET_OK on success (which for request_connect
+ * ONLY means that we transmitted the connect request to CORE,
+ * it does not mean that we are actually now connected!);
+ * GNUNET_NO on timeout,
+ * GNUNET_SYSERR if core was shut down
+ */
+typedef void (*GNUNET_CORE_ControlContinuation) (void *cls, int success);
+
+
+/**
+ * Entry in a doubly-linked list of control messages to be transmitted
+ * to the core service. Control messages include traffic allocation,
+ * connection requests and of course our initial 'init' request.
+ *
+ * The actual message is allocated at the end of this struct.
+ */
+struct ControlMessage
+{
+ /**
+ * This is a doubly-linked list.
+ */
+ struct ControlMessage *next;
+
+ /**
+ * This is a doubly-linked list.
+ */
+ struct ControlMessage *prev;
+
+ /**
+ * Function to run after transmission failed/succeeded.
+ */
+ GNUNET_CORE_ControlContinuation cont;
+
+ /**
+ * Closure for 'cont'.
+ */
+ void *cont_cls;
+
+ /**
+ * Transmit handle (if one is associated with this ControlMessage), or NULL.
+ */
+ struct GNUNET_CORE_TransmitHandle *th;
+};
+
+