dtn_api.h File Reference

#include "dtn_errno.h"
#include "dtn_types.h"

Go to the source code of this file.

Typedefs

typedef int * dtn_handle_t
 The basic handle for communication with the dtn router.

Functions

int dtn_open (dtn_handle_t *handle)
 Open a new connection to the router.
int dtn_close (dtn_handle_t handle)
 Close an open dtn handle.
int dtn_errno (dtn_handle_t handle)
 Get the error associated with the given handle.
char * dtn_strerror (int err)
 Get a string value associated with the dtn error code.
int dtn_build_local_eid (dtn_handle_t handle, dtn_endpoint_id_t *local_eid, const char *service_tag)
 Build an appropriate local endpoint id by appending the specified service tag to the daemon's preferred administrative endpoint id.
int dtn_register (dtn_handle_t handle, dtn_reg_info_t *reginfo, dtn_reg_id_t *newregid)
 Create a dtn registration.
int dtn_unregister (dtn_handle_t handle, dtn_reg_id_t regid)
 Remove a dtn registration.
int dtn_find_registration (dtn_handle_t handle, dtn_endpoint_id_t *eid, dtn_reg_id_t *regid)
 Check for an existing registration on the given endpoint id, returning DTN_SUCCSS and filling in the registration id if it exists, or returning ENOENT if it doesn't.
int dtn_change_registration (dtn_handle_t handle, dtn_reg_id_t newregid, dtn_reg_info_t *reginfo)
 Modify an existing registration.
int dtn_bind (dtn_handle_t handle, dtn_reg_id_t regid)
 Associate a registration with the current ipc channel.
int dtn_unbind (dtn_handle_t handle, dtn_reg_id_t regid)
 Explicitly remove an association from the current ipc handle.
int dtn_send (dtn_handle_t handle, dtn_bundle_spec_t *spec, dtn_bundle_payload_t *payload, dtn_bundle_id_t *id)
 Send a bundle either from memory or from a file.
int dtn_recv (dtn_handle_t handle, dtn_bundle_spec_t *spec, dtn_bundle_payload_location_t location, dtn_bundle_payload_t *payload, dtn_timeval_t timeout)
 Blocking receive for a bundle, filling in the spec and payload structures with the bundle data.
int dtn_begin_poll (dtn_handle_t handle, dtn_timeval_t timeout)
 Begin a polling period for incoming bundles.
int dtn_cancel_poll (dtn_handle_t handle)
 Cancel a polling interval.
void dtn_copy_eid (dtn_endpoint_id_t *dst, dtn_endpoint_id_t *src)
int dtn_parse_eid_string (dtn_endpoint_id_t *eid, const char *str)
int dtn_set_payload (dtn_bundle_payload_t *payload, dtn_bundle_payload_location_t location, char *val, int len)
void dtn_free_payload (dtn_bundle_payload_t *payload)


Typedef Documentation

typedef int* dtn_handle_t

The basic handle for communication with the dtn router.

Definition at line 47 of file dtn_api.h.


Function Documentation

int dtn_begin_poll ( dtn_handle_t  handle,
dtn_timeval_t  timeout 
)

Begin a polling period for incoming bundles.

Returns a file descriptor suitable for calling poll() or select() on. Note that dtn_bind() must have been previously called at least once on the handle.

If the kernel returns an indication that there is data ready on the file descriptor, a call to dtn_recv will then return the bundle without blocking.

Also, no other API calls besides dtn_recv can be executed during a polling period, so an app must call dtn_poll_cancel before trying to run other API calls.

Definition at line 491 of file dtn_api.c.

References DTN_BEGIN_POLL, DTN_EINPOLL, DTN_EXDR, dtnipc_send(), handle, and xdr_dtn_timeval_t().

int dtn_bind ( dtn_handle_t  handle,
dtn_reg_id_t  regid 
)

Associate a registration with the current ipc channel.

This serves to put the registration in "active" mode.

Definition at line 343 of file dtn_api.c.

References DTN_BIND, DTN_EINPOLL, DTN_EXDR, dtnipc_send_recv(), handle, and xdr_dtn_reg_id_t().

Referenced by DTNBindCommand::exec(), dtntunnel::DTNTunnel::init_registration(), main(), and make_registration().

int dtn_build_local_eid ( dtn_handle_t  handle,
dtn_endpoint_id_t local_eid,
const char *  service_tag 
)

Build an appropriate local endpoint id by appending the specified service tag to the daemon's preferred administrative endpoint id.

Definition at line 126 of file dtn_api.c.

References DTN_EINPOLL, DTN_EINVAL, DTN_EXDR, DTN_LOCAL_EID, DTN_MAX_ENDPOINT_ID, DTN_SUCCESS, dtnipc_recv(), dtnipc_send(), handle, xdr_dtn_endpoint_id_t(), and xdr_dtn_service_tag_t().

Referenced by TcaController::init(), dtntunnel::DTNTunnel::init_registration(), main(), and parse_eid().

