# HG changeset patch # User aidan # Date 1312378509 -3600 # Node ID 406d4f7eb00d7e8b4b1ad0db0d47b71a850eb477 # Parent 28b7fb13e35df4121bcd0e9a804c14c44b9b563e moved BPQ app consts to header file and set the BPQ Block flag to add block to each fragment diff -r 28b7fb13e35d -r 406d4f7eb00d applib/dtn_types.h --- a/applib/dtn_types.h Thu Jun 30 15:32:09 2011 +0100 +++ b/applib/dtn_types.h Wed Aug 03 14:35:09 2011 +0100 @@ -235,6 +235,30 @@ typedef enum dtn_extension_block_flags_t dtn_extension_block_flags_t; /** + * BPQ Extension block kind. + * + * BPQ_BLOCK_KIND_QUERY + * BPQ_BLOCK_KIND_RESPONSE + */ + +enum dtn_bpq_extension_block_kind_t { + BPQ_BLOCK_KIND_QUERY = 0, + BPQ_BLOCK_KIND_RESPONSE = 1, +}; +typedef enum dtn_bpq_extension_block_kind_t dtn_bpq_extension_block_kind_t; + +/** + * BPQ Extension block matching rule. (More may be added later) + * + * BPQ_MATCHING_RULE_EXACT + */ + +enum dtn_bpq_extension_block_matching_rule_t { + BPQ_MATCHING_RULE_EXACT = 1, +}; +typedef enum dtn_bpq_extension_block_matching_rule_t dtn_bpq_extension_block_matching_rule_t; + +/** * Extension block. */ @@ -424,6 +448,8 @@ extern bool_t xdr_dtn_bundle_delivery_opts_t (XDR *, dtn_bundle_delivery_opts_t*); extern bool_t xdr_dtn_extension_block_flags_t (XDR *, dtn_extension_block_flags_t*); extern bool_t xdr_dtn_extension_block_t (XDR *, dtn_extension_block_t*); +extern bool_t xdr_dtn_bpq_extension_block_kind_t (XDR *, dtn_bpq_extension_block_kind_t*); +extern bool_t xdr_dtn_bpq_extension_block_matching_rule_t (XDR *, dtn_bpq_extension_block_matching_rule_t*); extern bool_t xdr_dtn_bpq_extension_block_data_t (XDR *, dtn_bpq_extension_block_data_t*); extern bool_t xdr_dtn_sequence_id_t (XDR *, dtn_sequence_id_t*); extern bool_t xdr_dtn_bundle_spec_t (XDR *, dtn_bundle_spec_t*); @@ -446,6 +472,8 @@ extern bool_t xdr_dtn_bundle_delivery_opts_t (); extern bool_t xdr_dtn_extension_block_flags_t (); extern bool_t xdr_dtn_extension_block_t (); +extern bool_t xdr_dtn_bpq_extension_block_kind_t (); +extern bool_t xdr_dtn_bpq_extension_block_matching_rule_t (); extern bool_t xdr_dtn_bpq_extension_block_data_t (); extern bool_t xdr_dtn_sequence_id_t (); extern bool_t xdr_dtn_bundle_spec_t (); diff -r 28b7fb13e35d -r 406d4f7eb00d applib/dtn_types.x --- a/applib/dtn_types.x Thu Jun 30 15:32:09 2011 +0100 +++ b/applib/dtn_types.x Wed Aug 03 14:35:09 2011 +0100 @@ -221,6 +221,26 @@ BLOCK_FLAG_UNPROCESSED = 32 }; +%/** +% * BPQ Extension block kind. +% * +% * BPQ_BLOCK_KIND_QUERY +% * BPQ_BLOCK_KIND_RESPONSE +% */ +enum dtn_bpq_extension_block_kind_t { + BPQ_BLOCK_KIND_QUERY = 0, + BPQ_BLOCK_KIND_RESPONSE = 1 +}; + +%/** +% * BPQ Extension block matching rule. (More may be added later) +% * +% * BPQ_MATCHING_RULE_EXACT +% */ +enum dtn_bpq_extension_block_matching_rule_t { + BPQ_MATCHING_RULE_EXACT = 1 +}; + % %/** % * Extension block. diff -r 28b7fb13e35d -r 406d4f7eb00d apps/dtnquery/dtnquery.c --- a/apps/dtnquery/dtnquery.c Thu Jun 30 15:32:09 2011 +0100 +++ b/apps/dtnquery/dtnquery.c Wed Aug 03 14:35:09 2011 +0100 @@ -39,17 +39,11 @@ #define DTN_BPQ_BASE64 2 #define DTN_BPQ_FILE 3 -#define DTN_BPQ_EXACT 1 - #define DTN_BPQ_SEND 1 #define DTN_BPQ_RECV 2 #define DTN_BPQ_SEND_RECV 3 #define DTN_BPQ_BLOCK_TYPE 0xC8 -#define DTN_BPQ_BLOCK_FLAGS 0x00 - -#define DTN_BPQ_KIND_QUERY 0x00 -#define DTN_BPQ_KIND_RESPONSE 0x01 // Find the maximum commandline length #ifdef __FreeBSD__ @@ -249,7 +243,7 @@ } case 'u': if (!strcasecmp(optarg, "exact")) { - *matching_rule = DTN_BPQ_EXACT; + *matching_rule = BPQ_MATCHING_RULE_EXACT; break; } else { fprintf(stderr, "invalid query type '%s'\n", optarg); @@ -440,7 +434,8 @@ query_type == DTN_BPQ_BASE64 || query_type == DTN_BPQ_FILE, "-t invalid type\n"); - REQUIRE(matching_rule == DTN_BPQ_EXACT, "-u invalid rule\n"); + REQUIRE(matching_rule == BPQ_MATCHING_RULE_EXACT, + "-u invalid rule\n"); REQUIRE(bundle_expiry > 0, "-e must be a positive integer\n"); #undef REQUIRE //todo: check this is ok @@ -780,7 +775,7 @@ memset(&payload, 0, sizeof(dtn_bundle_payload_t)); // set the bpq block data - bpq_block_data.kind = DTN_BPQ_KIND_QUERY; + bpq_block_data.kind = BPQ_BLOCK_KIND_QUERY; bpq_block_data.matching_rule = matching_rule; bpq_block_data.query.query_len = strlen(query) + 1; // include the null char at the end bpq_block_data.query.query_val = query; @@ -792,7 +787,7 @@ // set the bpq block bpq_block.type = DTN_BPQ_BLOCK_TYPE; - bpq_block.flags = DTN_BPQ_BLOCK_FLAGS; + bpq_block.flags = BLOCK_FLAG_REPLICATE; bpq_block.data.data_len = buf_len; bpq_block.data.data_val = buf; @@ -949,7 +944,7 @@ char filename[PATH_MAX]; char query[PATH_MAX]; int query_type = DTN_BPQ_LITERAL; - int matching_rule = DTN_BPQ_EXACT; + int matching_rule = BPQ_MATCHING_RULE_EXACT; int mode = DTN_BPQ_SEND_RECV; int count = 1; dtn_timeval_t timeout = DTN_TIMEOUT_INF; //forever diff -r 28b7fb13e35d -r 406d4f7eb00d apps/dtnrespond/dtnrespond.c --- a/apps/dtnrespond/dtnrespond.c Thu Jun 30 15:32:09 2011 +0100 +++ b/apps/dtnrespond/dtnrespond.c Wed Aug 03 14:35:09 2011 +0100 @@ -35,10 +35,6 @@ #define COUNTER_MAX_DIGITS 9 #define DTN_BPQ_BLOCK_TYPE 0xC8 -#define DTN_BPQ_BLOCK_FLAGS 0x00 - -#define DTN_BPQ_KIND_QUERY 0x00 -#define DTN_BPQ_KIND_RESPONSE 0x01 // Find the maximum commandline length #ifdef __FreeBSD__ @@ -727,7 +723,7 @@ dtn_set_payload(&response_payload, DTN_PAYLOAD_FILE, pathname, strlen(pathname)); // set the bpq block data - response_bpq_block_data.kind = DTN_BPQ_KIND_RESPONSE; + response_bpq_block_data.kind = BPQ_BLOCK_KIND_RESPONSE; response_bpq_block_data.matching_rule = query_bpq_block_data->matching_rule; response_bpq_block_data.query.query_len = query_bpq_block_data->query.query_len; response_bpq_block_data.query.query_val = query_bpq_block_data->query.query_val; @@ -747,7 +743,7 @@ // set the bpq block response_bpq_block.type = DTN_BPQ_BLOCK_TYPE; - response_bpq_block.flags = DTN_BPQ_BLOCK_FLAGS; + response_bpq_block.flags = BLOCK_FLAG_REPLICATE; response_bpq_block.data.data_len = buf_len; response_bpq_block.data.data_val = buf; diff -r 28b7fb13e35d -r 406d4f7eb00d servlib/bundling/BundleDaemon.cc --- a/servlib/bundling/BundleDaemon.cc Thu Jun 30 15:32:09 2011 +0100 +++ b/servlib/bundling/BundleDaemon.cc Wed Aug 03 14:35:09 2011 +0100 @@ -916,7 +916,7 @@ } - // If the even source is PEER, APP or STORE, + // If the even source is PEER or STORE, // try to handle a BPQ block if ( event->source_ == EVENTSRC_PEER || event->source_ == EVENTSRC_STORE ) {