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
7
** Copyright (c) 2013, Alma Mater Studiorum, University of Bologna
8
** All rights reserved.
9
********************************************************/
21
#define AL_BP_MAX_ENDPOINT_ID 256
22
#define AL_BP_MAX_ORDINAL_NBR 254
25
* Bundle protocol implementation
32
} al_bp_implementation_t;
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).
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.
43
struct al_bp_endpoint_id_t {
44
char uri[AL_BP_MAX_ENDPOINT_ID]; //256
46
typedef struct al_bp_endpoint_id_t al_bp_endpoint_id_t;
49
* *************************************************************************CONTROLLA DESCRZIONE
50
* The basic handle for communication with the bp router.
52
typedef int * al_bp_handle_t;
55
* BP timeouts are specified in seconds.
58
typedef u32_t al_bp_timeval_t;
60
struct al_bp_timestamp_t {
64
typedef struct al_bp_timestamp_t al_bp_timestamp_t;
66
typedef u32_t al_bp_reg_token_t;
69
* A registration cookie.
72
typedef u32_t al_bp_reg_id_t;
78
struct al_bp_reg_info_t {
79
al_bp_endpoint_id_t endpoint;
83
al_bp_timeval_t expiration;
84
boolean_t init_passive;
85
al_bp_reg_token_t reg_token;
91
typedef struct al_bp_reg_info_t al_bp_reg_info_t;
93
* Registration flags are a bitmask of the following:
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
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
106
* BP_DELIVERY_ACKS - application will acknowledge delivered
107
* bundles with bp_ack()
111
enum al_bp_reg_flags_t {
115
BP_SESSION_CUSTODY = 4,
116
BP_SESSION_PUBLISH = 8,
117
BP_SESSION_SUBSCRIBE = 16,
118
BP_DELIVERY_ACKS = 32,
120
typedef enum al_bp_reg_flags_t al_bp_reg_flags_t;
122
* Value for an unspecified registration cookie (i.e. indication that
123
* the daemon should allocate a new unique id).
125
#define BP_REGID_NONE 0
128
* Bundle delivery option flags. Note that multiple options may be
129
* selected for a given bundle.
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
143
enum al_bp_bundle_delivery_opts_t {
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,
155
typedef enum al_bp_bundle_delivery_opts_t al_bp_bundle_delivery_opts_t;
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]
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,
173
typedef enum al_bp_bundle_priority_enum al_bp_bundle_priority_enum;
175
struct al_bp_bundle_priority_t {
176
al_bp_bundle_priority_enum priority;
179
typedef struct al_bp_bundle_priority_t al_bp_bundle_priority_t;
185
struct al_bp_extension_block_t {
193
typedef struct al_bp_extension_block_t al_bp_extension_block_t;
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.
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;
212
al_bp_extension_block_t *blocks_val;
216
al_bp_extension_block_t *metadata_val;
218
boolean_t unreliable;
222
typedef struct al_bp_bundle_spec_t al_bp_bundle_spec_t;
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'
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.
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.
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)
244
enum al_bp_bundle_payload_location_t {
247
BP_PAYLOAD_TEMP_FILE = 2,
249
typedef enum al_bp_bundle_payload_location_t al_bp_bundle_payload_location_t;
251
* Bundle Status Report "Reason Code" flags
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,
265
typedef enum al_bp_status_report_reason_t al_bp_status_report_reason_t;
267
* Bundle Status Report status flags that indicate which timestamps in
268
* the status report structure are valid.
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,
279
typedef enum al_bp_status_report_flags_t al_bp_status_report_flags_t;
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
289
struct al_bp_bundle_id_t {
290
al_bp_endpoint_id_t source;
291
al_bp_timestamp_t creation_ts;
296
typedef struct al_bp_bundle_id_t al_bp_bundle_id_t;
299
* Type definition for a bundle status report.
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;
313
typedef struct al_bp_bundle_status_report_t al_bp_bundle_status_report_t;
315
struct al_bp_bundle_payload_t {
316
al_bp_bundle_payload_location_t location;
326
al_bp_bundle_status_report_t *status_report;
328
typedef struct al_bp_bundle_payload_t al_bp_bundle_payload_t;
331
* AL BP API error codes
333
typedef enum al_bp_error_t
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*/
360
/****************************************************************
364
****************************************************************/
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;
372
typedef struct al_bp_bundle_object_t al_bp_bundle_object_t;
375
#endif /* BP_TYPES_H_ */