/home/dko/projects/mobilec/tags/MobileC-v1.10.2/MobileC-v1.10.2/src/include/message.h

Go to the documentation of this file.
00001 /* SVN FILE INFO
00002  * $Revision: 207 $ : Last Committed Revision
00003  * $Date: 2008-07-11 17:55:19 -0700 (Fri, 11 Jul 2008) $ : Last Committed Date */
00004 /*[
00005  * Copyright (c) 2007 Integration Engineering Laboratory
00006                       University of California, Davis
00007  *
00008  * Permission to use, copy, and distribute this software and its
00009  * documentation for any purpose with or without fee is hereby granted,
00010  * provided that the above copyright notice appear in all copies and
00011  * that both that copyright notice and this permission notice appear
00012  * in supporting documentation.
00013  *
00014  * Permission to modify the software is granted, but not the right to
00015  * distribute the complete modified source code.  Modifications are to
00016  * be distributed as patches to the released version.  Permission to
00017  * distribute binaries produced by compiling modified sources is granted,
00018  * provided you
00019  *   1. distribute the corresponding source modifications from the
00020  *    released version in the form of a patch file along with the binaries,
00021  *   2. add special version identification to distinguish your version
00022  *    in addition to the base release version number,
00023  *   3. provide your name and address as the primary contact for the
00024  *    support of your modified version, and
00025  *   4. retain our contact information in regard to use of the base
00026  *    software.
00027  * Permission to distribute the released version of the source code along
00028  * with corresponding source modifications in the form of a patch file is
00029  * granted with same provisions 2 through 4 for binary distributions.
00030  *
00031  * This software is provided "as is" without express or implied warranty
00032  * to the extent permitted by applicable law.
00033 ]*/
00034 
00035 #ifndef _MESSAGE_H_
00036 #define _MESSAGE_H_
00037 #include "config.h"
00038 #include "mtp_http.h"
00039 #include <mxml.h>
00040 #ifndef _WIN32
00041 #include <netinet/in.h>
00042 #else 
00043 #include <windows.h>
00044 #endif
00045 struct asm_node_s;
00046 
00047 
00048 typedef enum message_type_e {
00049   RELAY, 
00050   REQUEST, 
00051   SUBSCRIBE,
00052   CANCEL,
00053   N_UNDRSTD,
00054   MOBILE_AGENT,
00055   QUER_IF,
00056   QUER_REF,
00057   AGENT_UPDATE,
00058   RETURN_MSG,
00059   FIPA_ACL,
00060   ENCRYPTED_DATA,
00061   ENCRYPTION_INITIALIZE,
00062   REQUEST_ENCRYPTION_INITIALIZE,
00063   NUM_MESSAGE_TYPE
00064 } message_type_t;
00065 
00066 /*typedef enum http_type_e {
00067   HTTP_GET, 
00068   HTTP_POST, 
00069   HTTP_NOT
00070 }http_type_t;   */
00071 
00072 
00073 typedef struct message_s{
00074   /* The addr of the sender of the message */
00075   struct sockaddr_in* addr;
00076 
00077   /* id numbers */
00078   int connect_id;
00079   int message_id;
00080 
00081   /* Flag if it is an http message already */
00082   int isHTTP;
00083 
00084   /* the type of the message as discerned from the http header */
00085   enum message_type_e message_type;
00086   enum http_performative_e http_type;
00087 
00088   mxml_node_t* xml_root;
00089   mxml_node_t* xml_payload;
00090 
00091   /* the http header and the rest of the message */
00092   char* message_body;
00093 
00094   char *update_name;
00095   int update_num;
00096 
00097   char* from_address;
00098   char* to_address;
00099 
00100   char* target; /* This is the agency module to send the message to. It
00101                    will either be 'ams' for migration messages, or 'acc'
00102                    for ACL messages. ( And perhaps things like 'df' in the 
00103                    future) */
00104 
00105   /* This flag is set if an agent is using the xml nodes, so we know
00106    * not to free/delete them prematurely. */
00107   int agent_xml_flag;
00108 } message_t;
00109 typedef message_t* message_p;
00110 
00111 #ifdef MC_SECURITY
00112 int
00113 message_Decrypt(message_p message, struct asm_node_s* asm_node);
00114 
00115 int
00116 message_Encrypt(message_p message, struct asm_node_s* asm_node);
00117 #endif /*MC_SECURITY*/
00118 
00119 message_p 
00120 message_New(void);
00121 
00122 message_p 
00123 message_Copy(message_p src);
00124 
00125 struct agent_s;
00126 struct mc_platform_s;
00127 int
00128 message_InitializeFromAgent(
00129     struct mc_platform_s* mc_platform,
00130     message_p message,
00131     struct agent_s* agent);
00132 
00133 struct connection_s;
00134 int
00135 message_InitializeFromConnection(
00136     struct mc_platform_s* mc_platform,
00137     message_p message,
00138     struct connection_s* connection);
00139 
00140 int
00141 message_InitializeFromString(
00142     struct mc_platform_s* mc_platform,
00143     message_p message,
00144     const char* string,
00145     const char* destination_host,
00146     int destination_port,
00147     const char* target);
00148 
00149 int 
00150 message_Destroy(message_p message);
00151 
00152 int 
00153 message_Send(message_p message);
00154 
00155 int 
00156 http_to_hostport(const char* http_str, char** host, int* port, char** target);
00157 #endif

Generated on Fri Jul 11 17:59:45 2008 for Mobile-C by  doxygen 1.5.4