~ubuntu-branches/debian/sid/ion/sid

« back to all changes in this revision

Viewing changes to contrib/dtnperf/al_bp/src/al_bp_types.h

  • Committer: Package Import Robot
  • Author(s): Leo Iannacone
  • Date: 2013-07-09 16:22:20 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20130709162220-vfrvtfbl78wqzn9x
Tags: 3.2.0~dfsg1-1
* New upstream release.
* Updated debian/ion-tools.pod and debian/ion.links
  with new binaries.
* Updated fix-manpages-errors.patch (closes: #724143).
* Refreshed old patches.
* Removed fix-gcc4.8-errors.patch. Applied to upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************
 
2
 **  Authors: Michele Rodolfi, michele.rodolfi@studio.unibo.it
 
3
 **           Anna d'Amico, anna.damico@studio.unibo.it
 
4
 **           Carlo Caini (DTNperf_3 project supervisor), carlo.caini@unibo.it
 
5
 **
 
6
 **
 
7
 **  Copyright (c) 2013, Alma Mater Studiorum, University of Bologna
 
8
 **  All rights reserved.
 
9
 ********************************************************/
 
10
 
 
11
/*
 
12
 * bp_types.h
 
13
 *
 
14
 */
 
15
 
 
16
#ifndef BP_TYPES_H_
 
17
#define BP_TYPES_H_
 
18
 
 
19
#include "types.h"
 
20
 
 
21
#define AL_BP_MAX_ENDPOINT_ID 256
 
22
#define AL_BP_MAX_ORDINAL_NBR 254
 
23
 
 
24
/**
 
25
 * Bundle protocol implementation
 
26
 */
 
27
typedef enum
 
28
{
 
29
        BP_NONE = 0,
 
30
    BP_DTN,
 
31
    BP_ION,
 
32
} al_bp_implementation_t;
 
33
 
 
34
/**
 
35
 * Specification of a bp endpoint id, i.e. a URI, implemented as a
 
36
 * fixed-length char buffer. Note that for efficiency reasons, this
 
37
 * fixed length is relatively small (256 bytes).
 
38
 *
 
39
 * The alternative is to use the string XDR type but then all endpoint
 
40
 * ids would require malloc / free which is more prone to leaks / bugs.
 
41
 */
 
42
 
 
43
struct al_bp_endpoint_id_t {
 
44
        char uri[AL_BP_MAX_ENDPOINT_ID]; //256
 
45
};
 
46
typedef struct al_bp_endpoint_id_t al_bp_endpoint_id_t;
 
47
 
 
48
/**
 
49
 * *************************************************************************CONTROLLA DESCRZIONE
 
50
 * The basic handle for communication with the bp router.
 
51
 */
 
52
typedef int * al_bp_handle_t;
 
53
 
 
54
/**
 
55
 * BP timeouts are specified in seconds.
 
56
 */
 
57
 
 
58
typedef u32_t al_bp_timeval_t;
 
59
 
 
60
struct al_bp_timestamp_t {
 
61
        u32_t secs;
 
62
        u32_t seqno;
 
63
};
 
64
typedef struct al_bp_timestamp_t al_bp_timestamp_t;
 
65
 
 
66
typedef u32_t al_bp_reg_token_t;
 
67
 
 
68
/**
 
69
 * A registration cookie.
 
70
 */
 
71
 
 
72
typedef u32_t al_bp_reg_id_t;
 
73
 
 
74
/**
 
75
 * Registration state.
 
76
 */
 
77
 
 
78
struct al_bp_reg_info_t {
 
79
        al_bp_endpoint_id_t endpoint;
 
80
        al_bp_reg_id_t regid;
 
81
        u32_t flags;
 
82
        u32_t replay_flags;
 
83
        al_bp_timeval_t expiration;
 
84
        boolean_t init_passive;
 
85
        al_bp_reg_token_t reg_token;
 
86
        struct {
 
87
                u32_t script_len;
 
88
                char *script_val;
 
89
        } script;
 
90
};
 
91
typedef struct al_bp_reg_info_t al_bp_reg_info_t;
 
92
/**
 
93
 * Registration flags are a bitmask of the following:
 
94
 
 
95
 * Delivery failure actions (exactly one must be selected):
 
96
 *     BP_REG_DROP   - drop bundle if registration not active
 
97
 *     BP_REG_DEFER  - spool bundle for later retrieval
 
98
 *     BP_REG_EXEC   - exec program on bundle arrival
 
99
 *
 
100
 * Session flags:
 
101
 *     BP_SESSION_CUSTODY   - app assumes custody for the session
 
102
 *     BP_SESSION_PUBLISH   - creates a publication point
 
103
 *     BP_SESSION_SUBSCRIBE - create subscription for the session
 
104
 *
 
105
 * Other flags:
 
106
 *     BP_DELIVERY_ACKS - application will acknowledge delivered
 
107
 *                         bundles with bp_ack()
 
108
 *
 
109
 */
 
110
 
 
111
enum al_bp_reg_flags_t {
 
112
        BP_REG_DROP = 1,
 
113
        BP_REG_DEFER = 2,
 
114
        BP_REG_EXEC = 3,
 
115
        BP_SESSION_CUSTODY = 4,
 
116
        BP_SESSION_PUBLISH = 8,
 
117
        BP_SESSION_SUBSCRIBE = 16,
 
118
        BP_DELIVERY_ACKS = 32,
 
119
};
 
120
typedef enum al_bp_reg_flags_t al_bp_reg_flags_t;
 
121
/**
 
122
 * Value for an unspecified registration cookie (i.e. indication that
 
123
 * the daemon should allocate a new unique id).
 
124
 */
 
125
#define BP_REGID_NONE 0
 
126
 
 
127
/**
 
128
 * Bundle delivery option flags. Note that multiple options may be
 
129
 * selected for a given bundle.
 
130
 *
 
131
 *     BP_DOPTS_NONE            - no custody, etc
 
132
 *     BP_DOPTS_CUSTODY         - custody xfer
 
133
 *     BP_DOPTS_DELIVERY_RCPT   - end to end delivery (i.e. return receipt)
 
134
 *     BP_DOPTS_RECEIVE_RCPT    - per hop arrival receipt
 
135
 *     BP_DOPTS_FORWARD_RCPT    - per hop departure receipt
 
136
 *     BP_DOPTS_CUSTODY_RCPT    - per custodian receipt
 
137
 *     BP_DOPTS_DELETE_RCPT     - request deletion receipt
 
138
 *     BP_DOPTS_SINGLETON_DEST  - destination is a singleton
 
139
 *     BP_DOPTS_MULTINODE_DEST  - destination is not a singleton
 
140
 *     BP_DOPTS_DO_NOT_FRAGMENT - set the do not fragment bit
 
141
 */
 
142
 
 
143
enum al_bp_bundle_delivery_opts_t {
 
144
        BP_DOPTS_NONE = 0,
 
145
        BP_DOPTS_CUSTODY = 1,
 
146
        BP_DOPTS_DELIVERY_RCPT = 2,
 
147
        BP_DOPTS_RECEIVE_RCPT = 4,
 
148
        BP_DOPTS_FORWARD_RCPT = 8,
 
149
        BP_DOPTS_CUSTODY_RCPT = 16,
 
150
        BP_DOPTS_DELETE_RCPT = 32,
 
151
        BP_DOPTS_SINGLETON_DEST = 64,
 
152
        BP_DOPTS_MULTINODE_DEST = 128,
 
153
        BP_DOPTS_DO_NOT_FRAGMENT = 256,
 
154
};
 
155
typedef enum al_bp_bundle_delivery_opts_t al_bp_bundle_delivery_opts_t;
 
156
 
 
157
/**
 
158
 * Bundle priority specifier.
 
159
 *     BP_PRIORITY_BULK      - lowest priority
 
160
 *     BP_PRIORITY_NORMAL    - regular priority
 
161
 *     BP_PRIORITY_EXPEDITED - important
 
162
 *     BP_PRIORITY_RESERVED  - TBD
 
163
 * Only for ION implementation there is ordinal number
 
164
 *         ordinal [0 - AL_MAX_ORDINAL_NBR]
 
165
 */
 
166
 
 
167
enum al_bp_bundle_priority_enum {
 
168
        BP_PRIORITY_BULK = 0,
 
169
        BP_PRIORITY_NORMAL = 1,
 
170
        BP_PRIORITY_EXPEDITED = 2,
 
171
        BP_PRIORITY_RESERVED = 3,
 
172
};
 
173
typedef enum al_bp_bundle_priority_enum al_bp_bundle_priority_enum;
 
174
 
 
175
struct al_bp_bundle_priority_t {
 
176
        al_bp_bundle_priority_enum priority;
 
177
        u32_t ordinal;
 
178
};
 
179
typedef struct al_bp_bundle_priority_t al_bp_bundle_priority_t;
 
180
 
 
181
/**
 
182
 * Extension block.
 
183
 */
 
184
 
 
185
struct al_bp_extension_block_t {
 
186
        u32_t type;
 
187
        u32_t flags;
 
188
        struct {
 
189
                u32_t data_len;
 
190
                char *data_val;
 
191
        } data;
 
192
};
 
193
typedef struct al_bp_extension_block_t al_bp_extension_block_t;
 
194
 
 
195
/**
 
196
 * Bundle specifications. The delivery_regid is ignored when sending
 
197
 * bundles, but is filled in by the daemon with the registration
 
198
 * id where the bundle was received.
 
199
 */
 
200
 
 
201
struct al_bp_bundle_spec_t {
 
202
        al_bp_endpoint_id_t source;
 
203
        al_bp_endpoint_id_t dest;
 
204
        al_bp_endpoint_id_t replyto;
 
205
        al_bp_bundle_priority_t priority;
 
206
        al_bp_bundle_delivery_opts_t dopts;
 
207
        al_bp_timeval_t expiration;
 
208
        al_bp_timestamp_t creation_ts;
 
209
        al_bp_reg_id_t delivery_regid;
 
210
        struct {
 
211
                u32_t blocks_len;
 
212
                al_bp_extension_block_t *blocks_val;
 
213
        } blocks;
 
214
        struct {
 
215
                u32_t metadata_len;
 
216
                al_bp_extension_block_t *metadata_val;
 
217
        } metadata;
 
218
        boolean_t unreliable;
 
219
        boolean_t critical;
 
220
        u32_t flow_label;
 
221
};
 
222
typedef struct al_bp_bundle_spec_t al_bp_bundle_spec_t;
 
223
 
 
224
/**
 
225
 * The payload of a bundle can be sent or received either in a file,
 
226
 * in which case the payload structure contains the filename, or in
 
227
 * memory where the struct contains the data in-band, in the 'buf'
 
228
 * field.
 
229
 *
 
230
 * When sending a bundle, if the location specifies that the payload
 
231
 * is in a temp file, then the daemon assumes ownership of the file
 
232
 * and should have sufficient permissions to move or rename it.
 
233
 *
 
234
 * When receiving a bundle that is a status report, then the
 
235
 * status_report pointer will be non-NULL and will point to a
 
236
 * bp_bundle_status_report_t structure which contains the parsed fields
 
237
 * of the status report.
 
238
 *
 
239
 *     BP_PAYLOAD_MEM         - payload contents in memory
 
240
 *     BP_PAYLOAD_FILE        - payload contents in file
 
241
 *     BP_PAYLOAD_TEMP_FILE   - in file, assume ownership (send only)
 
242
 */
 
243
 
 
244
enum al_bp_bundle_payload_location_t {
 
245
        BP_PAYLOAD_FILE = 0,
 
246
        BP_PAYLOAD_MEM = 1,
 
247
        BP_PAYLOAD_TEMP_FILE = 2,
 
248
};
 
249
typedef enum al_bp_bundle_payload_location_t al_bp_bundle_payload_location_t;
 
250
/**
 
251
 * Bundle Status Report "Reason Code" flags
 
252
 */
 
253
 
 
254
enum al_bp_status_report_reason_t {
 
255
        BP_SR_REASON_NO_ADDTL_INFO = 0x00,
 
256
        BP_SR_REASON_LIFETIME_EXPIRED = 0x01,
 
257
        BP_SR_REASON_FORWARDED_UNIDIR_LINK = 0x02,
 
258
        BP_SR_REASON_TRANSMISSION_CANCELLED = 0x03,
 
259
        BP_SR_REASON_DEPLETED_STORAGE = 0x04,
 
260
        BP_SR_REASON_ENDPOINT_ID_UNINTELLIGIBLE = 0x05,
 
261
        BP_SR_REASON_NO_ROUTE_TO_DEST = 0x06,
 
262
        BP_SR_REASON_NO_TIMELY_CONTACT = 0x07,
 
263
        BP_SR_REASON_BLOCK_UNINTELLIGIBLE = 0x08,
 
264
};
 
265
typedef enum al_bp_status_report_reason_t al_bp_status_report_reason_t;
 
266
/**
 
267
 * Bundle Status Report status flags that indicate which timestamps in
 
268
 * the status report structure are valid.
 
269
 */
 
270
 
 
271
enum al_bp_status_report_flags_t {
 
272
        BP_STATUS_RECEIVED = 0x01,
 
273
        BP_STATUS_CUSTODY_ACCEPTED = 0x02,
 
274
        BP_STATUS_FORWARDED = 0x04,
 
275
        BP_STATUS_DELIVERED = 0x08,
 
276
        BP_STATUS_DELETED = 0x10,
 
277
        BP_STATUS_ACKED_BY_APP = 0x20,
 
278
};
 
279
typedef enum al_bp_status_report_flags_t al_bp_status_report_flags_t;
 
280
 
 
281
/**
 
282
 * Type definition for a unique bundle identifier. Returned from bp_send
 
283
 * after the daemon has assigned the creation_secs and creation_subsecs,
 
284
 * in which case orig_length and frag_offset are always zero, and also in
 
285
 * status report data in which case they may be set if the bundle is
 
286
 * fragmented.
 
287
 */
 
288
 
 
289
struct al_bp_bundle_id_t {
 
290
        al_bp_endpoint_id_t source;
 
291
        al_bp_timestamp_t creation_ts;
 
292
        u32_t frag_offset;
 
293
        u32_t orig_length;
 
294
};
 
295
 
 
296
typedef struct al_bp_bundle_id_t al_bp_bundle_id_t;
 
297
 
 
298
/**
 
299
 * Type definition for a bundle status report.
 
300
 */
 
301
 
 
302
struct al_bp_bundle_status_report_t {
 
303
        al_bp_bundle_id_t bundle_id;
 
304
        al_bp_status_report_reason_t reason;
 
305
        al_bp_status_report_flags_t flags;
 
306
        al_bp_timestamp_t receipt_ts;
 
307
        al_bp_timestamp_t custody_ts;
 
308
        al_bp_timestamp_t forwarding_ts;
 
309
        al_bp_timestamp_t delivery_ts;
 
310
        al_bp_timestamp_t deletion_ts;
 
311
        al_bp_timestamp_t ack_by_app_ts;
 
312
};
 
313
typedef struct al_bp_bundle_status_report_t al_bp_bundle_status_report_t;
 
314
 
 
315
struct al_bp_bundle_payload_t {
 
316
        al_bp_bundle_payload_location_t location;
 
317
        struct {
 
318
                u32_t filename_len;
 
319
                char *filename_val;
 
320
        } filename;
 
321
        struct {
 
322
                uint32_t buf_crc;
 
323
                u32_t buf_len;
 
324
                char *buf_val;
 
325
        } buf;
 
326
        al_bp_bundle_status_report_t *status_report;
 
327
};
 
328
typedef struct al_bp_bundle_payload_t al_bp_bundle_payload_t;
 
329
 
 
330
/**
 
331
 * AL BP API error codes
 
332
 */
 
333
typedef enum al_bp_error_t
 
334
{
 
335
        //Both Error
 
336
        BP_SUCCESS = 0, /* ok */
 
337
        BP_ERRBASE,             /* Base error code */
 
338
        BP_ENOBPI,              /* error NO Bundle Protocol Implementation */
 
339
        BP_EINVAL,              /* invalid argument */
 
340
        BP_ENULLPNTR,   /* operation on a null pointer */
 
341
        BP_EUNREG,              /* errot to unregister eid*/
 
342
        BP_ECONNECT,    /* error connecting to server */
 
343
        BP_ETIMEOUT,    /* operation timed out */
 
344
        BP_ESIZE,               /* payload / eid too large */
 
345
        BP_ENOTFOUND,   /* not found (e.g. reg) */
 
346
        BP_EINTERNAL,   /* misc. internal error */
 
347
        BP_EBUSY,               /* registration already in use */
 
348
        BP_ENOSPACE,    /* no storage space */
 
349
        BP_ENOTIMPL,    /* function not yet implemented */
 
350
        BP_EATTACH,     /* error to attach bp protocol */
 
351
        BP_EBUILDEID,   /* error to buil a local eid */
 
352
        BP_EOPEN,               /* error to open */
 
353
        BP_EREG,                /* error to register a eid */
 
354
        BP_EPARSEEID,   /* error to parse a endpoint id string */
 
355
        BP_ESEND,               /* error to send bundle*/
 
356
        BP_ERECV,               /* error to receive bundle*/
 
357
        BP_ERECVINT             /* reception interrupted*/
 
358
} al_bp_error_t;
 
359
 
 
360
/****************************************************************
 
361
 *
 
362
 *             HIGHER LEVEL TYPES
 
363
 *
 
364
 ****************************************************************/
 
365
 
 
366
 
 
367
struct al_bp_bundle_object_t {
 
368
        al_bp_bundle_id_t * id;
 
369
        al_bp_bundle_spec_t * spec;
 
370
        al_bp_bundle_payload_t * payload;
 
371
};
 
372
typedef struct al_bp_bundle_object_t al_bp_bundle_object_t;
 
373
 
 
374
 
 
375
#endif /* BP_TYPES_H_ */