dtn_ipc.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_IPC_H
00039 #define DTN_IPC_H
00040 
00041 #include <rpc/rpc.h>
00042 
00043 #ifdef __CYGWIN__
00044 #include <stdio.h>
00045 #include <string.h>
00046 #include <cygwin/socket.h>
00047 #endif
00048 
00049 #ifdef  __cplusplus
00050 extern "C" {
00051 #endif
00052 
00053 /*************************************************************
00054  *
00055  * Internal structures and functions that implement the DTN
00056  * IPC layer. Generally, this is not exposed to applications.
00057  *
00058  *************************************************************/
00059 
00067 #define DTN_IPC_VERSION 2
00068 
00074 #define DTN_IPC_PORT 5010
00075 
00080 #define DTN_MAX_API_MSG 65536
00081 
00085 struct dtnipc_handle {
00086     int sock;                           
00087     int err;                            
00088     int in_poll;                        
00089     char buf[DTN_MAX_API_MSG];          
00090     XDR xdr_encode;                     
00091     XDR xdr_decode;                     
00092 };
00093 
00094 typedef struct dtnipc_handle dtnipc_handle_t;
00095 
00099 typedef enum {
00100     DTN_OPEN                    = 1,
00101     DTN_CLOSE                   = 2,
00102     DTN_LOCAL_EID               = 3,
00103     DTN_REGISTER                = 4,
00104     DTN_UNREGISTER              = 5,
00105     DTN_FIND_REGISTRATION       = 6,
00106     DTN_CHANGE_REGISTRATION     = 7,
00107     DTN_BIND                    = 8,
00108     DTN_UNBIND                  = 9,
00109     DTN_SEND                    = 10,
00110     DTN_RECV                    = 11,
00111     DTN_BEGIN_POLL              = 12,
00112     DTN_CANCEL_POLL             = 13
00113 } dtnapi_message_type_t;
00114 
00118 const char* dtnipc_msgtoa(u_int8_t type);
00119 
00120 /*
00121  * Initialize the handle structure and a new ipc session with the
00122  * daemon.
00123  *
00124  * Returns 0 on success, -1 on error.
00125  */
00126 int dtnipc_open(dtnipc_handle_t* handle);
00127 
00128 /*
00129  * Clean up the handle. dtnipc_open must have already been called on
00130  * the handle.
00131  *
00132  * Returns 0 on success, -1 on error.
00133  */
00134 int dtnipc_close(dtnipc_handle_t* handle);
00135     
00136 /*
00137  * Send a message over the dtn ipc protocol.
00138  *
00139  * Returns 0 on success, -1 on error.
00140  */
00141 int dtnipc_send(dtnipc_handle_t* handle, dtnapi_message_type_t type);
00142 
00143 /*
00144  * Receive a message response on the ipc channel. May block if there
00145  * is no pending message.
00146  *
00147  * Sets status to the server-returned status code and returns the
00148  * length of any reply message on success, returns -1 on internal
00149  * error.
00150  */
00151 int dtnipc_recv(dtnipc_handle_t* handle, int* status);
00152 
00158 int dtnipc_send_recv(dtnipc_handle_t* handle, dtnapi_message_type_t type);
00159 
00160 
00161 #ifdef  __cplusplus
00162 }
00163 #endif
00164 
00165 #endif /* DTN_IPC_H */

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