apps/dtnrespond/dtnrespond.c
changeset 66 e1101c5d54a1
parent 65 333724f2f7cf
child 67 cfe2328ba1c6
equal deleted inserted replaced
65:333724f2f7cf 66:e1101c5d54a1
    58     fprintf(stderr, "usage: %s -l < local endpoint > -f < matching filename > "
    58     fprintf(stderr, "usage: %s -l < local endpoint > -f < matching filename > "
    59                     "[opts]\n", progname);
    59                     "[opts]\n", progname);
    60     fprintf(stderr, "options:\n");
    60     fprintf(stderr, "options:\n");
    61     fprintf(stderr, " -n  < count > exit after count bundles received\n");
    61     fprintf(stderr, " -n  < count > exit after count bundles received\n");
    62     fprintf(stderr, " -r  < eid > reply to endpoint\n");
    62     fprintf(stderr, " -r  < eid > reply to endpoint\n");
    63     fprintf(stderr, " -e  < seconds > bundle expiry time\n");
       
    64     fprintf(stderr, " -i  < regid > existing registration id\n");
    63     fprintf(stderr, " -i  < regid > existing registration id\n");
    65     fprintf(stderr, " -E  < seconds > registration expiry time\n");
    64     fprintf(stderr, " -E  < seconds > registration expiry time\n");
    66     fprintf(stderr, " -A  < defer | drop | exec > failure action\n");
    65     fprintf(stderr, " -A  < defer | drop | exec > failure action\n");
    67     fprintf(stderr, " -S  < script > failure script for exec action\n");
    66     fprintf(stderr, " -S  < script > failure script for exec action\n");
    68     fprintf(stderr, " -P  < bulk | normal | expedited | reserved > priority\n");
    67     fprintf(stderr, " -P  < bulk | normal | expedited | reserved > priority\n");
    91 parse_options(int argc, char** argv,
    90 parse_options(int argc, char** argv,
    92     char * local_eid_name,              // l
    91     char * local_eid_name,              // l
    93     char * reply_eid_name,              // r
    92     char * reply_eid_name,              // r
    94     char * matching_filename,           // f
    93     char * matching_filename,           // f
    95     int * count,                        // n
    94     int * count,                        // n
    96     dtn_timeval_t * bundle_expiry,      // e
       
    97     dtn_reg_id_t * regid,               // i
    95     dtn_reg_id_t * regid,               // i
    98     dtn_timeval_t * reg_expiry,         // E
    96     dtn_timeval_t * reg_expiry,         // E
    99     int * reg_fail_action,              // A
    97     int * reg_fail_action,              // A
   100     char * reg_fail_script,             // S
    98     char * reg_fail_script,             // S
   101     dtn_bundle_priority_t * priority,   // P
    99     dtn_bundle_priority_t * priority,   // P
   112     memset(matching_filename, 0, sizeof(char) * PATH_MAX);
   110     memset(matching_filename, 0, sizeof(char) * PATH_MAX);
   113     memset(reg_fail_script,   0, sizeof(char) * PATH_MAX);
   111     memset(reg_fail_script,   0, sizeof(char) * PATH_MAX);
   114 
   112 
   115     while( !done )
   113     while( !done )
   116     {
   114     {
   117         c = getopt(argc, argv, "l:f:n:r:e:i:E:A:S:P:DXFRcC1NWvhH");
   115         c = getopt(argc, argv, "l:f:n:r:i:E:A:S:P:DXFRcC1NWvhH");
   118         switch(c)
   116         switch(c)
   119         {
   117         {
   120         case 'l':
   118         case 'l':
   121             strncpy(local_eid_name, optarg, PATH_MAX);
   119             strncpy(local_eid_name, optarg, PATH_MAX);
   122             break;
   120             break;
   126         case 'f':
   124         case 'f':
   127             strncpy(matching_filename, optarg, PATH_MAX);
   125             strncpy(matching_filename, optarg, PATH_MAX);
   128             break;
   126             break;
   129         case 'n':
   127         case 'n':
   130             *count = atoi(optarg);
   128             *count = atoi(optarg);
   131             break;
       
   132         case 'e':
       
   133             *bundle_expiry = atoi(optarg);
       
   134             break;
   129             break;
   135         case 'i':
   130         case 'i':
   136             *regid = atoi(optarg);
   131             *regid = atoi(optarg);
   137             break;
   132             break;
   138         case 'E':
   133         case 'E':
   215             exit(1);
   210             exit(1);
   216         }             
   211         }             
   217     }
   212     }
   218 
   213 
   219     // if no reply-to eid set, use the local eid
   214     // if no reply-to eid set, use the local eid
   220     if (*reply_eid_name == NULL)
   215     if (reply_eid_name == NULL)
   221         strncpy(reply_eid_name, local_eid_name, PATH_MAX);
   216         strncpy(reply_eid_name, local_eid_name, PATH_MAX);
   222 
   217 
   223     return DTN_SUCCESS;
   218     return DTN_SUCCESS;
   224 }
   219 }
   225 
   220 
   383 
   378 
   384     memset(out, 0, out_len);
   379     memset(out, 0, out_len);
   385 
   380 
   386     // move past any leading whitespace
   381     // move past any leading whitespace
   387     // by testing if the current char is in the whitespace string
   382     // by testing if the current char is in the whitespace string
   388     while ( i<strlen(in) && strchr(whitespace, in[i]) != NULL )
   383     in_len = strlen(in);
       
   384     while ( i<in_len && strchr(whitespace, in[i]) != NULL )
   389     	++i;
   385     	++i;
   390 
   386 
   391     in_len = strlen(&(in[i]));
   387     in_len = strlen(&(in[i]));
   392     if (in_len > out_len) {
   388     if (in_len > out_len) {
   393     	fprintf(stderr, "Error trimming whitespace, input string [%d] is longer"
   389     	fprintf(stderr, "Error trimming whitespace, input string [%d] is longer"
   411 * first move past any leading whitespace 
   407 * first move past any leading whitespace 
   412 * after the first non-whitespace char escape any whitespace
   408 * after the first non-whitespace char escape any whitespace
   413 * @return 0 on success or -1 if input not completely read
   409 * @return 0 on success or -1 if input not completely read
   414 *******************************************************************************/
   410 *******************************************************************************/
   415 int
   411 int
   416 escape_spaces(const char * in, char * out, int out_len)
   412 escape_spaces(const char * in, char * out, size_t out_len)
   417 {
   413 {
   418     int i=0, j=0;
   414     u_int i=0, j=0;
   419     char escape = '\\';
   415     char escape = '\\';
   420     char space = ' ';
   416     char space = ' ';
   421 
   417 
   422     memset(out, 0, out_len);
   418     memset(out, 0, out_len);
   423 
   419 
   478 match_bpq(const dtn_bpq_extension_block_data_t * bpq,
   474 match_bpq(const dtn_bpq_extension_block_data_t * bpq,
   479     const char * matching_filename,
   475     const char * matching_filename,
   480     u_int * response_kind,
   476     u_int * response_kind,
   481     char  * response_path,
   477     char  * response_path,
   482     int     response_path_len,
   478     int     response_path_len,
   483     int   * response_expiry,
   479     dtn_timeval_t * response_expiry,
   484     int   * found)
   480     int   * found)
   485 {
   481 {
   486     char line[PATH_MAX];
   482     char line[PATH_MAX];
   487     char trim_path[PATH_MAX];
   483     char trim_path[PATH_MAX];
   488     char * matching_rule;
   484     char * matching_rule;
   506     	}
   502     	}
   507 
   503 
   508     	if (strncmp(line, "#", 1) == 0)
   504     	if (strncmp(line, "#", 1) == 0)
   509     		continue;
   505     		continue;
   510 
   506 
   511     	matching_rule 	= strtok(line, ",");
   507     	// if a null pointer is returned, loop again to get to the next line
   512 		query 			= strtok(NULL, ",");
   508     	if ((matching_rule 	= strtok(line, ",")) == NULL) continue;
   513 		path 	        = strtok(NULL, ",");
   509     	if ((query 			= strtok(NULL, ",")) == NULL) continue;
   514 		kind  			= strtok(NULL, ",");
   510     	if ((path 	        = strtok(NULL, ",")) == NULL) continue;
   515 		expiry			= strtok(NULL, ",");
   511     	if ((kind  			= strtok(NULL, ",")) == NULL) continue;
       
   512     	if ((expiry			= strtok(NULL, ",")) == NULL) continue;
   516 
   513 
   517 
   514 
   518     	// match query
   515     	// match query
   519         if (atoi(matching_rule) != (int)bpq->matching_rule		||
   516         if (atoi(matching_rule) != (int)bpq->matching_rule		||
   520 			BPQ_MATCHING_RULE_EXACT != bpq->matching_rule		||
   517 			BPQ_MATCHING_RULE_EXACT != bpq->matching_rule		||
   530 
   527 
   531         // make sure the file exists
   528         // make sure the file exists
   532         if (response_path_exists(trim_path)) {
   529         if (response_path_exists(trim_path)) {
   533         	*found = 1;
   530         	*found = 1;
   534         	*response_kind = (u_int) atoi(kind);
   531         	*response_kind = (u_int) atoi(kind);
   535         	*response_expiry = atoi(response_expiry);
   532         	*response_expiry = (dtn_timeval_t) atoi(expiry);
   536         	strncpy(response_path, trim_path, response_path_len);
   533         	strncpy(response_path, trim_path, response_path_len);
   537 
   534 
   538 			break;
   535 			break;
   539         } else {
   536         } else {
   540         	continue;
   537         	continue;
   567 * @return The number of bytes or -1 on error
   564 * @return The number of bytes or -1 on error
   568 *******************************************************************************/
   565 *******************************************************************************/
   569 int
   566 int
   570 bpq_to_char_array(const dtn_bpq_extension_block_data_t * bpq,
   567 bpq_to_char_array(const dtn_bpq_extension_block_data_t * bpq,
   571     char* buf,
   568     char* buf,
   572     size_t buf_len,
   569     int buf_len,
   573     int verbose)
   570     int verbose)
   574 {
   571 {
   575     int i=0, j=0, k=0;
   572     int i=0, j=0;
       
   573 	u_int k=0;
   576     int q_encoding_len, f_encoding_len, encoding_len;
   574     int q_encoding_len, f_encoding_len, encoding_len;
   577     char encoding[PATH_MAX];
   575     u_char encoding[PATH_MAX];
   578 
   576 
   579     memset(buf, 0, buf_len);
   577     memset(buf, 0, buf_len);
   580 
   578 
   581     // BPQ-kind             1-byte
   579     // BPQ-kind             1-byte
   582     if (i < buf_len)    buf[i++] = (char) bpq->kind;
   580     if (i < buf_len)    buf[i++] = (char) bpq->kind;
   613 		for (j=0; i<buf_len && j<q_encoding_len; ++j)
   611 		for (j=0; i<buf_len && j<q_encoding_len; ++j)
   614 	        buf[i++] = encoding[j];
   612 	        buf[i++] = encoding[j];
   615 	}
   613 	}
   616 
   614 
   617     // Source EID n-bytes
   615     // Source EID n-bytes
   618     for (j=0; i<buf_len && j<bpq->original_id.source_len; ++j)
   616     for (j=0; i<buf_len && j<(int)bpq->original_id.source_len; ++j)
   619         buf[i++] = bpq->original_id.source.uri[j];
   617         buf[i++] = bpq->original_id.source.uri[j];
   620 
   618 
   621 
   619 
   622 
   620 
   623     // Query length (SDNV)
   621     // Query length (SDNV)
   629     	for (j=0; i<buf_len && j<q_encoding_len; ++j)
   627     	for (j=0; i<buf_len && j<q_encoding_len; ++j)
   630     		buf[i++] = encoding[j];
   628     		buf[i++] = encoding[j];
   631     }
   629     }
   632 
   630 
   633     // Query value n-bytes
   631     // Query value n-bytes
   634     for (j=0; i<buf_len && j<bpq->query.query_len; ++j)
   632     for (j=0; i<buf_len && j<(int)bpq->query.query_len; ++j)
   635         buf[i++] = bpq->query.query_val[j];
   633         buf[i++] = bpq->query.query_val[j];
   636 
   634 
   637 
   635 
   638 
   636 
   639     // number of fragments  SDNV
   637     // number of fragments  SDNV
   679         fprintf (stdout, "  creation ts seq: %d\n",
   677         fprintf (stdout, "  creation ts seq: %d\n",
   680         		 (int) bpq->original_id.creation_ts.seqno);
   678         		 (int) bpq->original_id.creation_ts.seqno);
   681         fprintf (stdout, "   source eid len: %d\n",
   679         fprintf (stdout, "   source eid len: %d\n",
   682         		 (int) bpq->original_id.source_len);
   680         		 (int) bpq->original_id.source_len);
   683         fprintf (stdout, "       source eid: %s\n",
   681         fprintf (stdout, "       source eid: %s\n",
   684         		 (int) bpq->original_id.source.uri);
   682         		 bpq->original_id.source.uri);
   685 
   683 
   686         fprintf (stdout, "        query len: %d\n", bpq->query.query_len);
   684         fprintf (stdout, "        query len: %d\n", bpq->query.query_len);
   687         fprintf (stdout, "   q_encoding_len: %d\n", q_encoding_len);
   685         fprintf (stdout, "   q_encoding_len: %d\n", q_encoding_len);
   688         fprintf (stdout, "        query val: %s\n", bpq->query.query_val);
   686         fprintf (stdout, "        query val: %s\n", bpq->query.query_val);
   689 
   687 
   714 *   Fragment lengths     		SDNV
   712 *   Fragment lengths     		SDNV
   715 *
   713 *
   716 * @return The number of bytes or -1 on error
   714 * @return The number of bytes or -1 on error
   717 *******************************************************************************/
   715 *******************************************************************************/
   718 int
   716 int
   719 char_array_to_bpq(const char* buf,
   717 char_array_to_bpq(const u_char* buf,
   720     size_t buf_len,
   718     int buf_len,
   721     dtn_bpq_extension_block_data_t * bpq,
   719     dtn_bpq_extension_block_data_t * bpq,
   722     int verbose)
   720     int verbose)
   723 {
   721 {
   724     int i=0, j=0;
   722     int i=0, j=0;
   725     int q_decoding_len, f_decoding_len, decoding_len;
   723     int q_decoding_len, f_decoding_len, decoding_len;
   751     i += q_decoding_len;
   749     i += q_decoding_len;
   752 
   750 
   753     // Source EID length     SDNV
   751     // Source EID length     SDNV
   754     if ( (q_decoding_len = sdnv_decode (&(buf[i]),
   752     if ( (q_decoding_len = sdnv_decode (&(buf[i]),
   755     									buf_len - i,
   753     									buf_len - i,
   756     									&(bpq->original_id.source_len))) == -1 ) {
   754     									(u_int64_t*)&(bpq->original_id.source_len))) == -1 ) {
   757         fprintf (stderr, "Error decoding source EID length\n");
   755         fprintf (stderr, "Error decoding source EID length\n");
   758         return -1;
   756         return -1;
   759     }
   757     }
   760     i += q_decoding_len;
   758     i += q_decoding_len;
   761 
   759 
   762     // Source EID            n-bytes
   760     // Source EID            n-bytes
   763     if (i<buf_len && bpq->original_id.source_len <= DTN_MAX_ENDPOINT_ID) {
   761     if (i<buf_len && bpq->original_id.source_len <= DTN_MAX_ENDPOINT_ID) {
   764     	strncpy(bpq->original_id.source.uri, &(buf[i]), bpq->original_id.source_len);
   762     	strncpy(bpq->original_id.source.uri, (char*)&(buf[i]), bpq->original_id.source_len);
   765     	i += bpq->original_id.source_len;
   763     	i += bpq->original_id.source_len;
   766     } else {
   764     } else {
   767     	fprintf (stderr, "Error copying source EID\n");
   765     	fprintf (stderr, "Error copying source EID\n");
   768 		return -1;
   766 		return -1;
   769     }
   767     }
   771 
   769 
   772 
   770 
   773     // BPQ-value-length     SDNV
   771     // BPQ-value-length     SDNV
   774     if ( (q_decoding_len = sdnv_decode (&(buf[i]),
   772     if ( (q_decoding_len = sdnv_decode (&(buf[i]),
   775     									buf_len - i,
   773     									buf_len - i,
   776     									&(bpq->query.query_len))) == -1 ) {
   774     									(u_int64_t*)&(bpq->query.query_len))) == -1 ) {
   777         fprintf (stderr, "Error decoding BPQ-value-length\n");
   775         fprintf (stderr, "Error decoding BPQ-value-length\n");
   778         return -1;
   776         return -1;
   779     }
   777     }
   780     i += q_decoding_len;
   778     i += q_decoding_len;
   781 
   779 
   782     // BPQ-value            n-bytes
   780     // BPQ-value            n-bytes
   783     if (i<buf_len) bpq->query.query_val = &(buf[i]);
   781     if (i<buf_len) bpq->query.query_val = (char*)&(buf[i]);
   784     	i += bpq->query.query_len;
   782     	i += bpq->query.query_len;
   785 
   783 
   786 
   784 
   787     // number of fragments  SDNV
   785     // number of fragments  SDNV
   788     if ( (f_decoding_len = sdnv_decode (&(buf[i]),
   786     if ( (f_decoding_len = sdnv_decode (&(buf[i]),
   789     									buf_len - i,
   787     									buf_len - i,
   790     									&(bpq->fragments.num_frag_returned))) == -1 ) {
   788     									(u_int64_t*)&(bpq->fragments.num_frag_returned))) == -1 ) {
   791         fprintf (stderr, "Error decoding number of fragments\n");
   789         fprintf (stderr, "Error decoding number of fragments\n");
   792         return -1;
   790         return -1;
   793     }
   791     }
   794     i += f_decoding_len;
   792     i += f_decoding_len;
   795 
   793 
   796     for (j=0; i<buf_len && j<bpq->fragments.num_frag_returned; ++j) {
   794     for (j=0; i<buf_len && j<(int)bpq->fragments.num_frag_returned; ++j) {
   797 
   795 
   798         // fragment offsets     SDNV
   796         // fragment offsets     SDNV
   799         if ( (decoding_len = sdnv_decode (&(buf[i]),
   797         if ( (decoding_len = sdnv_decode (&(buf[i]),
   800         								  buf_len - i,
   798         								  buf_len - i,
   801         								  &(bpq->fragments.frag_offsets[j]))) == -1 ) {
   799         								  (u_int64_t*)&(bpq->fragments.frag_offsets[j]))) == -1 ) {
   802             fprintf (stderr, "Error decoding fragment[%d] offset\n", j);
   800             fprintf (stderr, "Error decoding fragment[%d] offset\n", j);
   803             return -1;
   801             return -1;
   804         }
   802         }
   805         i += decoding_len;
   803         i += decoding_len;
   806 
   804 
   807         // fragment lengths     SDNV
   805         // fragment lengths     SDNV
   808         if ( (decoding_len = sdnv_decode (&(buf[i]),
   806         if ( (decoding_len = sdnv_decode (&(buf[i]),
   809         								  buf_len - i,
   807         								  buf_len - i,
   810         								  &(bpq->fragments.frag_lenghts[j]))) == -1 ) {
   808         								  (u_int64_t*)&(bpq->fragments.frag_lenghts[j]))) == -1 ) {
   811             fprintf (stderr, "Error decoding fragment[%d] length\n", j);
   809             fprintf (stderr, "Error decoding fragment[%d] length\n", j);
   812             return -1;
   810             return -1;
   813         }
   811         }
   814         i += decoding_len;
   812         i += decoding_len;
   815     }
   813     }
   827         fprintf (stdout, "  creation ts seq: %d\n",
   825         fprintf (stdout, "  creation ts seq: %d\n",
   828         		 (int) bpq->original_id.creation_ts.seqno);
   826         		 (int) bpq->original_id.creation_ts.seqno);
   829         fprintf (stdout, "   source eid len: %d\n",
   827         fprintf (stdout, "   source eid len: %d\n",
   830         		 (int) bpq->original_id.source_len);
   828         		 (int) bpq->original_id.source_len);
   831         fprintf (stdout, "       source eid: %s\n",
   829         fprintf (stdout, "       source eid: %s\n",
   832         		 (int) bpq->original_id.source.uri);
   830         		 bpq->original_id.source.uri);
   833 
   831 
   834         fprintf (stdout, "        query len: %d\n", bpq->query.query_len);
   832         fprintf (stdout, "        query len: %d\n", bpq->query.query_len);
   835         fprintf (stdout, "   q_decoding_len: %d\n", q_decoding_len);
   833         fprintf (stdout, "   q_decoding_len: %d\n", q_decoding_len);
   836         fprintf (stdout, "        query val: %s\n", bpq->query.query_val);
   834         fprintf (stdout, "        query val: %s\n", bpq->query.query_val);
   837 
   835 
   852 int
   850 int
   853 send_response_bpq(dtn_handle_t * handle,
   851 send_response_bpq(dtn_handle_t * handle,
   854     dtn_reg_id_t regid,
   852     dtn_reg_id_t regid,
   855     u_int response_kind,
   853     u_int response_kind,
   856     dtn_bundle_spec_t * query_bundle_spec,
   854     dtn_bundle_spec_t * query_bundle_spec,
   857     const dtn_endpoint_id_t * reply_eid,
   855     dtn_endpoint_id_t * reply_eid,
   858     dtn_bpq_extension_block_data_t * query_bpq_block_data,
   856     dtn_bpq_extension_block_data_t * query_bpq_block_data,
   859     const char * pathname,
   857     char * pathname,
   860     int bundle_expiry,
   858     dtn_timeval_t bundle_expiry,
   861     dtn_bundle_priority_t  priority,
   859     dtn_bundle_priority_t  priority,
   862     int delivery_options,
   860     int delivery_options,
   863     int verbose)
   861     int verbose)
   864 {
   862 {
   865     int  ret = 0;
   863     int  ret = 0;
   866     char buf [PATH_MAX];
   864     char buf [PATH_MAX];
   867     size_t buf_len = 0;
   865     int buf_len = 0;
   868     dtn_bundle_id_t                 response_bundle_id;
   866     dtn_bundle_id_t                 response_bundle_id;
   869     dtn_bundle_spec_t               response_bundle_spec;
   867     dtn_bundle_spec_t               response_bundle_spec;
   870     dtn_extension_block_t           response_bpq_block;
   868     dtn_extension_block_t           response_bpq_block;
   871     dtn_bpq_extension_block_data_t  response_bpq_block_data;
   869     dtn_bpq_extension_block_data_t  response_bpq_block_data;
   872     dtn_bundle_payload_t            response_payload;
   870     dtn_bundle_payload_t            response_payload;
   914 
   912 
   915     // send the bundle, bpq extension and empty payload
   913     // send the bundle, bpq extension and empty payload
   916     ret = dtn_send(*handle, regid, &response_bundle_spec, &response_payload, &response_bundle_id);
   914     ret = dtn_send(*handle, regid, &response_bundle_spec, &response_payload, &response_bundle_id);
   917     if (ret != DTN_SUCCESS) {
   915     if (ret != DTN_SUCCESS) {
   918         fprintf(stderr, "error sending response bundle: %d (%s)\n",
   916         fprintf(stderr, "error sending response bundle: %d (%s)\n",
   919                     ret, dtn_strerror(dtn_errno(handle)));
   917                     ret, dtn_strerror(dtn_errno(*handle)));
   920     } else if (verbose) {
   918     } else if (verbose) {
   921         fprintf(stdout, "bundle sent successfully: id %s,%llu.%llu\n",
   919         fprintf(stdout, "bundle sent successfully: id %s,%llu.%llu\n",
   922                     response_bundle_id.source.uri,
   920                     response_bundle_id.source.uri,
   923                     response_bundle_id.creation_ts.secs,
   921                     response_bundle_id.creation_ts.secs,
   924                     response_bundle_id.creation_ts.seqno);
   922                     response_bundle_id.creation_ts.seqno);
   935 * source of the query.
   933 * source of the query.
   936 *******************************************************************************/
   934 *******************************************************************************/
   937 int
   935 int
   938 receive_bpq(dtn_handle_t * handle,
   936 receive_bpq(dtn_handle_t * handle,
   939     dtn_reg_id_t regid,
   937     dtn_reg_id_t regid,
   940     const dtn_endpoint_id_t * reply_eid,
   938     dtn_endpoint_id_t * reply_eid,
   941     const char * matching_filename,
   939     const char * matching_filename,
   942     int  count,
   940     int  count,
   943     int bundle_expiry,
       
   944     dtn_bundle_priority_t  priority,
   941     dtn_bundle_priority_t  priority,
   945     int delivery_options,
   942     int delivery_options,
   946     int verbose)
   943     int verbose)
   947 {
   944 {
   948     int i, j, num_blocks, found, ret = 0;
   945     int i, j, num_blocks, found, ret = 0;
       
   946     dtn_timeval_t bundle_expiry = 3600; // default one hour
   949     u_int response_kind;
   947     u_int response_kind;
   950     char pathname[PATH_MAX];
   948     char pathname[PATH_MAX];
   951     dtn_bundle_spec_t              bundle_spec;
   949     dtn_bundle_spec_t              bundle_spec;
   952     dtn_extension_block_t          * bpq_blocks;
   950     dtn_extension_block_t          * bpq_blocks;
   953     dtn_bpq_extension_block_data_t bpq_block_data;
   951     dtn_bpq_extension_block_data_t bpq_block_data;
   988             if (bpq_blocks[j].type == DTN_BPQ_BLOCK_TYPE) {
   986             if (bpq_blocks[j].type == DTN_BPQ_BLOCK_TYPE) {
   989 
   987 
   990                 if (verbose) fprintf(stdout, "bundle %d contains a "
   988                 if (verbose) fprintf(stdout, "bundle %d contains a "
   991                                              "BPQ extension block\n", i);
   989                                              "BPQ extension block\n", i);
   992 
   990 
   993                 ret = char_array_to_bpq(bpq_blocks[j].data.data_val, 
   991                 ret = char_array_to_bpq((u_char*)bpq_blocks[j].data.data_val,
   994                                         bpq_blocks[j].data.data_len, 
   992                                         bpq_blocks[j].data.data_len, 
   995                                         &bpq_block_data,
   993                                         &bpq_block_data,
   996 					verbose);
   994                                         verbose);
   997                 if (ret != DTN_SUCCESS) {
   995                 if (ret != DTN_SUCCESS) {
   998                     fprintf(stderr, "error decoding query bundle: %d\n", ret);
   996                     fprintf(stderr, "error decoding query bundle: %d\n", ret);
   999                     return ret;
   997                     return ret;
  1000                 }
   998                 }
  1001 
   999 
  1050     dtn_endpoint_id_t reply_eid;
  1048     dtn_endpoint_id_t reply_eid;
  1051     char local_eid_name[PATH_MAX];
  1049     char local_eid_name[PATH_MAX];
  1052     char reply_eid_name[PATH_MAX];
  1050     char reply_eid_name[PATH_MAX];
  1053     char matching_filename[PATH_MAX];
  1051     char matching_filename[PATH_MAX];
  1054     int count = 0;                                      //forever
  1052     int count = 0;                                      //forever
  1055     dtn_timeval_t bundle_expiry = 3600;                 //one hour
       
  1056     dtn_reg_id_t regid = DTN_REGID_NONE;
  1053     dtn_reg_id_t regid = DTN_REGID_NONE;
  1057     dtn_timeval_t reg_expiry = 30;
  1054     dtn_timeval_t reg_expiry = 30;
  1058     int reg_fail_action = DTN_REG_DEFER;
  1055     int reg_fail_action = DTN_REG_DEFER;
  1059     char reg_fail_script[PATH_MAX]; 
  1056     char reg_fail_script[PATH_MAX]; 
  1060     dtn_bundle_priority_t priority = COS_NORMAL;
  1057     dtn_bundle_priority_t priority = COS_NORMAL;
  1066     parse_options(argc, argv,
  1063     parse_options(argc, argv,
  1067         local_eid_name,
  1064         local_eid_name,
  1068         reply_eid_name,
  1065         reply_eid_name,
  1069         matching_filename,
  1066         matching_filename,
  1070         &count,
  1067         &count,
  1071         &bundle_expiry,
       
  1072         &regid,
  1068         &regid,
  1073         &reg_expiry,
  1069         &reg_expiry,
  1074         &reg_fail_action,
  1070         &reg_fail_action,
  1075         reg_fail_script,
  1071         reg_fail_script,
  1076         &priority,
  1072         &priority,
  1109     receive_bpq(&handle,
  1105     receive_bpq(&handle,
  1110         regid,
  1106         regid,
  1111         &reply_eid,
  1107         &reply_eid,
  1112         matching_filename,
  1108         matching_filename,
  1113         count,
  1109         count,
  1114         bundle_expiry,
       
  1115         priority,
  1110         priority,
  1116         delivery_options,
  1111         delivery_options,
  1117         verbose);
  1112         verbose);
  1118 
  1113 
  1119 // UNREACHABLE CODE if count = 0 //////////////////////////////////////////////
  1114 // UNREACHABLE CODE if count = 0 //////////////////////////////////////////////