dtn_ipc.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #ifndef DTN_IPC_H
00018 #define DTN_IPC_H
00019 
00020 #include <rpc/rpc.h>
00021 
00022 #ifdef __CYGWIN__
00023 #include <stdio.h>
00024 #include <string.h>
00025 #include <cygwin/socket.h>
00026 #endif
00027 
00028 #ifdef  __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 /*************************************************************
00033  *
00034  * Internal structures and functions that implement the DTN
00035  * IPC layer. Generally, this is not exposed to applications.
00036  *
00037  *************************************************************/
00038 
00046 #define DTN_IPC_VERSION 3
00047 
00053 #define DTN_IPC_PORT 5010
00054 
00059 #define DTN_MAX_API_MSG 65536
00060 
00064 struct dtnipc_handle {
00065     int sock;                           
00066     int err;                            
00067     int in_poll;                        
00068     char buf[DTN_MAX_API_MSG];          
00069     XDR xdr_encode;                     
00070     XDR xdr_decode;                     
00071 };
00072 
00073 typedef struct dtnipc_handle dtnipc_handle_t;
00074 
00078 typedef enum {
00079     DTN_OPEN                    = 1,
00080     DTN_CLOSE                   = 2,
00081     DTN_LOCAL_EID               = 3,
00082     DTN_REGISTER                = 4,
00083     DTN_UNREGISTER              = 5,
00084     DTN_FIND_REGISTRATION       = 6,
00085     DTN_CHANGE_REGISTRATION     = 7,
00086     DTN_BIND                    = 8,
00087     DTN_UNBIND                  = 9,
00088     DTN_SEND                    = 10,
00089     DTN_RECV                    = 11,
00090     DTN_BEGIN_POLL              = 12,
00091     DTN_CANCEL_POLL             = 13
00092 } dtnapi_message_type_t;
00093 
00097 const char* dtnipc_msgtoa(u_int8_t type);
00098 
00099 /*
00100  * Initialize the handle structure and a new ipc session with the
00101  * daemon.
00102  *
00103  * Returns 0 on success, -1 on error.
00104  */
00105 int dtnipc_open(dtnipc_handle_t* handle);
00106 
00107 /*
00108  * Clean up the handle. dtnipc_open must have already been called on
00109  * the handle.
00110  *
00111  * Returns 0 on success, -1 on error.
00112  */
00113 int dtnipc_close(dtnipc_handle_t* handle);
00114     
00115 /*
00116  * Send a message over the dtn ipc protocol.
00117  *
00118  * Returns 0 on success, -1 on error.
00119  */
00120 int dtnipc_send(dtnipc_handle_t* handle, dtnapi_message_type_t type);
00121 
00122 /*
00123  * Receive a message response on the ipc channel. May block if there
00124  * is no pending message.
00125  *
00126  * Sets status to the server-returned status code and returns the
00127  * length of any reply message on success, returns -1 on internal
00128  * error.
00129  */
00130 int dtnipc_recv(dtnipc_handle_t* handle, int* status);
00131 
00137 int dtnipc_send_recv(dtnipc_handle_t* handle, dtnapi_message_type_t type);
00138 
00139 
00140 #ifdef  __cplusplus
00141 }
00142 #endif
00143 
00144 #endif /* DTN_IPC_H */

Generated on Sat Sep 8 08:43:26 2007 for DTN Reference Implementation by  doxygen 1.5.3