dtn_api.h

Go to the documentation of this file.
00001 /*
00002  * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. By
00003  * downloading, copying, installing or using the software you agree to
00004  * this license. If you do not agree to this license, do not download,
00005  * install, copy or use the software.
00006  * 
00007  * Intel Open Source License 
00008  * 
00009  * Copyright (c) 2004 Intel Corporation. All rights reserved. 
00010  * 
00011  * Redistribution and use in source and binary forms, with or without
00012  * modification, are permitted provided that the following conditions are
00013  * met:
00014  * 
00015  *   Redistributions of source code must retain the above copyright
00016  *   notice, this list of conditions and the following disclaimer.
00017  * 
00018  *   Redistributions in binary form must reproduce the above copyright
00019  *   notice, this list of conditions and the following disclaimer in the
00020  *   documentation and/or other materials provided with the distribution.
00021  * 
00022  *   Neither the name of the Intel Corporation nor the names of its
00023  *   contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *  
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00027  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00028  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00029  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
00030  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00031  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00032  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00033  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00034  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00035  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037  */
00038 #ifndef DTN_API_H
00039 #define DTN_API_H
00040 
00041 #include "dtn_errno.h"
00042 #include "dtn_types.h"
00043 
00047 typedef int* dtn_handle_t;
00048 
00049 #ifdef  __cplusplus
00050 extern "C" {
00051 #endif
00052 
00053 /*************************************************************
00054  *
00055  *                     API Functions
00056  *
00057  *************************************************************/
00058 
00066 extern int dtn_open(dtn_handle_t* handle);
00067 
00071 extern int dtn_close(dtn_handle_t handle);
00072 
00076 extern int dtn_errno(dtn_handle_t handle);
00077 
00081 char* dtn_strerror(int err);
00082 
00087 extern int dtn_build_local_eid(dtn_handle_t handle,
00088                                dtn_endpoint_id_t* local_eid,
00089                                const char* service_tag);
00090 
00098 extern int dtn_register(dtn_handle_t handle,
00099                         dtn_reg_info_t* reginfo,
00100                         dtn_reg_id_t* newregid);
00101 
00112 extern int dtn_unregister(dtn_handle_t handle,
00113                           dtn_reg_id_t regid);
00114 
00120 extern int dtn_find_registration(dtn_handle_t handle,
00121                                  dtn_endpoint_id_t* eid,
00122                                  dtn_reg_id_t* regid);
00123 
00127 extern int dtn_change_registration(dtn_handle_t handle,
00128                                    dtn_reg_id_t newregid,
00129                                    dtn_reg_info_t *reginfo);
00130 
00135 extern int dtn_bind(dtn_handle_t handle, dtn_reg_id_t regid);
00136 
00143 extern int dtn_unbind(dtn_handle_t handle, dtn_reg_id_t regid);
00144 
00148 extern int dtn_send(dtn_handle_t handle,
00149                     dtn_bundle_spec_t* spec,
00150                     dtn_bundle_payload_t* payload,
00151                     dtn_bundle_id_t* id);
00152 
00164 extern int dtn_recv(dtn_handle_t handle,
00165                     dtn_bundle_spec_t* spec,
00166                     dtn_bundle_payload_location_t location,
00167                     dtn_bundle_payload_t* payload,
00168                     dtn_timeval_t timeout);
00169 
00184 extern int dtn_begin_poll(dtn_handle_t handle, dtn_timeval_t timeout);
00185 
00189 extern int dtn_cancel_poll(dtn_handle_t handle);
00190 
00191 /*************************************************************
00192  *
00193  *                     Utility Functions
00194  *
00195  *************************************************************/
00196 
00197 /*
00198  * Copy the contents of one eid into another.
00199  */
00200 extern void dtn_copy_eid(dtn_endpoint_id_t* dst, dtn_endpoint_id_t* src);
00201 
00202 /*
00203  * Parse a string into an endpoint id structure, validating that it is
00204  * in fact a valid endpoint id (i.e. a URI).
00205  */
00206 extern int dtn_parse_eid_string(dtn_endpoint_id_t* eid, const char* str);
00207 
00208 /*
00209  * Sets the value of the given payload structure to either a memory
00210  * buffer or a file location.
00211  *
00212  * Returns: 0 on success, DTN_ESIZE if the memory location is
00213  * selected and the payload is too big.
00214  */
00215 extern int dtn_set_payload(dtn_bundle_payload_t* payload,
00216                            dtn_bundle_payload_location_t location,
00217                            char* val, int len);
00218 
00219 /*
00220  * Frees dynamic storage allocated by the xdr for a bundle payload in
00221  * dtn_recv.
00222  */
00223 void dtn_free_payload(dtn_bundle_payload_t* payload);
00224 
00225 #ifdef  __cplusplus
00226 }
00227 #endif
00228 
00229 #endif /* DTN_API_H */

Generated on Fri Dec 22 14:47:58 2006 for DTN Reference Implementation by  doxygen 1.5.1