applib/dtn_types.x
changeset 0 2b3e5ec03512
child 28 406d4f7eb00d
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 /*
       
     2  * NOTE: To make comments appear in the generated files, they must be
       
     3  * preceded by a % sign (unlike this one).
       
     4  */
       
     5 
       
     6 %/*
       
     7 % *    Copyright 2004-2006 Intel Corporation
       
     8 % * 
       
     9 % *    Licensed under the Apache License, Version 2.0 (the "License");
       
    10 % *    you may not use this file except in compliance with the License.
       
    11 % *    You may obtain a copy of the License at
       
    12 % * 
       
    13 % *        http://www.apache.org/licenses/LICENSE-2.0
       
    14 % * 
       
    15 % *    Unless required by applicable law or agreed to in writing, software
       
    16 % *    distributed under the License is distributed on an "AS IS" BASIS,
       
    17 % *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    18 % *    See the License for the specific language governing permissions and
       
    19 % *    limitations under the License.
       
    20 %*/
       
    21 
       
    22 %
       
    23 %/**********************************
       
    24 % * This file defines the types used in the DTN client API. The structures are
       
    25 % * autogenerated using rpcgen, as are the marshalling and unmarshalling
       
    26 % * XDR routines.
       
    27 % */
       
    28 %
       
    29 %#include <limits.h>
       
    30 %#ifndef ARG_MAX
       
    31 %#define ARG_MAX _POSIX_ARG_MAX
       
    32 %#endif
       
    33 %
       
    34 %/**********************************
       
    35 % * Constants.
       
    36 % * (Note that we use #defines to get the comments as well)
       
    37 % */
       
    38 %#define DTN_MAX_ENDPOINT_ID 256	/* max endpoint_id size (bytes) */
       
    39 %#define DTN_MAX_PATH_LEN PATH_MAX	/* max path length */
       
    40 %#define DTN_MAX_EXEC_LEN ARG_MAX	/* length of string passed to exec() */
       
    41 %#define DTN_MAX_AUTHDATA 1024		/* length of auth/security data*/
       
    42 %#define DTN_MAX_REGION_LEN 64		/* 64 chars "should" be long enough */
       
    43 %#define DTN_MAX_BUNDLE_MEM 50000	/* biggest in-memory bundle is ~50K*/
       
    44 %#define DTN_MAX_BLOCK_LEN 1024         /* length of block data (currently 1K) */
       
    45 %#define DTN_MAX_BLOCKS 256             /* number of blocks in bundle */
       
    46 
       
    47 %
       
    48 %/**
       
    49 % * Specification of a dtn endpoint id, i.e. a URI, implemented as a
       
    50 % * fixed-length char buffer. Note that for efficiency reasons, this
       
    51 % * fixed length is relatively small (256 bytes). 
       
    52 % * 
       
    53 % * The alternative is to use the string XDR type but then all endpoint
       
    54 % * ids would require malloc / free which is more prone to leaks / bugs.
       
    55 % */
       
    56 struct dtn_endpoint_id_t {
       
    57     opaque	uri[DTN_MAX_ENDPOINT_ID];
       
    58 };
       
    59 
       
    60 %
       
    61 %/**
       
    62 % * A registration cookie.
       
    63 % */
       
    64 typedef u_int dtn_reg_id_t;
       
    65 
       
    66 %
       
    67 %/**
       
    68 % * DTN timeouts are specified in seconds.
       
    69 % */
       
    70 typedef u_int dtn_timeval_t;
       
    71 
       
    72 %
       
    73 %/**
       
    74 % * An infinite wait is a timeout of -1.
       
    75 % */
       
    76 %#define DTN_TIMEOUT_INF ((dtn_timeval_t)-1)
       
    77 
       
    78 /**
       
    79  * A dtn timestamp contains seconds and a sequence number.
       
    80  */
       
    81 
       
    82 %
       
    83 %#include "dtn-config.h"
       
    84 %
       
    85 %#ifdef HAVE_XDR_U_QUAD_T
       
    86 %    #define u_hyper u_quad_t
       
    87 %    #define xdr_u_hyper_t xdr_u_quad_t
       
    88 %#elif defined(HAVE_XDR_U_INT64_T)
       
    89 %    #define u_hyper u_int64_t
       
    90 %    #define xdr_u_hyper_t xdr_u_int64_t
       
    91 %#else
       
    92 %    #define u_hyper u_quad_t
       
    93 %    #define xdr_u_hyper_t xdr_u_quad_t
       
    94 %#endif
       
    95 
       
    96 struct dtn_timestamp_t {
       
    97     u_hyper secs;
       
    98     u_hyper seqno;
       
    99 };
       
   100 
       
   101 %
       
   102 %/**
       
   103 % * Specification of a service tag used in building a local endpoint
       
   104 % * identifier.
       
   105 % * 
       
   106 % * Note that the application cannot (in general) expect to be able to
       
   107 % * use the full DTN_MAX_ENDPOINT_ID, as there is a chance of overflow
       
   108 % * when the daemon concats the tag with its own local endpoint id.
       
   109 % */
       
   110 struct dtn_service_tag_t {
       
   111     char tag[DTN_MAX_ENDPOINT_ID];
       
   112 };
       
   113 
       
   114 %
       
   115 %/**
       
   116 % * Value for an unspecified registration cookie (i.e. indication that
       
   117 % * the daemon should allocate a new unique id).
       
   118 % */
       
   119 const DTN_REGID_NONE = 0;
       
   120 
       
   121 %
       
   122 %/**
       
   123 % * Registration flags are a bitmask of the following:
       
   124 %
       
   125 % * Delivery failure actions (exactly one must be selected):
       
   126 % *     DTN_REG_DROP   - drop bundle if registration not active
       
   127 % *     DTN_REG_DEFER  - spool bundle for later retrieval
       
   128 % *     DTN_REG_EXEC   - exec program on bundle arrival
       
   129 % *
       
   130 % * Session flags:
       
   131 % *     DTN_SESSION_CUSTODY   - app assumes custody for the session
       
   132 % *     DTN_SESSION_PUBLISH   - creates a publication point
       
   133 % *     DTN_SESSION_SUBSCRIBE - create subscription for the session
       
   134 % */
       
   135 enum dtn_reg_flags_t {
       
   136     DTN_REG_DROP          = 1,
       
   137     DTN_REG_DEFER         = 2,
       
   138     DTN_REG_EXEC          = 3,
       
   139     DTN_SESSION_CUSTODY   = 4,
       
   140     DTN_SESSION_PUBLISH   = 8,
       
   141     DTN_SESSION_SUBSCRIBE = 16
       
   142 };
       
   143 
       
   144 %
       
   145 %/**
       
   146 % * Registration state.
       
   147 % */
       
   148 struct dtn_reg_info_t {
       
   149     dtn_endpoint_id_t 	endpoint;
       
   150     dtn_reg_id_t	regid;
       
   151     unsigned int	flags;
       
   152     dtn_timeval_t	expiration;
       
   153     bool		init_passive;
       
   154     opaque		script<DTN_MAX_EXEC_LEN>;
       
   155 };
       
   156 
       
   157 %
       
   158 %/**
       
   159 % * Bundle priority specifier.
       
   160 % *     COS_BULK      - lowest priority
       
   161 % *     COS_NORMAL    - regular priority
       
   162 % *     COS_EXPEDITED - important
       
   163 % *     COS_RESERVED  - TBD
       
   164 % */
       
   165 enum dtn_bundle_priority_t {
       
   166     COS_BULK = 0,
       
   167     COS_NORMAL = 1,
       
   168     COS_EXPEDITED = 2,
       
   169     COS_RESERVED = 3
       
   170 };
       
   171 
       
   172 %
       
   173 %/**
       
   174 % * Bundle delivery option flags. Note that multiple options may be
       
   175 % * selected for a given bundle.
       
   176 % *     
       
   177 % *     DOPTS_NONE            - no custody, etc
       
   178 % *     DOPTS_CUSTODY         - custody xfer
       
   179 % *     DOPTS_DELIVERY_RCPT   - end to end delivery (i.e. return receipt)
       
   180 % *     DOPTS_RECEIVE_RCPT    - per hop arrival receipt
       
   181 % *     DOPTS_FORWARD_RCPT    - per hop departure receipt
       
   182 % *     DOPTS_CUSTODY_RCPT    - per custodian receipt
       
   183 % *     DOPTS_DELETE_RCPT     - request deletion receipt
       
   184 % *     DOPTS_SINGLETON_DEST  - destination is a singleton
       
   185 % *     DOPTS_MULTINODE_DEST  - destination is not a singleton
       
   186 % *     DOPTS_DO_NOT_FRAGMENT - set the do not fragment bit
       
   187 % */
       
   188 enum dtn_bundle_delivery_opts_t {
       
   189     DOPTS_NONE            = 0,
       
   190     DOPTS_CUSTODY         = 1,
       
   191     DOPTS_DELIVERY_RCPT   = 2,
       
   192     DOPTS_RECEIVE_RCPT    = 4,
       
   193     DOPTS_FORWARD_RCPT    = 8,
       
   194     DOPTS_CUSTODY_RCPT    = 16,
       
   195     DOPTS_DELETE_RCPT     = 32,
       
   196     DOPTS_SINGLETON_DEST  = 64,
       
   197     DOPTS_MULTINODE_DEST  = 128,
       
   198     DOPTS_DO_NOT_FRAGMENT = 256
       
   199 };
       
   200 
       
   201 %
       
   202 %/**
       
   203 % * Extension block flags. Note that multiple flags may be selected
       
   204 % * for a given block.
       
   205 % *
       
   206 % *     BLOCK_FLAG_NONE          - no flags
       
   207 % *     BLOCK_FLAG_REPLICATE     - block must be replicated in every fragment
       
   208 % *     BLOCK_FLAG_REPORT        - transmit report if block can't be processed
       
   209 % *     BLOCK_FLAG_DELETE_BUNDLE - delete bundle if block can't be processed
       
   210 % *     BLOCK_FLAG_LAST          - last block
       
   211 % *     BLOCK_FLAG_DISCARD_BLOCK - discard block if it can't be processed
       
   212 % *     BLOCK_FLAG_UNPROCESSED   - block was forwarded without being processed
       
   213 % */
       
   214 enum dtn_extension_block_flags_t {
       
   215     BLOCK_FLAG_NONE          = 0,
       
   216     BLOCK_FLAG_REPLICATE     = 1,
       
   217     BLOCK_FLAG_REPORT        = 2,
       
   218     BLOCK_FLAG_DELETE_BUNDLE = 4,
       
   219     BLOCK_FLAG_LAST          = 8,
       
   220     BLOCK_FLAG_DISCARD_BLOCK = 16,
       
   221     BLOCK_FLAG_UNPROCESSED   = 32
       
   222 };
       
   223 
       
   224 %
       
   225 %/**
       
   226 % * Extension block.
       
   227 % */
       
   228 struct dtn_extension_block_t {
       
   229     u_int                       type;
       
   230     u_int                       flags;
       
   231     opaque                      data<DTN_MAX_BLOCK_LEN>;
       
   232 };
       
   233 
       
   234 %
       
   235 %/**
       
   236 % * A Sequence ID is a vector of (EID, counter) values in the following
       
   237 % * text format:
       
   238 % *
       
   239 % *    < (EID1 counter1) (EID2 counter2) ... >
       
   240 % */
       
   241 struct dtn_sequence_id_t {
       
   242     opaque data<DTN_MAX_BLOCK_LEN>;
       
   243 };
       
   244 
       
   245 %
       
   246 %/**
       
   247 % * Bundle metadata. The delivery_regid is ignored when sending
       
   248 % * bundles, but is filled in by the daemon with the registration
       
   249 % * id where the bundle was received.
       
   250 % */
       
   251 struct dtn_bundle_spec_t {
       
   252     dtn_endpoint_id_t		source;
       
   253     dtn_endpoint_id_t		dest;
       
   254     dtn_endpoint_id_t		replyto;
       
   255     dtn_bundle_priority_t	priority;
       
   256     int				dopts;
       
   257     dtn_timeval_t		expiration;
       
   258     dtn_timestamp_t		creation_ts;
       
   259     dtn_reg_id_t		delivery_regid;
       
   260     dtn_sequence_id_t           sequence_id;
       
   261     dtn_sequence_id_t           obsoletes_id;
       
   262     dtn_extension_block_t       blocks<DTN_MAX_BLOCKS>;
       
   263     dtn_extension_block_t       metadata<DTN_MAX_BLOCKS>;
       
   264 };
       
   265 
       
   266 %
       
   267 %/**
       
   268 % * Type definition for a unique bundle identifier. Returned from dtn_send
       
   269 % * after the daemon has assigned the creation_secs and creation_subsecs,
       
   270 % * in which case orig_length and frag_offset are always zero, and also in
       
   271 % * status report data in which case they may be set if the bundle is
       
   272 % * fragmented.
       
   273 % */
       
   274 struct dtn_bundle_id_t {
       
   275     dtn_endpoint_id_t   source;
       
   276     dtn_timestamp_t     creation_ts;
       
   277     u_int               frag_offset;
       
   278     u_int               orig_length;
       
   279 };
       
   280 
       
   281 %/**
       
   282 % * Bundle Status Report "Reason Code" flags
       
   283 % */
       
   284 enum dtn_status_report_reason_t {
       
   285     REASON_NO_ADDTL_INFO	      = 0x00,
       
   286     REASON_LIFETIME_EXPIRED	      = 0x01,
       
   287     REASON_FORWARDED_UNIDIR_LINK      = 0x02,
       
   288     REASON_TRANSMISSION_CANCELLED     = 0x03,
       
   289     REASON_DEPLETED_STORAGE	      = 0x04,
       
   290     REASON_ENDPOINT_ID_UNINTELLIGIBLE = 0x05,
       
   291     REASON_NO_ROUTE_TO_DEST	      = 0x06,
       
   292     REASON_NO_TIMELY_CONTACT	      = 0x07,
       
   293     REASON_BLOCK_UNINTELLIGIBLE	      = 0x08
       
   294 };
       
   295 
       
   296 %/**
       
   297 % * Bundle Status Report status flags that indicate which timestamps in
       
   298 % * the status report structure are valid.
       
   299 % */
       
   300 enum dtn_status_report_flags_t {
       
   301     STATUS_RECEIVED		= 0x01,
       
   302     STATUS_CUSTODY_ACCEPTED	= 0x02,
       
   303     STATUS_FORWARDED		= 0x04,
       
   304     STATUS_DELIVERED		= 0x08,
       
   305     STATUS_DELETED		= 0x10,
       
   306     STATUS_ACKED_BY_APP		= 0x20
       
   307 };
       
   308 
       
   309 %
       
   310 %/**
       
   311 % * Type definition for a bundle status report.
       
   312 % */
       
   313 struct dtn_bundle_status_report_t {
       
   314     dtn_bundle_id_t 		bundle_id;
       
   315     dtn_status_report_reason_t 	reason;
       
   316     dtn_status_report_flags_t 	flags;
       
   317     dtn_timestamp_t		receipt_ts;
       
   318     dtn_timestamp_t 		custody_ts;
       
   319     dtn_timestamp_t 		forwarding_ts;
       
   320     dtn_timestamp_t 		delivery_ts;
       
   321     dtn_timestamp_t 		deletion_ts;
       
   322     dtn_timestamp_t 		ack_by_app_ts;
       
   323 };
       
   324 
       
   325 %
       
   326 %/**
       
   327 % * The payload of a bundle can be sent or received either in a file,
       
   328 % * in which case the payload structure contains the filename, or in
       
   329 % * memory where the struct contains the data in-band, in the 'buf'
       
   330 % * field.
       
   331 % *
       
   332 % * When sending a bundle, if the location specifies that the payload
       
   333 % * is in a temp file, then the daemon assumes ownership of the file
       
   334 % * and should have sufficient permissions to move or rename it.
       
   335 % *
       
   336 % * When receiving a bundle that is a status report, then the
       
   337 % * status_report pointer will be non-NULL and will point to a
       
   338 % * dtn_bundle_status_report_t structure which contains the parsed fields
       
   339 % * of the status report.
       
   340 % *
       
   341 % *     DTN_PAYLOAD_MEM         - payload contents in memory
       
   342 % *     DTN_PAYLOAD_FILE        - payload contents in file
       
   343 % *     DTN_PAYLOAD_TEMP_FILE   - in file, assume ownership (send only)
       
   344 % */
       
   345 enum dtn_bundle_payload_location_t {
       
   346     DTN_PAYLOAD_FILE,
       
   347     DTN_PAYLOAD_MEM,
       
   348     DTN_PAYLOAD_TEMP_FILE
       
   349 };
       
   350 
       
   351 struct dtn_bundle_payload_t
       
   352 {
       
   353     dtn_bundle_payload_location_t location;
       
   354     opaque                        filename<DTN_MAX_PATH_LEN>;
       
   355     opaque                        buf<DTN_MAX_BUNDLE_MEM>;
       
   356     dtn_bundle_status_report_t*   status_report;
       
   357 };