diff -r 333724f2f7cf -r e1101c5d54a1 apps/dtnrespond/dtnrespond.c --- a/apps/dtnrespond/dtnrespond.c Wed Oct 26 13:33:11 2011 +0100 +++ b/apps/dtnrespond/dtnrespond.c Fri Jan 06 17:28:36 2012 +0000 @@ -60,7 +60,6 @@ fprintf(stderr, "options:\n"); fprintf(stderr, " -n < count > exit after count bundles received\n"); fprintf(stderr, " -r < eid > reply to endpoint\n"); - fprintf(stderr, " -e < seconds > bundle expiry time\n"); fprintf(stderr, " -i < regid > existing registration id\n"); fprintf(stderr, " -E < seconds > registration expiry time\n"); fprintf(stderr, " -A < defer | drop | exec > failure action\n"); @@ -93,7 +92,6 @@ char * reply_eid_name, // r char * matching_filename, // f int * count, // n - dtn_timeval_t * bundle_expiry, // e dtn_reg_id_t * regid, // i dtn_timeval_t * reg_expiry, // E int * reg_fail_action, // A @@ -114,7 +112,7 @@ while( !done ) { - c = getopt(argc, argv, "l:f:n:r:e:i:E:A:S:P:DXFRcC1NWvhH"); + c = getopt(argc, argv, "l:f:n:r:i:E:A:S:P:DXFRcC1NWvhH"); switch(c) { case 'l': @@ -129,9 +127,6 @@ case 'n': *count = atoi(optarg); break; - case 'e': - *bundle_expiry = atoi(optarg); - break; case 'i': *regid = atoi(optarg); break; @@ -217,7 +212,7 @@ } // if no reply-to eid set, use the local eid - if (*reply_eid_name == NULL) + if (reply_eid_name == NULL) strncpy(reply_eid_name, local_eid_name, PATH_MAX); return DTN_SUCCESS; @@ -385,7 +380,8 @@ // move past any leading whitespace // by testing if the current char is in the whitespace string - while ( ioriginal_id.source_len; ++j) + for (j=0; ioriginal_id.source_len; ++j) buf[i++] = bpq->original_id.source.uri[j]; @@ -631,7 +629,7 @@ } // Query value n-bytes - for (j=0; iquery.query_len; ++j) + for (j=0; iquery.query_len; ++j) buf[i++] = bpq->query.query_val[j]; @@ -681,7 +679,7 @@ fprintf (stdout, " source eid len: %d\n", (int) bpq->original_id.source_len); fprintf (stdout, " source eid: %s\n", - (int) bpq->original_id.source.uri); + bpq->original_id.source.uri); fprintf (stdout, " query len: %d\n", bpq->query.query_len); fprintf (stdout, " q_encoding_len: %d\n", q_encoding_len); @@ -716,8 +714,8 @@ * @return The number of bytes or -1 on error *******************************************************************************/ int -char_array_to_bpq(const char* buf, - size_t buf_len, +char_array_to_bpq(const u_char* buf, + int buf_len, dtn_bpq_extension_block_data_t * bpq, int verbose) { @@ -753,7 +751,7 @@ // Source EID length SDNV if ( (q_decoding_len = sdnv_decode (&(buf[i]), buf_len - i, - &(bpq->original_id.source_len))) == -1 ) { + (u_int64_t*)&(bpq->original_id.source_len))) == -1 ) { fprintf (stderr, "Error decoding source EID length\n"); return -1; } @@ -761,7 +759,7 @@ // Source EID n-bytes if (ioriginal_id.source_len <= DTN_MAX_ENDPOINT_ID) { - strncpy(bpq->original_id.source.uri, &(buf[i]), bpq->original_id.source_len); + strncpy(bpq->original_id.source.uri, (char*)&(buf[i]), bpq->original_id.source_len); i += bpq->original_id.source_len; } else { fprintf (stderr, "Error copying source EID\n"); @@ -773,32 +771,32 @@ // BPQ-value-length SDNV if ( (q_decoding_len = sdnv_decode (&(buf[i]), buf_len - i, - &(bpq->query.query_len))) == -1 ) { + (u_int64_t*)&(bpq->query.query_len))) == -1 ) { fprintf (stderr, "Error decoding BPQ-value-length\n"); return -1; } i += q_decoding_len; // BPQ-value n-bytes - if (iquery.query_val = &(buf[i]); + if (iquery.query_val = (char*)&(buf[i]); i += bpq->query.query_len; // number of fragments SDNV if ( (f_decoding_len = sdnv_decode (&(buf[i]), buf_len - i, - &(bpq->fragments.num_frag_returned))) == -1 ) { + (u_int64_t*)&(bpq->fragments.num_frag_returned))) == -1 ) { fprintf (stderr, "Error decoding number of fragments\n"); return -1; } i += f_decoding_len; - for (j=0; ifragments.num_frag_returned; ++j) { + for (j=0; ifragments.num_frag_returned; ++j) { // fragment offsets SDNV if ( (decoding_len = sdnv_decode (&(buf[i]), buf_len - i, - &(bpq->fragments.frag_offsets[j]))) == -1 ) { + (u_int64_t*)&(bpq->fragments.frag_offsets[j]))) == -1 ) { fprintf (stderr, "Error decoding fragment[%d] offset\n", j); return -1; } @@ -807,7 +805,7 @@ // fragment lengths SDNV if ( (decoding_len = sdnv_decode (&(buf[i]), buf_len - i, - &(bpq->fragments.frag_lenghts[j]))) == -1 ) { + (u_int64_t*)&(bpq->fragments.frag_lenghts[j]))) == -1 ) { fprintf (stderr, "Error decoding fragment[%d] length\n", j); return -1; } @@ -829,7 +827,7 @@ fprintf (stdout, " source eid len: %d\n", (int) bpq->original_id.source_len); fprintf (stdout, " source eid: %s\n", - (int) bpq->original_id.source.uri); + bpq->original_id.source.uri); fprintf (stdout, " query len: %d\n", bpq->query.query_len); fprintf (stdout, " q_decoding_len: %d\n", q_decoding_len); @@ -854,17 +852,17 @@ dtn_reg_id_t regid, u_int response_kind, dtn_bundle_spec_t * query_bundle_spec, - const dtn_endpoint_id_t * reply_eid, + dtn_endpoint_id_t * reply_eid, dtn_bpq_extension_block_data_t * query_bpq_block_data, - const char * pathname, - int bundle_expiry, + char * pathname, + dtn_timeval_t bundle_expiry, dtn_bundle_priority_t priority, int delivery_options, int verbose) { int ret = 0; char buf [PATH_MAX]; - size_t buf_len = 0; + int buf_len = 0; dtn_bundle_id_t response_bundle_id; dtn_bundle_spec_t response_bundle_spec; dtn_extension_block_t response_bpq_block; @@ -916,7 +914,7 @@ ret = dtn_send(*handle, regid, &response_bundle_spec, &response_payload, &response_bundle_id); if (ret != DTN_SUCCESS) { fprintf(stderr, "error sending response bundle: %d (%s)\n", - ret, dtn_strerror(dtn_errno(handle))); + ret, dtn_strerror(dtn_errno(*handle))); } else if (verbose) { fprintf(stdout, "bundle sent successfully: id %s,%llu.%llu\n", response_bundle_id.source.uri, @@ -937,15 +935,15 @@ int receive_bpq(dtn_handle_t * handle, dtn_reg_id_t regid, - const dtn_endpoint_id_t * reply_eid, + dtn_endpoint_id_t * reply_eid, const char * matching_filename, int count, - int bundle_expiry, dtn_bundle_priority_t priority, int delivery_options, int verbose) { int i, j, num_blocks, found, ret = 0; + dtn_timeval_t bundle_expiry = 3600; // default one hour u_int response_kind; char pathname[PATH_MAX]; dtn_bundle_spec_t bundle_spec; @@ -990,10 +988,10 @@ if (verbose) fprintf(stdout, "bundle %d contains a " "BPQ extension block\n", i); - ret = char_array_to_bpq(bpq_blocks[j].data.data_val, + ret = char_array_to_bpq((u_char*)bpq_blocks[j].data.data_val, bpq_blocks[j].data.data_len, &bpq_block_data, - verbose); + verbose); if (ret != DTN_SUCCESS) { fprintf(stderr, "error decoding query bundle: %d\n", ret); return ret; @@ -1052,7 +1050,6 @@ char reply_eid_name[PATH_MAX]; char matching_filename[PATH_MAX]; int count = 0; //forever - dtn_timeval_t bundle_expiry = 3600; //one hour dtn_reg_id_t regid = DTN_REGID_NONE; dtn_timeval_t reg_expiry = 30; int reg_fail_action = DTN_REG_DEFER; @@ -1068,7 +1065,6 @@ reply_eid_name, matching_filename, &count, - &bundle_expiry, ®id, ®_expiry, ®_fail_action, @@ -1111,7 +1107,6 @@ &reply_eid, matching_filename, count, - bundle_expiry, priority, delivery_options, verbose);