apps/dtnquery/dtnquery.c
changeset 23 18b4c80456cf
parent 20 7fd5f0de6c59
child 28 406d4f7eb00d
equal deleted inserted replaced
22:3c36683e13be 23:18b4c80456cf
   841     char * filename,
   841     char * filename,
   842     int count,
   842     int count,
   843     int verbose)
   843     int verbose)
   844 {
   844 {
   845     int ret = 0, err = 0, num_blocks, i, j;
   845     int ret = 0, err = 0, num_blocks, i, j;
       
   846     int has_bpq_block = 0;
   846     dtn_bundle_spec_t               bundle_spec;
   847     dtn_bundle_spec_t               bundle_spec;
   847     dtn_extension_block_t*          bpq_blocks;
   848     dtn_extension_block_t*          bpq_blocks;
   848     dtn_bpq_extension_block_data_t  bpq_block_data;
   849     dtn_bpq_extension_block_data_t  bpq_block_data;
   849     dtn_bundle_payload_t            payload;
   850     dtn_bundle_payload_t            payload;
   850 
   851 
   866             fprintf(stdout, "bundle num %d received successfully: id %s,%llu.%llu\n",
   867             fprintf(stdout, "bundle num %d received successfully: id %s,%llu.%llu\n",
   867                              j+1,
   868                              j+1,
   868                              bundle_spec.source.uri,
   869                              bundle_spec.source.uri,
   869                              bundle_spec.creation_ts.secs,
   870                              bundle_spec.creation_ts.secs,
   870                              bundle_spec.creation_ts.seqno);
   871                              bundle_spec.creation_ts.seqno);
       
   872 
       
   873             fprintf(stdout, "Source: %s\n", bundle_spec.source.uri);
       
   874             fprintf(stdout, "Destination: %s\n", bundle_spec.dest.uri);
       
   875             fprintf(stdout, "Reply-To: %s\n", bundle_spec.replyto.uri);
   871         }
   876         }
   872 
   877 
   873         // extract the bpq
   878         // extract the bpq
   874         num_blocks = bundle_spec.blocks.blocks_len;
   879         num_blocks = bundle_spec.blocks.blocks_len;
   875         bpq_blocks = bundle_spec.blocks.blocks_val;
   880         bpq_blocks = bundle_spec.blocks.blocks_val;
   876 
   881 
   877         for (i = 0; i < num_blocks; ++i) {
   882         for (i = 0; i < num_blocks; ++i) {
   878             if (bpq_blocks[i].type == DTN_BPQ_BLOCK_TYPE) {
   883             if (bpq_blocks[i].type == DTN_BPQ_BLOCK_TYPE) {
       
   884                 has_bpq_block = 1;
   879 
   885 
   880                 if (verbose) fprintf(stdout, "bundle contains a "
   886                 if (verbose) fprintf(stdout, "bundle contains a "
   881                                              "BPQ extension block\n");
   887                                              "BPQ extension block\n");
   882 
   888 
   883                 if ( bpq_blocks[i].data.data_len <= 0 || 
   889                 if ( bpq_blocks[i].data.data_len <= 0 || 
   901                 if (*filename == NULL)
   907                 if (*filename == NULL)
   902                     strncpy(filename, bpq_block_data.query.query_val, PATH_MAX);
   908                     strncpy(filename, bpq_block_data.query.query_val, PATH_MAX);
   903     
   909     
   904                 break;
   910                 break;
   905             }
   911             }
       
   912         }
       
   913 
       
   914         if(!has_bpq_block) {
       
   915             fprintf(stderr, "no bpq block found in bundle\n");
       
   916             continue;
   906         }
   917         }
   907 
   918 
   908         if(err)
   919         if(err)
   909             continue;
   920             continue;
   910 
   921