forked from CAIDA/mper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scamper_task.h
117 lines (93 loc) · 3.49 KB
/
scamper_task.h
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
114
115
116
117
/*
* scamper_task.h
*
* $Id: scamper_task.h,v 1.24 2008/12/03 21:45:34 mjl Exp $
*
* Copyright (C) 2005-2008 The University of Waikato
* Author: Matthew Luckie
*
* 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_targetset;
struct scamper_writebuf;
typedef struct scamper_task_funcs
{
/* probe the destination */
void (*probe)(struct scamper_task *task);
/* handle some ICMP packet */
void (*handle_icmp)(struct scamper_task *task,
struct scamper_icmp_resp *icmp);
/* handle some information from the datalink */
void (*handle_dl)(struct scamper_task *task, struct scamper_dl_rec *dl_rec);
/* handle some message from the route socket */
void (*handle_rt)(struct scamper_task *task, struct scamper_rt_rec *rt_rec);
/* handle the task timing out on the wait queue */
void (*handle_timeout)(struct scamper_task *task);
/* write the task's data object out */
void (*write)(struct scamper_task *task);
/* free the task's data and state */
void (*task_free)(struct scamper_task *task);
/* call the supplied callback for each destination address */
int (*task_addrs)(void *data, void *param,
int (*foreach)(struct scamper_addr *, void *));
} scamper_task_funcs_t;
typedef struct scamper_task
{
/* the data pointer points to the collected data */
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;
void *source_task;
struct scamper_writebuf *wb; /* alias of source->client->wb */
/* pointer to a targetset structure, if used */
struct scamper_targetset *targetset;
} scamper_task_t;
scamper_task_t *scamper_task_alloc(void *data, 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 */