/home/dko/projects/mobilec/trunk/src/include/message.h

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

Generated on Fri May 16 14:49:54 2008 for Mobile-C by  doxygen 1.5.4