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 #include <string.h>
00036 #ifndef _WIN32
00037 #include <sys/types.h>
00038 #include <sys/socket.h>
00039 #include <netinet/in.h>
00040 #include <arpa/inet.h>
00041 #include <unistd.h>
00042 #include <netdb.h>
00043 #include <errno.h>
00044 #include "config.h"
00045 #else
00046 #include "winconfig.h"
00047 #endif
00048 #include <mxml.h>
00049 #include "include/libmc.h"
00050 #include "include/agent.h"
00051 #include "include/mc_platform.h"
00052 #include "include/message.h"
00053 #include "include/mtp_http.h"
00054 #include "include/xml_compose.h"
00055 #include "include/xml_helper.h"
00056 #include "include/xml_parser.h"
00057 #include "include/macros.h"
00058
00059 #include "security/asm_node.h"
00060
00061 #define SOCKET_INPUT_SIZE 4096
00062
00063 message_p
00064 message_New(void)
00065 {
00066 message_p message;
00067 message = (message_p)malloc(sizeof(message_t));
00068 CHECK_NULL(message, exit(0););
00069 message->addr = NULL;
00070 message->connect_id = 0;
00071 message->message_id = 0;
00072 message->isHTTP = 0;
00073 message->message_type = (enum message_type_e)0;
00074 message->http_type = (enum http_performative_e)0;
00075 message->xml_root = NULL;
00076 message->xml_payload = NULL;
00077 message->message_body = NULL;
00078 message->update_name = NULL;
00079 message->update_num = 0;
00080 message->from_address = NULL;
00081 message->to_address = NULL;
00082 message->target = NULL;
00083 message->agent_xml_flag = 0;
00084 return message;
00085 }
00086
00087 message_p
00088 message_Copy(message_p src)
00089 {
00090 fprintf(stderr, "FIXME: message_Copy() is not implemented yet. %s:%d\n",
00091 __FILE__, __LINE__);
00092 return NULL;
00093 }
00094
00095 int
00096 message_InitializeFromAgent(
00097 mc_platform_p mc_platform,
00098 message_p message,
00099 agent_p agent)
00100 {
00101 struct hostent* host;
00102
00103 char* buf;
00104 char* destination_host;
00105 char* destination_port_str;
00106 #ifndef _WIN32
00107 char* save_ptr;
00108 #endif
00109 int destination_port;
00110
00111 message->message_id = rand();
00112 message->message_type = MOBILE_AGENT;
00113
00114 message->xml_root = agent_xml_compose(agent);
00115
00116
00117 CHECK_NULL(message->xml_root, exit(0););
00118 message->message_body = mxmlSaveAllocString(
00119 message->xml_root,
00120 MXML_NO_CALLBACK );
00121
00122 message->update_name = NULL;
00123
00124 message->from_address =
00125 (char*)malloc(sizeof(char) * (strlen(mc_platform->hostname) + 10));
00126 sprintf(
00127 message->from_address,
00128 "%s:%d",
00129 mc_platform->hostname,
00130 mc_platform->port );
00131 if (
00132 agent->datastate->task_progress >=
00133 agent->datastate->number_of_tasks
00134 )
00135 {
00136 message->to_address =
00137 (char*)malloc
00138 (
00139 sizeof(char) *
00140 (
00141 strlen(agent->home) + 1
00142 )
00143 );
00144 CHECK_NULL(message->to_address, exit(0););
00145 strcpy
00146 (
00147 message->to_address,
00148 agent->home
00149 );
00150 } else {
00151 message->to_address =
00152 (char*) malloc
00153 (
00154 sizeof(char) *
00155 (
00156 strlen
00157 (
00158 agent->datastate->tasks[ agent->datastate->task_progress ]
00159 ->server_name
00160 )
00161 +1
00162 )
00163 );
00164 CHECK_NULL( message->to_address, mc_platform->err = MC_ERR_MEMORY; return MC_ERR_MEMORY;);
00165 strcpy(
00166 message->to_address,
00167 agent->datastate->tasks[ agent->datastate->task_progress ]->server_name
00168 );
00169 }
00170 message->agent_xml_flag = 0;
00171 message->target = strdup("ams");
00172 message->sending_agent_name = strdup(agent->name);
00173
00174 buf = (char*)malloc
00175 (
00176 sizeof(char) *
00177 (strlen(message->to_address)+1)
00178 );
00179 CHECK_NULL(buf, exit(0););
00180 strcpy(buf, message->to_address);
00181 destination_host = strtok_r(buf, ":", &save_ptr);
00182 destination_port_str = strtok_r(NULL, ":", &save_ptr);
00183 destination_port = atoi(destination_port_str);
00184 message->addr = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
00185 if ((host = gethostbyname(destination_host))) {
00186 memcpy(&(message->addr->sin_addr), host->h_addr, host->h_length);
00187 message->addr->sin_port = htons(destination_port);
00188 } else {
00189 WARN("Host not found.");
00190 }
00191 free(buf);
00192 return MC_SUCCESS;
00193 }
00194
00195 int
00196 message_InitializeFromConnection(
00197 mc_platform_p mc_platform,
00198 message_p message,
00199 connection_p connection)
00200 {
00201 int i = 1;
00202 int n;
00203 char *message_string;
00204 char *buffer;
00205
00206 message->addr = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
00207 CHECK_NULL(message->addr, exit(0););
00208 *(message->addr) = connection->addr;
00209
00210 message->connect_id = connection->connect_id;
00211
00212 message->message_id = rand();
00213
00214 message->to_address = NULL;
00215 message->from_address = NULL;
00216 message->target = NULL;
00217
00218 buffer = (char*) malloc(sizeof(char) * (SOCKET_INPUT_SIZE + 1));
00219 CHECK_NULL(buffer, exit(0););
00220 message_string = (char*) malloc(sizeof(char) * (SOCKET_INPUT_SIZE + 1));
00221 CHECK_NULL(message_string, exit(0););
00222 message_string[0] = '\0';
00223 buffer[0] = '\0';
00224
00225
00226 while(1) {
00227 #ifndef _WIN32
00228
00229
00230
00231
00232
00233
00234 n = recv(connection->clientfd, (void*)buffer, (size_t) sizeof(char)*SOCKET_INPUT_SIZE, MSG_WAITALL);
00235 #else
00236 n = recvfrom(connection->clientfd,
00237 buffer,
00238 (size_t) sizeof(char)*SOCKET_INPUT_SIZE,
00239 0,
00240 (struct sockaddr *) 0,
00241 0);
00242 #endif
00243 if (n < 0) {
00244 free(buffer);
00245 SOCKET_ERROR();
00246 return MC_ERR_CONNECT;
00247 }
00248 else if (n == 0) {
00249 free(buffer);
00250 break;
00251 } else {
00252 buffer[n] = '\0';
00253 i++;
00254 strcat(message_string, buffer);
00255 message_string = (char*)realloc
00256 (
00257 message_string,
00258 sizeof(char) * (SOCKET_INPUT_SIZE+1) * i
00259 );
00260 CHECK_NULL(message_string, exit(0););
00261 buffer[0] = '\0';
00262 }
00263 }
00264 message->message_body = (char*)malloc
00265 (
00266 sizeof(char) *
00267 (strlen(message_string) + 1)
00268 );
00269 CHECK_NULL(message->message_body, exit(0););
00270 strcpy(message->message_body, message_string);
00271 free(message_string);
00272 message->xml_root = mxmlLoadString
00273 (
00274 NULL,
00275 message->message_body,
00276 MXML_NO_CALLBACK
00277 );
00278 if (message_xml_parse(message)) {
00279 fprintf(stderr, "Error parsing message at %s:%d.\n",
00280 __FILE__, __LINE__);
00281 message_Destroy(message);
00282 return MC_ERR_PARSE;
00283 }
00284 return MC_SUCCESS;
00285 }
00286
00287 int http_to_hostport(const char* http_str, char** host, int* port, char** target)
00288 {
00289
00290
00291
00292
00293 const char* tmp;
00294 if(strncmp(http_str, "http://", 7)) {
00295 return MC_ERR_PARSE;
00296 }
00297 http_str += 7;
00298 tmp = strchr(http_str, (int)':');
00299 if (tmp == NULL) return MC_ERR_PARSE;
00300
00301
00302 *host = (char*)malloc(sizeof(char) *
00303 (tmp - http_str + 1) );
00304 strncpy(*host, http_str, tmp - http_str);
00305 (*host)[tmp-http_str] = '\0';
00306
00307
00308 tmp++;
00309 sscanf(tmp, "%d", port);
00310
00311
00312 tmp = strchr(tmp, (int)'/');
00313 tmp++;
00314 *target = (char*)malloc(sizeof(char) *
00315 (strlen(tmp)+1) );
00316 strcpy(*target, tmp);
00317
00318 return 0;
00319 }
00320
00321 int
00322 message_InitializeFromString(
00323 mc_platform_p mc_platform,
00324 message_p message,
00325 const char* string,
00326 const char* destination_host,
00327 int destination_port,
00328 const char* target)
00329 {
00330 char* destination;
00331 struct hostent* host;
00332
00333 message->connect_id = 0;
00334 message->message_id = rand();
00335
00336 message->message_type = MOBILE_AGENT;
00337
00338 message->xml_root = NULL;
00339
00340 message->message_body =
00341 (char*)malloc( sizeof(char) * (strlen(string)+1));
00342 CHECK_NULL(message->message_body,
00343 mc_platform->err = MC_ERR_MEMORY;
00344 return MC_ERR_MEMORY; );
00345 strcpy(message->message_body, string);
00346
00347 message->update_name = NULL;
00348
00349 if(destination_host != NULL) {
00350 destination = (char*)malloc(sizeof(char)*(strlen(destination_host) + 10));
00351 CHECK_NULL(destination,
00352 mc_platform->err = MC_ERR_MEMORY;
00353 return MC_ERR_MEMORY; );
00354 sprintf(destination, "%s:%d",
00355 destination_host,
00356 destination_port
00357 );
00358 message->to_address = destination;
00359 } else {
00360 message->to_address = NULL;
00361 }
00362
00363
00364
00365 message->from_address = (char*)malloc(
00366 sizeof(char) * (strlen(mc_platform->hostname)+10));
00367 sprintf(message->from_address,
00368 "%s:%d",
00369 mc_platform->hostname,
00370 mc_platform->port );
00371 message->target = (char*)malloc(sizeof(char) *
00372 (strlen(target)+1));
00373 strcpy(message->target, target);
00374
00375
00376 message->addr = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
00377 if (destination_host != NULL && strlen(destination_host)!= 0) {
00378 if((host = gethostbyname(destination_host)))
00379 {
00380 memcpy(&(message->addr->sin_addr), host->h_addr, host->h_length);
00381 message->addr->sin_port = htons(destination_port);
00382 } else {
00383 fprintf(stderr, "Warning: Host not found: %s:%d %s:%d",
00384 destination_host, destination_port, __FILE__, __LINE__ );
00385 }
00386 }
00387 message->xml_root = mxmlLoadString
00388 (
00389 NULL,
00390 message->message_body,
00391 MXML_NO_CALLBACK
00392 );
00393 if (message_xml_parse(message)) {
00394 fprintf(stderr, "Error parsing message at %s:%d.\n",
00395 __FILE__, __LINE__);
00396 return MC_ERR_PARSE;
00397 }
00398
00399 return MC_SUCCESS;
00400 }
00401
00402 int
00403 message_Destroy(message_p message)
00404 {
00405 if (message == NULL) {
00406 return MC_SUCCESS;
00407 }
00408
00409
00410 if(message->xml_root != NULL && message->agent_xml_flag == 0) {
00411 mxmlDelete(message->xml_root);
00412 }
00413
00414 if(message->addr) {
00415 free(message->addr);
00416 message->addr = NULL;
00417 }
00418 if(message->message_body != NULL) {
00419 free(message->message_body);
00420 message->message_body = NULL;
00421 }
00422 if(message->update_name != NULL) {
00423 free(message->update_name);
00424 }
00425 if(message->from_address != NULL) {
00426 free(message->from_address);
00427 }
00428 if(message->to_address != NULL) {
00429 free(message->to_address);
00430 }
00431 if(message->target != NULL) {
00432 free(message->target);
00433 }
00434
00435 free(message);
00436 message = NULL;
00437 return MC_SUCCESS;
00438 }
00439
00440
00441 int
00442 auth_rece_send_msg(int sockfd, char *hostname, char *message, char *privkey, char *known_host_filename){
00443
00444 int ret=-1;
00445 unsigned char passphrase[35], aes_key[35];
00446 int nonce, mode;
00447 char privatekey[1215];
00448 char peer_pubkey[300];
00449 char plaintext[135];
00450 FILE *fd;
00451
00452
00453 char *infile;
00454 char *outfile;
00455 memset(passphrase , '\0', 35);
00456 memset(privatekey , '\0', 1215);
00457 memset(plaintext , '\0', 135);
00458 memset(aes_key, '\0', 35);
00459
00460
00461
00462
00463 #ifndef _WIN32
00464 int fd1;
00465 infile = (char *)malloc(sizeof(char)*20);
00466 strcpy(infile, "msgXXXXXX");
00467 fd1 = mkstemp(infile);
00468 if (fd1 == -1) {
00469 fprintf(stderr, "Could not create temporary file:%s. %s:%d\n",
00470 infile, __FILE__, __LINE__ );
00471 exit(EXIT_FAILURE);
00472 }
00473 close(fd1);
00474
00475 outfile = (char *)malloc(sizeof(char)*20);
00476 strcpy(outfile, "en-msgXXXXXX");
00477 fd1 = mkstemp(outfile);
00478 if (fd1 == -1) {
00479 fprintf(stderr, "Could not create temporary file:%s. %s:%d\n",
00480 outfile, __FILE__, __LINE__ );
00481 exit(EXIT_FAILURE);
00482 }
00483 close(fd1);
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 #else
00495 infile = _tempnam(".", "msg");
00496 outfile = _tempnam(".", "en-msg");
00497 #endif
00498
00499
00500
00501
00502
00503
00504 strcpy(privatekey, privkey);
00505
00506
00507
00508
00509 if (read_known_host_file(peer_pubkey, hostname, known_host_filename) == -1 ){
00510 printf("Client: %s 's Public key not found in know host file\n", hostname);
00511 if( remove(infile) ) printf("message.c : remove error 4");
00512 if( remove(outfile) ) printf("message.c : remove error 5");
00513 #ifndef _WIN32
00514
00515 #else
00516
00517 #endif
00518 }else{
00519 if ((ret=initiate_migration_process(sockfd, &nonce, peer_pubkey, privatekey, aes_key)) != 1){
00520 if (ret == -1)
00521 printf("Client: Connected peer is not authenticated \n");
00522 if (ret == -2)
00523 printf("Client: Unable to get authentication from oither peer \n");
00524 }else{
00525
00526
00527
00528
00529 if( (fd = fopen(infile,"w")) == NULL){
00530 printf("Unable to write message in a file \n");
00531 if( remove(infile) ) printf("message.c : remove error 1");
00532 }else{
00533
00534 fwrite (message , 1 , strlen(message) , fd );
00535 fclose(fd);
00536
00537 mode = 0;
00538 if (aes_en_de(mode, infile, outfile, aes_key, &nonce, 0) != 1){
00539 printf("Client: AES Encryption Failed \n");
00540 if( remove(infile) ) printf("message.c : remove error 2");
00541 if( remove(outfile) ) printf("message.c : remove error 3");
00542 }else{
00543 if( remove(infile) ) printf("message.c : remove error 4");
00544 if (send_AES_en_MA(sockfd, &nonce, outfile, peer_pubkey) != 1 ){
00545 printf("Client: Error while sending mobile agent \n");
00546 if( remove(outfile) ) printf("message.c : remove error 5");
00547 }else{
00548 if( remove(outfile) ) printf("message.c : remove error 6");
00549
00550 ret = 2;
00551 }
00552 }
00553 }
00554 }
00555 }
00556
00557
00558
00559
00560 return ret;
00561 }
00562
00563 #define MSG_THREADS 40
00564 int message_Send(mc_platform_t* mc_platform, message_p message, char *privatekey)
00565 {
00566 THREAD_T msg_thread;
00567 message_send_arg_t* arg;
00568 #ifndef _WIN32
00569 pthread_attr_t attr;
00570 pthread_attr_init(&attr);
00571 #else
00572 int stack_size = 0;
00573 #endif
00574
00575 arg = (message_send_arg_t*)malloc(sizeof(message_send_arg_t));
00576 arg->mc_platform = mc_platform;
00577 arg->message = message;
00578 arg->privatekey = privatekey;
00579
00580 MUTEX_LOCK(&mc_platform->acc->msg_thread_lock);
00581 while(mc_platform->acc->num_msg_threads >= MSG_THREADS) {
00582 COND_WAIT(&mc_platform->acc->msg_thread_cond, &mc_platform->acc->msg_thread_lock);
00583 }
00584 mc_platform->acc->num_msg_threads++;
00585 MUTEX_UNLOCK(&mc_platform->acc->msg_thread_lock);
00586
00587 THREAD_CREATE(&msg_thread, message_send_Thread, arg);
00588 THREAD_DETACH(msg_thread);
00589 return 0;
00590 }
00591
00592
00593 #define MSG_THREAD_EXIT() \
00594 free(arg); \
00595 message_Destroy(message); \
00596 MUTEX_LOCK(&mc_platform->acc->msg_thread_lock); \
00597 mc_platform->acc->num_msg_threads--; \
00598 COND_SIGNAL(&mc_platform->acc->msg_thread_cond); \
00599 MUTEX_UNLOCK(&mc_platform->acc->msg_thread_lock); \
00600 THREAD_EXIT()
00601
00602 #ifndef _WIN32
00603 void*
00604 message_send_Thread(void* arg)
00605 #else
00606 DWORD WINAPI
00607 message_send_Thread( LPVOID arg )
00608 #endif
00609 {
00610 mc_platform_t* mc_platform;
00611 message_p message;
00612 char* privatekey;
00613 char *buffer;
00614 mtp_http_t* mtp_http;
00615 int n;
00616 #ifndef _WIN32
00617 int skt;
00618 struct sockaddr_in sktin;
00619 struct addrinfo* myaddrinfo;
00620 struct addrinfo hint_addrinfo;
00621 #else
00622 SOCKET skt;
00623 SOCKADDR_IN sktin;
00624 struct hostent host;
00625 struct hostent* host_result;
00626 #endif
00627 char *buf;
00628 char *hostname;
00629 #ifndef _WIN32
00630 char *saveptr;
00631 #endif
00632 int port;
00633
00634 int num_tries = 0;
00635 const int max_num_tries = 100;
00636 int errnum;
00637
00638 dynstring_t* message_string;
00639 #ifdef NEW_SECURITY
00640 int ret;
00641 #endif
00642
00643 mc_platform = ((message_send_arg_t*)arg)->mc_platform;
00644 message = ((message_send_arg_t*)arg)->message;
00645 privatekey = ((message_send_arg_t*)arg)->privatekey;
00646
00647
00648 if (
00649 mtp_http_ComposeMessage(
00650 message
00651 )
00652 )
00653 {
00654 fprintf(stderr, "Compose Message Error. %s:%d\n", __FILE__, __LINE__);
00655 MSG_THREAD_EXIT();
00656 }
00657
00658
00659 buf = (char*)malloc(sizeof(char)*(strlen(message->to_address)+1));
00660 strcpy(buf, message->to_address);
00661 hostname = strtok_r(buf, ":", &saveptr);
00662 sscanf( strtok_r(NULL, ":", &saveptr), "%d", &port );
00663
00664 if((skt = socket(PF_INET, SOCK_STREAM, 0)) < 0)
00665 {
00666 fprintf(stderr, "Error - can't create socket\n");
00667 MSG_THREAD_EXIT();
00668 }
00669
00670 memset(&sktin, 0, sizeof(sktin));
00671 sktin.sin_family = PF_INET;
00672 sktin.sin_port = htons(port);
00673
00674 #ifndef _WIN32
00675
00676 memset(&hint_addrinfo, 0, sizeof(hint_addrinfo));
00677 hint_addrinfo.ai_family = AF_INET;
00678 if( (errnum = getaddrinfo(hostname, NULL, &hint_addrinfo, &myaddrinfo)) == 0 )
00679 #else
00680 if(host_result = gethostbyname(hostname))
00681 #endif
00682 {
00683 #ifdef _WIN32
00684 host = *host_result;
00685 memcpy(&sktin.sin_addr, host.h_addr, host.h_length);
00686 #else
00687 ((struct sockaddr_in*)myaddrinfo->ai_addr)->sin_port = htons(port);
00688 #endif
00689 }
00690 else if((sktin.sin_addr.s_addr = inet_addr(hostname)) < 0)
00691 {
00692 fprintf(stderr, "Error - can't get host entry for %s\n", hostname);
00693 free(buf);
00694 MSG_THREAD_EXIT();
00695 }
00696
00697 while(
00698 #ifndef _WIN32
00699 (connect(skt, myaddrinfo->ai_addr, sizeof(struct sockaddr)) < 0) &&
00700 #else
00701 (connect(skt, (struct sockaddr *) &sktin, sizeof(sktin)) < 0) &&
00702 #endif
00703 (num_tries < max_num_tries)
00704 ) {
00705 printf("ERROR Socket Connect failed... errno:%s\n", strerror(errno));
00706 #ifndef _WIN32
00707 usleep(100000);
00708 #else
00709 Sleep(100);
00710 #endif
00711 num_tries++;
00712 }
00713 if (num_tries == max_num_tries) {
00714 fprintf(stderr, "Error - can't connect to %s:%d\n",
00715 hostname,
00716 port
00717 );
00718 free(buf);
00719 MSG_THREAD_EXIT();
00720 }
00721
00722 #ifdef NEW_SECURITY
00723
00724 ret = auth_rece_send_msg(skt, hostname, message->message_body, privatekey, mc_platform->agency->known_host_filename);
00725 if( ret == 1 ){
00726 printf("Successfull Authenticate and but send of MA is failed \n");
00727 #ifndef _WIN32
00728 if(close(skt) < 0) {
00729 SOCKET_ERROR();
00730 }
00731 #else
00732 closesocket(skt);
00733 #endif
00734 free(buf);
00735 fprintf(stderr, "Security Error. %s:%d\n", __FILE__, __LINE__);
00736 MSG_THREAD_EXIT();
00737 }else if(ret != 2){
00738 #ifndef _WIN32
00739 if(close(skt) < 0) {
00740 SOCKET_ERROR();
00741 }
00742 #else
00743 closesocket(skt);
00744 #endif
00745 free(buf);
00746 fprintf(stderr, "Security Error. %s:%d\n", __FILE__, __LINE__);
00747 MSG_THREAD_EXIT();
00748 }else if(ret == 2)
00749
00750 #else
00751 if(send(skt, message->message_body, strlen(message->message_body), 0) < 0) {
00752 perror("send");
00753 printf("cannot write to socket %s:%d\n", __FILE__, __LINE__);
00754 }
00755 else
00756 #endif
00757 {
00758
00759 buffer = (char*) malloc(sizeof(char) * (SOCKET_INPUT_SIZE + 1));
00760 CHECK_NULL(buffer, exit(0););
00761 mtp_http = mtp_http_New();
00762 message_string = dynstring_New();
00763 while(1) {
00764 #ifndef _WIN32
00765
00766
00767
00768
00769
00770
00771
00772 n = recv(skt, (void*)buffer, (size_t) sizeof(char)*SOCKET_INPUT_SIZE, MSG_WAITALL);
00773 #else
00774 n = recvfrom(skt,
00775 buffer,
00776 (size_t) sizeof(char)*SOCKET_INPUT_SIZE,
00777 0,
00778 (struct sockaddr *) 0,
00779 0);
00780 #endif
00781 if (n<0) {
00782
00783 SOCKET_ERROR();
00784 free(buffer);
00785 MSG_THREAD_EXIT();
00786 }
00787 else if (n==0) {
00788 break;
00789 }
00790 else
00791 {
00792 dynstring_Append(message_string, buffer);
00793 }
00794 }
00795 if( mtp_http_Parse(mtp_http, message_string->message) ) {
00796 fprintf(stderr, "http parsing error: Response expected. %s:%d\n",
00797 __FILE__, __LINE__);
00798 fprintf(stderr, "Received message was:\n%s\n", message_string->message);
00799 }
00800 if (mtp_http->response_code != 200) {
00801 fprintf(stderr, "Warning: remote http server responded: %d %s\n",
00802 mtp_http->response_code, mtp_http->response_string );
00803 }
00804
00805 mtp_http_Destroy(mtp_http);
00806 }
00807
00808 #ifndef _WIN32
00809 if(close(skt) <0) {
00810 SOCKET_ERROR();
00811 }
00812 #else
00813 closesocket(skt);
00814 #endif
00815 free(buf);
00816 free(buffer);
00817 dynstring_Destroy(message_string);
00818 MSG_THREAD_EXIT();
00819 }
00820
00821 #undef MSG_THREAD_EXIT