00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _MESSAGE_H_
00036 #define _MESSAGE_H_
00037 #include "mtp_http.h"
00038 #include <mxml.h>
00039 #ifndef _WIN32
00040 #include <netinet/in.h>
00041 #include "config.h"
00042 #else
00043 #include <windows.h>
00044 #include "winconfig.h"
00045 #endif
00046
00047
00048 #include "security/interface.h"
00049 struct asm_node_s;
00050
00051
00052 typedef enum message_type_e {
00053 RELAY,
00054 REQUEST,
00055 SUBSCRIBE,
00056 CANCEL,
00057 N_UNDRSTD,
00058 MOBILE_AGENT,
00059 QUER_IF,
00060 QUER_REF,
00061 AGENT_UPDATE,
00062 RETURN_MSG,
00063 FIPA_ACL,
00064 ENCRYPTED_DATA,
00065 ENCRYPTION_INITIALIZE,
00066 REQUEST_ENCRYPTION_INITIALIZE,
00067 NUM_MESSAGE_TYPE,
00068 MSG_SEC
00069 } message_type_t;
00070
00071
00072
00073
00074
00075
00076
00077
00078 typedef struct message_s{
00079
00080 struct sockaddr_in* addr;
00081
00082
00083 int connect_id;
00084 int message_id;
00085
00086
00087 int isHTTP;
00088
00089
00090 enum message_type_e message_type;
00091 enum http_performative_e http_type;
00092
00093 mxml_node_t* xml_root;
00094 mxml_node_t* xml_payload;
00095
00096
00097 char* message_body;
00098
00099 char *update_name;
00100 int update_num;
00101
00102 char* from_address;
00103 char* to_address;
00104
00105 char* target;
00106
00107
00108
00109
00110
00111
00112 int agent_xml_flag;
00113 char* sending_agent_name;
00114 } message_t;
00115 typedef message_t* message_p;
00116
00117 typedef struct message_send_arg_s
00118 {
00119 struct mc_platform_s* mc_platform;
00120 message_p message;
00121 char* privatekey;
00122 } message_send_arg_t;
00123
00124 #ifdef MC_SECURITY
00125 int
00126 message_Decrypt(message_p message, struct asm_node_s* asm_node);
00127
00128 int
00129 message_Encrypt(message_p message, struct asm_node_s* asm_node);
00130 #endif
00131
00132 message_p
00133 message_New(void);
00134
00135 message_p
00136 message_Copy(message_p src);
00137
00138 struct agent_s;
00139 struct mc_platform_s;
00140 int
00141 message_InitializeFromAgent(
00142 struct mc_platform_s* mc_platform,
00143 message_p message,
00144 struct agent_s* agent);
00145
00146 struct connection_s;
00147 int
00148 message_InitializeFromConnection(
00149 struct mc_platform_s* mc_platform,
00150 message_p message,
00151 struct connection_s* connection);
00152
00153 int
00154 message_InitializeFromString(
00155 struct mc_platform_s* mc_platform,
00156 message_p message,
00157 const char* string,
00158 const char* destination_host,
00159 int destination_port,
00160 const char* target);
00161
00162 int
00163 message_Destroy(message_p message);
00164
00165 int
00166 auth_rece_send_msg(int sockfd, char *hostname, char *message, char *privkey, char *known_host_filename);
00167
00168 int
00169 message_Send(struct mc_platform_s* mc_platform, message_p message, char *privatekey);
00170
00171 #ifndef _WIN32
00172 void*
00173 message_send_Thread(void* arg);
00174 #else
00175 DWORD WINAPI
00176 message_send_Thread(LPVOID arg);
00177 #endif
00178
00179 int
00180 http_to_hostport(const char* http_str, char** host, int* port, char** target);
00181 #endif