1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/*
* scamper_task.h
*
* $Id: scamper_task.h,v 1.17 2006/12/15 20:30:33 mjl Exp $
*
* Copyright (C) 2005-2006 The University of Waikato
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __SCAMPER__TASK_H
#define __SCAMPER__TASK_H
struct scamper_addr;
struct scamper_queue;
struct scamper_task;
struct scamper_dl_rec;
struct scamper_rt_rec;
struct scamper_icmp_resp;
struct scamper_cyclemon;
typedef struct scamper_task_funcs
{
/* probe the destination */
int (*probe)(struct scamper_task *task);
/* handle some ICMP packet */
int (*handle_icmp)(struct scamper_task *task,
struct scamper_icmp_resp *icmp);
/* handle some information from the datalink */
int (*handle_dl)(struct scamper_task *task, struct scamper_dl_rec *dl_rec);
/* handle some message from the route socket */
int (*handle_rt)(struct scamper_task *task, struct scamper_rt_rec *rt_rec);
/* handle the task timing out on the wait queue */
int (*handle_timeout)(struct scamper_task *task);
/* write the task's data object out */
int (*write)(struct scamper_task *task);
/* free the task's data and state */
void (*task_free)(struct scamper_task *task);
} scamper_task_funcs_t;
typedef struct scamper_task
{
/* the destination being probed */
struct scamper_addr *dst;
/* the data pointer points to a scamper_trace or scamper_ping struct */
void *data;
/* any state kept during the data collection is kept here */
void *state;
/* state / details kept internally to the task */
void *internal;
/* various callbacks that scamper uses to handle this task */
scamper_task_funcs_t *funcs;
/* pointer to a queue structure that manages this task in the queues */
struct scamper_queue *queue;
/* pointer to where the task came from */
struct scamper_source *source;
/* pointer to cycle monitor structure, if used */
struct scamper_cyclemon *cyclemon;
} scamper_task_t;
scamper_task_t *scamper_task_alloc(struct scamper_addr *dst,
scamper_task_funcs_t *funcs);
void scamper_task_free(scamper_task_t *task);
/*
* scamper_task_onhold
*
* given a task that another is blocked on, register the fact.
* when the task is free'd, the unhold function will be called.
*
* returns a cookie, so the dehold function can cancel the task
* from being on hold at a later point.
*/
void *scamper_task_onhold(scamper_task_t *task, void *param,
void (*unhold)(void *param));
/*
* scamper_task_dehold
*
* given a task and a cookie returned from putting another task on hold,
* de-hold the task with this cookie.
*/
int scamper_task_dehold(scamper_task_t *task, void *cookie);
#endif /* __SCAMPER_TASK_H */
|