int dtn_cancel_poll ( dtn_handle_t  handle  ) 

Cancel a polling interval.

Definition at line 521 of file dtn_api.c.

References DTN_CANCEL_POLL, DTN_EINVAL, dtnipc_send_recv(), and handle.

int dtn_change_registration ( dtn_handle_t  handle,
dtn_reg_id_t  newregid,
dtn_reg_info_t reginfo 
)

Modify an existing registration.

Definition at line 321 of file dtn_api.c.

References DTN_EINPOLL, DTN_EINTERNAL, and handle.

Referenced by main().

int dtn_close ( dtn_handle_t  handle  ) 

Close an open dtn handle.

Returns DTN_SUCCESS on success.

Definition at line 82 of file dtn_api.c.

References DTN_SUCCESS, dtnipc_close(), and handle.

Referenced by DTNCloseCommand::exec(), main(), dtntunnel::DTNTunnel::main(), reader_thread(), and TcaController::~TcaController().

void dtn_copy_eid ( dtn_endpoint_id_t dst,
dtn_endpoint_id_t src 
)

Definition at line 551 of file dtn_api.c.

References DTN_MAX_ENDPOINT_ID, src, and dtn_endpoint_id_t::uri.

Referenced by dtntunnel::TCPTunnel::Connection::Connection(), TcaController::dtn_reg(), DTNRegisterCommand::exec(), DTNSendCommand::exec(), from_bundles(), dtntunnel::DTNTunnel::init_registration(), main(), reader_thread(), dtntunnel::DTNTunnel::send_bundle(), TcaController::send_bundle(), and to_bundles().

int dtn_errno ( dtn_handle_t  handle  ) 

Get the error associated with the given handle.

Definition at line 91 of file dtn_api.c.

Referenced by TcaController::dtn_reg(), TcaController::eat_bundles(), DTNRegisterCommand::exec(), DTNUnregisterCommand::exec(), DTNSendCommand::exec(), DTNBindCommand::exec(), DTNUnbindCommand::exec(), DTNRecvCommand::exec(), from_bundles(), dtntunnel::DTNTunnel::init_registration(), main(), dtntunnel::DTNTunnel::main(), make_registration(), reader_thread(), dtntunnel::DTNTunnel::send_bundle(), TcaController::send_bundle(), and to_bundles().

int dtn_find_registration ( dtn_handle_t  handle,
dtn_endpoint_id_t eid,
dtn_reg_id_t regid 
)

Check for an existing registration on the given endpoint id, returning DTN_SUCCSS and filling in the registration id if it exists, or returning ENOENT if it doesn't.

Definition at line 273 of file dtn_api.c.

References DTN_EINPOLL, DTN_EXDR, DTN_FIND_REGISTRATION, DTN_SUCCESS, dtnipc_recv(), dtnipc_send(), handle, xdr_dtn_endpoint_id_t(), and xdr_dtn_reg_id_t().

Referenced by dtntunnel::DTNTunnel::init_registration(), main(), and make_registration().

void dtn_free_payload ( dtn_bundle_payload_t payload  ) 

Definition at line 611 of file dtn_api.c.

References xdr_dtn_bundle_payload_t().

Referenced by DTNRecvCommand::exec(), main(), and dtntunnel::DTNTunnel::main().

int dtn_open ( dtn_handle_t handle  ) 

Open a new connection to the router.

On success, initializes the handle parameter as a new handle to the daemon and returns DTN_SUCCESS. On failure, sets handle to NULL and returns a dtn_errno error code.

Definition at line 56 of file dtn_api.c.

References DTN_EINTERNAL, DTN_SUCCESS, dtnipc_open(), and handle.

Referenced by DTNOpenCommand::exec(), TcaController::init(), dtntunnel::DTNTunnel::init_registration(), main(), and reader_thread().

int dtn_parse_eid_string ( dtn_endpoint_id_t eid,
const char *  str 
)

Definition at line 558 of file dtn_api.c.

References DTN_EINVAL, DTN_ESIZE, DTN_MAX_ENDPOINT_ID, and dtn_endpoint_id_t::uri.

Referenced by main(), make_spec(), parse_eid(), TcaController::send_bundle(), and dtn::APIEndpointIDOpt::set().

int dtn_recv ( dtn_handle_t  handle,
dtn_bundle_spec_t spec,
dtn_bundle_payload_location_t  location,
dtn_bundle_payload_t payload,
dtn_timeval_t  timeout 
)

Blocking receive for a bundle, filling in the spec and payload structures with the bundle data.

The location parameter indicates the manner by which the caller wants to receive payload data (i.e. either in memory or in a file). The timeout parameter specifies an interval in milliseconds to block on the server-side (-1 means infinite wait).

Note that it is advisable to call dtn_free_payload on the returned structure, otherwise the XDR routines will memory leak.

Definition at line 438 of file dtn_api.c.

