/*********************** AUXILIARY FUNCTIONS *************************/
/******************************************************************************/
+/**
+ * Check if transmission is a payload packet.
+ *
+ * @param th Transmission handle.
+ *
+ * @return GNUNET_YES if it is a payload packet,
+ * GNUNET_NO if it is a mesh management packet.
+ */
+static int
+th_is_payload (struct GNUNET_MESH_TransmitHandle *th)
+{
+ return (th->notify != NULL) ? GNUNET_YES : GNUNET_NO;
+}
+
+
/**
* Get the tunnel handler for the tunnel specified by id from the given handle
* @param h Mesh handle
continue;
/* Clients should have aborted their requests already.
* Management traffic should be ok, as clients can't cancel that */
- GNUNET_break (NULL == th->notify);
+ GNUNET_break (GNUNET_NO == th_is_payload(th));
GNUNET_CONTAINER_DLL_remove (h->th_head, h->th_tail, th);
/* clean up request */
mesh = th->tunnel->mesh;
GNUNET_CONTAINER_DLL_remove (mesh->th_head, mesh->th_tail, th);
- if (th->notify != NULL)
+ if (GNUNET_YES == th_is_payload (th))
th->notify (th->notify_cls, 0, NULL);
GNUNET_free (th);
if ((NULL == mesh->th_head) && (NULL != mesh->th))
while ((NULL != (th = next)) && (size >= th->size))
{
t = th->tunnel;
- if (NULL != th->notify)
+ if (GNUNET_YES == th_is_payload (th))
{
if (t->max_pid < t->pid && ! PID_OVERFLOW (t->pid, t->max_pid)) {
/* This tunnel is not ready to transmit yet, try next message */
{
struct GNUNET_MESH_Tunnel *t = th->tunnel;
- if (NULL != th->notify ||
+ if (GNUNET_NO == th_is_payload (th) ||
(t->max_pid >= t->pid || PID_OVERFLOW (t->pid, t->max_pid)))
{
request = GNUNET_YES;
/* Make sure it is an allowed packet (everything else should have been
* already canceled).
*/
- GNUNET_break (NULL == th->notify);
+ GNUNET_break (GNUNET_NO == th_is_payload (th));
msg = (struct GNUNET_MessageHeader *) &th[1];
switch (ntohs(msg->type))
{
{
aux = th->next;
/* FIXME call the handler? */
- if (NULL != th->notify)
+ if (GNUNET_YES == th_is_payload (th))
th->notify (th->notify_cls, 0, NULL);
GNUNET_CONTAINER_DLL_remove (h->th_head, h->th_tail, th);
GNUNET_free (th);