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