References DTN_EXDR, DTN_RECV, DTN_SUCCESS, dtnipc_recv(), dtnipc_send_recv(), handle, xdr_dtn_bundle_payload_location_t(), xdr_dtn_bundle_payload_t(), xdr_dtn_bundle_spec_t(), and xdr_dtn_timeval_t().

Referenced by TcaController::eat_bundles(), DTNRecvCommand::exec(), from_bundles(), main(), dtntunnel::DTNTunnel::main(), TcaController::recv_bundle(), and to_bundles().

int dtn_register ( dtn_handle_t  handle,
dtn_reg_info_t reginfo,
dtn_reg_id_t newregid 
)

Create a dtn registration.

If the init_passive flag in the reginfo struct is true, the registration is initially in passive state, requiring a call to dtn_bind to activate it. Otherwise, the call to dtn_bind is unnecessary as the registration will be created in the active state and bound to the handle.

Definition at line 185 of file dtn_api.c.

References DTN_EINPOLL, DTN_EXDR, DTN_REGISTER, DTN_SUCCESS, dtnipc_recv(), dtnipc_send(), handle, xdr_dtn_reg_id_t(), and xdr_dtn_reg_info_t().

Referenced by TcaController::dtn_reg(), DTNRegisterCommand::exec(), dtntunnel::DTNTunnel::init_registration(), main(), make_registration(), and reader_thread().

int dtn_send ( dtn_handle_t  handle,
dtn_bundle_spec_t spec,
dtn_bundle_payload_t payload,
dtn_bundle_id_t id 
)

Send a bundle either from memory or from a file.

Definition at line 397 of file dtn_api.c.

References DTN_EINPOLL, DTN_EXDR, DTN_SEND, dtnipc_send_recv(), handle, xdr_dtn_bundle_id_t(), xdr_dtn_bundle_payload_t(), and xdr_dtn_bundle_spec_t().

Referenced by DTNSendCommand::exec(), main(), reader_thread(), dtntunnel::DTNTunnel::send_bundle(), TcaController::send_bundle(), and to_bundles().

int dtn_set_payload ( dtn_bundle_payload_t payload,
dtn_bundle_payload_location_t  location,
char *  val,
int  len 
)

Definition at line 585 of file dtn_api.c.

References dtn_bundle_payload_t::buf, dtn_bundle_payload_t::dtn_bundle_payload_t_u, DTN_ESIZE, DTN_MAX_BUNDLE_MEM, DTN_PAYLOAD_FILE, DTN_PAYLOAD_MEM, dtn_bundle_payload_t::filename, and dtn_bundle_payload_t::location.

Referenced by DTNSendCommand::exec(), fill_payload(), main(), reader_thread(), dtntunnel::DTNTunnel::send_bundle(), and TcaController::send_bundle().

char* dtn_strerror ( int  err  ) 

Get a string value associated with the dtn error code.

Definition at line 98 of file dtn_api.c.

References DTN_EBUSY, DTN_ECOMM, DTN_ECONNECT, DTN_EINPOLL, DTN_EINTERNAL, DTN_EINVAL, DTN_ENOTFOUND, DTN_ESIZE, DTN_ETIMEOUT, DTN_EXDR, and DTN_SUCCESS.

Referenced by TcaController::dtn_reg(), TcaController::eat_bundles(), DTNOpenCommand::exec(), DTNRegisterCommand::exec(), DTNUnregisterCommand::exec(), DTNSendCommand::exec(), DTNBindCommand::exec(), DTNUnbindCommand::exec(), DTNRecvCommand::exec(), from_bundles(), TcaController::init(), dtntunnel::DTNTunnel::init_registration(), main(), dtntunnel::DTNTunnel::main(), make_registration(), reader_thread(), dtntunnel::DTNTunnel::send_bundle(), TcaController::send_bundle(), and to_bundles().

int dtn_unbind ( dtn_handle_t  handle,
dtn_reg_id_t  regid 
)

Explicitly remove an association from the current ipc handle.

Note that this is also implicitly done when the handle is closed.

This serves to put the registration back in "passive" mode.

Definition at line 370 of file dtn_api.c.

References DTN_EINPOLL, DTN_EXDR, DTN_UNBIND, dtnipc_send_recv(), handle, and xdr_dtn_reg_id_t().

Referenced by DTNUnbindCommand::exec().

int dtn_unregister ( dtn_handle_t  handle,
dtn_reg_id_t  regid 
)

Remove a dtn registration.

If the registration is in the passive state (i.e. not bound to any handle), it is immediately removed from the system. If it is in active state and bound to the given handle, the removal is deferred until the handle unbinds the registration or closes. This allows applications to pre-emptively call unregister so they don't leak registrations.

Definition at line 233 of file dtn_api.c.

References DTN_EINPOLL, DTN_EXDR, DTN_SUCCESS, DTN_UNREGISTER, dtnipc_recv(), dtnipc_send(), handle, and xdr_dtn_reg_id_t().

Referenced by DTNUnregisterCommand::exec(), and main().


Generated on Fri Dec 22 14:48:01 2006 for DTN Reference Implementation by  doxygen 1.5.1